1. ATTN Derek: EuGrid Sort Menu and win32lib

Hi Derek,

You may recall some posts a few days ago about the sort popup menu
behaving strangely in EuGrid with win32lib 0.6.x.

I finally had a chance to have a look at this and found that the sort menu
placement was indeed working differently in 0.59 and 0.6.x of win32lib.

The difference is down to a change in the popup() procedure, specifically 
the way that the code determines the parent window for the menu.  This
drives the coordinate transformation used to place the menu on the screen.

The difference:

0.59.x : parent = window_owner[ id ] 
0.60.x : parent = findParentWindow(lPopupId)

The findParentWindow function travels up the tree until it finds a
top-level window class.  Unfortunately this means that it does not return
the id of the grid window as this is actually an owner-drawn button control.
The menu placement is therefore calculated on the basis of the window
containing the grid control, which accounts for the strange results.

I ended up creating the grid as a button control because when I started 
developing it I didn't seem to be able to create a vanilla child window
to draw the grid contents on.  I guess I always knew this would come back 
to haunt me in the end!

Anyway, unless you have any clever ideas, the easiest fix is probably for
me to clone the old version of the popup() procedure and use that instead
of the base win32lib version.

What do you think?

Regards,

Phil

new topic     » topic index » view message » categorize

2. Re: ATTN Derek: EuGrid Sort Menu and win32lib

Phil Russell wrote:
> 
> Hi Derek,
> 
> You may recall some posts a few days ago about the sort popup menu
> behaving strangely in EuGrid with win32lib 0.6.x.
> 
> I finally had a chance to have a look at this and found that the sort menu
> placement was indeed working differently in 0.59 and 0.6.x of win32lib.
> 
> The difference is down to a change in the popup() procedure, specifically 
> the way that the code determines the parent window for the menu.  This
> drives the coordinate transformation used to place the menu on the screen.
> 
> The difference:
> 
> 0.59.x : parent = window_owner[ id ] 
> 0.60.x : parent = findParentWindow(lPopupId)
> 
> The findParentWindow function travels up the tree until it finds a
> top-level window class.  Unfortunately this means that it does not return
> the id of the grid window as this is actually an owner-drawn button control.
> The menu placement is therefore calculated on the basis of the window
> containing the grid control, which accounts for the strange results.
> 
> I ended up creating the grid as a button control because when I started 
> developing it I didn't seem to be able to create a vanilla child window
> to draw the grid contents on.  I guess I always knew this would come back 
> to haunt me in the end!
> 
> Anyway, unless you have any clever ideas, the easiest fix is probably for
> me to clone the old version of the popup() procedure and use that instead
> of the base win32lib version.
> 
> What do you think?

Did you read the docs for popup()? You can use it with an alternative
reference point.

eg.   popup({myPopupMenu, theGrid}, x, y)

where 'x' and 'y' are relative to theGrid and not the top level window.

How are you getting the x/y values? 

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

3. Re: ATTN Derek: EuGrid Sort Menu and win32lib

Derek Parnell wrote:

> Did you read the docs for popup()? You can use it with an alternative
> reference point.
> 
> eg.   popup({myPopupMenu, theGrid}, x, y)
> 
> where 'x' and 'y' are relative to theGrid and not the top level window.
> 
> How are you getting the x/y values? 
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> 
Yes - I already tried passing {popup_id, grid_id} to popup(). Although it
improved the menu placement considerably, it seemed to be consistently out 
by approximately -10 (x-axis) and -5 (y-axis) pixels.  

I had a closer look just now and it seems that I only get the problem
when the grid is placed on a tab control. With a grid on a plain window
the placement is correct. I hadn't spotted it before because
my main test program is style.exw which has a number of grids on a 
multi-page tab window.

The x/y values I am using come from WM_RBUTTONDOWN, 
sent to the grid control.

Regards,

Phil

new topic     » goto parent     » topic index » view message » categorize

4. Re: ATTN Derek: EuGrid Sort Menu and win32lib

Phil Russell wrote:
> 
> Derek Parnell wrote:
> 
> > Did you read the docs for popup()? You can use it with an alternative
> > reference point.
> > 
> > eg.   popup({myPopupMenu, theGrid}, x, y)
> > 
> > where 'x' and 'y' are relative to theGrid and not the top level window.
> > 
> > How are you getting the x/y values? 
> > 
> > -- 
> > Derek Parnell
> > Melbourne, Australia
> > 
> Yes - I already tried passing {popup_id, grid_id} to popup(). Although it
> improved the menu placement considerably, it seemed to be consistently out 
> by approximately -10 (x-axis) and -5 (y-axis) pixels.  
> 
> I had a closer look just now and it seems that I only get the problem
> when the grid is placed on a tab control. With a grid on a plain window
> the placement is correct. I hadn't spotted it before because
> my main test program is style.exw which has a number of grids on a 
> multi-page tab window.
> 
> The x/y values I am using come from WM_RBUTTONDOWN, 
> sent to the grid control.

Okay, I've found my mistake. In the win32lib routine called 'popup'
find the line ...

   BBox = ScreenToClient(findParent(lRelId), BBox[1], BBox[2])

and change it to ...

   BBox = ScreenToClient(parent, BBox[1], BBox[2])

Then call it using 

  popup({mymenu, self}, x, y)

where 'self' is the id of the control that gets the right button
event.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

5. Re: ATTN Derek: EuGrid Sort Menu and win32lib

Derek Parnell wrote:
> 
> Okay, I've found my mistake. In the win32lib routine called 'popup'
> find the line ...
> 
>    BBox = ScreenToClient(findParent(lRelId), BBox[1], BBox[2])
> 
> and change it to ...
> 
>    BBox = ScreenToClient(parent, BBox[1], BBox[2])
> 
> Then call it using 
> 
>   popup({mymenu, self}, x, y)
> 
> where 'self' is the id of the control that gets the right button
> event.
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> 

Derek,

That works fine.  I'll issue a new version of EuGrid with the correct
popup() call plus some version-checking code for backwards compatibility
with 0.59.x.  

I'll put a note in about the win32lib change needed until your next release.

Many thanks for your help on this - and for all the hard work you have
put in on win32lib.  It's much appreciated...

Regards,

Phil Russell
Brighton, UK

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu