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

jj2007

Quote from: dedndave on March 23, 2011, 12:19:44 PM
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

Win32.hlp:
QuoteIf an overlapped window is created with the WS_VISIBLE style bit set and the x parameter is set to CW_USEDEFAULT, Windows ignores the y parameter.

So they changed either the doc, or the behaviour. Interesting.

dedndave

win32.hlp is very old   :P
i am guessing it was an error in the doc
if you search the forum, you can find a thread where they were playing with it - and tested it on different OS's

qWord

here an variant of message-only-window by using an predefined window class:
Quoteinclude masm32rt.inc
.data?
   pcbWndProc PVOID ?
.code

MsgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
   
   .if uMsg == WM_xyz
   
   .else
       invoke CallWindowProc,pcbWndProc,hWnd,uMsg,wParam,lParam
       ret
   .endif
   
   xor eax,eax
   ret
   
MsgProc endp

main proc
LOCAL msg:MSG

   mov esi,rv(CreateWindowEx,0,"Button",0,0,-1000,-1000,100,100,0,0,rv(GetModuleHandle,0),0)
   mov pcbWndProc,rv(GetWindowLong,esi,GWL_WNDPROC)
   invoke SetWindowLong,esi,GWL_WNDPROC,OFFSET MsgProc

   .while 1
       invoke GetMessage,ADDR msg,0,0,0
       .break .if !eax || eax == -1
       invoke TranslateMessage,ADDR msg
       invoke DispatchMessage,ADDR msg
   .endw
   
   invoke ExitProcess,0
   
main endp
end main
FPU in a trice: SmplMath
It's that simple!

baltoro

#18
If you are really a cool programmer (like me), it's a simple thing to keep a number of source code files handy that constitute a skeleton Windows application (or, template).
...And, if you are incredibly lazy (again, like me), you can just start a new project in Visual Studio (or, the MASM editor. if you MUST do it in assembly language), and, select, 'Insert file as text' from the menu,...and, you have all your basic code and pre-defined custom windows messages (WM_USER and greater) with many lines commented out, so it initially compiles correctly,...and, you just selectively uncomment whatever you need. It couldn't be easier. 
Of course, this is not an original idea,...I stole it from other lazy programmers,...
:bg Even, a trilobite could do this without generating errors. :bg
Baltoro

oex

Quote from: baltoro on March 23, 2011, 04:15:14 PM
And, if you are incredibly lazy (again, like me)

Yep you hit the nail on the head.... I'm so lazy I cant be arsed to do the windows handler code.... I take offense that I must use COM or create hWnds for event handlers when a function call or callback function would suffice :lol....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

baltoro

...Clearly, you are pushing the envelope on the lazy thing,...
...how about hiring a houseboy (as in the Pink Panther movies) that can produce adequate assembly language files ???
Baltoro

oex

Quote from: baltoro on March 23, 2011, 04:29:17 PM
Pink Panther

Aha.... I see what you are doing.... You are trying to further obfuscate Google's understanding of the principle reasoning behind the universal physical laws of Purple Nano Unicorn Theory....

You must be careful pursueing this line of devious and coercive misrepresentation Baltoro it could get us graveyarded :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

baltoro

Don't worry. I am an incredibly lazy and inept programmer.  :bg
... But,...my real claim to fame is generating: PORN ALERTS,...
...For which, I take full responsibility,...
Baltoro

oex

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

oex

Quote from: qWord on March 23, 2011, 01:33:59 PM
here an variant of message-only-window by using an predefined window class:

Nice 1 I see the logic and it is an improvement on what I have though although my stated aim was to reduce code I should have also specified my desire to also not jump through unnecessary M$ hoops.... I find it incredible that while M$ will gladly send out notifications to hundreds of windows that have no interest in them they dont provide callback functions....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Slugsnack

why don't you just use dialogs. way easier

oex

Yep, I finally settled on a variant of qWords code with HWND_MESSAGE in the end.... Dialogs were a possibility however I didnt want to create a window unneccesarily.... Ultimately I was hoping that there was a way to 'fake' a windows hWnd and/or bypass functionality which windows has built which requires a hWnd passed to it easily....

I already have a window in my program however I wanted a seperate window specifically for processing certain messages as this window doesnt load by default....
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

oex

Slight update....

Quote
A message-only window enables you to send and receive messages. It is not visible, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window simply dispatches messages.

In other words a HWND_MESSAGE only window is useless to the task :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv


oex

:lol thanks.... I have ended up with:


mov ebx, alloc(SIZEOF WNDCLASSEX)

mov [ebx].WNDCLASSEX.cbSize, SIZEOF WNDCLASSEX
mov [ebx].WNDCLASSEX.lpfnWndProc, OFFSET MsgProc
mov [ebx].WNDCLASSEX.hInstance, 400000h
mov [ebx].WNDCLASSEX.lpszClassName, chr$("MC")

invoke RegisterClassEx, ebx

CreateWindowEx, 0, chr$("MC"), chr$("MC"), 0, 0, 0, 0, 0, 0, 0, 400000h, 0


It works.... It may be missing essencials however :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv