wxFrame MakeModal no wxCloseEvent

66 views
Skip to first unread message

Markus Plessing

unread,
Jul 20, 2010, 2:50:16 AM7/20/10
to wx-...@googlegroups.com
Hi there,

I have a wxFrame that is opened with style wxDEFAULT_FRAME_STYLE.

The first case is, that the Frame is opened as a second level Frame
and brought to front with ->Show() and ->Raise();

The second case is that the Frame is opened as a third level Frame
from within a modal dialog. To bring the Frame to front I have to
call ->Show() ->Raise() ->MakeModal(true);

The problem is, that in the second case a click on the wxCLOSE_BOX is
not triggering any action. Why in this case no wxCloseEvent is generated
and therefor the EventHandler for EVT_CLOSE is not called?

wxSTAY_ON_TOP is not what I want, because it affects all Frames managed
by the WindowManager beeing permanently overlayed by my Frame.

Thanks for your help. I'm using wx 2.8.9.1 and the behaviour was found
on Linux (Ubuntu 9.04) with GTK.

Markus

Markus Plessing

unread,
Jul 20, 2010, 7:10:19 AM7/20/10
to wx-...@googlegroups.com
Hi,

thanks for the answer. The parents are set properly. An additional event
for the parent may work, but how to get the info that the wxCLOSE_BOX
was clicked ?!?

I've investigated a bit more into this and found that the second level
window, which is opened before this special third level frame, is
derived from wxDialog to block processing until user action ...

wxFrame -> wxFrame (MakeModal) ==> wxCLOSE_BOX event
wxFrame -> wxDialog (modal) -> wxFrame (modal) ==> wxCLOSE_BOX no event

If I try to open the second wxFrame from the main frame by sending an
event to the main frame the behaviour is the same. It seems that if a
modal wxDialog is active the wxCloseEvents are suppressed.

Markus

Kinaou HERVE schrieb:
> Hi,
>
> Did you correctly defined the parent of the children frames (which is
> used for the events propagation)?
>
> Probably you may connect the closing event of your children frames on
> a specific function into your first level frame to close effectively
> the expected frame:
>
> my_second_third_frame->Connect(wxEVT_CLOSE_WINDOW,
> wxCloseEventHandler(ParentFrame::OnClose),
> NULL,
> my_parent_frame);
>
> ParentFrame::OnClose(wxCloseEvent & event)
> {
> wxDynamicCast(event.GetEventObject(), wxFrame)->Destroy();
> }
>
>
>
> 2010/7/20 Markus Plessing <ples...@ems-wuensche.com>:

>> --
>> To unsubscribe, send email to wx-dev+un...@googlegroups.com
>> or visit http://groups.google.com/group/wx-dev
>>
> -- --
>

Vadim Zeitlin

unread,
Jul 20, 2010, 7:41:59 AM7/20/10
to wx-...@googlegroups.com
On Tue, 20 Jul 2010 08:50:16 +0200 Markus Plessing <ples...@ems-wuensche.com> wrote:

MP> The second case is that the Frame is opened as a third level Frame
MP> from within a modal dialog. To bring the Frame to front I have to
MP> call ->Show() ->Raise() ->MakeModal(true);

This won't work with wxGTK. You need to use a dialog and call its
ShowModal() method to allow it to get any events while another modal dialog
is active.

Regards,
VZ

Reply all
Reply to author
Forward
0 new messages