FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Window WM_CLOSE
Posts: 28
Joined: Mon Apr 27, 2009 03:37 PM
Window WM_CLOSE
Posted: Fri Nov 20, 2009 03:36 PM

Hi,

We have a Main.exe program that calls various other executeables. When we close the Main program we send as an example:-
SendMessage( FindWindow( 0, default_text("TITLE","ORDERS") ), WM_CLOSE ) to all the seperate executeables.

One of our programs (ORDERS.exe) opens a seperate MDI window, unfortunately when it receives the WM_CLOSE it actually errors before the VALID is called that closes the MDI window. Is there any way to catch WM_CLOSE so I can close the MDI as soon as it receives the message.

I have added an MDI window close which is called on the VALID of the ORDERS screen and it closes correctly, but when the ORDERS.exe receives the WM_CLOSE from the Mian window it errors before the VALID is called.

Any ideas how to stop the error?

Regards

Gary

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Window WM_CLOSE
Posted: Fri Nov 20, 2009 04:42 PM

Gary,

Here you have a working example to manage WM_CLOSE yourself:

#include "FiveWin.ch"

function Main()

   local oWnd := TMyMDI():New()

   ACTIVATE WINDOW oWnd

return nil

CLASS TMyMDI FROM TMDIFrame

   METHOD HandleEvent( nMsg, nWParam, nLParam )

ENDCLASS

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyMDI

   if nMsg == WM_CLOSE
      return nil // nil requires default Windows behavior
   endif
   
return Super:HandleEvent( nMsg, nWParam, nLParam )

Could you please post here your error.log to review it ? thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 28
Joined: Mon Apr 27, 2009 03:37 PM
Re: Window WM_CLOSE
Posted: Wed Nov 25, 2009 03:46 PM

Hi Antonio,

Does that mean I have to change my original class that created the MDI Window?

Unfortunately I don’t get an error log, but the Visual Studio Just-in-time debugger displays stating ‘An unhandled Win32 exception has occurred’ . If I run the program on a Vista system no error seems to occur. Opening Microsoft Visual Studio displays:-
Unhandled exception at 0x0044e55a in ord_mod.exe: 0xC0000005: Access violation reading location 0x00000000.

Regards

Gary

Posts: 28
Joined: Mon Apr 27, 2009 03:37 PM
Re: Window WM_CLOSE - Solved
Posted: Wed Nov 25, 2009 04:09 PM

Hi Antonio,

Problem solved, we issue a SendMessage( FindWindow( 0, "NEWSCHED" ), WM_CLOSE ) followed by Inkey(.1) to the window (NEWSCHED) that was causing the problem and now functions correctly. Needed the time delay as well, I assume to allow the mdi to close before the main window closed.

Regards

Gary

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Window WM_CLOSE
Posted: Wed Nov 25, 2009 06:26 PM

Gary,

> Does that mean I have to change my original class that created the MDI Window?

Yes, you may modify FWH\source\classes\mdiframe.prg, recompile it and use it as another OBJ of your EXE, or use an inherited Class as I have shown you.

There is no other way to modify the behavior for WM_CLOSE management.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion