flat assembler
Message board for the users of flat assembler.
Index
> Windows > Message loop without window Goto page 1, 2 Next |
Author |
|
LocoDelAssembly 20 Sep 2008, 14:05
Re-read SetTimer documentation, you'll see that it is not always required to have a WndProc.
|
|||
20 Sep 2008, 14:05 |
|
asmcoder 20 Sep 2008, 17:51
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:56; edited 1 time in total |
|||
20 Sep 2008, 17:51 |
|
LocoDelAssembly 20 Sep 2008, 17:58
&/%$/&$%$"!!!!!
|
|||
20 Sep 2008, 17:58 |
|
dxl 20 Sep 2008, 21:24
a window is a Windows object and it don't need to be visible.
|
|||
20 Sep 2008, 21:24 |
|
bitRAKE 21 Sep 2008, 03:07
I wonder how many of the 1,100+ handles currently allocated are invisible windows? Don't worry about creating another one.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
21 Sep 2008, 03:07 |
|
Tomasz Grysztar 21 Sep 2008, 10:30
Have you ever tried to make a small program going through all the parent-less windows in system and applying WS_VISIBLE to them? Results can be funny.
As long as having to restart your system is not too much not-funny for you. |
|||
21 Sep 2008, 10:30 |
|
revolution 21 Sep 2008, 11:47
Tomasz Grysztar wrote: Have you ever tried to make a small program going through all the parent-less windows in system and applying WS_VISIBLE to them? Results can be funny. |
|||
21 Sep 2008, 11:47 |
|
LocoDelAssembly 21 Sep 2008, 13:47
Code: include 'win32axp.inc' DELAY = 1000 proc start local msg: MSG xor edi, edi lea ebx, [msg] invoke SetTimer, edi, edi, DELAY, TimerProc jmp .getMessage .messageLoop: invoke DispatchMessage, ebx .getMessage: invoke GetMessage, ebx, edi, edi, edi sub eax, -1 cmp eax, 1 ja .messageLoop invoke ExitProcess, edi ; No asmcoder, I won't use ret in place of ExitProcess, don't waste your time posting endp proc TimerProc hwnd, uMsg, idEvent, dwTime inc [count] cmp [count], 5 je .quit invoke MessageBox, 0, "It got called!!", "Windowless timer test", 0 .exit: ret .quit: invoke PostQuitMessage, 0 jmp .exit endp count dd 0 .end start ;Note that the function return value can be TRUE, FALSE, or -1. Thus, you should avoid code like this: ;while (GetMessage( lpMsg, hWnd, 0, 0)) ... ;The possibility of a -1 return value means that such code can lead to fatal application errors. But if you need a window create it then, it is not wrong doing that and in fact you can even create a window that it will be used specifically for message retrieval, but that may not work on Windows versions prior to 2000 (MSDN does not specify if Vista supports this, though: "Windows 2000/XP: To create a message-only window, supply HWND_MESSAGE or a handle to an existing message-only window."). [edit]Fixed a bug in the GetMessage return address checker Last edited by LocoDelAssembly on 21 Sep 2008, 15:33; edited 1 time in total |
|||
21 Sep 2008, 13:47 |
|
bitRAKE 21 Sep 2008, 14:51
Although, maybe not as thorough as another solution, I like to use WinSpy++ - source availible and well maintained. Parent and child windows can be easily navigated and changed.
...I don't think there is any reason to change EAX on return from GetMessage. Code: .messageLoop: invoke DispatchMessage, ebx .getMessage: invoke GetMessage, ebx, edi, edi, edi test eax,eax ; -1,0,1 jg .messageLoop ; jne .error ; je .exit (reading his source code is very educational, too ) _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup Last edited by bitRAKE on 22 Sep 2008, 01:17; edited 2 times in total |
|||
21 Sep 2008, 14:51 |
|
asmfan 21 Sep 2008, 15:04
RegisterHotKey with 0
Quote: If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop. Hence no window needed. Thread will receive thread-only messages via message loop if there are no windows created. _________________ Any offers? |
|||
21 Sep 2008, 15:04 |
|
LocoDelAssembly 21 Sep 2008, 15:09
Excellent bitRAKE!! But, can we be sure that it will work always? Look the documentation
Quote: Return Value In the "return value is nonzero" part, can we be sure that it will always be greater (signed) than zero (except for ONLY the -1 case)? Your link [2] doesn't work (says "The requested URL /~files19/wasm.ru/wasm.ru/tools/22/jcc.zip was not found on this server."), and the first one is all in Russian so I don't know what I have to download |
|||
21 Sep 2008, 15:09 |
|
revolution 21 Sep 2008, 15:11
asmfan wrote: RegisterHotKey with 0 |
|||
21 Sep 2008, 15:11 |
|
bitRAKE 21 Sep 2008, 15:17
LocoDelAssembly wrote: But, can we be sure that it will work always? Code: 0 through WM_USER Messages reserved for use by the system. WM_USER through 0x7FFF Integer messages for use by private window classes. WM_APP through 0xBFFF Messages available for use by applications. 0xC000 through 0xFFFF String messages for use by applications. Greater than 0xFFFF Reserved by the system. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup Last edited by bitRAKE on 21 Sep 2008, 15:20; edited 1 time in total |
|||
21 Sep 2008, 15:17 |
|
revolution 21 Sep 2008, 15:17
Wouldn't this be more appropriate?
Code: .messageLoop: invoke DispatchMessage, ebx .getMessage: invoke GetMessage, ebx, edi, edi, edi cmp eax, 0 jz .wm_quit cmp eax, -1 jz .big_problem_display_error_and_quit jmp .messageLoop |
|||
21 Sep 2008, 15:17 |
|
LocoDelAssembly 21 Sep 2008, 15:30
bitRAKE wrote:
Where the documentation says that GetMessage returns the message id? revolution, too many branches for my taste, if separate handling is needed for the three conditions I would use this: Code: .messageLoop: invoke DispatchMessage, ebx .getMessage: invoke GetMessage, ebx, edi, edi, edi sub eax, -1 cmp eax, 1 ja .messageLoop test eax, eax jz .big_problem_display_error_and_quit .wm_quit: . . . .big_problem_display_error_and_quit: . . . |
|||
21 Sep 2008, 15:30 |
|
revolution 21 Sep 2008, 15:38
LocoDelAssembly, too many tests for my taste, if separate handling is needed for the three conditions I would use this:
Code: .messageLoop: invoke DispatchMessage, ebx .getMessage: invoke GetMessage, ebx, edi, edi, edi sub eax, -1 cmp eax, 1 ja .messageLoop jb .big_problem_display_error_and_quit .wm_quit: . . . .big_problem_display_error_and_quit: . . . |
|||
21 Sep 2008, 15:38 |
|
LocoDelAssembly 21 Sep 2008, 15:39
I just fixed my original code, there was a bug and it was working by miracle*, now this one really halts in the [-1,0] range.
The whole miracle was that the return value was either 1 or 0, not the whole integer range. [edit]Seems that I need The Svin's tool |
|||
21 Sep 2008, 15:39 |
|
asmfan 21 Sep 2008, 15:47
Quote: When a key is pressed, the system looks for a match against all thread hot keys. |
|||
21 Sep 2008, 15:47 |
|
revolution 21 Sep 2008, 15:57
asmfan wrote:
|
|||
21 Sep 2008, 15:57 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.