Microsoft KB Archive/187743

= PRB: Right Mouse with Manual OLE D&D Disables Left Mouse =

Article ID: 187743

Article Last Modified on 8/26/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q187743



SYMPTOMS
When OLE Drag and Drop is started in manual mode by trapping for the right mouse button (right-click) on the drag source object, the left mouse button seems to be disabled until the right mouse button is clicked again.



CAUSE
This is caused by setting the nEffect parameter in the OLEStartDrag event.



RESOLUTION
Here are two workarounds for this behavior:


 * Place the NODEFAULT keyword in the method that calls the OLEDrag method of the drag source. Normally, this is either the MouseDown or the MouseMove event.

-or-
 * Do not set the nEffect parameter in the OLEStartDrag event.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  Place the following code in a new program file and save it as Test.prg: PUBLIC oform1

oform1=NEWOBJECT("form1") oform1.Show RETURN

**************************************************     *-- Form:         form1 *-- ParentClass: form *-- BaseClass:   form *     DEFINE CLASS form1 AS form

Top = 1 Left = 2 Height = 350 Width = 474 DoCreate = .T.        OLEDropMode = 1 Caption = "Try to move the form by dragging after right "+ ; "clicking the button" WindowState = 0 BackColor = RGB(0,128,128) Name = "Form1"

ADD OBJECT command1 AS commandbutton WITH ; Top = 120, ; Left = 240, ; Height = 73, ; Width = 97, ; Caption = "Right Click Me", ; Name = "Command1"

PROCEDURE command1.MouseDown LPARAMETERS nButton, nShift, nXCoord, nYCoord IF nButton=2 *  NODEFAULT This.OLEDrag(.T.) ENDIF ENDPROC

PROCEDURE command1.OLEDrag LPARAMETERS lDetectDrag IF lDetectDrag This.ForeColor=RGB(0,255,64) ELSE This.ForeColor=RGB(255,0,255) ENDIF ENDPROC

PROCEDURE command1.OLECompleteDrag LPARAMETERS nEffect This.ResetToDefault("ForeColor") ENDPROC

PROCEDURE command1.OLEStartDrag LPARAMETERS oDataObject, nEffect nEffect=3 ENDPROC

ENDDEFINE  Run the Test.prg program. Right-click the command button. The caption text should change color when you click the button. This is just for visual confirmation. Try to move the form by dragging the title bar with the left mouse. The left mouse button should act disabled, or in other words, you should not be able to move the form. You may have to right-click the command button more than once, because this behavior does not always occur. Right-clicking anywhere on the form enables the left mouse button allowing you to move or close the form.</li> Edit the Test.prg file and remove the remark on the NODEFAULT keyword in the command1.MouseDown procedure. Save and rerun the form. Note that the left mouse button is not disabled.</li></ol>

<div class="references_section">