zoukankan      html  css  js  c++  java
  • delphi中获取memo鼠标所在位置的行和列(通过EM_GETRECT消息取得Rect后,自己算一下)

    也是看别人写的,但是不容易找到,就转发一篇delphi版本的

    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;

    http://blog.csdn.net/youthon/article/details/5781995

  • 相关阅读:
    HttpServletRequest
    实现重定向
    HttpServletResponse
    Servlet简介和ServletContext
    JavaWeb 之 Http
    JavaWeb 之 Cookie
    Pycharm2019.3.2专业版激活
    How to Use Arrays and Vectors
    软件工程学习心得
    MySQL 连接
  • 原文地址:https://www.cnblogs.com/findumars/p/7230767.html
Copyright © 2011-2022 走看看