Hi,
On running debug I found out that some variables weren't changing when explicitly asked to, i.e. int a = 5. They are inside a dialog box function.
gametype is a global variable (since I never figured out how to pass an array into a dialog box - if any one knows how to do that I'd be glad to hear it!) and dummy is a local one. Neither dummy[0] = something nor gametype[0] = dummy[0] work. gametype[0] stays as what it was before and dummy[0] stays as a random huge negative number.
So what's happening?
On a related note, some child window buttons work fine until this dialog is called, then they won't work anymore (they look enabled, but can't be clicked). Does anyone know why that might happen?
Anyway, here is the code for the dialog box function:
Code:
BOOL CALLBACK DialogSettings( HWND dwin, UINT message, WPARAM wParam, LPARAM lParam )
{
switch(message)
{
case WM_INITDIALOG:
//make dummy variable(for if user changes their mind about settings)
int a, b, c, d, e;
//int dummy[5];
//set initial checks
int radioID;
if(gametype[0] == TAKELASTLOSE) radioID = IDC_TAKELASTLOSE;
if(gametype[0] == TAKELASTWIN) radioID = IDC_TAKELASTWIN;
CheckRadioButton(dwin, IDC_TAKELASTLOSE, IDC_TAKELASTWIN, radioID);
if(gametype[1] == TAKE2) radioID = IDC_Take2;
if(gametype[1] == TAKE3) radioID = IDC_Take3;
if(gametype[1] == TAKE4) radioID = IDC_Take4;
if(gametype[1] == TAKE5) radioID = IDC_Take5;
CheckRadioButton(dwin, IDC_Take2, IDC_Take5, radioID);
if(gametype[2] == YOU) radioID = IDC_Pfirst;
if(gametype[2] == COMP) radioID = IDC_Compfirst;
if(gametype[2] == RAND) radioID = IDC_Comprand;
CheckRadioButton(dwin, IDC_Pfirst, IDC_Comprand, radioID);
if(gametype[3] == P1) radioID = IDC_P1first;
if(gametype[3] == P2) radioID = IDC_P2first;
if(gametype[3] == P3) radioID = IDC_P3first;
if(gametype[3] == P4) radioID = IDC_P4first;
if(gametype[3] == P5) radioID = IDC_P5first;
if(gametype[3] == RAND) radioID = IDC_Multirand;
CheckRadioButton(dwin, IDC_P1first, IDC_Multirand, radioID);
if(gametype[4] == 2) radioID = IDC_2players;
if(gametype[4] == 3) radioID = IDC_3players;
if(gametype[4] == 4) radioID = IDC_4players;
if(gametype[4] == 5) radioID = IDC_5players;
CheckRadioButton(dwin, IDC_2players, IDC_5players, radioID);
return TRUE;
case WM_COMMAND:
switch LOWORD(wParam)
{
case IDC_2players:
//dummy[4] = 2;
e = 2;
break;
case IDC_3players:
//dummy[4] = 3;
e = 3;
break;
case IDC_4players:
//dummy[4] = 4;
e = 4;
break;
case IDC_5players:
//dummy[4] = 5;
e = 4;
break;
case IDC_TAKELASTWIN:
//dummy[0] = TAKELASTWIN;
a = TAKELASTWIN;
break;
case IDC_TAKELASTLOSE:
//dummy[0] = TAKELASTLOSE;
a = TAKELASTLOSE;
break;
case IDC_Pfirst:
//dummy[2] = YOU;
c = YOU;
break;
case IDC_Compfirst:
//dummy[2] = COMP;
c = COMP;
break;
case IDC_Comprand:
//dummy[2] = RAND;
c = RAND;
break;
case IDC_P1first:
//dummy[3] = P1;
d = P1;
break;
case IDC_P2first:
//dummy[3] = P2;
d = P2;
break;
case IDC_P3first:
//dummy[3] = P3;
d = P3;
break;
case IDC_P4first:
//dummy[3] = P4;
d = P4;
break;
case IDC_P5first:
//dummy[3] = P5;
d = P5;
break;
case IDC_Multirand:
//dummy[3] = RAND;
d = RAND;
break;
case IDC_Take2:
//dummy[1] = TAKE2;
b = TAKE2;
break;
case IDC_Take3:
//dummy[1] = TAKE3;
b = TAKE3;
break;
case IDC_Take4:
//dummy[1] = TAKE4;
b = TAKE4;
break;
case IDC_Take5:
//dummy[1] = TAKE5;
b = TAKE5;
break;
case IDOK:
//commit changes:
gametype[0] = a;
//dummy[0];
gametype[1] = b;
//dummy[1];
gametype[2] = c;
//dummy[2];
gametype[3] = d;
//dummy[3];
gametype[4] = e;
//dummy[4];
EndDialog(dwin, IDOK);
break;
case IDCANCEL:
EndDialog(dwin, IDCANCEL);
break;
}
return true;
}
return false;
}
If anyone has an idea of why the buttons might not work I will post the code of WM_COMMAND where the buttons are processed and the dialog is called.
Thanks heaps in advance, it is puzzling me incredibly!!