一个sendmessage问题……在线等待。 (100分)

  • 主题发起人 主题发起人 Argus
  • 开始时间 开始时间
A

Argus

Unregistered / Unconfirmed
GUEST, unregistred user!
var<br>&nbsp; test:thandle;<br>begin<br>&nbsp; test:=findwindow('TForm1','Form1'); <br>&nbsp; sendmessage(test,WM_RBUTTONDOWN,0,10); <br>&nbsp; sendmessage(test,WM_RBUTTONUP,0,10);<br>end;<br>……………………<br>问题:sendmessage中的最后两个参数如何设置?<br>我要实现的是,form1上有个POPUPMENU弹出来。但我不知道怎么设置弹出来的位置!!<br>比如我想在某个特定的位置弹出右键!!<br>
 
参考一下winapi吧
 
to wb_l<br>我手头没有.我在网上查了一下.没找具体的参数设置.
 
直接测试的话。第一个参数(这里0)为什么都没有影响。<br>第二个参数是form的X坐标。晕
 
WM_RBUTTONDOWN &nbsp;<br>fwKeys = wParam; &nbsp; &nbsp; &nbsp; &nbsp;// key flags <br>xPos = LOWORD(lParam); &nbsp;// horizontal position of cursor <br>yPos = HIWORD(lParam); &nbsp;// vertical position of cursor <br>&nbsp;<br><br>Parameters<br><br>fwKeys<br><br>Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: <br><br>Value Description<br>MK_CONTROL Set if the CTRL key is down.<br>MK_LBUTTON Set if the left mouse button is down.<br>MK_MBUTTON Set if the middle mouse button is down.<br>MK_RBUTTON Set if the right mouse button is down.<br>MK_SHIFT Set if the SHIFT key is down.<br>&nbsp;<br><br>xPos<br><br>Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper left corner of the client area. <br><br>yPos<br><br>Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper left corner of the client area.
 
to 桦树皮:<br>比较乱.水平有限.能详细说.最后有一个结果.
 
第一个参数可以是如下值的组合<br>MK_CONTROL CTRL键按下<br>MK_LBUTTON  鼠标左键按下<br>MK_MBUTTON  鼠标中键按下<br>MK_RBUTTON  鼠标右键按下<br>MK_SHIFT SHIFT键按下<br>第二个参数的低字节为水平坐标,高字节为垂直坐标
 
var<br>&nbsp; x,y :Integer;<br>begin<br>&nbsp; x :=100; //Left<br>&nbsp; y :=200; //Top<br>&nbsp; SendMessage(Handle,WM_RButtonDown,0,y shl 16 + x);<br>&nbsp; SendMessage(Handle,WM_RButtonUp,0,y shl 16 + x);<br>end;
 
seven_918说得对
 
试一试?<br>var<br>&nbsp;test:thandle;<br>&nbsp; pt:TPoint;<br>begin<br>&nbsp; &nbsp;GetCursorPos(Pt);<br>&nbsp; &nbsp;Pt:=ClientToScreen(Pt);<br>&nbsp; &nbsp;test:=findwindow('TForm1','Form1'); <br>&nbsp; &nbsp;SendMessage(Handle,WM_RButtonDown,0,pt.y shl 16 + pt.x);<br>&nbsp; &nbsp;SendMessage(Handle,WM_RButtonUp,0,pt.y shl 16 + pt.x);<br>end;
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
848
DelphiTeacher的专栏
D
D
回复
0
查看
858
DelphiTeacher的专栏
D
D
回复
0
查看
687
DelphiTeacher的专栏
D
后退
顶部