Mousemove event in a control created with MFC.
Posted on 1998-02-10
If I inside a custom mfc-activex control's MouseMove event uses SetCapture on some window,
and later release the capture. Then the activex control starts notifying me wrongly that
the "button" is pressed in the mousemove event, even though it isnt...
Its very simple (For me atleast) to recreate the "feature", using Visual Basic 5.0 and
Visual C++ 5.0.
Start Visual C++ 5.0
1. Create a MFC ActiveX control, just name it and finish the wizard...
2. Add the stock event "MouseMove"
3. Compile the activex control and register it.
Start Visual Basic 5.0
1. Create a new project.
2. Place a picturebox control(Picture1) and the "MFC activex control" (MFC1) on the form.
3. Insert this code into the form's code view:
Private Sub MFC1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
As you see, pressing the button on the mfc control and moving the mouse will "capture" the
windows messages to the "Picture1" control. Which again will release it as soon as you
release the left button...
After this, the "MFC1_MouseMove" event will start reporting that "Button" is 1, ie pressed
even though it isnt... (See it in the debug window)
Am I missing something vital???
Should I do something at "WM_CAPTURECHANGED"??
Any help will be appreciated...