News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

WM_AVOIDANCE

Started by oex, March 23, 2011, 03:48:50 AM

Previous topic - Next topic

dedndave

yah - i think it's missing a few things
if you take that Hidden program, it would be easy to add handling of WM_DEVICECHANGE to the WndProc
WndProc PROC    hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

        mov     ecx,uMsg
        cmp     ecx,WM_DEVICECHANGE
        jz      DevChange

        cmp     ecx,WM_DESTROY
        jz      WndPrZ

;------------------------------

;unhandled messages come here

;the return address and 4 parms are already on the stack
;if you push EBX, EBP, ESI, or EDI, be sure to pop them

        leave
        JMP     DefWindowProc

;------------------------------

;WM_DEVICECHANGE

DevChange:

;code here - refer to DBT_DEVICEARRIVAL documentation

;------------------------------

;exit with 0

WndPr0: xor     eax,eax
        ret

;------------------------------

;WM_DESTROY

WndPrZ: INVOKE  PostQuitMessage,NULL
        jmp     WndPr0

WndProc ENDP


if you are using it the way i think you are, you could remove the WM_DESTROY code

oex

Quote from: dedndave on March 27, 2011, 03:55:51 AM
yah - i think it's missing a few things
if you take that Hidden program, it would be easy to add handling of WM_DEVICECHANGE to the WndProc

Yep already tested and working with the code I just posted.... (I excluded the loops etc and just posted the 'guts' :lol)....

The missing bits might be things like Icon and CreateWindowEx params however as the window doesnt get drawn I dont see that this would be necessary....

I already had most of the code in the program's main window however this window is not always loaded hence the minimal window on a seperate thread....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

Peter,
i had a need for a hidden window, as well
in my case, i wanted the hidden window to run a visible one
and, i wanted them to be able to communicate back and forth
once each window has the handle to the other, it is pretty simple

the user opens the hidden window
it runs the visible window, passing the handle on the command line

the visible window then sends its' handle back to the hidden window via WM_COPYDATA
once the handles have been exchanged, the hidden window can revector the WM_COPYDATA handler for other messages

closing the visible window sends a message to the hidden one to close also   :P

(the visible window .EXE is renamed as .BIN, and can be in any PATH'ed folder)