   how to implement mouse drag function
  hi,guys!I want to read a class to encapsulate I/O operation.The class get mouse input data and then put that in a buffer.The problem is every time the data only include which button is pressed or whether the mouse is moving.I do not know how to get them all to implement mouse drag function.Any help is appreciatedcode:DIPROPDWORD dipROPdw;dipROPdw.diph.dwSize = sizeof(DIPROPDWORD);dipROPdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);dipROPdw.diph.dwObj= 0;dipROPdw.diph.dwHow= DIPH_DEVICE;dipROPdw.dwData= MOUSEBUFFERNUM;if (FAILED(m_pMouseDevice->SetProperty(DIPROP_BUFFERSIZE,&dipROPdw.diph))){::MessageBoxA(NULL,"failed to set mouse buffer!","Error!",MB_OK);return SF_ERROR;}for (int i = 0;i<MOUSEBUFFERNUM;i++){if(FAILED(m_pMouseDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA),&m_mouseBuffer,&dwReadNum,0))){m_pMouseDevice->Acquire();}}int SFCInputController::mouseDragLeft(DWORD button){for (int i = 0;i<MOUSEBUFFERNUM;i++){if(m_mouseBuffer.dwOfs == button && m_mouseBuffer.dwData & 0x80){if (m_mouseBuffer.dwOfs == DIMOFS_X && m_mouseBuffer.dwData < 0){return true;}elsereturn false;}elsereturn false;}}
  You'll need to store previous states as well to detect whether the mouse has just been clicked or is being hold.mousePreviousState = mouseCurrentStatemouseCurrentState = UpdateState()This example is simplified, you should be having a second buffer. When your previous state was up, and your current state is down you start dragging.   ;  Your application should have a MouseDown, MouseUp, and MouseMoved function to capture all the mouse events.I am posting snippets of code that are not 100% accurate, but you should get the idea of how to implement itYour application should also have the previous state of the mouse: bool LMouseButtonDown, RMouseButtonDown;there should also be a global variable storing the current mouse position, as well as the last mouse positionbool MouseButtonDown(const uint32_t &button){if(button == MOUSE_RBUTTON) RButtonDown=true; if(button == MOUSE_LBUTTON) LButtonDown = true;}bool MouseButtonUp(const uint32_t &button){if(button == MOUSE_RBUTTON) RButtonDown=false; if(button == MOUSE_LBUTTON) LButtonDown = false;}bool MouseMoved(){if(LButtonDown){// we are clicking and holding and draggin because the LButtonDown is set to true and the mouse is moving!!    Put code here for mouse dragging stuffthis is where you would use the last mouseposition and the new mouse position to see where to mouse moving from to implement your dragging function}}that is about it. I tried to be as simple as possible so you could get the idea.   