Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » How to Close Modal Dlg from Constructor?
How to Close Modal Dlg from Constructor? [message #18371] Thu, 25 September 2008 09:46 Go to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Hi,
I am trying to make a "Wait a moment, please..." dlg that is shown while computation is running. When computation finish the dlg must be closed automatically.
So, I used a modal dlg and in the contructor i have the following code:

ConstructorMethod
{
...
executeAlgorithm();
Close();
}

But the dlg never closes... As it as a close button if I click it the dlg closes.

Any ideas?

Alex
Re: How to Close Modal Dlg from Constructor? [message #18372 is a reply to message #18371] Thu, 25 September 2008 10:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Too little to comment... Testcase?

Do you use "Open"?

Mirek
Re: How to Close Modal Dlg from Constructor? [message #18373 is a reply to message #18372] Thu, 25 September 2008 10:28 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
LancaAnuids.h

#ifndef _CLancaAnuidsDlg_h
#define _CLancaAnuidsDlg_h

#include <CtrlLib/CtrlLib.h>
#include "Main.h"
using namespace Upp;

#define LAYOUTFILE <Main/LancaAnuids.lay>
#include <CtrlCore/lay.h>

class CLancaAnuidsDlg : public WithLancaLayout<TopWindow>
{
public:
typedef CLancaAnuidsDlg CLASSNAME;
CLancaAnuidsDlg();

private:
void Lanca(void);
};

#endif





LancaAnuids.cpp

#include "LancaAnuids.h"
CLancaAnuidsDlg::CLancaAnuidsDlg()
{
CtrlLayout(*this, Ctrl::GetAppName());

Lanca();

Close();
}


void CLancaAnuidsDlg::Lanca(void)
{
//Database intensive operations here...
}


On Main dlg I do:

void Main::LancaAnuidades(void)
{
CLancaAnuidsDlg dlg;
dlg.Run(true);
}


The dlg just has a static box saying:

Wait a moment please...


Thanks

Alex
Re: How to Close Modal Dlg from Constructor? [message #18374 is a reply to message #18373] Thu, 25 September 2008 10:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ah, this one is obvious:)

Dialog gets opened (and closed) in modal loop of "Run". Means your Close is basically NOP, because it is not opened yet.

What you need to do is to Open, Lance, Close. No modal loop.

I recommend seeing ProgressIndicator code....

Mirek
Re: How to Close Modal Dlg from Constructor? [message #18375 is a reply to message #18374] Thu, 25 September 2008 10:36 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Yes, I also thought that and thought to put a timer on contructor and after 2 seconds call the close but it is not a good fix...


Alex
Re: How to Close Modal Dlg from Constructor? [message #18376 is a reply to message #18371] Thu, 25 September 2008 10:39 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Cant find progress sample...

Alex
Re: How to Close Modal Dlg from Constructor? [message #18379 is a reply to message #18376] Thu, 25 September 2008 12:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kbyte wrote on Thu, 25 September 2008 04:39

Cant find progress sample...

Alex


CtrlLib/Progress

BTW, I guess maybe Progress is what you really need....

Mirek
Re: How to Close Modal Dlg from Constructor? [message #18380 is a reply to message #18371] Thu, 25 September 2008 12:16 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Any sample of usage? Embarassed


Alex
Re: How to Close Modal Dlg from Constructor? [message #18411 is a reply to message #18380] Sun, 28 September 2008 19:56 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
Ok,

Progress dlg("Sample",0);
dlg.Run(true);
Re: How to Close Modal Dlg from Constructor? [message #18412 is a reply to message #18411] Sun, 28 September 2008 20:15 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Progress pi("Working");
for(int i = 0; i < 100; i++) {
    if(pi.StepCanceled()) {
       Exclamation("Interrupted by user");
       return;
    }
    Sleep(500);
}
Previous Topic: ImageBuffer Paint problem
Next Topic: DHCtrl based control issue in Windows Vista
Goto Forum:
  


Current Time: Fri Apr 19 02:43:38 CEST 2024

Total time taken to generate the page: 0.02747 seconds