本文整理自网络,侵删。
function GetLine(X, Y: integer): TPoint;var OldFont : HFont; Hand : THandle; TM : TTextMetric; Rect : TRect;begin Hand := GetDC(mmotest.Handle); try OldFont := SelectObject(Hand, mmotest.Font.Handle); try GetTextMetrics(Hand, TM); mmotest.Perform(EM_GETRECT, 0, longint(@Rect)); Result.Y:= GetScrollPos( mmotest.Handle, SB_VERT ) + (Y - Rect.Top) div (TM.tmHeight); Result.X:= (X - Rect.Left) div (TM.tmHeight); ShowMessage( IntToStr( Result.X ) + ',' + IntToStr( Result.Y ) ); finally SelectObject(Hand, OldFont); end; finally ReleaseDC(mmotest.Handle, Hand); end;end;
procedure TF_Main.mmotestMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);begin GetLine( x, y );end;
相关阅读 >>
Delphi qr /条形码扫描仪应用示例代码(使用zxing,tframestand)
Delphi android实例-红外线操作(xe10.2+小米5)
Delphixe7关于android 检测屏幕是否处于关闭状态
更多相关阅读请进入《Delphi》频道 >>