I just noticed that the coordinates which are issued by the
x/y/width/height properties are not in pixels but something
else. On my system, I noticed that the reported coordinates
are larger by the factor 4.57 (I suppose this is different
on other systems), so a window at position 960px has an 'x'
property of 4389. Does anybody know why that is, and is
there a portable function to translate PowerBuilder
coordinates into pixel coordinates?
- Frerich
Yes. I believe the idea is to use the DPI setting of your display and
your printer when working out where everything should go.
Use unitstopixels / pixelstounits for conversion.
Ah, I see. Makes sense. However, I noticed an odd thing.
I'm trying to compute absolute position for my controls. For
instance, I'm computing the absolute coordinates of my main
form
(in pixels) like this:
int l_absx;
int l_absy;
l_absx = UnitsToPixels( w_sample1_main.x, XUnitsToPixels!
)
l_absy = UnitsToPixels( w_sample1_main.y, YUnitsToPixels!
)
However, at runtime, this gives me the top left corner of
the main window, so it's at the top left corner of the
Windows title bar. What I really meant was the top left
corner of the main form though, so I basically need the
coordinates as computed above plus the height of the Windows
title bar, menu bar, toolbar etc.
I basically need the 'client rect' coordinates of the
window.
Is there a function for this, or do I need to compute that
myself by adding up the height of th emenu bar, toolbar
(assuming the toolbar orientation is at the top) etc.?
- Frerich
sorry for having to follow up to myself, just wanted to add
some information:
On Sep 2, 7:17 pm, Frerich Raabe wrote:
> I'm trying to compute absolute position for my controls.
> For instance, I'm computing the absolute coordinates of my
> main form (in pixels) like this:
>
> int l_absx;
> int l_absy;
> l_absx = UnitsToPixels( w_sample1_main.x,
XUnitsToPixels!)
> l_absy = UnitsToPixels( w_sample1_main.y,
YUnitsToPixels!)
>
> However, at runtime, this gives me the top left corner of
> the main window, so it's at the top left corner of the
> Windows title bar. What I really meant was the top left
> corner of the main form though, so I basically need the
> coordinates as computed above plus the height of the
> Windows title bar, menu bar, toolbar etc.
I noticed that it works considerably better if I use
w_sample1_main.WorkSpaceX()
w_sample1_main.WorkSpaceY()
instead. However, WorkSpaceY() still does not the height of
the
toolbar into account, so WorkSpaceY() is, in my case, below
the
menu bar but above the toolbar. I tried to compensate for
this
by adding w_sample1_main.ToolbarHeight to my l_absy
coordinate,
but unfortunately ToolbarHeight always returns zero.
It seems that the Toolbar is not a discrete control but
rather
a property of and Window or Menu. Hmm.
- Frerich
I've never heard of anyone trying to set object locations by pixels. What
benifit do you think you will have?
<Frerich Raabe> wrote in message news:4a9fcedc.2f...@sybase.com...
I'm using an external tool to automate my PowerBuilder GUI;
the
tool requires (in some situations) the absolute coordinates
of
an object to interact with (e.g. click on) in pixels. Hence,
I'm
creating some helper functions in my PowerBuilder GUI which
I can
call via to PBNI to determine this information.
- Frerich
Calculating the exact on screen coordinate of a sheet window is
difficult.
It might be quicker to pass the window handle to an external win32
call and do it from there.
eg;
http://msdn.microsoft.com/en-us/library/ms633519%28VS.85%29.aspx
I would like to note that many of those automation tools provide some
utilitys to find the informations you are requesting...
I'm also using an automation tool and never needed to search for the
information you are looking for.
Andreas Mykonios.