Re: Orphaned Popups?

new topic     » goto parent     » topic index » view thread      » older message » newer message

I want to be able to position the Popup right over the System Tray icon. My
Window will be
hidden. The Popup will only popup relative to its parent window. I've only been
able to get it
to popup over the icon if the window is Maximized, since otherwise the mouse
position will be
past the window's edges.

here's what I've got so far:
maximize the window then click the icon towards the top of the system tray, the
Popup will
appear.

-- begin code --
include win32lib.ew

constant MyIcon = extractIcon( {"shell32.dll",14} ) -- globe icon

constant

    Main = create( Window, "Test", 0, 0.2, 0.2, 320, 240, 0 ),
    SysTray = systray_Create( Main ),
    MyPopup = create( Popup, "", Main, 0, 0, 0, 0, 0 ),
    Exit = create( MenuItem, "E&xit", MyPopup, 0, 0, 0, 0, 0 )

systray_SetIcon( SysTray, MyIcon )
systray_Show( SysTray )

procedure Main_w32HClose( integer self, integer event, sequence params )
    systray_Hide( SysTray )
end procedure
setHandler( {Main}, {w32HClose}, routine_id("Main_w32HClose") )

procedure SysTray_onEvent(integer id, atom msg)
sequence pos

    if msg = LeftDown then
        pos = getMousePos()
        popup( MyPopup, pos[1], pos[2] )
        repaintWindow( Main )
        wPuts( Main, sprintf("Clicked (%d, %d)", pos) )
    end if

end procedure
systray_SetEvent( SysTray, routine_id("SysTray_onEvent") )

WinMain( Main, Normal )

-- end code --

----- Original Message -----
From: Derek Parnell <ddparnell at bigpond.com>
To: EUforum <EUforum at topica.com>
Sent: Sunday, March 23, 2003 9:39 PM
Subject: Re: Orphaned Popups?



On Sun, 23 Mar 2003 20:13:22 -0500, Greg Haberek <g.haberek at comcast.net>
wrote:

>
> How would I create a Popup menu in Win32Lib with no parent, or the Screen
> as a parent? I am
> using PatRat's Systray.ew to create a System Tray icon and I want a menu
> to popup when the user
> clicks the icon.
>
> If I try to create a Popup with no parent, I get a "getHandle() failed"
> error.
> If I try to create a Popup with Screen as a parent, I get a
> "ClientToScreen failed" error.
>

Hi Greg,
a couple of questions first.

What problem is caused by having the Popup menu use a parent?

Have you tried using a non-visible parent?

Now, the reason you need a parent is that win32lib calls the API routine
"TrackPopupMenu" to manage it. And this routine needs a handle to a window
so that messages can be passed to something. Your application needs to
receive WM_NOTIFY etc messages to know which menu item has been clicked.


--

cheers,
Derek Parnell



TOPICA - Start your own email discussion group. FREE!

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu