本文整理自网络,侵删。
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 tarray<tarray<string>> 用法
Delphi2010安装twordapplication控件
Delphi colorbox不需要系统那么多颜色,只想自定义显示其中几个,怎么做?
Delphi strutils.dupestring - 反复字符串
更多相关阅读请进入《Delphi》频道 >>