strtpage.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 6k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #include "shwizard.h"
  2. #include <string.h>
  3. #include <tchar.h>
  4. #include <shlguidp.h>
  5. #include <shellids.h>
  6. #include <shlwapi.h>
  7. #include "winreg.h"
  8. void CCTF_ChoosePath::Describe(UINT uiDescId)
  9. {
  10.     if (uiDescId)
  11.     {
  12.         TCHAR szText[MAX_PATH];
  13.         LoadString(g_hAppInst, uiDescId, szText, ARRAYSIZE(szText));
  14.         SendMessage(GetDlgItem(_hwndDlg, IDC_INTRO_DESC), WM_SETTEXT, 0, (LPARAM)szText);
  15.     }
  16. }
  17. void GetHTMLFileName(void)
  18. {
  19.     GetTemporaryTemplatePath(g_szFullHTMLFile);
  20. }
  21. typedef struct tagMapIDDIDC {
  22.     DWORD idd;
  23.     DWORD idc;
  24.     TCHAR szRegValue[30];
  25. } MapIDDIDC;
  26. MapIDDIDC aDialogs[] = {
  27.     {IDD_PAGEA3, IDC_WEBVIEW_TEMPLATE, REG_VAL_TEMPLATE_CHECKED},
  28.     {IDD_PAGET1, IDC_LISTVIEW_STUFF, REG_VAL_LISTVIEW_CHECKED},
  29.     {IDD_COMMENT, IDC_COMMENT, REG_VAL_COMMENT_CHECKED}};
  30. void CCTF_ChoosePath::OnInit()
  31. {
  32.     // Set the default radio button
  33.     Button_SetCheck(GetDlgItem(_hwndDlg, IDC_CUSTOMIZE), BST_CHECKED);
  34.     Describe(IDS_CUSTOMIZE);
  35.     // Set the default status of the check boxes
  36.     for (int i = 0; i < ARRAYSIZE(aDialogs); i++)
  37.     {
  38.         DWORD dwType, dwChecked, cbData = sizeof(dwChecked);
  39.         if (!(ERROR_SUCCESS == SHGetValue(HKEY_CURRENT_USER, REG_FC_WIZARD, aDialogs[i].szRegValue, &dwType, &dwChecked, &cbData)))
  40.         {
  41.             dwChecked = (aDialogs[i].idc == IDC_WEBVIEW_TEMPLATE);
  42.         }
  43.         Button_SetCheck(GetDlgItem(_hwndDlg, aDialogs[i].idc), dwChecked ? BST_CHECKED : BST_UNCHECKED);
  44.         _pCommonInfo->SetPathChoice(aDialogs[i].idd, dwChecked);
  45.     }
  46.     // Disable IDC_REMOVE if not valid
  47.     if (!IsBackgroundImageSet() && !IsIconTextColorSet() && !IsFolderCommentSet() && !IsWebViewTemplateSet())
  48.     {
  49.         EnableWindow(GetDlgItem(_hwndDlg, IDC_REMOVE), FALSE);
  50.     }
  51.     _pCommonInfo->OnSetActive(_hwndDlg);    // Set the wizard buttons properly now.
  52.     
  53.     GetHTMLFileName();          // pre-load file paths
  54. }
  55. INT_PTR APIENTRY CCTF_ChoosePath::WndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  56. {
  57.     BOOL bRet = TRUE;
  58.     CCTF_ChoosePath* pChoosePath = NULL;
  59.     pChoosePath = (CCTF_ChoosePath*)GetWindowPtr(hwndDlg, GWLP_USERDATA);
  60.     //ASSERT(pChoosePath);
  61.     //ASSERT(pChoosePath->_hwndDlg == hwndDlg);
  62.     switch (msg)
  63.     {
  64.     case WM_INITDIALOG:
  65.     {
  66.         CCTF_CommonInfo* pCommonInfo = (CCTF_CommonInfo*)((LPPROPSHEETPAGE)lParam)->lParam;
  67.         //ASSERT(pCommonInfo);
  68.         pChoosePath = new CCTF_ChoosePath(hwndDlg, pCommonInfo);
  69.         if (pChoosePath)
  70.         {
  71.             SetWindowPtr(hwndDlg, GWLP_USERDATA, pChoosePath);
  72.             pChoosePath->OnInit();
  73.         }
  74.         else
  75.         {
  76.             bRet = FALSE ;
  77.         }
  78.         break;
  79.     }
  80.     case WM_DESTROY:
  81.     {
  82.         SetWindowPtr(hwndDlg, GWLP_USERDATA, NULL);
  83.         delete pChoosePath;
  84.         break;
  85.     }
  86.     
  87.     case WM_COMMAND:
  88.     {
  89.         UINT uiDescId = IDS_CUSTOMIZE;  // Default to the desc for the customization option
  90.         DWORD dwChecked;
  91.         switch (LOWORD(wParam))
  92.         {
  93.         case IDC_CUSTOMIZE:
  94.             pChoosePath->_pCommonInfo->SetPath(IDC_CUSTOMIZE);
  95.             break;
  96.         case IDC_REMOVE:
  97.             pChoosePath->_pCommonInfo->SetPath(IDD_REMOVE);
  98.             uiDescId = IDS_UNCUSTOMIZE;
  99.             break;
  100.         case IDC_LISTVIEW_STUFF:
  101.             pChoosePath->_pCommonInfo->SetPathChoice(IDD_PAGET1, dwChecked = BOOLIFY(IsDlgButtonChecked(hwndDlg, IDC_LISTVIEW_STUFF)));
  102.             SHSetValue(HKEY_CURRENT_USER, REG_FC_WIZARD, REG_VAL_LISTVIEW_CHECKED, REG_DWORD, (LPBYTE)&dwChecked, SIZEOF(dwChecked));
  103.             break;
  104.         case IDC_COMMENT:
  105.             pChoosePath->_pCommonInfo->SetPathChoice(IDD_COMMENT, dwChecked = BOOLIFY(IsDlgButtonChecked(hwndDlg, IDC_COMMENT)));
  106.             SHSetValue(HKEY_CURRENT_USER, REG_FC_WIZARD, REG_VAL_COMMENT_CHECKED, REG_DWORD, (LPBYTE)&dwChecked, SIZEOF(dwChecked));
  107.             break;
  108.         case IDC_WEBVIEW_TEMPLATE:
  109.             pChoosePath->_pCommonInfo->SetPathChoice(IDD_PAGEA3, dwChecked = BOOLIFY(IsDlgButtonChecked(hwndDlg, IDC_WEBVIEW_TEMPLATE)));
  110.             SHSetValue(HKEY_CURRENT_USER, REG_FC_WIZARD, REG_VAL_TEMPLATE_CHECKED, REG_DWORD, (LPBYTE)&dwChecked, SIZEOF(dwChecked));
  111.             break;
  112.         }
  113.         pChoosePath->Describe(uiDescId);
  114.         BOOL bEnableCheckBoxes = TRUE;
  115.         if (IsDlgButtonChecked(hwndDlg, IDC_REMOVE))
  116.         {
  117.             // Disable the check boxes
  118.             bEnableCheckBoxes = FALSE;
  119.         }
  120.         EnableWindow(GetDlgItem(hwndDlg, IDC_LISTVIEW_STUFF), bEnableCheckBoxes);
  121.         EnableWindow(GetDlgItem(hwndDlg, IDC_COMMENT), bEnableCheckBoxes);
  122.         EnableWindow(GetDlgItem(hwndDlg, IDC_WEBVIEW_TEMPLATE), bEnableCheckBoxes);
  123.         pChoosePath->_pCommonInfo->OnSetActive(hwndDlg);
  124.         break;
  125.     }
  126.     
  127.     case WM_NOTIFY:
  128.     {
  129.         UINT uiCode = ((NMHDR FAR *)lParam)->code;
  130.         switch (uiCode)
  131.         {
  132.         case PSN_QUERYCANCEL:
  133.             bRet = FALSE;
  134.         case PSN_KILLACTIVE:
  135.         case PSN_RESET:
  136.             pChoosePath->_pCommonInfo->OnCancel(hwndDlg);
  137.             break;
  138.         case PSN_SETACTIVE:
  139.             pChoosePath->_pCommonInfo->OnSetActive(hwndDlg);
  140.             break;
  141.         case PSN_WIZNEXT:
  142.             pChoosePath->_pCommonInfo->OnNext(hwndDlg);
  143.             break;
  144.         case PSN_WIZBACK:
  145.             pChoosePath->_pCommonInfo->OnBack(hwndDlg);
  146.             break;
  147.         default:
  148.             return(FALSE);
  149.         }
  150.         break;
  151.     }
  152.     default:
  153.         bRet = FALSE;
  154.         break;
  155.     }
  156.     return bRet;   
  157. }