The MASM Forum

General => The Campus => Topic started by: xandaz on June 28, 2020, 07:09:12 AM

Title: Autoradiobuttons help.
Post by: xandaz on June 28, 2020, 07:09:12 AM
    hey guys. thanks in advance. I've been trying my way around autoradiobuttons but havent got a clue to what message to process. can someone help out?
    thanks
Title: Re: Autoradiobuttons help.
Post by: jj2007 on June 28, 2020, 09:45:44 AM
Attached a test case, it shows the messages that you get when clicking. The *.asc source opens in WordPad or RichMasm.
Title: Re: Autoradiobuttons help.
Post by: hutch-- on June 28, 2020, 10:46:33 AM
It really works for you to get hold of the old WIN32.HLP file as it has all of this core information. You have to learn your way around it but it will save you heaps of time. Translation from C is easy enough in most instances, DWORD in size and you make sure you understand the differences between a variable passed by VALUE or a POINTER. The pointer in win32 is always a DWORD as well.
Title: Re: Autoradiobuttons help.
Post by: jj2007 on June 28, 2020, 11:21:26 AM
That's correct, but instead of guessing which of the hundreds of messages is the right one, it's often much faster to simply look which messages are sent when you click on the control. A button sends three messages, and WM_MOUSEACTIVATE is not the right one.
Title: Re: Autoradiobuttons help.
Post by: hutch-- on June 28, 2020, 12:24:23 PM
Look up these messages,

BM_SETCHECK
BM_GETCHECK

Title: Re: Autoradiobuttons help.
Post by: jj2007 on June 28, 2020, 07:37:39 PM
Quote from: xandaz on June 28, 2020, 07:09:12 AMwhat message to process

QuoteAn application sends a BM_GETCHECK message to retrieve the check state of a radio button or check box

You can use BM_GETCHECK to check the state, but before that, you need to process the message that the OS sends to you. Every click on the control produces three messages. One of them has even the control's ID.
Title: Re: Autoradiobuttons help.
Post by: K_F on June 28, 2020, 07:43:33 PM
Create radios with Button Class
if you're looking at auto radios include the BS_AUTORADIOBUTTON style (bold text below),  and use WM_COMMAND Notification in the parent window procedure to BM_GETCHECK the status of the radio


FFT_GUI_CreateCustRad_Freq Proc USES ESI hWin:DWord, ptr_hObject:DWord
Invoke CreateWindowEx, NULL,
ADDR sz_Class_Button, ; "BUTTON",0
ADDR sz_CustRad_Frequency,
WS_CHILD or WS_VISIBLE or [b]BS_AUTORADIOBUTTON[/b] OR WS_BORDER,
Gen_Rect.left,
Gen_Rect.top,
Gen_Rect.right,
Gen_Rect.bottom,
hWin,
NULL,
MainWin_Handles.hInstance,
NULL
mov esi, ptr_hObject
mov [esi], eax
    invoke ShowWindow,eax,SW_SHOW
ret
FFT_GUI_CreateCustRad_Freq endp



Here I've just subclassesd the window procedure for the radio buttons, which uses another proc to play with it.
From the Win API the Button Class cannot be sub-classed so you have to use the parent procedure/sub class procedure

;---RADIO BUTTON WINPROC---
WinProc_FFT_Cust_Grp Proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD

.if uMsg == WM_COMMAND
mov eax, lParam
cmp eax, Handles_FFT_CustGrp.h_GUI_Cust_Rad_Freq
jne @F
Invoke WinProc_FFT_Cust_Rad_Freq, lParam, uMsg, wParam, lParam
jmp WPCustGrp_EX
@@:
cmp eax, Handles_FFT_CustGrp.h_GUI_Cust_Rad_Impuls
jne @F
Invoke WinProc_FFT_Cust_Rad_Imp, lParam, uMsg, wParam, lParam
jmp WPCustGrp_EX
@@:
cmp eax, Handles_FFT_CustGrp.h_GUI_Cust_Rad_Kernel
jne @F
Invoke WinProc_FFT_Cust_Rad_Kernel, lParam, uMsg, wParam, lParam
.endif

WPCustGrp_EX:
invoke CallWindowProc, Handles_FFT_CustGrp.ptr_Cust_Grp, hWin, uMsg, wParam, lParam
ret
WinProc_FFT_Cust_Grp endp
Title: Re: Autoradiobuttons help.
Post by: xandaz on July 26, 2020, 01:15:11 AM
   yeah. it was the BM_GETSTATE message. thanks