Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio Button Problem

Status
Not open for further replies.

KimiSue

Programmer
May 24, 1999
32
US
Myy roomate and I have a problem that in driving us INASANE! We have a search screen that comes up, has a text entry box for the search criteria, and 2 radio buttons - by name or by i.d. We have tried all we can find in books or think of to get the code written to distinguish between the 2 radio buttons. Does anyone have any ideas, please? Thanks!
 
Well.... It depends on what compiler you are using, and how your radio buttons are created.<br>
If you are using a Resource compiler, you would assign an ID to each radio button and simply check for that ID against the "wParam" variable of the "WM_COMMAND" message for the window that owns the radio buttons.<br>
Kind of like this:<br>
In your RESOURCE file (This is a paste from some of my working code of a dialog box with radio button controls. Borland C++ 3.1):<br>
<br>
MyPortSetup DIALOG 25, 16, 174, 179<br>
STYLE DS_MODALFRAME ¦ WS_POPUP ¦ WS_CAPTION ¦ WS_SYSMENU<br>
CAPTION "Communications Setup"<br>
BEGIN<br>
CONTROL "4800", BAUD_4800, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_GROUP ¦ WS_TABSTOP, 85, 106, 32, 12<br>
CONTROL "9600", BAUD_9600, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 85, 122, 32, 12<br>
CONTROL "19200", BAUD_19200, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 85, 138, 32, 12<br>
CONTROL "38400", BAUD_38400, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 85, 153, 32, 12<br>
CONTROL "COM 1", SEL_COM1, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_GROUP ¦ WS_TABSTOP, 23, 106, 32, 12<br>
CONTROL "COM 2", SEL_COM2, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 23, 122, 32, 12<br>
CONTROL "COM 3", SEL_COM3, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 23, 138, 32, 12<br>
CONTROL "COM 4", SEL_COM4, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 23, 153, 32, 12<br>
//stuff deleted!<br>
END<br>
<br>
//And in the header file...:<br>
<br>
#define SEL_COM1 401 //or what ever #'s the resource compiler puts here...<br>
#define SEL_COM2 402<br>
#define SEL_COM3 403<br>
#define SEL_COM4 404<br>
#define BAUD_4800 405<br>
#define BAUD_9600 406<br>
#define BAUD_19200 407<br>
#define BAUD_38400 408<br>
<br>
//And in your source code for the above dialog box:<br>
<br>
BOOL FAR PASCAL _export ComSetupBox( HWND hDlg, UINT message,<br>
UINT wParam, LONG lParam )<br>
{<br>
//stuff deleted!<br>
switch( message )<br>
{<br>
//stuff deleted!<br>
<br>
case WM_COMMAND:<br>
switch( wParam )<br>
{<br>
//stuff deleted!<br>
<br>
case SEL_COM1:<br>
MuttIniData[3] = '1'; //here we do stuff for one radio button...<br>
break;<br>
<br>
case SEL_COM2:<br>
MuttIniData[3] = '2'; //here we do stuff for another radio button...<br>
break;<br>
<br>
case SEL_COM3:<br>
MuttIniData[3] = '3'; // and another...<br>
break;<br>
<br>
case SEL_COM4:<br>
MuttIniData[3] = '4'; // and another...<br>
break;<br>
<br>
case BAUD_4800:<br>
memcpy( &MuttIniData[4], ":4800,n,8,1\r", 12 ); // and another...<br>
break;<br>
<br>
case BAUD_9600:<br>
memcpy( &MuttIniData[4], ":9600,n,8,1\r", 12 ); // and so on...<br>
break;<br>
<br>
case BAUD_19200:<br>
memcpy( &MuttIniData[4], ":19200,n,8,1", 12 );<br>
break;<br>
<br>
case BAUD_38400:<br>
memcpy( &MuttIniData[4], ":38400,n,8,1", 12 );<br>
break;<br>
<br>
<br>
}<br>
break;<br>
<br>
case WM_CLOSE:<br>
EndDialog( hDlg, TRUE );<br>
return TRUE;<br>
<br>
}<br>
return FALSE;<br>
}<br>
<br>
I hope this helps.
 
Thank you so much - it was just one little detail piece that I couldn't seem to find. I REALLY appreciate your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top