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
delphi中获取memo鼠标所在位置的行和列(通过EM_GETRECT消息取得Rect后,自己算一下)的更多相关文章
- jquery获取当前鼠标所在位置的坐标
$(document).ready(function(){ $(document).mousemove(function(e){ $('#xy').html("X :"+e.pag ...
- (转)C# WinForm中 获得当前鼠标所在控件 或 将窗体中鼠标所在控件名显示在窗体标题上
原文地址:http://www.cnblogs.com/08shiyan/archive/2011/04/14/2015758.html /********************** * 课题:将窗 ...
- MFC中状态栏显示鼠标坐标位置
原文:MFC中状态栏显示鼠标坐标位置,蝈蝈 1,利用MFC向导创建一个应用工程ewq. 2,打开ResourceView,右击Menu菜单,插入Menu,在空白处双击,Caption中填入Point. ...
- (转载)delphi中获取汉字的拼音首字母
delphi中获取汉字的拼音首字母1.py: array[216..247] of string = ({216}'CJWGNSPGCGNESYPB' + 'TYYZDXYKYGTDJNMJ' + ' ...
- 如何在 Windows Phone 8 中获取手机的当前位置
原文 如何在 Windows Phone 8 中获取手机的当前位置 适用于:仅限于 Windows Phone 8. 本主题演示如何使用 Windows Phone 位置 API 确定手机的当前位置. ...
- android 中获取当前焦点所在屏幕中的位置 view.getLocationOnScreen(location)
final int[] location = new int[2]; view.getLocationOnScreen(location); final int[] location = new in ...
- Delphi中获取Unix时间戳及注意事项(c语言中time()是按格林威治时间计算的,比北京时间多了8小时)
uses DateUtils;DateTimeToUnix(Now) 可以转换到unix时间,但是注意的是,它得到的时间比c语言中time()得到的时间大了8*60*60这是因为Now是当前时区的时间 ...
- 在Delphi中获取和修改文件的时间
转载自 http://www.cnblogs.com/jieke/archive/2013/01/11/2855782.html 本文介绍了在Delphi中利用系统函数和Windows API函数调用 ...
- 百度地图中使用mouseover事件获取经纬度时无法拿到鼠标所在位置的经纬度。
用百度2.0的话使用mousemove 鼠标在地图区域移动过程中触发此事件.mouseover参数e中没有point参数
随机推荐
- jquery 点击其他地方
<script type="text/javascript"> function stopPropagation(e) { if (e.stopPropagation) ...
- 【codeforces 754B】 Ilya and tic-tac-toe game
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- SpringMVC ModelAndView跳转失效
今天隔壁的兄弟遇到一个奇怪的问题,他写好了一个表单用post提交到了addNew.do 里面,然后利用 return new ModelAndView("forward:success.js ...
- Delphi程序的自我修改
前言: 对于Delphi在编译时对代码所做的工作,大部分使用Object Pascal之类的高级语言的程序员并不是很熟悉.如果你对汇编程序以及EXE文件格式有一点基本认识,那么源代码里包含的注 ...
- iOS 一个简单的单例
比如我有一个Singleton的类(DemoStatusManage),他有一个实例方法currentStatus会返回一个1-100的随机数. @interface DemoStatusManage ...
- Xcode7 不能使用http网络请求问题解决
最近使用Xcode 7.0 写代码,发送网路请求提示: App Transport Security has blocked a cleartext HTTP (http://) resource ...
- Using Eredis, Redis With Erlang
http://no-fucking-idea.com/blog/2012/03/23/using-eredis-in-erlang/ Using Eredis, Redis With Erlang M ...
- 【BZOJ 1007】 [HNOI2008]水平可见直线
[题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1007 [题意] [题解] 这个人讲得很好 http://blog.csdn.net/o ...
- 使用多target来构建大量相似App
转自 come from : http://devtang.com/blog/2013/10/17/the-tech-detail-of-ape-client-1/ 猿题库iOS客户端的技术细节(一) ...
- 还是Qt 通过stylesheet或者palette设置背景色的问题
关于Qt,设置一个widget的背景色后,希望子对象不受影响. 很久以前在QtForum上问过一个问题:http://www.qtforum.org/post/94103/setting-backgr ...