I rewrote it using CreateFont instead of CreateFontIndirect. Now it
seems to work OK. The usage is
.GetTextSize("string","font",size[,bold][,italic])
E.g., .GetTextSize("This is a test.","Courier New",12,1,1)

-------------- GetTextSize.PowerPro ---------------------------------
args  sString,sFaceName,nHeight,bold,italic
local hWnd,hDC,hFont,hFold,aSize

hWnd=0
hDC=dll.call("GetDC|ui",hWnd)
nHeight=0-dll.call("MulDiv|i i i",;;+
nHeight,dll.call("GetDeviceCaps|ui i",hDC,90),72)

hFont=dll.call("CreateFont|i i i i i ui ui ui ui ui ui ui ui s ui",;;+
nHeight,0,0,0,400+300*bold,1*italic,0,0,1,0,0,0,0,sFaceName)
hFold=dll.call("SelectObject|ui ui",hDC,hFont)

aSize=dll.create_array(2,"i")
dll.call("GetTextExtentPoint32|ui s i a* b",;;+
hDC,sString,length(sString),aSize)

dll.call("SelectObject|ui ui",hDC,hFold)
dll.call("DeleteObject|ui",hFont)
dll.call("ReleaseDC|ui ui",hWnd,hDC)

win.debug("Width:"++aSize[1],"Height:"++aSize[2])
quit
---------------------------------------------------------------------

Sean






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/JV_rlB/TM
--------------------------------------------------------------------~-> 

Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to