×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Radio Button Problem

Radio Button Problem

Radio Button Problem

(OP)
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!

RE: Radio Button Problem

Well.... It depends on what compiler you are using, and how your radio buttons are created.
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.
Kind of like this:
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):

MyPortSetup DIALOG 25, 16, 174, 179
STYLE DS_MODALFRAME ¦ WS_POPUP ¦ WS_CAPTION ¦ WS_SYSMENU
CAPTION "Communications Setup"
BEGIN
CONTROL "4800", BAUD_4800, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_GROUP ¦ WS_TABSTOP, 85, 106, 32, 12
CONTROL "9600", BAUD_9600, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 85, 122, 32, 12
CONTROL "19200", BAUD_19200, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 85, 138, 32, 12
CONTROL "38400", BAUD_38400, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 85, 153, 32, 12
CONTROL "COM 1", SEL_COM1, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_GROUP ¦ WS_TABSTOP, 23, 106, 32, 12
CONTROL "COM 2", SEL_COM2, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 23, 122, 32, 12
CONTROL "COM 3", SEL_COM3, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 23, 138, 32, 12
CONTROL "COM 4", SEL_COM4, "BUTTON", BS_AUTORADIOBUTTON ¦ WS_CHILD ¦ WS_VISIBLE ¦ WS_TABSTOP, 23, 153, 32, 12
//stuff deleted!
END

//And in the header file...:

#define SEL_COM1 401 //or what ever #'s the resource compiler puts here...
#define SEL_COM2 402
#define SEL_COM3 403
#define SEL_COM4 404
#define BAUD_4800 405
#define BAUD_9600 406
#define BAUD_19200 407
#define BAUD_38400 408

//And in your source code for the above dialog box:

BOOL FAR PASCAL _export ComSetupBox( HWND hDlg, UINT message,
UINT wParam, LONG lParam )
{
//stuff deleted!
switch( message )
{
//stuff deleted!

case WM_COMMAND:
switch( wParam )
{
//stuff deleted!

case SEL_COM1:
MuttIniData[3] = '1'; //here we do stuff for one radio button...
break;

case SEL_COM2:
MuttIniData[3] = '2'; //here we do stuff for another radio button...
break;

case SEL_COM3:
MuttIniData[3] = '3'; // and another...
break;

case SEL_COM4:
MuttIniData[3] = '4'; // and another...
break;

case BAUD_4800:
memcpy( &MuttIniData[4], ":4800,n,8,1\r", 12 ); // and another...
break;

case BAUD_9600:
memcpy( &MuttIniData[4], ":9600,n,8,1\r", 12 ); // and so on...
break;

case BAUD_19200:
memcpy( &MuttIniData[4], ":19200,n,8,1", 12 );
break;

case BAUD_38400:
memcpy( &MuttIniData[4], ":38400,n,8,1", 12 );
break;


}
break;

case WM_CLOSE:
EndDialog( hDlg, TRUE );
return TRUE;

}
return FALSE;
}

I hope this helps.

RE: Radio Button Problem

(OP)
Thank you so much - it was just one little detail piece that I couldn't seem to find. I REALLY appreciate your help!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close