On Mon, Dec 3, 2012 at 4:02 PM, Art Heimsoth <artst...@artheimsoth.com>wrote:
> How do I find the width of the window in character units? If I am using
> a 10 point font, is that 10 dialog units or 10 pixels or something else?
>
10 point font is something else. Neither dialog units or pixels.
There is no way to get the width of a window in character units, if the
dialog is not using a mono-spaced font. There is no easy way to get the
width if the window is using a mono-spaced font.
You should be able to accurately get the width in pixels of a string
displayed in a specific dialog, by using the getTextSizePx() method, after
the underlying window has been created.
If the window is using a mono-spaced font, you could use a loop and
repeatedly get the width of longer and longer strings until you get a width
equal to the window's width and then count the characters in that string.
But, there is no need for that in almost all cases.
>
> The following does not position it correctly:
> titleBarText = self~getWindowText(hwnd)
> size = .size~new(self~pixelCX, self~pixelCY)
> sizefix = Pos(" ",titleBarText)
> if sizefix = 0 then
> sizefix = length(titleBarText)
> sizetxt = size~width % self~fontSize
> sizedb = length(message)
> sizetxt = sizetxt - sizedb - 4
> titleBarText = left(titleBarText,sizefix)
> titleBarText = left(titleBarText,sizetxt,' ') message
> self~setWindowText(hwnd,titleBarText)
>
> The content of the var message appears toward of the middle of the
> window text area.
>
I can't tell what you are trying to do here. What type of window is this?
You use the term 'titleBarText'. But a title bar is usually the term for
the text in the caption of a dialog. You can not figure out the width of
the text in the caption bar, because you do not know what font it is.
If you can post more of a complete example, I can show you how to do it.
For one thing, or another thing, if your window is a static control and it
has the center text style, that could be why the text is in the middle of
the 'window text area'. "Window text area" is an ambiguous term unless you
know what type of window you are talking about.
--
Mark Miesfeld
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users