How to handle RADIOBUTTON's BN_CLICKED message which are in the same group. And tell me, just by putting WS_GROUP flag in CreateWindowEx() will the buttons be in same group ?
See.. what I'm trying to do is.. I'm creating a few RADIOBUTTONS dynamically within a DialogBox and there is one PUSHBUTTON. So while the PUSHBUTTON is pressed it'll retrieve the selected RADIOBUTTON's text.
The simplest way would be using CheckRadioButton API:
void CheckRadioButton(HWND hwndDlg,
int nIDFirstButton,
int nIDLastButton,
int nIDCheckButton)
This function clears the selection from all buttons with IDs in the range given by nIDFirstButton and nIDLastButton except the one whose ID is given by nIDCheckButton
Last edited by VictorN; October 21st, 2009 at 02:28 AM.
See.. I'm creating RADIOBUTTONs dynamically by CreateWindowEx(). So how should I obtain the Identifier (Resource ID) of those RADIOBUTTONs. see my code..
See.. I'm creating RADIOBUTTONs dynamically by CreateWindowEx(). So how should I obtain the Identifier (Resource ID) of those RADIOBUTTONs. see my code..
here ID is IDB_RADIO.. for this I need to put it in the Resource.h file of the project. so how it can be done in case of dynamic creation..
But you are passing this id into CreateWindowEx as HMENU hMenu (that is according to MSDN:
hMenu
[in] Handle to a menu, or specifies a child-window identifier, depending on the window style. For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; it can be NULL if the class menu is to be used. For a child window, hMenu specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events. The application determines the child-window identifier; it must be unique for all child windows with the same parent window.
This should be placed into resource.h. Am I right ??.
But the problem is Im creating multiple RADIOBUTTONs Dynamically using loop. So How should I put those Dynamic IDs in resource.h file ?
This should be placed into resource.h. Am I right ??...
Mmm...
You may and you may not...
Generally you don't need to put in the resource.h. It doesn't matter in what file it will be defined.
Just define (reserve) a range (beginning from IDB_RADIO) of "unique" IDs for your radio buttons so no other control of the same dialog uses any ID from this range.
Increment the ID passed in the CreateWindowEx in your while loop and save the count of all created radio buttons (say, nCount)
Now all your radio buttons will have the IDs from IDB_RADIO to (IDB_RADIO + nCount -1), so you'll be able to use CheckRadioButton and IsDlgButtonChecked APIs
[QUOTE=hypheni;1888738... how do I handle these in CALLBACK function.
Hope you got my point.[/QUOTE]And what would be the problem if you knew all your button IDs?
Now, the message handling code.. where Im having the actual problem.. See I need to choose only one radio button at a time and process that RadioButton while pressing a PUSHBUTTON to get the RadioButton's name.
Code:
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case ID_RADIO1:
if ( HIWORD(wParam) == BN_CLICKED)
{
WCHAR text[100];
SendMessage((HWND)hRadio, WM_GETTEXT, 100, (LPARAM)text);
MessageBox(0,text,0,0);
}
break;
}
}
But this is handling just 1st radio button which in fact working but if i process same way IDB_RADIO2 and so on it's not working for those buttons. and I need to process radiobutton with a pushbutton.
Last edited by hypheni; October 23rd, 2009 at 01:32 AM.
Bookmarks