Bring to foreground

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Bring to foreground

Post by priyank_bolia » Sat Jan 07, 2006 4:42 pm

is there wxWidgets API for bring window to foreground and accept key events. Raise don't work for me.

Ksmith22
I live to help wx-kind
I live to help wx-kind
Posts: 199
Joined: Mon Nov 21, 2005 4:34 pm

Post by Ksmith22 » Mon Jan 09, 2006 3:55 pm


priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Mon Jan 09, 2006 4:50 pm

Ksmith22 wrote:SetFocus()
No, not that, actually the problem is when I click a tree item, a show a dialog box, and it goes behind the main window, so I want to bring it to the front, no stay on top and timer solution.

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Mon Jan 09, 2006 6:22 pm

Have you tried wxDialog::Show(true) ? according to the help text:
If true, the dialog box is shown and brought to the front; otherwise the box is hidden. If false and the dialog is modal, control is returned to the calling program.
Maybe it helps...

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Tue Jan 10, 2006 6:31 am

Jorg wrote:Have you tried wxDialog::Show(true) ? according to the help text:
If true, the dialog box is shown and brought to the front; otherwise the box is hidden. If false and the dialog is modal, control is returned to the calling program.
Maybe it helps...

- Jorgen
Its a frame, and I already call show in the constructor, the problem is due to tree ctrl, I show the frame in the onclick event handler, it comes up and goes down. I had to use a timer, to again bring it up. And I don't want that, so any solution.

DFYX
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Apr 04, 2007 10:36 am
Contact:

Post by DFYX » Wed Apr 04, 2007 10:50 am

I'm sorry for posting in a thread which is more than one year old, but I guess that's better than opening a new one since I have exactly the same problem.

I made a wxTreeCtrl with a list of files and there are two ways for the user to open a preview window. He can either doble click on the node in the tree or he can use a popup menu. While the popup menu works great, a doble click (EVT_TREE_ITEM_ACTIVATED) causes the new Frame to appear behind the current one. I think the reason is that there is another event (something about mouse clicks) which gets to the wxTreeCtrl after the event I actually use.

I thought about setting wxSTAY_ON_TOP or wxFRAME_FLOAT_ON_PARENT, but I don't really like this solution. At least not if there is no way to remove those flags after half a second or something.

tan
Moderator
Moderator
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan » Wed Apr 04, 2007 11:05 am

Hi,
what way you show the new Frame from EVT_TREE_ITEM_ACTIVATED event handler? Just call some_frame->Show()?
My suggestion is using AddPendingEvent in the activate handler. You can use your popup menu event here since it make the same job :)
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10

DFYX
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Apr 04, 2007 10:36 am
Contact:

Post by DFYX » Wed Apr 04, 2007 11:29 am

I guess that could work. I'll edit this post as soon as I've tried.

Edit:
Works great. Thanks!

evendine
Experienced Solver
Experienced Solver
Posts: 70
Joined: Tue Dec 05, 2006 6:39 pm

Post by evendine » Tue Jan 29, 2008 6:58 pm

I have wasted much time on this issue (identical problem to the one DFXY described)...

Under MSW these functions seem to be patchy at best and often non-functional, as far as I can tell:

Code: Select all

SetFocus()
Raise()
Show()
One would expect

Code: Select all

event.Skip(false)
at the end of the wxTreeCtrl activate handler to prevent all further event processing related to that event, but it clearly doesn't, which makes one wonder if things as basic as Skip() and Raise() don't work - what does!? :wink:
wxLib 3.0.3
MSVS 2010 Ultimate RTMRel v10.0.30319.1
MSVC++ 2010
Windows 7 Ultimate x64 v6.1.7601 SP1

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Wed Jan 30, 2008 2:30 am

I guess, setting the tree control as parent of the frame would resolve the issue. Try it, also try with set_on_top_of_parent flag.

rex666
Earned a small fee
Earned a small fee
Posts: 20
Joined: Mon Nov 08, 2004 12:15 am

Post by rex666 » Wed Jan 30, 2008 7:54 pm

I was having the same problem on wxMac. In my situation, I double-clicked on a list to show a window with info about the item. I found that if I used the menu or menu shortcut the new window would be above my list window, but if the list control's activate handler was used the new window would be behind the list window.

Tracing in the debugger, it seems that the Mac mouse handling code would bring the window that was clicked on to the front after the wxEvent processing was finished, but before the next wxEvent was processed. I solved the problem by changing my code to use AddPendingEvent to simulate a menu selection, instead of just calling my menu handler directly from inside the list event handler. This allows the mac mouse code to do its thing and bring the clicked list window to the front before creating the history view.

If you have a context menu, then you should also make a custom menu class that does the same thing.

Post Reply