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

oex

WM_THIS, WM_THAT.... I write a lot of console code but there are some things where I have to interface with windows which I dont want to have to write at an insanely low level and also dont want to create a window just to proces WM_ messages.... ie WM_DEVICECHANGED....

What is the simplest way to create a message handling proc for these.... Is there any problem with this from console? CreateDialogEx? CreateWindowEX? Something even simpler? Obviously I just need an invisible message handler and not a window....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

lol
that stuff isn't so bad
anyways - Hutch has a program that might help
search for "Code Generator" or "ProStart" in the masm32 project sub-forum
it gets the code started for you - you just add in the things you need

i am not sure what you are trying to do
another term you might search is "message only" window
a window that handles messages, but displays nothing

oex

Yeah atm I would use CreateWindowEx but it's annoying because you have about 20 lines of code to do a simple interface with windows.... I just wondered if there was a quicker and easier way of creating a hWnd and a messaging proc but still probably lower level than CreateDialog
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

it sounds to me like a message-only window is what you want, Peter

dedndave

here is an example to get you started
http://www.masm32.com/board/index.php?topic=10266.msg75422#msg75422

but - a regular window isn't that bad

register a class
create the window
message loop
WndProc to handle messages

as i said, Hutch's ProStart will get it started for you

oex

Perfect :bg ty.... At least better than I have got already with HWND_MESSAGE.... :lol still all the class struct crap but I minimise most of that already.... It's never neat and simple is it :lol....

All I want is to catch notification events but they require registration of windows I think....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

hutch--

Peter,

There is an old trick of starting a window off screen and using its message loop to do the stuff you have in mind. For the 4 co-ordinates just use negative numbers, -1024,-1024,500,400 and the window will start but you just don't see it. A bare "main" with an attached WndProc() is very simple code and its small as well. If you want it to run on later OS versions a manifest and version control block are more or less necessary.

have a look at the "masm1k" example in the example code, you cannot do it smaller.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

184 bytes of code.... (i.e. not counting data)
i am sure it could be smaller   :bg

hutch--

Dave,

just merge the sections and it will drop to 1k.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: dedndave on March 23, 2011, 04:58:58 AM
184 bytes of code.... (i.e. not counting data)
i am sure it could be smaller   :bg


        INVOKE  CreateWindowEx,edi,esi,offset AppName,
                WS_OVERLAPPEDWINDOW or WS_VISIBLE or WS_CLIPCHILDREN,
                CW_USEDEFAULT,SW_SHOWNORMAL,400,300,edi,edi,ebx,edi
Y=SW_SHOWNORMAL happens to be 1 ::)

sinsi

Quote from: oex on March 23, 2011, 03:48:50 AM
WM_THIS, WM_THAT.... I write a lot of console code but there are some things where I have to interface with windows which I dont want to have to write at an insanely low level and also dont want to create a window just to proces WM_ messages.... ie WM_DEVICECHANGED....

What is the simplest way to create a message handling proc for these.... Is there any problem with this from console? CreateDialogEx? CreateWindowEX? Something even simpler? Obviously I just need an invisible message handler and not a window....
Maybe go the other way, make a window then create a console?
Light travels faster than sound, that's why some people seem bright until you hear them.

Ghandi

What about getting a handle to the console window and subclassing its window proc to point at yours, pass the messages you don't want to process to the original handler and process the ones you do want to.

*EDIT* Scratch that, i have only donea simple test but it appears that changing the WndProc is not allowed from a Console app...

HR,
Ghandi

dedndave

Jochen,
QuoteY=SW_SHOWNORMAL happens to be 1  ::)
QuoteIf an overlapped window is created with the WS_VISIBLE style bit set and the x parameter is set to CW_USEDEFAULT,
then the y parameter determines how the window is shown. If the y parameter is CW_USEDEFAULT, then the window
manager calls ShowWindow with the SW_SHOW flag after the window has been created. If the y parameter is some
other value, then the window manager calls ShowWindow with that value as the nCmdShow parameter.

he was looking for a way to hide the window
so, it could be SW_HIDE

dedndave

Peter,
here is a hidden window
you can terminate it with the Task Manager   :P

dedndave

Ghandi,
Quotei have only done a simple test but it appears that changing the WndProc is not allowed from a Console app...

i think if you run an app, shell the cmd.exe window (so that your program is the owner), then use SetClassLong, you can do it
haven't had a chance to try it - it's on my list   :P