SOL9 2.0 Class: PropertyDialog

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * PropertyDialog.h 
 * Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
// 2000.02.18
// 2009/11/04 Modified not to depend on SOL::PropertyPage class.

#pragma once
#include <sol\PopupView.h>

namespace SOL {

class PropertyDialog :public PopupView {
private:
    int    pages;
    int    curIndex;
    PROPSHEETPAGE*   psp;
    PROPSHEETHEADER* psh;

public:
    PropertyDialog(): PopupView() { }

public:
    /**
     * Constructor
     */
    PropertyDialog(View* parent, const TCHAR* caption, Args& args)
    :PopupView(parent)
    {
        psh = new PROPSHEETHEADER;
        memset(psh, 0, sizeof(PROPSHEETHEADER));
        pages = 5;    // default
        ulong val = args.get(XmNpages);
        if(val) {
            pages = (int)val;
        }
        curIndex = 0;

        psp = new PROPSHEETPAGE[pages];

        psh->ppsp = (LPCPROPSHEETPAGE)psp;
        psh->nPages = curIndex;
        psh->nStartPage = 0;
        psh->dwSize     = sizeof(PROPSHEETHEADER);
        psh->dwFlags    = PSH_PROPSHEETPAGE; //|PSH_PROPTITLE;

        if(parent) {
            psh -> hwndParent = parent->getWindow();
        }

        //Application& applet = Application::getApplet(NULL);

        psh->hInstance  = GetModuleHandle(NULL);//applet.getInstance();//Application::getInstance();

        psh->pszCaption = caption;

        setValues(args);
    }


public:
    ~PropertyDialog() 
    { 
        delete psh;
        delete [] psp;
    }

public:
    Boolean create(View* parent, const TCHAR* caption, Args& args)
    {
        Boolean rc = True;

        View::setParent(parent);

        psh = new PROPSHEETHEADER;
        memset(psh, 0, sizeof(PROPSHEETHEADER));
        pages = 5;    // default
        ulong val = args.get(XmNpages);
        if(val) {
            pages = (int)val;
        }
        curIndex = 0;

        psp = new PROPSHEETPAGE[pages];

        psh->ppsp = (LPCPROPSHEETPAGE)psp;
        psh->nPages = curIndex;
        psh->nStartPage = 0;
        psh->dwSize     = sizeof(PROPSHEETHEADER);
        psh->dwFlags    = PSH_PROPSHEETPAGE; //|PSH_PROPTITLE;

        if(parent) {
            psh -> hwndParent = parent->getWindow();
        }
        //Application& applet = Application::getApplet(NULL);

        psh->hInstance  = GetModuleHandle(NULL);//applet.getInstance();//Application::getInstance();
        psh->pszCaption = caption;

        setValues(args);

        return rc;
    }


public:
    PROPSHEETPAGE* getCurPage() 
    {
        if(curIndex<pages) {
            return &psp[curIndex];
        }
        else {
            return NULL;
        }
    }

/*
VOID CALLBACK PropertyDialog::SheetCallback(HWND  hwndDlg,    
    UINT  message,    LPARAM  lParam)
{
    if(message == PSCB_INITIALIZED) {
        View* self = (View*)lParam;
        if(self) {
            Application::Add(hwndDlg, self);
        }
    }    
}
*/


public:
    BOOL addPage(HPROPSHEETPAGE hPage) //PropertyPage* page) 
    {
        BOOL rc = FALSE;
        //if(page) {
            if(hPage) {//page->getPageHandle()) {
                send(PSM_ADDPAGE, 0, (LPARAM)hPage);//page->getPageHandle());
                rc = TRUE;
            }
            curIndex++;
        //}
        return rc;
    }


public:
    void popup(Action& action) 
    { 
        psh -> nPages = curIndex;
        action.setResult(::PropertySheet(psh));
    }

public:
    void setValues(Args& args)
    {
        ulong val = NULL;
        val = args.get(XmNflags);
        if(val) { 
            psh -> dwFlags |= val;
        }

        val = args.get(XmNicon);
        if(val) { 
            psh -> hIcon = (HICON)val;
        }

        val = args.get(XmNstartPage);
        if(val) {
            psh -> nStartPage = (int)val;
        }
    }


public:
    int        getCurIndex() { return curIndex; }

public:
    void    setCurSel(int indx, HPROPSHEETPAGE hPage) //PropertyPage* page) {
    {
               send(PSM_SETCURSEL, indx, (LPARAM)hPage);//page->getPageHandle());
    }

public:
    void    removePage(int indx, HPROPSHEETPAGE hPage) //PropertyPage* page) {
    {
            send(PSM_REMOVEPAGE, indx, (LPARAM)hPage);//page->getPageHandle());
    }

public:
    void    changed(HPROPSHEETPAGE hPage) //PropertyPage* page) {
    {
            send(PSM_CHANGED, (WPARAM)hPage,
                //page->getPageHandle(),
                0);
    }    

public:
    void    unChanged(HPROPSHEETPAGE hPage) //PropertyPage* page) {
    {
            send(PSM_UNCHANGED, (WPARAM)hPage,
                //page->getPageHandle(), 
                0);
    }    

public:
    void    restartWindows() {
            send(PSM_RESTARTWINDOWS, 0, 0);            
    }

public:
    void    rebootSystem() {
            send(PSM_REBOOTSYSTEM, 0, 0);            
    }

public:
    void    cancelToClose() {
            send(PSM_CANCELTOCLOSE, 0, 0);            
    }

public:
    void    querySiblings(WPARAM wParam, LPARAM lParam) {
            send(PSM_QUERYSIBLINGS, wParam, lParam);
    }

public:
    void    apply() {
            send(PSM_APPLY, 0, 0);                
    }    

public:
    void    setTitle(WPARAM style, TCHAR* title) {
            send(PSM_SETTITLE, style, (LPARAM)title);
    }

public:
    void    setWizButtons(LPARAM flags) {
            send(PSM_SETWIZBUTTONS, 0, (LPARAM)flags);
    }

public:
    void    pressButton(int idbutton) {
            send(PSM_PRESSBUTTON, idbutton, 0);
    }

public:
    void    setCurSelByID(int id) {
            send(PSM_SETCURSELID, 0, (LPARAM)id);
    }

public:
    void    setFinishText(TCHAR* text) {
            send(PSM_SETFINISHTEXT, 0, (LPARAM)text);
    }

public:
    HWND    getTabControl() {
            return (HWND)send(PSM_GETTABCONTROL, 0, 0);
    }

public:
    BOOL    isDialogMessage(MSG* pMsg) {
            return (BOOL)send(PSM_ISDIALOGMESSAGE, 0, (LPARAM)pMsg);
    }

public:
    HWND    getCurrentPageHwnd() {
            return (HWND)send(PSM_GETCURRENTPAGEHWND, 0, 0L);
    }
};

}



Last modified: 1 Feb 2012

Copyright (c) 2009-2012 Antillia.com ALL RIGHTS RESERVED.