- Joined
- Aug 6, 2011
- Messages
- 405
- Reaction score
- 3
- Points
- 18
UpdateStatus is only called once in your callbacks, and never when the switch status changes. You probably have to add it to the dialog code that handles a mouseclick.
Without that second UpdateDialog, your code for updating the callback will never get called.
The final SetWindowText is outside of any conditional, which means the final line (in red) is always run.
Code:
BOOL PayloadBayOp::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
bool action = false;
switch (uMsg) {
case WM_INITDIALOG: {
SWITCHPARAM sp = { SWITCHPARAM::THREESTATE, SWITCHPARAM::VERTICAL };
UpdateDialog(hWnd);
} return TRUE;
case IDC_PLBD3:
if (HIWORD(wParam) == BN_CLICKED) {
int idx = (LOWORD(wParam) == IDC_PLBD3 ? 0 : 1);
switch (lParam) {
case 0:
PYROPRI = BD_ON;
break;
case 1:
PYROPRI = BD_OFF;
break;
}
[COLOR="Red"]UpdateDialog(hWnd);[/COLOR]
}
break;
}
return oapiDefDialogProc(hWnd, uMsg, wParam, lParam);
}
Without that second UpdateDialog, your code for updating the callback will never get called.
Yes, the enum is either on or off. However, your UpdateDialog doesn't work like you probably intended-it always sets it the talkback text to " ", regardless of the state of PYROPRI.As I understand it. If I switch the switch is will be either :
enum { BD_ON, BD_OFF } PYROPRI;
then check to see if PYROPRI is BD_ON if it is change the
static char *PLBDstr[2] = { " ", "\\\\\\\\\\", };
SetWindowText(GetDlgItem(hWnd, IDC_PLBD_TLKBK7), PLBDstr[0]);
The final SetWindowText is outside of any conditional, which means the final line (in red) is always run.
Code:
void PayloadBayOp::UpdateDialog(HWND hWnd)
{
char cbuf[256];
//int i;
sprintf(cbuf, "IUSASE %s: Payload Bay Operation", sts->GetName());
SetWindowText(hWnd, cbuf);
{
int plbd_ctrl[1] = { IDC_PLBD3 };
bool switchstatus = (PYROPRI == BD_ON);
oapiSetSwitchState(GetDlgItem(hWnd, plbd_ctrl[1]), switchstatus ? 0 : 1, true);
}
oapiSetSwitchState(GetDlgItem(hWnd, IDC_PLBD3), PYROPRI == BD_ON ? 0 : PYROPRI == BD_OFF ? 1 : 2, true);
static char *PLBDstr[2] = { " ", "\\\\\\\\\\", };
[COLOR="Red"] SetWindowText(GetDlgItem(hWnd, IDC_PLBD_TLKBK7), PLBDstr[0]);[/COLOR]
}