Nonlin
Nonlin

Reputation: 560

PropertySheet Application and Usage Win32

I'm trying to use a Property Sheet in my Win32 DialogBox application so that I can get user input first, have it apply to my classes and then run the program with that user entered specfication.

Property Page seems good but I'm not sure if I'm mistaken.

Regardless, I'm trying to implement it and I'm having some trouble. I read the documentation but still I'm not getting.

I've managed to make the property pages (2 of them) first page has an edit box and a few combo boxes with OK, Cancel and a disabled Apply button. What I'm trying to do is..

A. Have the apply button enable when I add an int to the edit box

B. Figure out how to have that data get put into a variable.

I know how it works with my DialogBox window. I have WM_Command for all my IDC_ stuff I've put in it. But the property page, I don't know what the IDC are for it or how to call the EDIT box and listboxes I've put in it. Or how to have it recognize that they've been used to enable the apply button.

here is my properypage setup method

void propertyPages(HINSTANCE hInstance){

    memset(m_psp, 0, sizeof(m_psp));
    memset(&m_PropSheet, 0, sizeof(m_PropSheet));

    m_psp[0].dwSize = sizeof(PROPSHEETPAGE);
    m_psp[0].dwFlags = PSH_WIZARD;
    m_psp[0].hInstance = hInstance;
    m_psp[0].pszTemplate = (LPCWSTR) IDD_PROPPAGE_LARGE;
    m_psp[0].pszTitle = L"Champ 1 Scenario";

    m_psp[1].dwSize = sizeof(PROPSHEETPAGE);
    m_psp[1].dwFlags = PSP_USETITLE;
    m_psp[1].hInstance = hInstance;
    m_psp[1].pszTemplate = (LPCWSTR) IDD_PROPPAGE_LARGE1;
    m_psp[1].pszTitle = L"Champ 2 Scenario";

    m_PropSheet.dwSize = sizeof(PROPSHEETHEADER);
    m_PropSheet.dwFlags = PSH_PROPSHEETPAGE;
    m_PropSheet.hInstance = hInstance;
    m_PropSheet.pszCaption = L"Champion Level/Runes/Masteries";
    m_PropSheet.nPages = 2;
    m_PropSheet.nStartPage = 0;
    m_PropSheet.ppsp = (LPCPROPSHEETPAGE) m_psp;
    //SendMessage(GetParent(hDlg), PSM_CHANGED, IDD_PROPPAGE_LARGE, 0);
    //PropSheet_Changed(PROPSHEETPAGE,IDD_PROPPAGE_LARGE);
    PropertySheet(&m_PropSheet);
}

I call it first in

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{

Any tips, tricks, pointers or advice? Maybe on the best way to get user data before the main application launches? I'm finding it tricky to have values set by user.

Upvotes: 0

Views: 1152

Answers (2)

Clebson Derivan
Clebson Derivan

Reputation: 11

for each page you need to create a diagloproc:

LRESULT CALLBACK IntPage1DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    UNREFERENCED_PARAMETER(wParam);

    BOOL myCondition = 0;
    LPNMHDR lpnm;
    switch (uMsg) {
    case WM_INITDIALOG:
        break;
    case WM_NOTIFY:
        lpnm = (LPNMHDR)lParam;
        switch (lpnm->code) {
        case PSN_SETACTIVE:

            if (myCondition) {
                PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
            }
            else {
                PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK);
            }

            break;

        case PSN_WIZFINISH:
            break;

        case PSN_WIZBACK:
            break;

        case PSN_RESET:
            break;

        default:
            break;
        }
        break;
    }
    return 0;
}

Upvotes: 0

David Erceg
David Erceg

Reputation: 11

You can set the dialog procedure for a page using the pfnDlgProc member:

m_psp[0].dwSize = sizeof(PROPSHEETPAGE);
m_psp[0].dwFlags = PSH_WIZARD;
m_psp[0].hInstance = hInstance;
m_psp[0].pszTemplate = (LPCWSTR) IDD_PROPPAGE_LARGE;
m_psp[0].pszTitle = L"Champ 1 Scenario";
m_psp[0].pfnDlgProc = MyDialogProc;

where MyDialogProc is just a normal dialog procedure.

To set the state of the apply button, use the PropSheet_Changed/PropSheet_UnChanged macros.

Upvotes: 1

Related Questions