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.
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:
[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 ??...
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.
if ( HIWORD(wParam) == BN_CLICKED)
SendMessage((HWND)hRadio, WM_GETTEXT, 100, (LPARAM)text);
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.