News:

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

Lingo's Message Loop ?

Started by ic2, February 15, 2007, 04:38:55 AM

Previous topic - Next topic

ic2

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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ic2

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]

lingo

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]

Seb

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:

ic2

Totally  from old school . ..  Always down with the diff.  How lucky can we be...  :)

Y Y  (both fingers crossed)

ic2

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...


ic2

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.

Seb

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]

ic2

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.

Seb

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.

ic2

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.


hutch--

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].
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Seb

Thanks hutch, for clearing that up. I was about to explain it myself, but you took the words out of my mouth. :U