Thread: Radio button is it checked?

  1. #1
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    Unhappy Radio button is it checked?

    I finally figured out how to set a radio button in my dialog to my 'default' state that I want.

    Now, I want to check to see if the user selects my other radio button and when he or she does to change the value of a variable to a negative number. When I tried using BM_GETCHECKED my compiler chokes and says it is an undeclared identifier.

    What is the correct way to implement this?
    I've rem'd out the various things that I have tried below.

    Here is the code I tried...

    Code:
    BOOL CALLBACK CircleProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    	int nLen = 0;
    	LPTSTR pbuffer = NULL;
    
        switch(Message)
        {
            case WM_INITDIALOG:
    			// Default radio button.
    			hdlg = GetDlgItem(hwnd,IDC_RADIO_ADD );
    			SendMessage(hdlg, BM_SETCHECK, 1,0);
    
            return TRUE;
            case WM_COMMAND:
                switch(LOWORD(wParam))
                {
                    case IDOK:
    						{
    						hdlg = GetDlgItem(hwnd, IDC_EDIT_DIAMETER);  //(hOwner, hDialogEditField)
    						nLen = GetWindowTextLength(hdlg);
    						pbuffer = (LPTSTR)malloc(nLen + 1);
    
    						GetDlgItemText(hwnd,	//(hOwner, hDialogEditField)
    							IDC_EDIT_DIAMETER,	// control identifier
    							pbuffer,			// pointer to buffer for text
    							nLen+1				// maximum size of string + NULL
    						);
    
    						// pbuffer is valid so do calculations.
    						diameter = strtod(pbuffer, NULL);
    						free(pbuffer);
    
    						Ixc = (PI/64)*(pow(diameter, 4.0));
    						area = PI * pow(diameter/2, 2);
    
    // Here are the varoius things that I have tried.
    					//	int iCheck;
    					//	iCheck =  SendMessage (IDC_RADIO_SUBTRACT, BM_GETCHECKED, 0, 0);
    					//if(Button_GetCheck(hwnd,IDC_RADIO_ADD ))
    					//	if (iCheck != 0)
    					//		area = -1*area;
    						}
    						// Since OK call center coord. dialog.
    						DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_CENTER_COORDINATES), 
    							hwnd, CenterCoordinates);
    						EndDialog(hwnd, IDOK);
                    break;
                    case IDCANCEL:
    					MessageBeep (0) ;
                        EndDialog(hwnd, IDCANCEL);
                    break;
                }
            break;
            default:
                return FALSE;
        }
        return TRUE;
    }
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    BM_GETCHECK and BM_SETCHECK
    Code:
    	if(SendMessage(GetDlgItem(hWnd,IDC_CHECK), BM_GETCHECK, (WPARAM)0 ,(LPARAM)0) == BST_CHECKED)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    Talking Thank you!

    You are AWESOME novacain. Thanks for the response.
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dialog Boxes - Radio Button mischief
    By MrWizard in forum Windows Programming
    Replies: 2
    Last Post: 05-15-2002, 08:06 PM
  2. Radio button linked to text box
    By J_Bravo in forum Windows Programming
    Replies: 9
    Last Post: 05-07-2002, 10:15 PM
  3. Unselecting a radio button
    By canine in forum Windows Programming
    Replies: 1
    Last Post: 11-27-2001, 06:58 AM
  4. Default checking of radio button in a group box
    By juhigarg in forum Windows Programming
    Replies: 3
    Last Post: 11-08-2001, 12:25 AM
  5. Default checking of radio button in a group box
    By juhigarg in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2001, 01:31 AM