in

DevPinoy.org

A Filipino Developers Community
ATTENTION:Take our Code Challenge for the month of October 2008 and win some great prize! Learn more about it here!
Latest post 08-22-2008 1:36 AM by modchip. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 03-08-2007 5:49 PM

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 709
    • Points 10,105

    Assembly Choices

    Hi again...

    Radio boxes & checkboxes. How do you get the selections/choices in assembly language? I've searched all over some asm sites and some books, but I cannot find one that is easy to read and understand.

    If it's no hassle to you guys, could you please give some nice examples about these to controls?

    Thank you very much (again)!

    Regards,
    m0ds

    Filed under:
    • Post Points: 20
  • 03-08-2007 7:37 PM In reply to

    • cvega
    • Top 10 Contributor
    • Joined on 11-25-2005
    • Posts 497
    • Points 8,440

    Re: Assembly Choices

    Answer
    Checkbox and Radiobutton are all types of "button" class.

    For checkbox, add "button" window with style BS_CHECKBOX or BS_AUTOCHECKBOX.
    For radiobutton, add "button" window with style BS_RADIOBUTTON or BS_AUTORADIOBUTTON.

    Cheers,

    -chris
    Chris Vega This posting is provided "AS IS" with no warranties, and confers no rights My Weblog|Visit MSDN Community
    • Post Points: 35
  • 03-08-2007 8:34 PM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 709
    • Points 10,105

    Re: Assembly Choices

    ok superman, will try that. Thank you!

    -"Batman" Stick out tongue

    Filed under:
    • Post Points: 5
  • 03-08-2007 9:43 PM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 709
    • Points 10,105

    Re: Assembly Choices

    Answer
    cvega:
    Checkbox and Radiobutton are all types of "button" class.

    For checkbox, add "button" window with style BS_CHECKBOX or BS_AUTOCHECKBOX.
    For radiobutton, add "button" window with style BS_RADIOBUTTON or BS_AUTORADIOBUTTON.

    Cheers,

    -chris



    Ok Chris! I got the Radio buttons to work now, thanks!

    I want to follow-up the question. The scenario is that I want the messagebox to appear only after I click the ok button, the code below does not work but...
    .386
    ...
    .data
    caption db "Information",0
    yes_message db "You chose yes!",0
    no_message db "You chose no!",0
    ...
    .code
    start:
    ...
    .elseif uMsg==WM_COMMAND
        .if wParam==IDC_BUTTON_MAIN_OK
            .if wParam==IDC_RADIO_YES
                push 0
                push offset caption
                push offset yes_message
                push hWin
                call MessageBox
            .elseif wParam==IDC_RADIO_NO
                push 0
                push offset caption
                push offset no_message
                push hWin
                call MessageBox
            .endif
        ...
       
    .endif
    ...
    end start
    ... I tried this one, cause I'm out of ideas, but it works. Is there a better way to do what the working code below does?
    .386
    ...
    .data
    caption db "Information",0
    yes_message db "You chose yes!",0
    no_message db "You chose no!",0
    final_message db 128 dup(0)
    ...
    .code
    start:
    ...
    .elseif uMsg==WM_COMMAND
        .if wParam==IDC_BUTTON_MAIN_OK
            push 0
            push offset caption
            push offset final_message
            push hWin
            call MessageBox
        .elseif wParam==IDC_RADIO_YES
            push offset yes_message
            push offset final_message
            call lstrcpy
        .elseif wParam==IDC_RADIO_NO
            push offset no_message
            push offset final_message
            call lstrcpy
        ...
       
    .endif
    ...
    end start
    Thanks again dude! I really appreciate your help. :D

    Regards,
    m0ds


    Filed under:
    • Post Points: 5
  • 08-22-2008 1:00 AM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 709
    • Points 10,105

    Re: Assembly Choices

    Hi,

    I tried to send the BM_CHECK message whenever a checkbox is checked or unchecked. Is the method I'm doing correct? Anyways I searched MSDN for the SendMessage function and...

    lResult = SendMessage( // returns LRESULT in lResult
       (HWND) hWndControl, // handle to destination control
       (UINT) BM_GETCHECK, // message ID
       (WPARAM) wParam, // = 0; not used, must be zero
       (LPARAM) lParam // = 0; not used, must be zero
    );

    ...which in MASM32 I believe is invoke SendMessage, hWin, BM_GETCHECK, 0, 0 -- where can I find the lResult/Return value? In eax?

    Also, the return value will be either BST_CHECKED or BST_UNCHECKED according to the doc, is it literally "BST_CHECKED" and "BST_UNCHECKED"?

    Thank you!

     

    • Post Points: 20
  • 08-22-2008 1:05 AM In reply to

    • cvega
    • Top 10 Contributor
    • Joined on 11-25-2005
    • Posts 497
    • Points 8,440

    Re: Assembly Choices

    Yes, the result will be in EAX.

    .IF eax == BST_CHECKED
       ; do something
    .ENDIF

    Cheers,

    -chris

    Chris Vega This posting is provided "AS IS" with no warranties, and confers no rights My Weblog|Visit MSDN Community
    • Post Points: 20
  • 08-22-2008 1:36 AM In reply to

    • modchip
    • Top 10 Contributor
    • Joined on 02-09-2006
    • Ivalice
    • Posts 709
    • Points 10,105

    Re: Assembly Choices

    Hmmm... yeah, I did this already, but the problem is that whether it is ticked or not, it always returns BST_UNCHECKED... here's the current code on that part...

    1. ...
    2. mChecked db "Checked!",0
    3. mCleared db "Cleared!",0
    4. ...
    5. .if wParam==IDC_BUTTON_MAIN_OK
    6.     .if eax==BST_CHECKED
    7.         invoke MessageBox, hWin, addr mChecked, addr caption, MB_OK
    8.     .else
    9.         invoke MessageBox, hWin, addr mCleared, addr caption, MB_OK
    10.     .endif
    11. .elseif wParam==IDC_CHECKBOX1
    12.     invoke SendMessage, hWin, BM_GETCHECK, 0, 0
    13. ...
    14. end start


    Thanks!

     

    • Post Points: 5
Page 1 of 1 (7 items)

Copyright DevPinoy 2005-2008
Powered by Community Server (Commercial Edition), by Telligent Systems