Property Sheet

I want to use Property Sheets. Can someone please write a simple Property Sheet example. I just need a simple source codes to start with.
redhat092798Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BudVVeezerCommented:
In MFC or just straight C?  C++?

~Aaron
0
cyberbumCommented:
This should help you get started:

CPropertySheet * pSheet = new CPropertySheet;

pSheet->Construct("My Sheet", pParentWnd);
// In your resource editor, construct a few dialogs that will be used for each page in the property sheet

// Construct your pages
CPropertyPage * pPage = new CPropertyPage;
pPage->Construct(IDD_YOURDIALOG);
pSheet->AddPage(pPage);
pSheet->DoModal();
0
redhat092798Author Commented:
In Plain C API
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

wyllikerCommented:
While this code snippet wouldn't be relevant to your specific application you should be able to get the idea.

Read up on the PROPSHEETPAGE, and PROPSHEETHEADER structure docs as well as the CreatePropertySheetPage and PropertySheet function docs.

In my example below I am creating a four page property sheet.

Note that I am using a variable called ThisInstance - this is the value of hInstance that was passed into WinMain.

Also, I am passing a parameter to each dialog as it is created - (LPARAM) PPCriteria - which you may not need to do depending on your requirements

Here goes ...
--------------

#define PAGE_TERMS      0
#define PAGE_CUSTOMER   1
#define PAGE_PPORDER    2
#define PAGE_HELP       3

#define TOTAL_PAGES     4


PROPSHEETPAGE  Page[TOTAL_PAGES];
HPROPSHEETPAGE hPage[TOTAL_PAGES];
PROPSHEETHEADER PropSheetHeader;

    memset(&PropSheetHeader, 0, sizeof(PROPSHEETHEADER));
    memset(&Page, 0, TOTAL_PAGES * sizeof(PROPSHEETPAGE));

    Page[PAGE_TERMS].dwSize = sizeof(PROPSHEETPAGE);
    Page[PAGE_TERMS].hInstance = ThisInstance;
    Page[PAGE_TERMS].pszTemplate = MAKEINTRESOURCE(IDD_TERMS);
    Page[PAGE_TERMS].pfnDlgProc = TermsDlgProc;
    Page[PAGE_TERMS].lParam = (LPARAM) PPCriteria;
    hPage[PAGE_TERMS] = CreatePropertySheetPage((PROPSHEETPAGE *) &Page[PAGE_TERMS]);

    Page[PAGE_CUSTOMER].dwSize = sizeof(PROPSHEETPAGE);
    Page[PAGE_CUSTOMER].hInstance = ThisInstance;
    Page[PAGE_CUSTOMER].pszTemplate = MAKEINTRESOURCE(IDD_CUSTOMER);
    Page[PAGE_CUSTOMER].pfnDlgProc = CustomerDlgProc;
    Page[PAGE_CUSTOMER].lParam = (LPARAM) PPCriteria;
    hPage[PAGE_CUSTOMER] = CreatePropertySheetPage((PROPSHEETPAGE *) &Page[PAGE_CUSTOMER]);

    Page[PAGE_PPORDER].dwSize = sizeof(PROPSHEETPAGE);
    Page[PAGE_PPORDER].hInstance = ThisInstance;
    Page[PAGE_PPORDER].pszTemplate = MAKEINTRESOURCE(IDD_PPORDER);
    Page[PAGE_PPORDER].pfnDlgProc = PPOrderDlgProc;
    Page[PAGE_PPORDER].lParam = (LPARAM) PPCriteria;
    hPage[PAGE_PPORDER] = CreatePropertySheetPage((PROPSHEETPAGE *) &Page[PAGE_PPORDER]);

    Page[PAGE_HELP].dwSize = sizeof(PROPSHEETPAGE);
    Page[PAGE_HELP].hInstance = ThisInstance;
    Page[PAGE_HELP].pszTemplate = MAKEINTRESOURCE(IDD_HELP);
    Page[PAGE_HELP].pfnDlgProc = HelpDlgProc;
    Page[PAGE_HELP].lParam = (LPARAM) PPCriteria;
    hPage[PAGE_HELP] = CreatePropertySheetPage((PROPSHEETPAGE *) &Page[PAGE_HELP]);

    PropSheetHeader.dwSize = sizeof(PROPSHEETHEADER);
    PropSheetHeader.dwFlags = PSH_NOAPPLYNOW;
    PropSheetHeader.hwndParent = HWND_DESKTOP;
    PropSheetHeader.hInstance = ThisInstance;
    PropSheetHeader.pszCaption = "Prospect Profile";
    PropSheetHeader.nPages = TOTAL_PAGES;
    PropSheetHeader.nStartPage = PAGE_TERMS;
    PropSheetHeader.phpage = (HPROPSHEETPAGE *) &hPage;

    PropertySheet(&PropSheetHeader);




