标题:RichTextBox字符占的實際寬度 【已解决】
只看楼主
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
得分:0 
16樓做了解答,但是用到了數據庫,因爲我這個程序沒用到數據庫,然後要給國外客戶用的,怕有很多麻煩,所以想用另一種方法,謝謝!

汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2007-09-15 09:26
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
得分:0 
還沒解决啊~!

汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2007-09-18 16:45
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
得分:0 

Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_POSFROMCHAR = 214
Private Const EM_GETSEL = &HB0

Private Sub Command1_Click()
Dim ret As Long
Dim intStart As Integer
Dim intEnd As Integer
Dim intStartX As Integer
Dim intEndX As Integer
ret = SendMessage(RichTextBox1.hwnd, EM_GETSEL, 0, 0)
intStart = ret And 65535
intEnd = (ret And &HFFFF0000) / (2 ^ 16)
ret = SendMessage(RichTextBox1.hwnd, EM_POSFROMCHAR, intStart, 0)
intStartX = ret And 65535
ret = SendMessage(RichTextBox1.hwnd, EM_POSFROMCHAR, intEnd + 1, 0)
intEndX = ret And 65535
MsgBox intEndX - intStartX
End Sub
已经解决了,这个可以得到选中字符的实际宽度


汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2007-09-20 16:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-169888-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.141960 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved