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.
MyDialog * pDlg = new MyDialog(...);
pDlg->Show();
Where to put delete this?
Neither MyDialog::~MyDialog nor OnDestroy(EVT_WINDOW_DESTROY) is called when the window is closed by click the close button.
Until the parent window (the main window for the app) is closed, OnDestroy and MyDialog::~MyDialog are called in order.
Neither MyDialog::~MyDialog nor OnDestroy(EVT_WINDOW_DESTROY) is called when the window is closed by click the close button.
Handle the wxEVT_CLOSE event.
However, if you need a modal window, use wxDialog. For non-modal, use wxFrame.
Why do you need a non-modal dialog?
Additionally, a wxDialog should not destroy itself as it could be created on the stack and there is no way for the dialog itself to know. The part in your application that creates the dialog should also destroy it.
doublemax wrote: ↑Thu Sep 05, 2019 2:37 pm
However, if you need a modal window, use wxDialog. For non-modal, use wxFrame.
Why do you need a non-modal dialog?
For updating data for a long time. I should use wxFrame.
doublemax wrote: ↑Thu Sep 05, 2019 2:37 pm
Additionally, a wxDialog should not destroy itself as it could be created on the stack and there is no way for the dialog itself to know. The part in your application that creates the dialog should also destroy it.
OK, I'm from MFC, there a dialog can be modal or modaless.
ONEEYEMAN wrote: ↑Thu Sep 05, 2019 2:53 pm
Which function?
Are you creating a thread behind this dialog?
a button click event handler
ONEEYEMAN wrote: ↑Thu Sep 05, 2019 2:53 pm
What is the exact scenario?
crawl data from web, needs a long time.
ONEEYEMAN wrote: ↑Thu Sep 05, 2019 2:53 pm
As doublemaxc pointed out - it is better to use wxDialog for modality and wxFrame/wxPanel for modeless things.
But in any case - dialogs are very rarely created on the heap.
wxFrame is what I need here, I'm from MFC and wxDialog has a method Show, it makes me think it can be modal by design.
1. You have a main top-level wxFrame with the button.
2. When this button is clicked, you start the web crawler in a thread and at the same time display the dialog.
3. When the crawler is done you dismiss the dialog and display the data acquired in the main top-level window.
Am I right?
In this case you should probably run wxProgressDialog during crawling.
ONEEYEMAN wrote: ↑Thu Sep 05, 2019 3:07 pm
Hi,
So the scenario you are looking for is this:
1. You have a main top-level wxFrame with the button.
2. When this button is clicked, you start the web crawler in a thread and at the same time display the dialog.
3. When the crawler is done you dismiss the dialog and display the data acquired in the main top-level window.
Am I right?
When crawling data, the newest crawled data can be used by the application instantly.
ONEEYEMAN wrote: ↑Thu Sep 05, 2019 3:07 pm
In this case you should probably run wxProgressDialog during crawling.
Currently the dialog is quite customized:
1. contain a wxPropertyGrid for config crawler
2. contain a wxPropertyGrid for showing different summary status for the progress, such as: total tasks/left tasks/succeeded tasks/failed tasks
3. contain a list ctrl for show logging messages
Is wxProgressDialog suitable?
Hi,
The customization crawler dialog should probably be done as a modal dialog.
Now when the crawler setting is satisfactory, user presses OK, wxProgressDialog starts (probnably wxGenericProgressDialog) with some customizatrions - such as number of tasks completed/succeeded/failed, etc.
ONEEYEMAN wrote: ↑Thu Sep 05, 2019 5:32 pm
Hi,
The customization crawler dialog should probably be done as a modal dialog.
Now when the crawler setting is satisfactory, user presses OK, wxProgressDialog starts (probnably wxGenericProgressDialog) with some customizatrions - such as number of tasks completed/succeeded/failed, etc.
I've looked some screenshot about wxProgressDialog, it is designed for progress.
ONEEYEMAN wrote: ↑Thu Sep 05, 2019 5:32 pm
But both of them should be modal.
What does modal mean here?
If modal means parent window is not operatable, it can't be modal in the case, because data updating is a background job.
I think wxFrame is more suitable.
Thanks