I think I should start a new thread here because the Laboratory was design to address more complicated issues than what im asking about.
Could someone help me out with one more thing concerning Lingo Message Loop.
I put a couple of static buttons on the window and I'm trying to do cmp WM_LBUTTONDOWN/UP and cmp WM_RBUTTONDOWN/UP
.const
Butt_e1 equ 101
Butt_e2 equ 102
WM_LBUTTONDOWN equ 201h
.data?
hButt_1 dd ?
hButt_1 dd ?
WndProc:
This don't work but if I click the window it will close
cmp dword ptr [esp+2*4], 201h
je L_BUTTONDOWN
I tried this and it does nothing.
cmp dword ptr [esp+2*4], 101 ; Butt_e1
je L_BUTTONDOWN
L_BUTTONDOWN:
PUSH 0
CALL ExitProcess
Could someone tell how to make this work.
Thanks in advance
http://www.masm32.com/board/index.php?PHPSESSID=4e9f1eb8397e9418a468f9e2b74698ec&topic=6628.0
ic2,
There is not enough code there to make sense. Put the complete project into a zip file and Lingo may fix it for you.
I got interested because I been looking at masm32 Type2 High Speed Message System and others just weeks before ... My present project make use of nearly all WM_ Style Button Clicks and that's where i need to go from this new style MessageLoop. It may be simple but when your mind get blow again by something new, it don't seem that way anymore.
I know a little more about debugging only because I finally founded something of interest that makes me want to use it and someone gave me an assignment a few days ago that force me understand it better.
Anyway, I don't fully understand the code yet but coming from ground up with all those good comments I be darn if i don't learn to sail this ship the right way instead of just being a blind user of the greatest assembler tools on earth. By right it should be part of masm32 sooner rather than latter Demo, Tutor and All.
Sorry for running of at the jibs again... HELP, HELP, p HELP
zip attached
[attachment deleted by admin]
ic2,
Another small example with buttons: :lol
.686
.mmx
;k3d
.xmm
.model flat, stdcall
option casemap:none,language:stdcall,dotname
assume fs:nothing
include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
.data
align 8
MyStack dd offset ExitProcess, 400000h, offset DlgTempl
dd 0, offset Start+3Bh,0,0,0
lenMyStack equ 0-($-MyStack)
MyStack1 dd offset L_WM_INITDIALOG+60h, 0, IDI_APPLICATION
dd offset LoadMenuIndirect
hWnd dd 0, WM_SETICON,ICON_SMALL,0, offset L_WM_INITDIALOG+6Ah
dd offset MenuTempl,offset DefEnd_1
hWnd_1 dd 0
DlgTempl db 0,8,200,16,0,0,0,0,2,0,20,0,10,0,186,0
db 94,0,0,0,0,0,72,0,105,0,0,0,0,0,1,80
db 0,0,0,0,64,0,12,0,50,0,21,0,110,0,255,255
db 128,0,38,0,72,0,105,0,0,0,0,0,0,0,1,80
db 0,0,0,0,64,0,42,0,50,0,21,0,120,0,255,255
db 128,0,38,0,69,0,120,0,105,0,116,0,0,0,0,0
MenuTempl db 0,0,0,0,144,0,38,0,70,0,105,0,108,0,101,0
db 0,0,0,0,11,0,38,0,83,0,97,0,121,0,32,0
db 104,0,101,0,108,0,108,0,111,0,0,0,128,0,12,0
db 38,0,69,0,120,0,105,0,116,0,0,0
Mymsg db "Hi there",0
Mytitle db "Hello Example1!",0
.code
Start:
add esp, lenMyStack ; loading the stack
movq MM1, qword ptr [MyStack+0*8]
movq MM2, qword ptr [MyStack+1*8]
movq MM3, qword ptr [MyStack+2*8]
movq MM4, qword ptr [MyStack+3*8]
movq [esp+0*8], MM1
movq [esp+1*8], MM2
movq [esp+2*8], MM3
movq [esp+3*8], MM4
jne DialogBoxIndirectParam ; action
cmp dword ptr [esp+2*4], WM_CLOSE
je L_WM_CLOSE
cmp dword ptr [esp+2*4], WM_INITDIALOG
je L_WM_INITDIALOG
cmp dword ptr [esp+2*4], WM_COMMAND
jne DefEnd_0
cmp dword ptr [esp+4*4], 0 ; Is it menu?
jne @f ; No, jmp
cmp word ptr [esp+3*4], 11 ; HELLO from Menu = 11
je L_IDC_HELLO
cmp word ptr [esp+3*4], 12 ; EXIT from Menu = 12
jne DefEnd_0
L_WM_CLOSE:
mov eax, [esp+1*4] ; eax->hwnd
add esp, -3*4 ; loading the stack
mov [esp], offset DefEnd_1 ; return address
mov [esp+1*4], eax ; parameter for EndDialog API
mov dword ptr [esp+2*4], 0 ; parameter for EndDialog API
jne EndDialog ; action
DefEnd_0:
xor eax, eax ; return false
ret 4*4
@@:
cmp dword ptr [esp+3*4], 120 ; EXIT from button = 120
je L_WM_CLOSE
cmp dword ptr [esp+3*4], 110 ; HELLO from button = 110
jne DefEnd_0
L_IDC_HELLO:
add esp, -5*4 ; loading the stack
mov [esp], offset DefEnd_1 ; return address
mov dword ptr [esp+1*4], 0 ; parameter for MessageBox API
mov [esp+2*4], offset Mymsg ; parameter for MessageBox API
mov [esp+3*4], offset Mytitle ; parameter for MessageBox API
mov dword ptr [esp+4*4], MB_OK ; parameter for MessageBox API
jne MessageBox ; action
DefEnd_1:
mov eax, 1 ; return true
ret 4*4
L_WM_INITDIALOG:
mov ecx, [esp+1*4] ; ecx->hwnd
add esp, -13*4 ; loading the stack
mov hWnd, ecx
mov hWnd_1,ecx
movq MM1, qword ptr [MyStack1+0*8]
movq MM2, qword ptr [MyStack1+1*8]
movq MM3, qword ptr [MyStack1+2*8]
movq MM4, qword ptr [MyStack1+3*8]
movq MM5, qword ptr [MyStack1+4*8]
movq MM6, qword ptr [MyStack1+5*8]
movq [esp+0*8], MM1
movq [esp+1*8], MM2
movq [esp+2*8], MM3
movq [esp+3*8], MM4
movq [esp+4*8], MM5
movq [esp+5*8], MM6
jne LoadIcon ; action
add [esp+4*4], eax ; change stack; eax->hIcon
jne SendMessage ; continue action
mov [esp+2*4], eax ; change stack; eax->hMenu
jno SetMenu ; continue action
End Start
Regards,
Lingo
[attachment deleted by admin]
I've said it before and I'll say it again: lingo's friggin' insane...in a positive way. :bg
Thanks for the code, lingo! :clap:
Totally from old school . .. Always down with the diff. How lucky can we be... :)
Y Y (both fingers crossed)
Humm. Lingo, can WM_WHAT_EVER_BUTTON control style come from the rearranged example i posted.
It's your original code with a few extra windows (CreateWindowEx) button style... I really don't use or understand dialogs. I don't know why but the truth is i avoided using every dialog program in masm32 and Icz Examples since the day i can remember and that was the easy stuff. It would be much more difficult for me to change things using your style dialogs to standard Window windows. I bend trying for the pass few hours and is getting no where fast.
Don't mean to be a pain but if i can see WM_LBUTTONDOWN control used with the buttons in your original window code it would be a road map to follow and figure out how to attaching others controls like WM_MOUSEMOVE and such. Than again controls to the hWnd may be no problem for me but controls to childwindows of hWnd is the problem that need to be fired-up.
That's why i was asking so i would not have bug you every other day. ... With the dialog it be every 9 hours or so than i loss a friend for sure...
Now that i think about it. You probably never implemented that yet. It probably was one on of those Lingo Lingo's Free-time personal discovery and all you did was take some time out to share as you usually do.
Cool Lingo... Don't go out your way if you have to re-build. Don't stop doing what you doing my account and miss something important in that project of yours . It got to be a monster...
You're still the Man. One of me Kings, out the small, but surviving group, of D ONLY, True Code Warriors.
I forgot people are people too and got a hundred of things to do. But do keep it in mind. It's boss or to be more professional about it, I be d***. Looks like new technology. :)
I rest my case.
What's up Seb... did you come up with something ... kind of funny asm people _ not to be interested But someone of M$ is watching and i bet he like it.
Quote from: ic2 on February 16, 2007, 07:18:48 AM
What's up Seb... did you come up with something ... kind of funny asm people _ not to be interested But someone of M$ is watching and i bet he like it.
Yeah, I tried lingo's example out and it worked fine. I also modified your example to handle button clicks. :U
[attachment deleted by admin]
Thank Seb for showing how to reach COMMAND:, code to connect child windows and the parameter to the MessageBox.
It's not that much info was not there already but for me it makes things seem a whole lot more clearer. I never would have figured it out and would have given up by now. It's really really great to see how things work from ground up. Every new and old ASM programmer got to experience it. It going to make me a much better programmer with fewer questions that makes more since.
Yeah, well, if you want to catch a click, you've gotta catch WM_COMMAND and then check the control ID specified in the lower 16-bits of wParam (esp+12). Before I changed your code, you were checking for WM_LBUTTONDOWN or something, and that's a mouse-related message.
Anyway, glad I could help.
Quotecontrol ID specified in the lower 16-bits of wParam (esp+12)
Where do i find information like that. Is there a list somewhere and/or something i should be reading.
All i use to do was try to keep up with the basic BYTE, not much with brackets and PTR'S + - * BITS, etc. It looked confusing to me but Lingo coding kind of changed that. I will be paying attention for now on end.
The info. about wParam can be found on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Resources/Menus/MenuReference/MenuMessages/WM_COMMAND.asp
ic2,
If you want to access the stack variable directly in a WndProc, you need to know where they are on the stack. Without a stack frame, they start at [esp+4]. If you have a stack frame they start at [ebp+8].
They occur in order in memory, with no stack frame you get,
handle = [esp+4]
message = [esp+8]
wParam = [esp+12]
lParam = [esp+16]
If you modify the stack BEFORE you use these arguments you must calculate the offset changes. If you have code like,
push ebx
push esi
push edi
You must add the byte count of the changes to the [esp+???] address.
[esp+4] becomes [esp+16] with the above 3 pushes. Often you see it written like [esp+4+12].
Thanks hutch, for clearing that up. I was about to explain it myself, but you took the words out of my mouth. :U
What a sling-shot.. hutch
I just want to make sure I got most of this right.
[esp+2*4] This is where all Window Messages Begin
[esp+3*4] I add 4 for any ChildWindow or new function or API call i want to start with.
mov eax, [esp+1*4] ; same as [esp+4]
add esp, -5*4 ; What is negative 5 x 4
; Is it going backward if so
; Where and how do you figure.
; wild guest = TranslateMessage
mov [esp], offset @ret_1 ; Ok set up a return address
mov dword ptr [esp+1*4], eax ; same as [esp+4]
mov [esp+2*4], offset buttonText_1 ; same as [esp+8]
mov [esp+3*4], offset buttonText_1 ; same as [esp+12]
mov dword ptr [esp+4*4], MB_OK ; Call any API as long
; as i push (mov) the
; right amount of parameters
; the API need... in this
; case it is [esp+16] 4
jmp MessageBox ; parametersaction
wParam = [esp+12] where do these come in at.
lParam = [esp+16] Just want to be sure
I this right? I know I got a few wrong but im getting a good idea only because of the way it was explained. I don't want to ware out the word but I'll say thanks now because i'm going to be back tracking the forum to catch up on stuff i never an effort to understand...You guys know how much i appreciate it but don't let this be the end, make it an option.
.....................................
Seb, you were not sure of what i was taking about and hutch explained fully, i'm sure. Thanks for giving me the benefit of an douth of having a brain. It's a big difference when all you know is
Push 0
Call. Call. Call
knowing nothing about ...
movq [esp+4*8*1999 sub 2 infinity ], MM7
or
INVOKE ReadFile,EBX,[S1$.pBuffer+3*DWORD],[S1$.iFileLength+2*DWORD],EAX,EBP
other than it look interesting. I hate math i thought it was trigonometry or that i had to move up to something like that so i simply turned the pages .... Now i see.
Hutch has some kind of special since of people and *usually* know how to break things down to nearly anyone with-out making them feel to bad or offensive provided he didn't have a bad day. :) don't know if im kidding or not . Anyway, that's a lot of people power. Most of us do wish you well :)
Yeah, Seb... Above all we're at D LINGOS_COMMAND: Center.
Doom Doomm
Quote from: ic2 on February 18, 2007, 03:01:54 AM
[esp+2*4] This is where all Window Messages Begin
Yes, this is the "uMsg" parameter of WndProc (esp+8).
Quote from: ic2 on February 18, 2007, 03:01:54 AM
[esp+3*4] I add 4 for any ChildWindow or new function or API call i want to start with.
Not sure what you mean... the x*4 is, atleast by me, used for readability reasons to show the Xth DWORD of the call-stack... It'll be assembled to [esp+X] (where X is an even number) anyway. The [esp+3*4] in this case points to wParam.
Quote from: ic2 on February 18, 2007, 03:01:54 AM
mov eax, [esp+1*4] ; same as [esp+4]
Yes, EAX now holds to the hWnd (the first call-stack parameter of WndProc).
Quote from: ic2 on February 18, 2007, 03:01:54 AM
add esp, -5*4 ; What is negative 5 x 4
; Is it going backward if so
; Where and how do you figure.
; wild guest = TranslateMessage
Here lingo's allocating space on the stack for 5 DWORDs... The first DWORD is used to save the return address, which is an offset to a label that'll return 1 and bail out (@ret_1 or DefEnd_1 or whatever) and the last 4 DWORDs to save the parameters for the MessageBox-API...makes 5 DWORDs. :wink
In this case, you could also do...
sub esp, 5*4 ; allocate space for 5 DWORDs
...to achieve the same result as...
add esp, -5*4 ; allocate space for 5 DWORDs
AFAIK, the latter is the Microsoft-way of doing it, maybe lingo want to stick to their standard? :P
Quote from: ic2 on February 18, 2007, 03:01:54 AM
wParam = [esp+12] where do these come in at.
lParam = [esp+16] Just want to be sure
These are two of the parameters pushed onto the stack by either GetMeessage or TranslateMessage (I reckon the latter though), because they're the functions notifying your own WndProc when a message arrives... So basically, they belong to the stack of your WndProc function.
Quote from: ic2 on February 18, 2007, 03:01:54 AM
Seb, you were not sure of what i was taking about and hutch explained fully, i'm sure.
Yes, I didn't fully understand you, I thought you were only interested in the wParam and WndProc-stuff.