--- In [email protected], "brucexs" <[EMAIL PROTECTED]> wrote:
>
> --- In [email protected], bizaro <bizaro137@> wrote:
> >
> > Hello everyone,
> > 
> > Bruce, since PowerPro can adjust bar width/height to make room for 
> the
> > text is it much work for you to add a function which can return 
> screen size
> > of a given text in a given font with a given font size and font 
> styling?
> > 
> > Or maybe I should use hidden temp bar to get this info via 
> Win.Width and
> > Win.Height?
> 
> The above approach is probably possible. 
> 
>  Or if you or someone else is feeling industrious, you can try the 
> dll plugin with gettextextentpoint32
> 
> http://msdn.microsoft.com/library/default.asp?url=/library/en-
> us/gdi/fontext_8smq.asp
> 
> You'd have to do something like
> - get a DC with GetDC(NULL)
> - create the font with createfontindirect
> - select the font into the dc with selectobject
> - call getextentpoint32
> - put the old font back with selectobject
> - release the dc with releasedc
> 
> Isn't Windows programming fun?  
> 
> I'm winding down for the summer but I can look at this later if you 
> or someone else does not want to brave the above.

I wrote a script according to this instruction. The usage is
.GetTextSize("string","FontName",FontSize[,boldness][,italic])
E.g., .GetTextSize("Test","Tahoma",12,1,1) or
.GetTextSize("Test","Courier New",10)


However, it didn't work well as expected. There seems to be a
difficulty to set a literal string with create_struct.

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

hWnd=0
hDC=dll.call("GetDC|ui",hWnd)

tLogFont=dll.create_struct("i i i i i uc uc uc uc uc uc uc uc s",;;+
nHeight,0,0,0,400+300*bold,1*italic,0,0,1,0,0,0,0,sFaceName)
hFont=dll.call("CreateFontIndirect|t* ui",tLogFont)
hForg=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,hForg)
dll.call("DeleteObject|ui",hFont)
dll.call("ReleaseDC|ui ui",hWnd,hDC)

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

Sean





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