- Joined
- Jan 13, 2008
- Messages
- 2,302
- Reaction score
- 6
- Points
- 38
- Location
- Atlanta, GA, USA, North America
I hit a strange problem writing a scenario editor page. It seems that a call to SetDialogText for one specific Edit Control I have is causing the window to close, and I'm at a loss as to why. Here's a chunk of my message handler method:
The section I've highlighted in red is the problem section. What's really weird, is the other two calls to that method for other edit boxes don't exhibit this behavior. I traced it down to this line by commenting everything else out and adding lines back in. I've double checked the properties on the dialog and on this control and the other controls all match this control
Has anyone else seen this behavior and solved it? I'm at a loss.
Thanks,
Matt
---------- Post added at 20:27 ---------- Previous post was at 19:51 ----------
Also, while I'm on the topic of Scenario Editor dialogs, how do the IDC_BACK buttons get handled? The Deltaglider example includes no explicit handling of those buttons, yet they work.
Code:
case WM_NOTIFY:
if (((NMHDR*)lParam)->code == UDN_DELTAPOS)
{
NMUPDOWN *nmud = (NMUPDOWN*)lParam;
int val = 1;
double posval = 0.0;
int id = ((NMHDR*)lParam)->idFrom;
char cbuf[256];
if(id == IDC_SPIN1)
{
GetWindowText (GetDlgItem (hTab, IDC_EDIT1), cbuf, 256);
sscanf (cbuf, "%d", &val);
val -= nmud->iDelta * 1;
if(val < 1)
val = 1;
sprintf (cbuf, "%d", val);
SetWindowText (GetDlgItem (hTab, IDC_EDIT1), cbuf);
OBJHANDLE hVessel;
SendMessage (hTab, WM_SCNEDITOR, SE_GETVESSEL, (LPARAM)&hVessel);
PalletCarrier* ves = (PalletCarrier*)oapiGetVesselInterface(hVessel);
if(ves->getNumSegments() != val)
{
bool bTemp = SendDlgItemMessage(hTab, IDC_CHECK1, BM_GETCHECK, 0, 0) == BST_CHECKED;
ves->changeCarrier(val,bTemp);
}
}
else if(id == IDC_SPIN2 || id == IDC_SPIN2A)
{
GetWindowText (GetDlgItem (hTab, IDC_EDIT2), cbuf, 256);
sscanf (cbuf, "%lf", &posval);
posval -= nmud->iDelta * (id == IDC_SPIN2 ? 1 : 0.001);
if(posval > 1000000)
posval = 1000000;
else if(posval < -1000000)
posval = -1000000;
sprintf (cbuf, "%.3lf", posval);
[COLOR="Red"]SetWindowText(GetDlgItem(hTab, IDC_EDIT2), cbuf);[/COLOR]
}
else if(id == IDC_SPIN3 || id == IDC_SPIN3A)
{
GetWindowText (GetDlgItem (hTab, IDC_EDIT3), cbuf, 256);
sscanf (cbuf, "%lf", &posval);
posval -= nmud->iDelta * (id == IDC_SPIN3 ? 1 : 0.001);
if(posval > 1000000)
posval = 1000000;
else if(posval < -1000000)
posval = -1000000;
sprintf (cbuf, "%.3lf", posval);
SetWindowText (GetDlgItem (hTab, IDC_EDIT3), cbuf);
}
else if(id == IDC_SPIN4 || id == IDC_SPIN4A)
{
GetWindowText (GetDlgItem (hTab, IDC_EDIT4), cbuf, 256);
sscanf (cbuf, "%lf", &posval);
posval -= nmud->iDelta * (id == IDC_SPIN4 ? 1 : 0.001);
if(posval > 1000000)
posval = 1000000;
else if(posval < -1000000)
posval = -1000000;
sprintf (cbuf, "%.3lf", posval);
SetWindowText (GetDlgItem (hTab, IDC_EDIT4), cbuf);
}
VECTOR3 temp = _V(0,0,0);
GetWindowText (GetDlgItem (hTab, IDC_EDIT2), cbuf, 256);
sscanf (cbuf, "%lf", &temp.x);
GetWindowText (GetDlgItem (hTab, IDC_EDIT3), cbuf, 256);
sscanf (cbuf, "%lf", &temp.y);
GetWindowText (GetDlgItem (hTab, IDC_EDIT4), cbuf, 256);
sscanf (cbuf, "%lf", &temp.z);
OBJHANDLE hVessel;
SendMessage (hTab, WM_SCNEDITOR, SE_GETVESSEL, (LPARAM)&hVessel);
VESSEL3* ves = (VESSEL3*)oapiGetVesselInterface(hVessel);
((PalletCarrier*)ves)->setOfs(temp);
return TRUE;
}
The section I've highlighted in red is the problem section. What's really weird, is the other two calls to that method for other edit boxes don't exhibit this behavior. I traced it down to this line by commenting everything else out and adding lines back in. I've double checked the properties on the dialog and on this control and the other controls all match this control
Has anyone else seen this behavior and solved it? I'm at a loss.
Thanks,
Matt
---------- Post added at 20:27 ---------- Previous post was at 19:51 ----------
Also, while I'm on the topic of Scenario Editor dialogs, how do the IDC_BACK buttons get handled? The Deltaglider example includes no explicit handling of those buttons, yet they work.
Last edited: