Bring to foreground
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
Bring to foreground
is there wxWidgets API for bring window to foreground and accept key events. Raise don't work for me.
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
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.Ksmith22 wrote:SetFocus()
Have you tried wxDialog::Show(true) ? according to the help text:
- Jorgen
Maybe it helps...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.
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
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.Jorg wrote:Have you tried wxDialog::Show(true) ? according to the help text:
Maybe it helps...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.
- Jorgen
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.
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.
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:
One would expect
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!? 
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()
Code: Select all
event.Skip(false)

wxLib 3.0.3
MSVS 2010 Ultimate RTMRel v10.0.30319.1
MSVC++ 2010
Windows 7 Ultimate x64 v6.1.7601 SP1
MSVS 2010 Ultimate RTMRel v10.0.30319.1
MSVC++ 2010
Windows 7 Ultimate x64 v6.1.7601 SP1
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
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.
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.