SystemTray, SetForegroundWindow and DialogBoxParam 
Author Message
 SystemTray, SetForegroundWindow and DialogBoxParam

Hi,
There is this problem I'm trying to solve for hours, maybe someone's got an
idea; I've tried everything to no avail.

The setup:
It's a small application; it creates an icon in the system tray , which ,
when clicked, opens a popup menu. You can select 'Configure' from the
popup-menu and a configuration dialog box pops up. The problem is that, when
I select 'Configure' from the popup-menu, the dialog box
pops up, but has no focus and it's impossible to activate it (clicking with
the mouse, Alt-Tab, etc).

The implementation:
First I create an invisible window with the WS_OVERLAPPEDWINDOW style. When
showing the pop-up system tray menu, I call
SetForegroundWindow (this invisible window). When a menu command is
selected, I call DialogBoxParam() to create the dialog box.

Now, If I call SetForegroundWindow() before TrackPopupMenu, the dialog box
appears with no focus. If I don't call SetForegroundWindow(),
the tray menu won't dissapear unless you select an option, but the dialog
appears ok (activated, with focus).
I'm sure I've had this problem before, but I can't remember how I solved it
then.

Any ideas ?

Thanks,

Florin



Mon, 25 Apr 2005 22:01:18 GMT  
 SystemTray, SetForegroundWindow and DialogBoxParam
When calling DialogBoxParam, what do you pass as a parent window handle?
Try passing your main window
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hi,
> There is this problem I'm trying to solve for hours, maybe someone's
got an
> idea; I've tried everything to no avail.

> The setup:
> It's a small application; it creates an icon in the system tray ,
which ,
> when clicked, opens a popup menu. You can select 'Configure' from the
> popup-menu and a configuration dialog box pops up. The problem is
that, when
> I select 'Configure' from the popup-menu, the dialog box
> pops up, but has no focus and it's impossible to activate it (clicking
with
> the mouse, Alt-Tab, etc).

> The implementation:
> First I create an invisible window with the WS_OVERLAPPEDWINDOW style.
When
> showing the pop-up system tray menu, I call
> SetForegroundWindow (this invisible window). When a menu command is
> selected, I call DialogBoxParam() to create the dialog box.

> Now, If I call SetForegroundWindow() before TrackPopupMenu, the dialog
box
> appears with no focus. If I don't call SetForegroundWindow(),
> the tray menu won't dissapear unless you select an option, but the
dialog
> appears ok (activated, with focus).
> I'm sure I've had this problem before, but I can't remember how I
solved it
> then.



Tue, 26 Apr 2005 01:33:15 GMT  
 SystemTray, SetForegroundWindow and DialogBoxParam
Tried both (NULL and main window), same results.


Quote:
> When calling DialogBoxParam, what do you pass as a parent window handle?
> Try passing your main window
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > Hi,
> > There is this problem I'm trying to solve for hours, maybe someone's
> got an
> > idea; I've tried everything to no avail.

> > The setup:
> > It's a small application; it creates an icon in the system tray ,
> which ,
> > when clicked, opens a popup menu. You can select 'Configure' from the
> > popup-menu and a configuration dialog box pops up. The problem is
> that, when
> > I select 'Configure' from the popup-menu, the dialog box
> > pops up, but has no focus and it's impossible to activate it (clicking
> with
> > the mouse, Alt-Tab, etc).

> > The implementation:
> > First I create an invisible window with the WS_OVERLAPPEDWINDOW style.
> When
> > showing the pop-up system tray menu, I call
> > SetForegroundWindow (this invisible window). When a menu command is
> > selected, I call DialogBoxParam() to create the dialog box.

> > Now, If I call SetForegroundWindow() before TrackPopupMenu, the dialog
> box
> > appears with no focus. If I don't call SetForegroundWindow(),
> > the tray menu won't dissapear unless you select an option, but the
> dialog
> > appears ok (activated, with focus).
> > I'm sure I've had this problem before, but I can't remember how I
> solved it
> > then.



Tue, 26 Apr 2005 02:08:32 GMT  
 SystemTray, SetForegroundWindow and DialogBoxParam
That's strange. I'm using it all the time, works for me just fine.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Tried both (NULL and main window), same results.



> > When calling DialogBoxParam, what do you pass as a parent window
handle?
> > Try passing your main window



Tue, 26 Apr 2005 02:15:55 GMT  
 SystemTray, SetForegroundWindow and DialogBoxParam
Could you please explain (or give me a pointer as to where to read about)
why it should work ?
I've been trying to find a detailed document which explains z-order,
foreground and background windows, etc but
couldn't manage to find anything except definitions in MSDN.


Quote:
> That's strange. I'm using it all the time, works for me just fine.
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > Tried both (NULL and main window), same results.



> > > When calling DialogBoxParam, what do you pass as a parent window
> handle?
> > > Try passing your main window



Tue, 26 Apr 2005 04:30:58 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. DialogBoxParam problems...

2. Error using DialogBoxParam or DialogBox

3. DialogBoxParam Error?

4. ActiveX is not working with DialogBoxParam()???

5. DialogBoxParam problem!

6. SystemTray Position?

7. Balloon Tips in SystemTray (or Soup, Again)

8. Balloon Tips in SystemTray (or Soup, Again)

9. Minimise to SystemTray

10. locale.nls & systemtray clock replacing

11. SystemTray problem

12. locale.nls & SystemTray clock replacing

 

 
Powered by phpBB® Forum Software