wxProgressDialog without mainframe-window but eventloop 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
MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

wxProgressDialog without mainframe-window but eventloop

Post by MoonKid »

wxProgressDialog need a running eventloop to work.

I have a wxApp without creating a top-level window. It only do some work automaticly and tell the progress with a progress-window and close after that automaticly.

Using wxProgressDialog inside wxApp::OnInit() doesn't work because while this no eventloop is running.

Using it in wxApp::OnRun() has the same problem.
When I call the default OnRun() the eventloop run but idle and never step back. So my app can not do it's work.

How can I solve that?
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Moin!

Try with a wxWidgets 2.9.x release. Quoting the changelog:

"Major new features in this release
----------------------------------
....
- Event loops, timers and sockets can now be used in wxBase, without GUI.
...."

Apparently this would solve your issue.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

wxProgressDialog derives from wxDialog, so it should have it's own event loop. What platform/wx version are you using?

If i put the following code in MyApp::OnInit() of the "minimal" sample, it does work:

Code: Select all

{
  wxProgressDialog prog(wxT("test"), wxT("test"));
  bool ok=true;
  for(int i=0; i<100 && ok; i++) {
    ok=prog.Update(i);
    ::wxMilliSleep(25);
  } 
}
Using wxProgressDialog inside wxApp::OnInit() doesn't work because while this no eventloop is running.
Is it a console application, or a "normal" GUI application, just without a main window? If it's a console application, you must follow upCASEs advice and use 2.9.x
Use the source, Luke!
MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

Post by MoonKid »

Does prog.Pulse() work, too?

btw: I will update my SVN and try it with the newest version. If this doesn't work I will post more code here.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

Yes, prog.Pulse() works, too.
BTW, this was tested on wx 2.8.9
Use the source, Luke!
Post Reply