News:

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

BM_SETSTATE not working

Started by Mark Jones, July 26, 2005, 05:34:45 PM

Previous topic - Next topic

Mark Jones

 Strange... I've used code similar to this before without any problems:


    xor eax,eax                             ; erase eax
    mov al,byte ptr [edx]                   ; fetch ascii byte "0" or "1" from .ini buffer
    sub al,30                               ; make it 00-01h
int 3                                       ; debug shows eax==00000001
    invoke SendDlgItemMessage,hWnd,1019,BM_SETSTATE,eax,0


But the checkbox is not checked. It is grey, like it were tri-stated or something. I'm not using BS_3STATE or BS_AUTO3STATE style (that I know of.) Using BM_GETSTATE to read it, it is always read as BST_UNCHECKED, regardless of its state:


; save autorun button state
        invoke SendDlgItemMessage,hWnd,1019,BM_GETSTATE,0,0
        mov ecx,offset szAutorun
        .if eax==BST_CHECKED
            mov byte ptr [ecx],"1"
        .else
            mov byte ptr [ecx],"0"
        .endif
; write .ini file now


What should I look for? The checkbox is the default "auto" RadASM style. Main proc is a DialogBoxParam. I'm using the XP theme too and a bunch of other controls if that matters. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Mark Jones


    invoke SendDlgItemMessage,hWnd,1019,BM_GETSTATE,0,0


Returns 0x00000004 in eax. According to windows.inc:


BST_UNCHECKED                        equ 00h
BST_CHECKED                          equ 1
BST_INDETERMINATE                    equ 2
BST_PUSHED                           equ 4
BST_FOCUS                            equ 8


Why am I getting a 4???
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Mark Jones

Sigh... :red

BM_SETCHECK   <-- only works for checkboxes
BM_GETCHECK

BM_SETSTATE
GM_GETSTATE  <-- only works for radio buttons

And even this was wrong, 30 needed to be 30h:


    mov al,byte ptr [edx]                   ; fetch ascii value
    sub al,30h                              ; make 0-1
    invoke SendDlgItemMessage,hWnd,1019,BM_SETCHECK,eax,0


...just call me the "absent-minded-professor." :bg
I must need to take a break, maybe get a big cup of coffee or something. :eek
Good thing assembler is just a hobby! :lol
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

PBrennick

Mark,
If I told you half of the dumb things I absentmindedly tried I would lock up the forum.  :bdg

I am glad to see you always seem to figure it out, though!  I am also glad that there are no flamers around this forum, just a bunch of kewl people!

Paul
The GeneSys Project is available from:
The Repository or My crappy website

ninjarider

thanx. just solved my problem was trying to get it to work with sendmessage.

ninjarider

QuoteSigh...

BM_SETCHECK   <-- only works for checkboxes
BM_GETCHECK

BM_SETSTATE
GM_GETSTATE  <-- only works for radio buttons

BM_SETCHECK and BM_GETCHECK <-- Works with both Checkbox's and Radio buttons

BM_GETSTATE <-- Can be used to get checked state. Must and eax with 1 to get check state
BM_SETSTATE <-- Can not be used to set the checked state

SendDlgItemMessage and Send Message both work. Had to figure out how to get it to work, but I got it.