Hi Laurent,

I like your IsChild() method much better than my kludge. You're welcome to 
replace my changes in the CVS with your method of doing it. It seems a much 
more elegant solution.

Thanks for looking into this,

Steve


-----Original Message-----
From: Laurent ROCHER [mailto:[EMAIL PROTECTED]
Sent: 16 December 2003 19:13
To: Stephen Pick
Cc: Win32 GUI Hackers
Subject: Re: [perl-win32-gui-hackers] bugfixed some cvs



OK, i understand your problem now.
I agree Main window and Dialog box have screen coordinate.
Dialog box have a parent window but it's not a child window.
No translation must be done.

But, you change break use of -parent option for normal child window (show in
my sample).

In this case, it's better to replace in Top and Left :

    parent = GetParent(handle);
    perlud = (LPPERLWIN32GUI_USERDATA) GetWindowLong(handle, GWL_USERDATA);
    if(perlud && perlud->hasParentAttribute == FALSE && parent)
ScreenToClient(parent, &myPt);

with :

    parent = GetParent(handle);
    if (parent && IsChild(parent, handle)) ScreenToClient(parent, &myPt);

IsChild() do job you want. It's return false when handle is a dialog window.

Are you agree ?

Laurent.

----- Original Message ----- 
From: "Stephen Pick"
Subject: RE: [perl-win32-gui-hackers] bugfixed some cvs


Hi,

The problem is simply that the implementation of relative co-ordinates is
not done properly.

If you make a parent window and give it a child window that is a DialogBox,
then position the main window at screen co-ordinates 100x100, then call

$CHILD->Top(0);

to position child window at the very top of the screen, the child window
will move to the top of the screen but WILL ALSO MOVE 100px TO THE LEFT
because Win32::GUI is treating the relative X co-ordinate it gets using
ScreenToClient() as an absolute co-ordinate when it passes it to
SetWindowPos(). The Y co-ordinate given as the argument (0) is not converted
by ScreenToClient() since it's not part of (and not put into) the myRect
struct, and therefore is passed directly to SetWindowPos resulting in
correct, absolute positioning for the Y co-ordinate. The same goes for the
Left() function, but the co-ordinate affected by the bug is then the Y
co-ordinate instead of the X co-ordinate.

This is the bug I'm on about, and this is the bug that I believe I have
fixed. The child window must be a DialogBox.

The correct behaviour perhaps, for dialogboxes, is for Top(0) to position
them at the Y co-ordinate of their parent, however this is not what I would
expect Top(0) to do. To be honest I'm not sure why Win32::GUI makes the
distinction between a Window and a DialogBox anyway, internally both are the
same thing with slightly different styles. I can't see any real
justification for just using Win32::GUI::Window at all (other than the fact
that it does not suffer from this bug :) ).

The code here demonstrates the problem:

...

If that's the behaviour YOU expect then I strongly disagree with you.
Setting Top() should certainly NOT affect Left().

Steve




Reply via email to