0
wyllikerCommented:
I want to make this clear ...

(LPARAM) PPCriteria

.... is a pointer to my own defined structure that all of the pages share so that the data collected on each page can be updated in a central place.

This is not part of Property Pages but part of my implementation.
0
wyllikerCommented:
Here is the Property sheet dialog handler for the PAGE_ORDER (IDD_ORDER) page ....

------------

static PCRITERIA Criteria = (PCRITERIA) NULL;


BOOL CALLBACK PPOrderDlgProc ( HWND hwndDlg,    UINT Message,
                               WPARAM wParam, LPARAM lParam )
{
LRESULT RC = 0;
PPROPSHEETPAGE PropSheetPage = (PPROPSHEETPAGE) NULL;
NMHDR * pNotification = (NMHDR *) NULL;
unsigned int TextLen = 0;
LOGBRUSH LogBrush;

    switch(Message)
    {
        case WM_INITDIALOG:
             PropSheetPage = (PPROPSHEETPAGE) lParam;
             Criteria = (PCRITERIA) PropSheetPage->lParam;
             return (LRESULT) 1;
             break;

        case WM_CTLCOLORSTATIC:
             if(GetWindowLong((HWND) lParam, GWL_ID) == IDC_COPYRIGHTMSG)
             {
                 SetTextColor((HDC) wParam, 0x000000FF);
                 SetBkColor((HDC) wParam, GetBkColor((HDC) wParam));
                 SetBkMode((HDC) wParam, TRANSPARENT);
                 LogBrush.lbStyle = BS_SOLID;
                 LogBrush.lbColor = GetSysColor(COLOR_3DFACE);
                 return (BOOL) CreateBrushIndirect(&LogBrush);
             }
             else
                 return FALSE;

        case WM_NOTIFY:
             pNotification = (NMHDR *) lParam;
             if(pNotification->code == PSN_KILLACTIVE)
             {
                 TextLen = GetDlgItemText(hwndDlg,IDC_PROSPECTNAME,
                                          &Criteria->ProspectName[0], MAXLEN_PROSPECTNAME);

                 if(TextLen)
                     Criteria->fProspectInformation = 1;

                 TextLen = GetDlgItemText(hwndDlg, IDC_PROSPECTADDRESS,
                                          Criteria->ProspectAddress, MAXLEN_PROSPECTADDRESS);

                 if(TextLen)
                     Criteria->fProspectInformation = 1;

                 TextLen = GetDlgItemText(hwndDlg, IDC_PROSPECTCITY,
                                          Criteria->ProspectCity, MAXLEN_PROSPECTCITY);

                 if(TextLen)
                     Criteria->fProspectInformation = 1;

                 TextLen = GetDlgItemText(hwndDlg, IDC_PROSPECTSTATE,
                                          Criteria->ProspectState, MAXLEN_PROSPECTSTATE);

                 if(TextLen)
                     Criteria->fProspectInformation = 1;

                 TextLen = GetDlgItemText(hwndDlg, IDC_PROSPECTZIP,
                                          Criteria->ProspectZip, MAXLEN_PROSPECTZIP);

                 if(TextLen)
                     Criteria->fProspectInformation = 1;

                 TextLen = GetDlgItemText(hwndDlg, IDC_PROSPECTTELEPHONE,
                                          Criteria->ProspectTelephone, MAXLEN_PROSPECTTELEPHONE);

                 if(TextLen)
                     Criteria->fProspectInformation = 1;
                 
                 TextLen = GetDlgItemText(hwndDlg, IDC_PROSPECTPRODUCTORSERVICE,
                                          Criteria->ProspectProductOrService, MAXLEN_PROSPECTPRODUCTORSERVICE);
                 if(TextLen)
                     Criteria->fProspectInformation = 1;

               
                 SetWindowLong(hwndDlg, DWL_MSGRESULT, (LONG) FALSE);
                 return (LRESULT) TRUE;
             }
             else
             if(pNotification->code == PSN_APPLY)
             {
                 SendToDB(hwndDlg, Criteria);
                 return (LRESULT) TRUE;
             }
             break;
    }

    return (LRESULT) 0;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
redhat092798Author Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.