News:

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

how to detect event of Checkbox control?

Started by RHL, February 28, 2012, 03:05:20 AM

Previous topic - Next topic

RHL

Hello, I am trying detect the event of a checkbox control but cannot do :/
I try this:

.elseif eax==BM_SETCHECK
mov edx,wParam
.if edx==1001
invoke MessageBox,0,"1","1",0
.elseif edx==1002
invoke MessageBox,0,"2","2",0
.endif


not show nothing :/
can anyone help please, use radasm

Gunner

.elseif eax==WM_COMMAND
mov edx,wParam
movzx eax,dx
shr edx,16
.if edx==BN_CLICKED

...
...
...
.if eax == 1001
invoke IsDlgButtonChecked, hWin, eax
.if eax == BST_CHECKED
; button checked
.else
; button unchecked
.endif

...
...
...
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

dedndave

BM_SETCHECK is used the other way - if you want to set the box as checked, you might use SendMessage or PostMessage
also, if you use the BS_NOTIFY style to create the button, you can handle WM_NOTIFY messages to get the state change
Rob's code is easier, though   :P

RHL

Gunner,dedndave:
very thanks!
I resolved my problem  :clap:



RHL

sorry , a question, why use this lines

mov edx,wParam
movzx eax,dx
shr edx,16
.if edx==BN_CLICKED
...
invoke IsDlgButtonChecked, hWin, eax


I trying this and it has worked:

.elseif eax==WM_COMMAND
mov edx,wParam
.if edx==BN_CLICKED
.if eax==1001


I want to know because it uses the lines, I do not want to be ignorant and not knowing, thanks :)

MichaelW

I can't see how your code could work.

If the WM_COMMAND message is from a control, the high-order word contains the notification code and the low-order word contains the control ID. One method of testing the notification code is to isolate it in the low-order word of a 32-bit register:

mov edx, wParam
...
shr edx, 16


Likewise, one method of testing the control ID is to isolate it in the low-order word of a 32-bit register:

mov edx, wParam
movzx eax, dx

eschew obfuscation

dedndave

    mov     eax,uMsg
    .if eax==WM_COMMAND
        movzx   edx,word ptr wParam+2  ;EDX = notification code
        movzx   eax,word ptr wParam    ;EAX = control ID
        .if dx==BN_CLICKED
            .if ax==1001
                INVOKE  IsDlgButtonChecked,hDlg,eax
                .if eax==BST_CHECKED
                    INVOKE  Beep,1000,100
                .elseif eax==BST_UNCHECKED
                    INVOKE  Beep,750,100
                .endif
            .elseif ax==1002
                INVOKE  IsDlgButtonChecked,hDlg,eax
                .if eax==BST_CHECKED
                    INVOKE  Beep,500,100
                .elseif eax==BST_UNCHECKED
                    INVOKE  Beep,250,100
                .endif
            .endif
        .endif
    .endif


gawd - i hate if/else/endif - lol

RHL