Deleting non-modal dialogs Topic is solved

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
Ravilj
Knows some wx things
Knows some wx things
Posts: 40
Joined: Mon Aug 22, 2005 3:49 pm

Deleting non-modal dialogs

Post by Ravilj » Wed Sep 21, 2005 8:52 pm

How does one go about deleting/destroying/closing a non modal dialog? Show( false ) just hides it. The dialog gets created on the click of a button. The parent has a pointer to the dialog to allow for it to be updated. Now how do I go about deleting/destroying/closing the dialog when the close button or the ok button is clicked.

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Wed Sep 21, 2005 11:03 pm

Code: Select all

MyModal* modal = new MyModal(this);
// Show the modal dialog.. this function blocks
modal->ShowModal();
// After they push "OK" on modal and the OK button calls Hide();
// we destroy the dialog
modal->Destroy();

hope that helps...

Ravilj
Knows some wx things
Knows some wx things
Posts: 40
Joined: Mon Aug 22, 2005 3:49 pm

Post by Ravilj » Thu Sep 22, 2005 12:49 am

What I really am looking for is this:

I have a panel with a button, on the click it initiates a non-modal dialog at this time the button is disabled. When the dialog closes (the user clicks the ok button or the close button) the button should be re-enabled.

The dialog needs to be model since there are controls on the panel that change things on the dialog.

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

Post by priyank_bolia » Thu Sep 22, 2005 5:14 am

When the dialog is Modal, why do you care to disable the panel buttons, and way you can disable them by Calling m_button->Enable(false); before ShowModal(); on the dialog and after ShowModal(); renable them by m_button->Enable(true);

Ravilj
Knows some wx things
Knows some wx things
Posts: 40
Joined: Mon Aug 22, 2005 3:49 pm

Post by Ravilj » Thu Sep 22, 2005 8:50 am

What happens is the button captures a frame from a video feed and displays the image in a dialog box.

A panel is the parent of the dialog box. It contains controls that are used to change some attributes on the image frame hence why the dialog must be non-model.

When they close the dialog box, obviously the capture button needs to be re-enabled such that another sample can be taken.

Unfortunately the image can not be shown in the panel which would solve a lot of problems hence why the dialog.

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

Post by priyank_bolia » Thu Sep 22, 2005 9:11 am

So, what the problem creating non-modal dialog or disabling the buttons.

Disabling the buttons:
Save the pointer of the parent passed in the dialog constructor, and before calling the dialog disable the panel button by Enable(false); in the dialog OK button or in OnClose handler, from the parent pointer call a function to renable the panel button by Enable(true);

Ravilj
Knows some wx things
Knows some wx things
Posts: 40
Joined: Mon Aug 22, 2005 3:49 pm

Post by Ravilj » Thu Sep 22, 2005 9:45 am

Thats what I am actually implementing now. The problem was that I was making use of a slider for a threshold level on the image. On a slider event it would update the image. So when the dialog box was hidden the images still get updated hence moving the threshold slider was slow/delayed.

I have since then dropped that idea.

Ahhh, I forgot about the close event.

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

Post by priyank_bolia » Thu Sep 22, 2005 9:51 am

In the Update function you can also check whether the dialog is visible or not by IsShown, and return immediately is hidden.

Ravilj
Knows some wx things
Knows some wx things
Posts: 40
Joined: Mon Aug 22, 2005 3:49 pm

Post by Ravilj » Thu Sep 22, 2005 9:54 am

Ah! I was looking for that function, hmm its not in the documentation that I was using :( That works for me.

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

Post by priyank_bolia » Thu Sep 22, 2005 10:00 am

It is in the wxWindow class documentation, which is the base class of all controls.

Post Reply