C++ Question Help Adding Resource Files to Project?

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
382
Reaction score
254
Points
78
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
Hi all,

I am trying to get a scenario editor working for a project I'm developing, and I've been stuck trying to create a resource (.rc) file. Not sure if this is the best place to post this, so I do apologize in advance if not.

The default ShuttleA in the OrbiterSDK has a resource file which includes the dialog layout for the scenario editor. When working in the ShuttleA's solution I can add new resource files without any issue, but in my solution, when I go to add a new resource I get "Fatal error RC1015: cannot open include file 'winres.h'".

As far as I can tell I have the correct platform toolsets installed, I can create resource files in new/blank projects on VS2022 without any issue. Just wondering if anyone else might know what I'm missing? My project's properties are set up identically to the default ShuttleA as far as I can tell. I am using platform toolset v100, as v143 will not work for Orbiter projects (in my experience, please correct me if I'm wrong on that).

Any help is much appreciated!

Thanks,
MrMartian
 
Okay so update: I have played around with the project settings and got it to work, maybe it would have been best not to attempt this after midnight! I have a resource file with a dialog and everything compiles normally. I have a button in the scenario editor which is supposed to open the dialog box, much like the 'animations' window in the ShuttleA scenario editor, but when I click the button my dialog is not shown, instead I have a blank window.

For reference, this is the code I have for the scenario editor:
C++:
HINSTANCE hDLL;

DLLCLBK void InitModule(HINSTANCE hModule)
{
    hDLL = hModule;
    oapiRegisterCustomControls(hModule);
}

DLLCLBK void ExitModule(HINSTANCE hModule)
{
    oapiUnregisterCustomControls(hDLL);
}

VESSEL* GetV(HWND hDlg)
{
    // retrieve DG interface from scenario editor
    OBJHANDLE hVessel;
    SendMessage(hDlg, WM_SCNEDITOR, SE_GETVESSEL, (LPARAM)&hVessel);
    return (VESSEL*)oapiGetVesselInterface(hVessel);
}

// initialize page 1
void InitEdPg1(HWND hDlg, OBJHANDLE hVessel)
{
    ShowWindow(GetDlgItem(hDlg, IDC_BUTTON2), SW_SHOW);
}

// Message procedure for editor page 1 (animation settings)
BOOL CALLBACK EdPg1Proc(HWND hTab, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
    case WM_INITDIALOG:
        InitEdPg1(hTab, (OBJHANDLE)lParam);
        return TRUE;
    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDC_BUTTON2:
            sprintf(oapiDebugString(), "Button pressed");
            return TRUE;
        }
    }
    return FALSE;
}

// Add vessel-specific pages into scenario editor
DLLCLBK void secInit(HWND hEditor, OBJHANDLE hVessel)
{
    EditorPageSpec eps1 = { "Parameters", hDLL, IDD_PARAMS, EdPg1Proc };
    SendMessage(hEditor, WM_SCNEDITOR, SE_ADDPAGEBUTTON, (LPARAM)&eps1);
}

This is my first time making use of resource files, is there anything I need to do to 'compile' my resource file? I feel like I must be just missing something obvious...

Thanks all,
MrMartian
 
Last edited:
Back
Top