- Understanding radio buttons
- Posted by JoeC on February 3rd, 2007
Question here, I am using the win32 programming book by Pezold and his
explantion of radio buttons is confusing. I am starting a game with a
menu that has three choices which will control my game.
So far I have:
#include <windows.h>
extern bool email;
extern bool gload;
BOOL CALLBACK startProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp){
int choice = 2;//IDC_NEW;
const int IDC_NEW = 2;
const int IDC_EMAIL = 3;
const int IDC_LOAD = 4;
HWND menu;
switch(msg){
case WM_INITDIALOG:
CheckRadioButton(hwnd, 2,3, choice);
menu = GetDlgItem(hwnd, choice);
SetFocus(GetDlgItem(hwnd, choice));
return FALSE;
case WM_COMMAND:
switch(LOWORD(wp)){
case IDOK:
EndDialog(hwnd, IDOK);
return true;
break;
case IDC_NEW:
email = false;
gload = false;
break;
case IDC_EMAIL:
email = true;
gload = false;
break;
case IDC_LOAD:
email = true;
gload = true;
break;
}
InvalidateRect(hwnd,NULL,FALSE);
break;
default:
return FALSE;
}
return true;
}
I am having some trouble because it dosn't want to read the def I have
in my resources.h file so I jsut made const to see if it would work.
- Posted by JoeC on February 4th, 2007
On Feb 3, 6:47 pm, "JoeC" <enki...@yahoo.com> wrote:
I did find some errors and corrected them. It was a few simple thing
like forgotten headers and a few other things.
I did make some changes:
switch(msg){
case WM_INITDIALOG:
choice = IDC_NEW;
CheckRadioButton(hwnd, IDC_NEW, IDC_LOAD ,choice);
menu = GetDlgItem(hwnd, IDC_GROUP);
SetFocus(GetDlgItem(hwnd,choice));
return FALSE;
The dialog box does comes up with all the radio buttons, the scrips I
think is right. But the problem is that I cant make any selections.
- Posted by John Carson on February 5th, 2007
"JoeC" <enki034@yahoo.com> wrote in message
news:1170556757.990845.306440@v45g2000cwv.googlegr oups.com...
In WM_COMMAND processing, you check for
HIWORD(wParam) == BN_CLICKED
and use CheckRadioButton to set the radio button that has been clicked.
--
John Carson
- Posted by Sten Westerback \(MVP SDK\) on February 5th, 2007
"JoeC" <enki034@yahoo.com> wrote in message
news:1170556757.990845.306440@v45g2000cwv.googlegr oups.com...
Do you mean that the user interface isn't responding? If so, you aren't
blocking your message loop somehow?
Or, more likely, you don't get the proper notification when you click a
radiobutton. If so that's probably because your recources.h says that the ID
of the first control is 100 -- not 2 as you claim in your code. You should
use the definitions in the .h file (unless you really want to edit the .rc
to make the ID's match.
- Sten
- Posted by JoeC on February 6th, 2007
On Feb 5, 12:46 am, "John Carson" <jcarson_n_o_sp_...@netspace.net.au>
wrote:
Thanks, That worked. My game is now done. It can be found:
http://cgp.praat.nu/component/option...ileinfo/id,38/