www.pudn.com > 嵌入式linux9应用开发祥解.rar > psdemo.c


#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 

#include "dlgdemo.h"
#include "resouce.h"

static int 
PageProc1 (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{

    switch (message) {
    case MSG_INITPAGE:
        break;
    case MSG_SHOWPAGE:
        return 1;

    case MSG_SHEETCMD:
        if (wParam == IDOK) {
            char buffer [20];
            GetDlgItemText (hDlg, IDC_EDIT1, buffer, 18);
            buffer [18] = '\0';

            if (buffer [0] == '\0') {
                MessageBox (hDlg, 
                            "Please input something in the first edit box.", 
                            "Warning!", 
                            MB_OK | MB_ICONEXCLAMATION | MB_BASEDONPARENT);
                return -1;
            }
        }
        return 0;

    case MSG_COMMAND:
        switch (wParam) {
        case IDOK:
        case IDCANCEL:
            MessageBox (hDlg, "Button pushed", "OK", 
                            MB_OK | MB_ICONINFORMATION | MB_BASEDONPARENT);
            break;
        }
        break;
    }
    
    return DefaultPageProc (hDlg, message, wParam, lParam);
}

static int 
PageProc2 (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_INITPAGE:
        break;

    case MSG_SHOWPAGE:
        return 1;
        
    case MSG_COMMAND:
        switch (wParam) {
        case IDOK:
        case IDCANCEL:
            MessageBox (hDlg, "Button pushed", "OK", 
                            MB_OK | MB_ICONINFORMATION | MB_BASEDONPARENT);
            break;
        }
        break;
        
    }
    
    return DefaultPageProc (hDlg, message, wParam, lParam);
}

static int 
PageProc3 (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    int i;
    char temp [20];

    switch (message) {
    case MSG_INITPAGE:
        for (i = 0; i < 20; i++) { 
            sprintf (temp, "%d-Welcome", i);
            SendDlgItemMessage (hDlg, IDC_BOX1, CB_ADDSTRING, 0, (LPARAM)temp) ;
            SendDlgItemMessage (hDlg, IDC_BOX2, CB_ADDSTRING, 0, (LPARAM)temp) ;
            SendDlgItemMessage (hDlg, IDC_BOX4, CB_ADDSTRING, 0, (LPARAM)temp) ;
        } 
        break;

    case MSG_SHOWPAGE:
        return 1;

    case MSG_GETDLGCODE:
        return DLGC_WANTARROWS;

    case MSG_COMMAND:
        switch (wParam) {
        case IDOK:
        case IDCANCEL:
            MessageBox (hDlg, "Button pushed", "OK", 
                            MB_OK | MB_ICONINFORMATION | MB_BASEDONPARENT);
            break;
        }
        break;
        
    }
    
    return DefaultPageProc (hDlg, message, wParam, lParam);
}

static int 
PageProc4 (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_INITPAGE:
        break;
    case MSG_SHOWPAGE:
        return 1;

    case MSG_COMMAND:
        switch (wParam) {
        case IDOK:
        case IDCANCEL:
            MessageBox (hDlg, "Button pushed", "OK", 
                            MB_OK | MB_ICONINFORMATION | MB_BASEDONPARENT);
            break;
        }
    }
    
    return DefaultPageProc (hDlg, message, wParam, lParam);
}

static int PropSheetProc (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
        case MSG_INITDIALOG:
        {
            HWND pshwnd = GetDlgItem (hDlg, IDC_PROPSHEET);

 //           DlgStructParams.controls = CtrlStructParams;
 //           SendMessage (pshwnd, PSM_ADDPAGE,
  //                          (WPARAM)&DlgStructParams, (LPARAM)PageProc1);

            DlgPassword.controls = CtrlPassword;
            SendMessage ( pshwnd, PSM_ADDPAGE,
                            (WPARAM)&DlgPassword,(LPARAM) PageProc2);

 //           DlgStartupMode.controls = CtrlStartupMode;
  //          SendMessage ( pshwnd, PSM_ADDPAGE,
  //                          (WPARAM)&DlgStartupMode,(LPARAM)PageProc3);

            DlgInitProgress.controls = CtrlInitProgress;
            SendMessage ( pshwnd, PSM_ADDPAGE, 
                            (WPARAM)&DlgInitProgress, (LPARAM) PageProc4);

            break;
        }

        case MSG_COMMAND:
        switch (wParam) 
        {
            case IDC_APPLY:
            break;

            case IDOK:
            {
                int index = SendDlgItemMessage (hDlg, IDC_PROPSHEET, 
                                PSM_SHEETCMD, IDOK, 0);
                if (index) {
                    SendDlgItemMessage (hDlg, IDC_PROPSHEET, 
                                    PSM_SETACTIVEPAGE, index - 1, 0);
                }
                else 
                    EndDialog (hDlg, wParam);

                break;
            }
            case IDCANCEL:
                EndDialog (hDlg, wParam);
            break;
        }
        break;
    }

    return DefaultDialogProc (hDlg, message, wParam, lParam);
}

void testPropertySheet (HWND hWnd)
{
    DlgPropertySheet.controls = CtrlPropertySheet;
    
    DialogBoxIndirectParam (&DlgPropertySheet, hWnd, PropSheetProc, 0L);
}