How does FiveW shut down xHb when you close the Mdi frameWND

How does FiveW shut down xHb when you close the Mdi frameWND

Postby peterk » Mon Oct 13, 2008 3:54 pm

If I hit Alt + F4 while my app is starting up and while the main mdi frame wnd is being opened, the main wnd closes and I end up with the application running with no interface and no way of shutting it down (except via task manager)

Normally when I shut down the main aplication Wnd, xHb quits without me having to make a call to xHb quit

This has got me thinking - when you close the FW mdi frame, does FiveWin call a xHb "quit" to quit the xHb application ?
[/list]
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Mon Oct 13, 2008 5:09 pm

Peter,

FiveWin does not call Harbour/xharbour QUIT.

We call PostQuitMessage( 0 ) that makes the main event loop to finalize.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Oct 13, 2008 5:10 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby peterk » Tue Oct 14, 2008 3:48 am

Antonio

Thank you for the quick reply - I wil play around with that

Regards
Peter
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby peterk » Tue Oct 14, 2008 7:07 am

Antonio - is the following a correct description of how an xHb/Fwh application works

1) xHb code starts
2) At some point the xHb code activates the FW Mdi frame Wnd
3) This starts the main FW event loop to handle events
4) xHb code stops at this point (on the line of code that activates the Mdi frame wnd)
5) When the Mdi frame Wnd is closed, the FW event loop is stopped via PostQuitMsg(1) called by the Wnd Destroy event
6) xHb code then continues from the point after the call to activate the Mdi frame Wnd, until it ends

Thanks Peter
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Tue Oct 14, 2008 7:37 am

Peter,

Yes :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby peterk » Tue Oct 14, 2008 7:54 am

Antonio - last thing on this

Per above, if I close the FW Frame Wnd during the bInit, the tWindow class method 'destroy' does call PostQuitMessage(0), however I end up with the xHb app code running in task manager with the Frame Wnd closed.

If I check lWRunning() at that point it returns .f. so the FW event loop is not running but the xHb code is still running and never returns to after the Frame Wnd activate statement

If I manually call PostQuitMessage(0) again after activating the Frame Wnd (If the hWnd == 0), then the xHB app quits

So PostQuitMessage() will shut down the xHb app even if lWRunning returns .f. and the frame Wnd is closed (hWnd == 0) which makes me think PostQuitMessage(0) must also call xHb __Quit()

Is this correct / can you comment on the above please

Thanks
Peter
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Tue Oct 14, 2008 7:59 am

Peter,

__Quit() is not called. You can do this test: declare this function in your main PRG:
Code: Select all  Expand view
function __Quit()
   
   MsgInfo( "QUIT called" )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Tue Oct 14, 2008 8:06 am

Peter,

Are you doing it this way ?
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd

   oWnd:bInit = { || oWnd:End() }

   ACTIVATE WINDOW oWnd

return nil

function __Quit()

   MsgInfo( "quit" )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby peterk » Tue Oct 14, 2008 8:43 am

Antonio

I am pressing ALT F4 during the wnd bInit (which does quite a few startup tasks and so takes a few seconds). When I do this, Twindow Destroy does call PostQuitMessage() but the application continues to run without a Window (in task manager) and the xHb code after the Wnd activate statement is never reached i.e. the system is still runnning the Fw event loop even though the frame Wnd is closed

My code at the end of bInit checks to see if oWnd:hWnd > 0, and if not calls PostQuitMessage() again which shuts the event loop down and then the xHb code after the oWnd:Activate line runs and the app quits normally

However I dont think I should have to call PostQuitMessage a 2nd time ??

Also FW function WinRun() [not documentedin help file] - does this start the FW event handler ?

Thanks, Peter
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Tue Oct 14, 2008 8:53 am

Peter,

> However I dont think I should have to call PostQuitMessage a 2nd time ??

You solution seems ok as probably due the amount of work done before starting the main window, it has not been subclassed yet, so WM_DESTROY is not routed to call PostQuitMessage() thats why the main event loop remains active.

In other words, the window is receiving an order to be destroyed, before than FiveWin can do its job.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Tue Oct 14, 2008 8:54 am

yes, WinRun() starts the main event loop.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby peterk » Tue Oct 14, 2008 9:17 am

Antonio - thanks for the assistance

F Y I - I can also get around this by setting oWnd:bValid to {|| .f.} while the Wnd bInit runs which prevents the user closing the Wnd - this also works ok

Peter
Peter
peterk
 
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Postby Antonio Linares » Tue Oct 14, 2008 9:37 am

Peter,

Thanks for the information.

Yes, that solution is simpler
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 63 guests