Problem Scenario Editor dialog buttons do not work right

Zatnikitelman

Addon Developer
Addon Developer
Joined
Jan 13, 2008
Messages
2,302
Reaction score
6
Points
38
Location
Atlanta, GA, USA, North America
For some reason, the buttons I've declared in a vessel page for scenario editor do not work right. The button I have as IDC_BUTTON1 closes the page and goes back to the default vessel page, while the button IDC_BACK does nothing. In my callback function IDC_BUTTON1 has an action, however after running it under the debugger, it doesn't even trigger the stuff for IDC_BUTTON1. The other scenario editor pages I've created behave correctly, the IDC_BACK button does its job, and I have actions for the "non-default" buttons, but this doesn't and there really isn't any reason for it. Here's my .rc file, the button in question is in IDD_DIALOG1:
Code:
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE 
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_DIALOG1 DIALOGEX 0, 0, 309, 207
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    COMBOBOX        IDC_COMBO1,7,7,48,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
    LTEXT           "Attachment Point",IDC_STATIC,61,8,56,8
    COMBOBOX        IDC_COMBO2,7,29,111,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
    GROUPBOX        "Attachment Status:",IDC_STATIC,181,6,121,194
    LISTBOX         IDC_LIST1,181,18,121,182,NOT LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_NOSEL | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP
    PUSHBUTTON      "<< Done",IDC_BACK,7,186,50,14
    PUSHBUTTON      "Attach",IDC_BUTTON1,7,68,50,14
    COMBOBOX        IDC_COMBO3,7,49,48,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
    LTEXT           "Payload",IDC_STATIC,123,31,26,8
    LTEXT           "Payload Attachment #",IDC_STATIC,59,52,73,8
END

IDD_DIALOG2 DIALOGEX 0, 0, 309, 218
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "<< Done",IDOK,7,197,50,14
    CONTROL         "",IDC_SPIN1,"msctls_updown32",UDS_ARROWKEYS,90,39,11,14
    EDITTEXT        IDC_EDIT1,19,38,70,14,ES_AUTOHSCROLL
    CONTROL         "STS",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,109,41,28,10
    EDITTEXT        IDC_EDIT2,18,80,40,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN2,"msctls_updown32",UDS_ARROWKEYS,59,80,11,14
    CONTROL         "",IDC_SPIN2A,"msctls_updown32",UDS_ARROWKEYS,70,77,11,20
    EDITTEXT        IDC_EDIT3,90,80,40,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN3,"msctls_updown32",UDS_ARROWKEYS,131,80,11,14
    CONTROL         "",IDC_SPIN3A,"msctls_updown32",UDS_ARROWKEYS,142,77,11,20
    EDITTEXT        IDC_EDIT4,161,80,40,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN4,"msctls_updown32",UDS_ARROWKEYS,201,80,11,14
    CONTROL         "",IDC_SPIN4A,"msctls_updown32",UDS_ARROWKEYS,213,77,11,20
    LTEXT           "Payload Attachment Offset:",IDC_STATIC,20,61,91,8
    LTEXT           "X",IDC_STATIC,35,70,8,8
    LTEXT           "Y",IDC_STATIC,109,70,8,8
    LTEXT           "Z",IDC_STATIC,180,70,8,8
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
    IDD_DIALOG1, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 302
        TOPMARGIN, 7
        BOTTOMMARGIN, 200
    END

    IDD_DIALOG2, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 302
        TOPMARGIN, 7
        BOTTOMMARGIN, 211
    END
END
#endif    // APSTUDIO_INVOKED

#endif    // English (United States) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED
And here's the callback function:
Code:
switch (uMsg) 
	{
        case WM_COMMAND:
		switch(LOWORD(wParam))
		{
case IDC_BUTTON1:
			{
				char cbuf[256];
				int index = SendDlgItemMessage(hTab,IDC_COMBO1,CB_GETCURSEL,0,0);
				SendDlgItemMessage(hTab,IDC_COMBO1,CB_GETLBTEXT,(WPARAM)index,(LPARAM)cbuf);

				char tbuf[256];
				GetDlgItemText(hTab,IDC_BUTTON1,tbuf,256);
				if(!strnicmp(tbuf,"Attach",6))
				{
					char nbuf[256];
					index = SendDlgItemMessage(hTab,IDC_COMBO2,CB_GETCURSEL,0,0);
					SendDlgItemMessage(hTab,IDC_COMBO2,CB_GETLBTEXT,(WPARAM)index,(LPARAM)nbuf);

					OBJHANDLE o = oapiGetVesselByName(nbuf);
					if(oapiIsVessel(o))
					{
						char abuf[256];
						index = SendDlgItemMessage(hTab,IDC_COMBO3,CB_GETCURSEL,0,0);
						SendDlgItemMessage(hTab,IDC_COMBO3,CB_GETLBTEXT,(WPARAM)index,(LPARAM)abuf);

						int ppoint;
						int cpoint;
						sscanf(abuf,"%d",&cpoint);
						sscanf(cbuf,"%d",&ppoint);

						OBJHANDLE hVessel;
						SendMessage (hTab, WM_SCNEDITOR, SE_GETVESSEL, (LPARAM)&hVessel);
						VESSEL3* ves = (VESSEL3*)oapiGetVesselInterface(hVessel);
						((PalletCarrier*)ves)->attachPayload(ppoint, cpoint, o);
					}
				}
				else
				{
					int ptemp;
					sscanf(cbuf,"%d",&ptemp);

					OBJHANDLE hVessel;
					SendMessage (hTab, WM_SCNEDITOR, SE_GETVESSEL, (LPARAM)&hVessel);
					VESSEL3* ves = (VESSEL3*)oapiGetVesselInterface(hVessel);
					((PalletCarrier*)ves)->detachPayload(ptemp);				
				}
			}
			return TRUE;
			break;
		default:
			break;
        }
}
I may have messed up the exact formatting and spacing a little bit when copying from VS2012 into here, but the important parts are correct. The callback function does not seem to be called at all when IDC_BUTTON1 is clicked.

Thanks for any help getting this to work right.
 
Top