发信人: powerbuilder()
整理人: leitiger(2002-06-05 23:49:05), 站内信件
|
【 在 tangyuq (独孤九剑) 的大作中提到: 】 : pb如何得到显示一个串所需的宽度? : 或DW如何得到一个列控件可以显示的字符数? 需要通过API函数调用得到
首先定义一个用户结构str_size long width long length
然后声明Local External Functions Function ulong GetDC(ulong hWnd) Library "USER32.DLL" Function long ReleaseDC(ulong hWnd, ulong hdcr) Library "USER32.DLL" Function boolean GetTextExtentPoint32A(ulong hdcr, string lpString, lo ng nCount, ref str_size size) Library "GDI32.DLL" Function ulong SelectObject(ulong hdc, ulong hWnd) Library "GDI32.DLL"
按下列方法可得到静态文本Static Text中字符串的长度可宽度 str_size lstr_Size
ll_Handle = Handle(st_text) ll_HDC = GetDC(ll_Handle)
// Get the font in use on the Static Text ll_hFont = Send(ll_Handle, li_WM_GETFONT, 0, 0) // Select it into the device context SelectObject(ll_HDC, ll_hFont) // Get the size of the text. If Not GetTextExtentpoint32A(ll_HDC, st_text.Text, li_Len, lstr_Size ) Then Return -1
lstr_size中的width,height记录了st_text.Text的高度和宽度
-- 菩提本非树,明镜亦非台。 本就无一物,何处惹尘埃。
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.96.184.201]
发信人: ilike (ilike), 信区: Powerbuilder 标 题: Re: pb如何得到显示一个串所需的宽度? 发信站: 网易虚拟社区 (Fri Aug 27 15:37:52 1999), 站内信件
【 在 powerbuilder (大将南北) 的大作中提到: 】 : 需要通过API函数调用得到 : .......
老兄真是高手!!!!不愧叫PowerBuilder. 不过对于任意的字符串,还缺一段选择字体的工作,那几个关于字体的结构特别 繁琐。 好在PFC帮我们作好了,我推荐使用PFC: n_cst_platform.of_gettextsize 调用 。 如果不喜欢PFC,可以将这段代码抽出来单独用。
-- ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.96.156.11]
|
|