sendmessage参数问题,谢谢(100分)

  • 主题发起人 主题发起人 Tipsyeye
  • 开始时间 开始时间
T

Tipsyeye

Unregistered / Unconfirmed
GUEST, unregistred user!
我试图用sendmessage带EM_CHARFROMPOS来返回当前鼠标下字符的位置 <br>var<br>&nbsp; &nbsp; mPos:tpoint; <br>&nbsp; &nbsp; res:integer; <br>&nbsp; &nbsp; Wnd:longint; <br>begin <br>&nbsp; &nbsp; getcursorpos(mPos); <br>&nbsp; &nbsp; Wnd:=windowfrompoint(mPos); <br>&nbsp; &nbsp; res:=sendmessage(Wnd,EM_CHARFROMPOS,0,mPos);//在这里报错 <br>end <br>错误信息 <br>[Error] untMain.pas(134):Incompatible types:'Integer' and 'TPoint' <br><br>我查阅了msdn,说明中是这样定义的: <br>SendMessage( <br>&nbsp; &nbsp;(HWND) hWnd, &nbsp; &nbsp; //handle to destination window <br>&nbsp; &nbsp;EM_CHARFROMPOS, &nbsp;//message to send <br>&nbsp; &nbsp;(wparam) wParam, //not used;must be zero <br>&nbsp; &nbsp;(lparam) lparam &nbsp;//point coordinates <br>&nbsp; ); <br>这里第四个参数是相应的point,那为什么我的mPos不行啊,另外,我是刚从vb转向delphi的,同样的sendmessage,vb里怎么就可以呢?是不是delphi里有不同的用法呢? <br>&nbsp; 请帮忙看看。谢谢! <br>
 
res:=sendmessage(Wnd,EM_CHARFROMPOS,0,mPos.Y shl 16 or mPos.X);<br><br>x<br><br>Value of the low-order word of lParam. Specifies the x-coordinate of a point in the edit control's client area. The coordinate is relative to the upper-left corner of the client area.<br><br>y<br><br>Value of the high-order word of lParam. Specifies the y-coordinate of a point in the edit control's client area. The coordinate is relative to the upper-left corner of the client area.
 
TPoint(p); 试试
 
integer(@mPos)试试
 
接受答案了.
 
后退
顶部