Hey everybody,
I'm using a LISTBOX as a main window for my application. As the main app, I have to subclass it to handle WM_DESTROY so I can call PostQuitMessage. Since this is the only message I need to handle, I want to do this as cheap as possible. Here's what I'm using:



OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

ListSubProc PROC hWnd,uMsg,wParam,lParam:DWORD
cmp DWORD PTR [esp+8],WM_DESTROY
jne @F
invoke PostQuitMessage,NULL
@@: pop eax
push oldListProc
push eax
jmp CallWindowProc
ListSubProc ENDP

OPTION PROLOGUE:PROLOGUEDEF
OPTION EPILOGUE:EPILOGUEDEF


Anybody have any other ideas?
My other thought was to watch my message loop for a WM_DESTROY

--Chorus
Posted on 2002-10-15 18:13:50 by chorus
Chorus,

there is an example in MASM32 that does just what you are doing so it may be worth you having a look at it. Running a list box as a seperate window works fine as long as you understand that the subclass is actually acting like the WndProc in a normal window.

Regards,

hutch@movsd.com
Posted on 2002-10-15 23:40:09 by hutch--
As the main app, I have to subclass it to handle WM_DESTROY so I can call PostQuitMessage.
Why? The listview is one of the standard windows, it should already handle this message itself.
Posted on 2002-10-16 20:24:46 by sluggy
Sluggy, for the very reason that it is one of the common controls it does not post the quit message. Otherwise, everytime you closed a List box, your app would terminate.

What it does do for WM_DESTROY is free any memory associated with the window (strings, etc). But if I don't handle the message, only the window closes. The process continues to run.

Since this is the only message that I have to subclass the window for I'd like to do it as efficiently as possible. The only other thing I can think of is to not subclass it and watch in my message loop for the WM_DESTROY message and post the quit message from there (or just terminate)

--Chorus
Posted on 2002-10-16 22:16:28 by chorus
This is what I was thinking of as an alternative (a slightly modified message loop):



@@: invoke GetMessage,addr msg,NULL,NULL,NULL
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
cmp msg.message,WM_DESTROY
jne @B
invoke ExitProcess,NULL


I'm assuming DispatchMessage doesn't change the message field of msg

--Chorus
Posted on 2002-10-16 22:20:57 by chorus