Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

610 lines
18 KiB

  1. /*****************************************************************************\
  2. FILE: EffectsAdvPg.cpp
  3. DESCRIPTION:
  4. This code will display the Effect tab in the Advanced Display Control
  5. panel.
  6. BryanSt 4/13/2000 Updated and Converted to C++
  7. Copyright (C) Microsoft Corp 2000-2000. All rights reserved.
  8. \*****************************************************************************/
  9. #include "priv.h"
  10. #include "EffectsAdvPg.h"
  11. #include "regutil.h"
  12. //#undef _SHSEMIP_H_
  13. //#include <shsemip.h>
  14. typedef struct
  15. {
  16. DWORD dwControlID;
  17. DWORD dwHelpContextID;
  18. }POPUP_HELP_ARRAY;
  19. POPUP_HELP_ARRAY phaMainDisplay[] = {
  20. { IDC_LARGEICONS, IDH_DISPLAY_EFFECTS_LARGE_ICONS_CHECKBOX },
  21. { IDC_ICONHIGHCOLOR, IDH_DISPLAY_EFFECTS_ALL_COLORS_CHECKBOX },
  22. { IDC_MENUANIMATION, IDH_DISPLAY_EFFECTS_ANIMATE_WINDOWS },
  23. { IDC_FONTSMOOTH, IDH_DISPLAY_EFFECTS_SMOOTH_FONTS_CHECKBOX },
  24. { IDC_SHOWDRAG, IDH_DISPLAY_EFFECTS_DRAG_WINDOW_CHECKBOX },
  25. { IDC_KEYBOARDINDICATORS, IDH_DISPLAY_EFFECTS_HIDE_KEYBOARD_INDICATORS },
  26. { IDC_GRPBOX_2, IDH_COMM_GROUPBOX },
  27. { IDC_COMBOEFFECT, IDH_DISPLAY_EFFECTS_ANIMATE_LISTBOX },
  28. { IDC_COMBOFSMOOTH, IDH_DISPLAY_EFFECTS_SMOOTH_FONTS_LISTBOX },
  29. { IDC_MENUSHADOWS, IDH_DISPLAY_EFFECTS_MENUSHADOWS},
  30. { 0, 0 },
  31. { 0, 0 }, // double-null terminator NECESSARY!
  32. };
  33. #define SZ_HELPFILE_DISPLAY TEXT("DISPLAY.HLP")
  34. #define SZ_HELPFILE_WINDOWS TEXT("WINDOWS.HLP")
  35. ULONG g_ulFontInformation, g_ulNewFontInformation;
  36. //===========================
  37. // *** Class Internals & Helpers ***
  38. //===========================
  39. int FontSmoothingTypeToListIndex(DWORD dwFontSmoothingType)
  40. {
  41. // We OR dwSmoothingType with 0x3 because USER may add other high bits that we don't care about.
  42. return ((0x3 & dwFontSmoothingType) - 1);
  43. }
  44. DWORD ListIndexToFontSmoothingType(int nIndex, DWORD dwPreviousType)
  45. {
  46. // We want to keep the high bits in dwPreviousType because we are only replacing
  47. // the lower bits.
  48. return ((0xFFFFFFF0 & dwPreviousType) | (nIndex + 1));
  49. }
  50. void HideComboEffectsWindow(HWND hDlg)
  51. {
  52. TCHAR szText[MAX_PATH];
  53. // We change the text so it doesn't have a reference to the drop down.
  54. LoadString(HINST_THISDLL, IDS_COMBO_EFFECTS_NOLIST, szText, ARRAYSIZE(szText));
  55. SetWindowText(GetDlgItem(hDlg, IDC_MENUANIMATION), szText);
  56. ShowWindow(GetDlgItem(hDlg, IDC_COMBOEFFECT), SW_HIDE);
  57. }
  58. BOOL FadeEffectAvailable()
  59. {
  60. BOOL fFade = FALSE, fTestFade = FALSE;
  61. ClassicSystemParametersInfo( SPI_GETMENUFADE, 0, (PVOID)&fFade, 0 );
  62. if (fFade)
  63. return TRUE;
  64. ClassicSystemParametersInfo( SPI_SETMENUFADE, 0, (PVOID)1, 0);
  65. ClassicSystemParametersInfo( SPI_GETMENUFADE, 0, (PVOID)&fTestFade, 0 );
  66. ClassicSystemParametersInfo( SPI_SETMENUFADE, 0, IntToPtr(fFade), 0);
  67. return (fTestFade);
  68. }
  69. HRESULT CEffectsPage::_OnApply(HWND hDlg)
  70. {
  71. HRESULT hr = S_OK;
  72. // Full Color Icons
  73. if (m_pEffectsState && (m_pEffectsState->_nOldHighIconColor != m_pEffectsState->_nHighIconColor))
  74. {
  75. if ((GetBitsPerPixel() < 16) && (m_pEffectsState->_nHighIconColor == 16)) // Display mode won't support icon high colors
  76. {
  77. TCHAR szTemp1[512];
  78. TCHAR szTemp2[256];
  79. LoadString(HINST_THISDLL, IDS_256COLORPROBLEM, szTemp1, ARRAYSIZE(szTemp1));
  80. LoadString(HINST_THISDLL, IDS_ICONCOLORWONTWORK, szTemp2, ARRAYSIZE(szTemp2));
  81. StrCatBuff(szTemp1, szTemp2, ARRAYSIZE(szTemp1));
  82. LoadString(HINST_THISDLL, IDS_EFFECTS, szTemp2, ARRAYSIZE(szTemp2));
  83. MessageBox(hDlg, szTemp1, szTemp2, MB_OK|MB_ICONINFORMATION);
  84. }
  85. }
  86. return hr;
  87. }
  88. HRESULT CEffectsPage::_OnInit(HWND hDlg)
  89. {
  90. HRESULT hr = S_OK;
  91. TCHAR szRes[100];
  92. if (!m_pEffectsState)
  93. {
  94. return E_INVALIDARG;
  95. }
  96. //////////////////////////////////////////////////////////////////////////
  97. // Load the state from persisted form (registry) to the state struct
  98. //////////////////////////////////////////////////////////////////////////
  99. g_bMirroredOS = IS_MIRRORING_ENABLED();
  100. //////////////////////////////////////////////////////////////////////////
  101. // Update UI based on the state struct
  102. //////////////////////////////////////////////////////////////////////////
  103. if (m_pEffectsState->_nLargeIcon == ICON_INDETERMINATE)
  104. {
  105. HWND hItem = GetDlgItem(hDlg, IDC_LARGEICONS);
  106. SendMessage(hItem, BM_SETSTYLE, (WPARAM)LOWORD(BS_AUTO3STATE), MAKELPARAM(FALSE,0));
  107. }
  108. // Set CheckBoxes
  109. SendMessage((HWND)GetDlgItem(hDlg, IDC_LARGEICONS), BM_SETCHECK, (WPARAM)m_pEffectsState->_nLargeIcon, 0);
  110. SendMessage((HWND)GetDlgItem(hDlg, IDC_MENUSHADOWS), BM_SETCHECK, (WPARAM)m_pEffectsState->_fMenuShadows, 0);
  111. SendMessage((HWND)GetDlgItem(hDlg, IDC_ICONHIGHCOLOR ), BM_SETCHECK, (WPARAM)(BOOL)(m_pEffectsState->_nHighIconColor == 16), 0);
  112. SendMessage((HWND)GetDlgItem(hDlg, IDC_MENUANIMATION), BM_SETCHECK, (WPARAM)m_pEffectsState->_wpMenuAnimation, 0);
  113. SendMessage((HWND)GetDlgItem(hDlg, IDC_FONTSMOOTH), BM_SETCHECK, (WPARAM)m_pEffectsState->_fFontSmoothing, 0);
  114. SendMessage((HWND)GetDlgItem(hDlg, IDC_SHOWDRAG), BM_SETCHECK, (WPARAM)m_pEffectsState->_fDragWindow, 0);
  115. SendMessage((HWND)GetDlgItem(hDlg, IDC_KEYBOARDINDICATORS), BM_SETCHECK, (WPARAM)(m_pEffectsState->_fKeyboardIndicators ? BST_UNCHECKED : BST_CHECKED), 0);
  116. // Set Effects Drop Down
  117. HWND hwndCombo = GetDlgItem(hDlg,IDC_COMBOEFFECT);
  118. ComboBox_ResetContent(hwndCombo);
  119. LoadString(HINST_THISDLL, IDS_FADEEFFECT, szRes, ARRAYSIZE(szRes) );
  120. ComboBox_AddString(hwndCombo, szRes);
  121. LoadString(HINST_THISDLL, IDS_SCROLLEFFECT, szRes, ARRAYSIZE(szRes) );
  122. ComboBox_AddString(hwndCombo, szRes);
  123. ComboBox_SetCurSel(hwndCombo, (MENU_EFFECT_FADE == m_pEffectsState->_dwAnimationEffect) ? 0 : 1);
  124. EnableWindow(hwndCombo, (UINT)m_pEffectsState->_wpMenuAnimation);
  125. if (IsTSPerfFlagEnabled(TSPerFlag_NoAnimation))
  126. {
  127. EnableWindow(GetDlgItem(hDlg, IDC_MENUANIMATION), FALSE);
  128. EnableWindow(GetDlgItem(hDlg, IDC_COMBOEFFECT), FALSE);
  129. LogStatus("Animation Forced off because of TS Perf Flags\r\n");
  130. }
  131. if (IsTSPerfFlagEnabled(TSPerFlag_NoWindowDrag))
  132. {
  133. EnableWindow(GetDlgItem(hDlg, IDC_SHOWDRAG), FALSE);
  134. LogStatus("FullWindowDrag feature Forced off because of TS Perf Flags\r\n");
  135. }
  136. if (!FadeEffectAvailable())
  137. {
  138. HideComboEffectsWindow(hDlg);
  139. }
  140. if (0 != SHGetRestriction(NULL,POLICY_KEY_EXPLORER,POLICY_VALUE_ANIMATION))
  141. {
  142. //disable
  143. //0= enable
  144. //non-0= disable
  145. //relies on the fact that if the key does not exist it returns 0 as well
  146. EnableWindow((HWND)GetDlgItem(hDlg, IDC_MENUANIMATION), FALSE);
  147. EnableWindow((HWND)GetDlgItem(hDlg, IDC_COMBOEFFECT), FALSE);
  148. }
  149. hwndCombo = GetDlgItem(hDlg,IDC_COMBOFSMOOTH);
  150. ComboBox_ResetContent(hwndCombo);
  151. LoadString(HINST_THISDLL, IDS_STANDARDSMOOTHING, szRes, ARRAYSIZE(szRes));
  152. ComboBox_AddString(hwndCombo, szRes);
  153. LoadString(HINST_THISDLL, IDS_CLEARTYPE, szRes, ARRAYSIZE(szRes));
  154. ComboBox_AddString(hwndCombo, szRes);
  155. BOOL fTemp;
  156. ComboBox_SetCurSel(hwndCombo, m_pEffectsState->_dwFontSmoothingType-1);
  157. if (ClassicSystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, (PVOID)&fTemp, 0))
  158. {
  159. EnableWindow((HWND)hwndCombo, m_pEffectsState->_fFontSmoothing);
  160. }
  161. else
  162. {
  163. ShowWindow(hwndCombo, SW_HIDE);
  164. ShowWindow(GetDlgItem(hDlg, IDC_SHOWME), SW_HIDE);
  165. }
  166. if (0 != SHGetRestriction(NULL, POLICY_KEY_EXPLORER, POLICY_VALUE_KEYBOARDNAV))
  167. {
  168. //disable, see comment for animation
  169. EnableWindow((HWND)GetDlgItem(hDlg, IDC_KEYBOARDINDICATORS), FALSE);
  170. }
  171. //disable and uncheck things if we are on terminal server
  172. BOOL bEffectsEnabled;
  173. if (!ClassicSystemParametersInfo(SPI_GETUIEFFECTS, 0, (PVOID) &bEffectsEnabled, 0))
  174. {
  175. // This flag is only available on Win2k and later. We're depending
  176. // on the call returning false if the flag doesn't exist...
  177. bEffectsEnabled = TRUE;
  178. }
  179. if (!bEffectsEnabled)
  180. {
  181. EnableWindow((HWND)GetDlgItem( hDlg, IDC_MENUANIMATION), FALSE);
  182. EnableWindow((HWND)GetDlgItem(hDlg, IDC_ICONHIGHCOLOR), FALSE);
  183. EnableWindow((HWND)GetDlgItem(hDlg, IDC_KEYBOARDINDICATORS), FALSE);
  184. EnableWindow((HWND)GetDlgItem(hDlg, IDC_FONTSMOOTH), FALSE);
  185. EnableWindow((HWND)GetDlgItem(hDlg, IDC_COMBOFSMOOTH), FALSE);
  186. HideComboEffectsWindow(hDlg);
  187. SendDlgItemMessage(hDlg, IDC_MENUANIMATION, BM_SETCHECK, 0, 0);
  188. SendDlgItemMessage(hDlg, IDC_ICONHIGHCOLOR, BM_SETCHECK, 0, 0);
  189. SendDlgItemMessage(hDlg, IDC_KEYBOARDINDICATORS, BM_SETCHECK, 0, 0);
  190. SendDlgItemMessage(hDlg, IDC_FONTSMOOTH, BM_SETCHECK, 0, 0);
  191. }
  192. // We remove the Keyboard indicators check box on non-NT platform since User32
  193. // does not provide the functionality to implement the feature.
  194. if (!IsOSNT())
  195. {
  196. HWND hwndSWC = GetDlgItem(hDlg, IDC_SHOWDRAG);
  197. HWND hwndKI = GetDlgItem(hDlg, IDC_KEYBOARDINDICATORS);
  198. HWND hwndGroup = GetDlgItem(hDlg, IDC_GRPBOX_2);
  199. // Hide the Hide keyboard cues check box on non-NT platform
  200. ShowWindow(hwndKI, SW_HIDE);
  201. // Calculate the bottom margin
  202. RECT rect;
  203. RECT rectGroup;
  204. GetWindowRect(hwndKI, &rect);
  205. GetWindowRect(hwndGroup, &rectGroup);
  206. int margin = rectGroup.bottom - rect.bottom;
  207. GetWindowRect(hwndSWC, &rect);
  208. SetWindowPos(hwndGroup, HWND_TOP, 0, 0, rectGroup.right - rectGroup.left,
  209. rect.bottom - rectGroup.top + margin, SWP_NOMOVE | SWP_NOZORDER);
  210. }
  211. return hr;
  212. }
  213. INT_PTR CEffectsPage::_OnCommand(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  214. {
  215. BOOL fHandled = 1; // Not handled (WM_COMMAND seems to be different)
  216. WORD idCtrl = GET_WM_COMMAND_ID(wParam, lParam);
  217. WORD wEvent = GET_WM_COMMAND_CMD(wParam, lParam);
  218. switch (idCtrl)
  219. {
  220. case IDOK:
  221. EndDialog(hDlg, IDOK);
  222. break;
  223. case IDCANCEL:
  224. EndDialog(hDlg, IDCANCEL);
  225. break;
  226. case IDC_LARGEICONS:
  227. if (m_pEffectsState)
  228. {
  229. m_pEffectsState->_nLargeIcon = (int)SendMessage ( (HWND)lParam, BM_GETCHECK, 0, 0 );
  230. }
  231. break;
  232. case IDC_MENUSHADOWS:
  233. if (m_pEffectsState)
  234. {
  235. m_pEffectsState->_fMenuShadows = (int)SendMessage ( (HWND)lParam, BM_GETCHECK, 0, 0 );
  236. }
  237. break;
  238. case IDC_ICONHIGHCOLOR:
  239. if (m_pEffectsState)
  240. {
  241. m_pEffectsState->_nHighIconColor = 4;
  242. if (SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == TRUE)
  243. {
  244. m_pEffectsState->_nHighIconColor = 16;
  245. }
  246. }
  247. break;
  248. case IDC_SHOWDRAG:
  249. if (m_pEffectsState)
  250. {
  251. m_pEffectsState->_fDragWindow = (SendMessage( (HWND)lParam, BM_GETCHECK, 0, 0 ) == BST_CHECKED);
  252. }
  253. break;
  254. case IDC_MENUANIMATION:
  255. if (m_pEffectsState)
  256. {
  257. switch (m_pEffectsState->_wpMenuAnimation)
  258. {
  259. case BST_UNCHECKED:
  260. m_pEffectsState->_wpMenuAnimation = BST_CHECKED;
  261. break;
  262. case BST_CHECKED:
  263. m_pEffectsState->_wpMenuAnimation = BST_UNCHECKED;
  264. break;
  265. case BST_INDETERMINATE:
  266. m_pEffectsState->_wpMenuAnimation = BST_UNCHECKED;
  267. break;
  268. }
  269. SendMessage( (HWND)lParam, BM_SETCHECK, (WPARAM)m_pEffectsState->_wpMenuAnimation, 0 );
  270. EnableWindow((HWND)GetDlgItem( hDlg, IDC_COMBOEFFECT), (BST_CHECKED == m_pEffectsState->_wpMenuAnimation));
  271. }
  272. break;
  273. case IDC_COMBOEFFECT:
  274. if ((wEvent == CBN_SELCHANGE) && m_pEffectsState)
  275. {
  276. m_pEffectsState->_dwAnimationEffect = (DWORD)ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_COMBOEFFECT)) + 1;
  277. }
  278. break;
  279. case IDC_COMBOFSMOOTH:
  280. if ((wEvent == CBN_SELCHANGE) && m_pEffectsState)
  281. {
  282. m_pEffectsState->_dwFontSmoothingType = ListIndexToFontSmoothingType(ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_COMBOFSMOOTH)), m_pEffectsState->_dwFontSmoothingType);
  283. }
  284. break;
  285. case IDC_FONTSMOOTH:
  286. if (m_pEffectsState)
  287. {
  288. m_pEffectsState->_fFontSmoothing = (SendMessage( (HWND)lParam, BM_GETCHECK, 0, 0 ) == BST_CHECKED);
  289. EnableWindow((HWND)GetDlgItem( hDlg, IDC_COMBOFSMOOTH), m_pEffectsState->_fFontSmoothing);
  290. if (m_pEffectsState->_fFontSmoothing)
  291. {
  292. m_pEffectsState->_dwFontSmoothingType = ListIndexToFontSmoothingType(ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_COMBOFSMOOTH)), m_pEffectsState->_dwFontSmoothingType);
  293. }
  294. }
  295. break;
  296. case IDC_KEYBOARDINDICATORS:
  297. if (m_pEffectsState)
  298. {
  299. m_pEffectsState->_fKeyboardIndicators = ((SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED) ? FALSE : TRUE);
  300. }
  301. break;
  302. default:
  303. break;
  304. }
  305. return fHandled;
  306. }
  307. INT_PTR CALLBACK PropertySheetDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
  308. {
  309. CEffectsPage * pThis = (CEffectsPage *)GetWindowLongPtr(hDlg, DWLP_USER);
  310. if (WM_INITDIALOG == wMsg)
  311. {
  312. pThis = (CEffectsPage *) lParam;
  313. if (pThis)
  314. {
  315. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  316. }
  317. }
  318. if (pThis)
  319. return pThis->_PropertySheetDlgProc(hDlg, wMsg, wParam, lParam);
  320. return DefWindowProc(hDlg, wMsg, wParam, lParam);
  321. }
  322. //---------------------------------------------------------------------------
  323. //
  324. // PropertySheetDlgProc()
  325. //
  326. // The dialog procedure for the "PlusPack" property sheet page.
  327. //
  328. //---------------------------------------------------------------------------
  329. INT_PTR CEffectsPage::_PropertySheetDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
  330. {
  331. switch( uMessage )
  332. {
  333. case WM_INITDIALOG:
  334. _OnInit(hDlg);
  335. break;
  336. case WM_COMMAND:
  337. _OnCommand(hDlg, uMessage, wParam, lParam);
  338. break;
  339. case WM_HELP:
  340. {
  341. LPHELPINFO lphi = (LPHELPINFO)lParam;
  342. if( lphi->iContextType == HELPINFO_WINDOW )
  343. {
  344. LPCWSTR pszHelpFile = ((lphi->hItemHandle == GetDlgItem(hDlg, IDC_GRPBOX_2)) ? SZ_HELPFILE_WINDOWS : SZ_HELPFILE_DISPLAY);
  345. WinHelp( (HWND)lphi->hItemHandle, pszHelpFile, HELP_WM_HELP, (DWORD_PTR)phaMainDisplay);
  346. }
  347. }
  348. break;
  349. case WM_CONTEXTMENU:
  350. // first check for dlg window
  351. if( (HWND)wParam == hDlg )
  352. {
  353. // let the def dlg proc decide whether to respond or ignore;
  354. // necessary for title bar sys menu on right click
  355. return FALSE; // didn't process message EXIT
  356. }
  357. else
  358. {
  359. // else go for the controls
  360. LPCWSTR pszHelpFile = (((HWND)wParam == GetDlgItem(hDlg, IDC_GRPBOX_2)) ? SZ_HELPFILE_WINDOWS : SZ_HELPFILE_DISPLAY);
  361. WinHelp( (HWND)wParam, pszHelpFile, HELP_CONTEXTMENU, (DWORD_PTR)phaMainDisplay);
  362. }
  363. break;
  364. default:
  365. return FALSE;
  366. }
  367. return(TRUE);
  368. }
  369. HRESULT CEffectsPage::_IsDirty(IN BOOL * pIsDirty)
  370. {
  371. HRESULT hr = E_INVALIDARG;
  372. if (pIsDirty && m_pEffectsState)
  373. {
  374. // Ask state if it's dirty
  375. *pIsDirty = m_pEffectsState->IsDirty();
  376. hr = S_OK;
  377. }
  378. return hr;
  379. }
  380. //===========================
  381. // *** IAdvancedDialog Interface ***
  382. //===========================
  383. HRESULT CEffectsPage::DisplayAdvancedDialog(IN HWND hwndParent, IN IPropertyBag * pBasePage, IN BOOL * pfEnableApply)
  384. {
  385. HRESULT hr = E_INVALIDARG;
  386. if (hwndParent && pBasePage && pfEnableApply)
  387. {
  388. // Load State Into Advanced Dialog
  389. if (m_pEffectsState)
  390. {
  391. m_pEffectsState->Release();
  392. m_pEffectsState = NULL;
  393. }
  394. *pfEnableApply = FALSE;
  395. CEffectState * pEffectClone = NULL;
  396. hr = SHPropertyBag_ReadByRef(pBasePage, SZ_PBPROP_EFFECTSSTATE, (void *)&pEffectClone, sizeof(pEffectClone));
  397. if (SUCCEEDED(hr) && pEffectClone)
  398. {
  399. // We want a copy of their state
  400. hr = pEffectClone->Clone(&m_pEffectsState);
  401. if (SUCCEEDED(hr))
  402. {
  403. LinkWindow_RegisterClass();
  404. // Display Advanced Dialog
  405. if ((IDOK == DialogBoxParam(HINST_THISDLL, MAKEINTRESOURCE(DLG_EFFECTS), hwndParent, PropertySheetDlgProc, (LPARAM)this)) && m_pEffectsState)
  406. {
  407. // The user clicked OK, so merge modified state back into base dialog
  408. _IsDirty(pfEnableApply);
  409. // The user clicked Okay in the dialog so merge the dirty state from the
  410. // advanced dialog into the base dialog.
  411. hr = SHPropertyBag_WriteByRef(pBasePage, SZ_PBPROP_EFFECTSSTATE, (void *)m_pEffectsState);
  412. m_pEffectsState->Release();
  413. m_pEffectsState = NULL;
  414. }
  415. }
  416. LinkWindow_UnregisterClass(HINST_THISDLL);
  417. pEffectClone->Release();
  418. }
  419. }
  420. return hr;
  421. }
  422. //===========================
  423. // *** IUnknown Interface ***
  424. //===========================
  425. ULONG CEffectsPage::AddRef()
  426. {
  427. return InterlockedIncrement(&m_cRef);
  428. }
  429. ULONG CEffectsPage::Release()
  430. {
  431. if (InterlockedDecrement(&m_cRef))
  432. return m_cRef;
  433. delete this;
  434. return 0;
  435. }
  436. HRESULT CEffectsPage::QueryInterface(REFIID riid, void **ppvObj)
  437. {
  438. static const QITAB qit[] =
  439. {
  440. QITABENT(CEffectsPage, IObjectWithSite),
  441. QITABENT(CEffectsPage, IAdvancedDialog),
  442. { 0 },
  443. };
  444. return QISearch(this, qit, riid, ppvObj);
  445. }
  446. //===========================
  447. // *** Class Methods ***
  448. //===========================
  449. CEffectsPage::CEffectsPage() : m_cRef(1)
  450. {
  451. // This needs to be allocated in Zero Inited Memory.
  452. // Assert that all Member Variables are inited to Zero.
  453. m_fDirty = FALSE;
  454. }
  455. CEffectsPage::~CEffectsPage()
  456. {
  457. if (m_pEffectsState)
  458. {
  459. m_pEffectsState->Release();
  460. }
  461. }
  462. HRESULT CEffectsPage_CreateInstance(OUT IAdvancedDialog ** ppAdvDialog)
  463. {
  464. HRESULT hr = E_INVALIDARG;
  465. if (ppAdvDialog)
  466. {
  467. CEffectsPage * pThis = new CEffectsPage();
  468. if (pThis)
  469. {
  470. hr = pThis->QueryInterface(IID_PPV_ARG(IAdvancedDialog, ppAdvDialog));
  471. pThis->Release();
  472. }
  473. else
  474. {
  475. *ppAdvDialog = NULL;
  476. hr = E_OUTOFMEMORY;
  477. }
  478. }
  479. return hr;
  480. }