Window WM_CLOSE

Window WM_CLOSE

Postby Gary Woodley » Fri Nov 20, 2009 3: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
Gary Woodley
 
Posts: 28
Joined: Mon Apr 27, 2009 3:37 pm
Location: Oxford UK

Re: Window WM_CLOSE

Postby Antonio Linares » Fri Nov 20, 2009 4:42 pm

Gary,

Here you have a working example to manage WM_CLOSE yourself:
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Window WM_CLOSE

Postby Gary Woodley » Wed Nov 25, 2009 3: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
Gary Woodley
 
Posts: 28
Joined: Mon Apr 27, 2009 3:37 pm
Location: Oxford UK

Re: Window WM_CLOSE - Solved

Postby Gary Woodley » Wed Nov 25, 2009 4: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
Gary Woodley
 
Posts: 28
Joined: Mon Apr 27, 2009 3:37 pm
Location: Oxford UK

Re: Window WM_CLOSE

Postby Antonio Linares » Wed Nov 25, 2009 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests