FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How does FiveW shut down xHb when you close the Mdi frameWND
Posts: 47
Joined: Thu Jul 13, 2006 02:39 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Mon Oct 13, 2008 03: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Mon Oct 13, 2008 05: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Mon Oct 13, 2008 05:10 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 47
Joined: Thu Jul 13, 2006 02:39 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 03:48 AM

Antonio

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

Regards
Peter

Peter
Posts: 47
Joined: Thu Jul 13, 2006 02:39 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 07: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 07:37 AM

Peter,

Yes :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 47
Joined: Thu Jul 13, 2006 02:39 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 07: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 07:59 AM
Peter,

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

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 08:06 AM
Peter,

Are you doing it this way ?
#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
Posts: 47
Joined: Thu Jul 13, 2006 02:39 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 08: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 08: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 08:54 AM

yes, WinRun() starts the main event loop.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 47
Joined: Thu Jul 13, 2006 02:39 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 09: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How does FiveW shut down xHb when you close the Mdi frameWND
Posted: Tue Oct 14, 2008 09:37 AM

Peter,

Thanks for the information.

Yes, that solution is simpler

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion