ExtResizableDialog.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:54k
源码类别:

界面编程

开发平台:

Visual C++

  1. // This is part of the Professional User Interface Suite library.
  2. // Copyright (C) 2001-2009 FOSS Software, Inc.
  3. // All rights reserved.
  4. //
  5. // http://www.prof-uis.com
  6. // mailto:support@prof-uis.com
  7. //
  8. // This source code can be used, modified and redistributed
  9. // under the terms of the license agreement that is included
  10. // in the Professional User Interface Suite package.
  11. //
  12. // Warranties and Disclaimers:
  13. // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
  14. // INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  16. // IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,
  17. // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES,
  18. // INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA,
  19. // INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE
  20. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  21. #include "stdafx.h"
  22. #if (!defined __EXT_RESIZABLE_DIALOG_H)
  23. #include <ExtResizableDialog.h>
  24. #endif
  25. #if (!defined __EXT_CONTROLBAR_H)
  26. #include <ExtControlBar.h>
  27. #endif
  28. #if (!defined __ExtCmdManager_H)
  29. #include <ExtCmdManager.h>
  30. #endif
  31. #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  32. #if (!defined __EXT_CONTROLBAR_TABBED_FEATURES_H)
  33. #include "ExtControlBarTabbedFeatures.h"
  34. #endif // __EXT_CONTROLBAR_TABBED_FEATURES_H
  35. #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  36. #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
  37. #if (! defined __EXT_TAB_PAGE_CONTAINER_WND_H)
  38. #include <ExtTabPageContainerWnd.h>
  39. #endif
  40. #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
  41. #if (!defined __EXT_SCROLLWND_H)
  42. #include <ExtScrollWnd.h>
  43. #endif 
  44. #if (!defined __EXT_MFC_NO_TAB_CTRL)
  45. #if (!defined __EXT_TABWND_H)
  46. #include <ExtTabWnd.h>
  47. #endif
  48. #endif // (!defined __EXT_MFC_NO_TAB_CTRL)
  49. #ifdef _DEBUG
  50. #define new DEBUG_NEW
  51. #undef THIS_FILE
  52. static char THIS_FILE[] = __FILE__;
  53. #endif
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CExtResizableDialog
  56. IMPLEMENT_DYNCREATE( CExtResizableDialog, CExtResDlg )
  57. bool CExtResizableDialog::g_bAllowLongFocusJumpFix = true;
  58. CExtResizableDialog::CExtResizableDialog()
  59. : m_bEnabledControlBarUpdate( false )
  60. , m_bInConrolBarUpdate( false )
  61. , m_hWndFocus( NULL )
  62. , m_bHelperSizingMoving( false )
  63. , m_bAllowLongFocusJumpFix( g_bAllowLongFocusJumpFix )
  64. {
  65. m_bShowResizingGripper = true;
  66. }
  67. CExtResizableDialog::CExtResizableDialog(
  68. UINT nIDTemplate,
  69. CWnd * pParentWnd
  70. )
  71. : CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > > ( nIDTemplate, pParentWnd )
  72. , m_bEnabledControlBarUpdate( false )
  73. , m_bInConrolBarUpdate( false )
  74. , m_hWndFocus( NULL )
  75. , m_bHelperSizingMoving( false )
  76. , m_bAllowLongFocusJumpFix( g_bAllowLongFocusJumpFix )
  77. {
  78. m_bShowResizingGripper = true;
  79. }
  80. CExtResizableDialog::CExtResizableDialog(
  81. __EXT_MFC_SAFE_LPCTSTR lpszTemplateName,
  82. CWnd * pParentWnd
  83. )
  84. : CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > > ( lpszTemplateName, pParentWnd )
  85. , m_bEnabledControlBarUpdate( false )
  86. , m_bInConrolBarUpdate( false )
  87. , m_hWndFocus( NULL )
  88. , m_bHelperSizingMoving( false )
  89. , m_bAllowLongFocusJumpFix( g_bAllowLongFocusJumpFix )
  90. {
  91. m_bShowResizingGripper = true;
  92. }
  93. CExtResizableDialog::~CExtResizableDialog()
  94. {
  95. }
  96. bool CExtResizableDialog::_SaveFocusControl()
  97. {
  98. if( GetSafeHwnd() == NULL )
  99. return false;
  100. HWND hWndFocus = ::GetFocus();
  101. if( hWndFocus != NULL
  102. && ::IsChild( m_hWnd, hWndFocus )
  103. )
  104. {
  105. m_hWndFocus = hWndFocus;
  106. return true;
  107. }
  108. return false;
  109. }
  110. __EXT_MFC_SAFE_LPCTSTR CExtResizableDialog::OnQuerySkinnedFontParmName() const
  111. {
  112. ASSERT_VALID( this );
  113. return _T("Dialog");
  114. }
  115. BEGIN_MESSAGE_MAP( CExtResizableDialog, CExtResDlg )
  116. //{{AFX_MSG_MAP(CExtResizableDialog)
  117. //}}AFX_MSG_MAP
  118. END_MESSAGE_MAP()
  119. /////////////////////////////////////////////////////////////////////////////
  120. // CExtResizableDialog message handlers
  121. void CExtResizableDialog::OnOK()
  122. {
  123. DWORD dwStyle = GetStyle();
  124. if( (dwStyle & WS_CHILD) == 0 )
  125. CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::OnOK();
  126. }
  127. void CExtResizableDialog::OnCancel()
  128. {
  129. DWORD dwStyle = GetStyle();
  130. if( (dwStyle & WS_CHILD) == 0 )
  131. CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::OnCancel();
  132. }
  133. bool CExtResizableDialog::g_bProcessingLongFocusJump = false;
  134. bool CExtResizableDialog::g_bProcessingLongFocusJumpToPrevDir = false;
  135. HWND CExtResizableDialog::stat_GetNextItemZ( HWND hWndMain, HWND hWndDialog, HWND hWndControl, BOOL bPrevious )
  136. {
  137. LONG nStyle, nStyleEx;
  138. UINT nSearchCode = bPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
  139. HWND hWndRetVal = NULL, hWndFirstChild = NULL;
  140. if( hWndControl == NULL )
  141. {
  142. hWndFirstChild = ::GetWindow( hWndDialog, GW_CHILD );
  143. if( bPrevious )
  144. hWndFirstChild = ::GetWindow( hWndFirstChild, GW_HWNDLAST );
  145. }
  146. else if( ::IsChild( hWndMain, hWndControl ) )
  147. {
  148. hWndFirstChild = ::GetWindow( hWndControl, nSearchCode );
  149. if( hWndFirstChild == NULL )
  150. {
  151. if( ::GetParent( hWndControl ) != hWndMain )
  152. hWndFirstChild = ::GetWindow( ::GetParent( hWndControl ), nSearchCode );
  153. else
  154. {
  155. if( bPrevious )
  156. hWndFirstChild = ::GetWindow( hWndControl, GW_HWNDLAST );
  157. else
  158. hWndFirstChild = ::GetWindow( hWndControl, GW_HWNDFIRST );
  159. }
  160. }
  161. }
  162. for( ; hWndFirstChild != NULL ; )
  163. {
  164. BOOL bCtrl = FALSE;
  165. for( ; hWndFirstChild != NULL;  )
  166. {
  167. nStyle = (LONG)__EXT_MFC_GetWindowLong( hWndFirstChild, GWL_STYLE );
  168. nStyleEx = (LONG)__EXT_MFC_GetWindowLong( hWndFirstChild, GWL_EXSTYLE );
  169. if( ( nStyle & DS_CONTROL || nStyleEx & WS_EX_CONTROLPARENT ) && ( nStyle & WS_VISIBLE ) && (!( nStyle & WS_DISABLED )) )
  170. {
  171. bCtrl = TRUE;
  172. break;
  173. }
  174. else if( ( nStyle & WS_TABSTOP ) && ( nStyle & WS_VISIBLE ) && (!( nStyle & WS_DISABLED )) )
  175. break;
  176. hWndFirstChild = ::GetWindow( hWndFirstChild, nSearchCode );
  177. }
  178. if( hWndFirstChild != NULL )
  179. {
  180. if( bCtrl )
  181. hWndRetVal = stat_GetNextItemZ( hWndMain, hWndFirstChild, NULL, bPrevious );
  182. else
  183. hWndRetVal = hWndFirstChild;
  184. }
  185. if( hWndRetVal )
  186. break;
  187. hWndFirstChild = ::GetWindow( hWndFirstChild, nSearchCode );
  188. }
  189. if( hWndRetVal == NULL && hWndControl )
  190. {
  191. HWND hWndParent = ::GetParent( hWndControl );
  192. for( ; hWndParent != NULL; )
  193. {
  194. if( hWndParent == hWndMain )
  195. break;
  196. hWndRetVal = stat_GetNextItemZ( hWndMain, ::GetParent( hWndParent ), hWndParent , bPrevious );
  197. if( hWndRetVal )
  198. break;
  199. hWndParent = ::GetParent( hWndParent );
  200. }
  201. if( hWndRetVal == NULL )
  202. hWndRetVal = stat_GetNextItemZ(hWndMain,hWndMain,NULL,bPrevious );
  203. }
  204. return hWndRetVal;
  205. }
  206. bool CExtResizableDialog::OnHookSpyPreTranslateMessage(
  207. MSG * pMSG
  208. )
  209. {
  210. __PROF_UIS_MANAGE_STATE;
  211. if( m_bHelperSizingMoving )
  212. return CExtHookSpy::OnHookSpyPreTranslateMessage( pMSG );
  213. if( pMSG->message == WM_ENTERSIZEMOVE )
  214. m_bHelperSizingMoving = true;
  215. else if( pMSG->message == WM_EXITSIZEMOVE )
  216. m_bHelperSizingMoving = false;
  217. // if( pMSG->message == WM_ACTIVATE && pMSG->wParam == WA_INACTIVE  )
  218. // _SaveFocusControl();
  219. if( pMSG->message == WM_KILLFOCUS )
  220. _SaveFocusControl();
  221. #if (!defined __EXT_MFC_NO_SCROLLCONAINERWND)
  222. if( pMSG->message == WM_SETFOCUS
  223. && GetSafeHwnd() != NULL
  224. && ( GetStyle() & (WS_DISABLED|WS_VISIBLE) ) == (WS_VISIBLE)
  225. )
  226. {
  227. HWND hWndFocus = ::GetFocus();
  228. if( hWndFocus != NULL )
  229. {
  230. HWND hWndParentOfFocus = ::GetParent( hWndFocus );
  231. if( hWndParentOfFocus != NULL )
  232. {
  233. CWnd * pWndFocusParent = CWnd::FromHandlePermanent( hWndParentOfFocus );
  234. if( pWndFocusParent != NULL && pWndFocusParent->IsKindOf( RUNTIME_CLASS(CExtResizableDialog) ) )
  235. {
  236. CWnd * pWndParent = pWndFocusParent->GetParent();
  237. if( pWndParent != NULL )
  238. {
  239. CExtScrollContainerWnd * pWndScrollContainer = DYNAMIC_DOWNCAST( CExtScrollContainerWnd, pWndParent );
  240. if( pWndScrollContainer != NULL )
  241. {
  242. CRect rcCheck, rcBounds = pWndScrollContainer->OnSwGetClientRect();
  243. //rcBounds.OffsetRect( pWndScrollContainer->OnSwGetScrollPos() );
  244. ::GetWindowRect( hWndFocus, &rcCheck );
  245. pWndScrollContainer->ScreenToClient( &rcCheck );
  246. rcCheck.InflateRect( ::GetSystemMetrics(SM_CXVSCROLL) + 2, ::GetSystemMetrics(SM_CYHSCROLL) + 2 );
  247. CPoint ptLT = rcCheck.TopLeft(), ptRB = rcCheck.BottomRight();
  248. if( ! ( rcBounds.PtInRect( ptLT ) && rcBounds.PtInRect( ptRB ) ) )
  249. {
  250. pWndScrollContainer->OnSwEnsurePointAvail( ptRB );
  251. pWndScrollContainer->OnSwEnsurePointAvail( ptLT );
  252. pWndScrollContainer->OnSwRecalcLayout( true );
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. #endif // (!defined __EXT_MFC_NO_SCROLLCONAINERWND)
  261. return CExtHookSpy::OnHookSpyPreTranslateMessage( pMSG );
  262. }
  263. bool CExtResizableDialog::OnHookSpyKeyMsg(
  264. MSG * pMSG
  265. )
  266. {
  267. __PROF_UIS_MANAGE_STATE;
  268. if( m_bHelperSizingMoving )
  269. return CExtHookSpy::OnHookSpyKeyMsg( pMSG );
  270. if( WM_KEYFIRST <= pMSG->message
  271. && pMSG->message <= WM_KEYLAST
  272. && ( pMSG->wParam == VK_UP
  273. || pMSG->wParam == VK_DOWN
  274. || pMSG->wParam == VK_LEFT
  275. || pMSG->wParam == VK_RIGHT
  276. || pMSG->wParam == VK_RETURN
  277. || pMSG->wParam == VK_ESCAPE
  278. || pMSG->wParam == VK_MENU
  279. || ( ( HIWORD(pMSG->lParam) & KF_ALTDOWN ) != 0 // CExtPopupMenuWnd::IsKeyPressed( VK_MENU )
  280. && ( ( VK_NUMPAD0 <= pMSG->wParam && pMSG->wParam <= VK_NUMPAD9 )
  281. || pMSG->wParam == VK_INSERT // 0
  282. || pMSG->wParam == VK_END    // 1
  283. || pMSG->wParam == VK_DOWN   // 2
  284. || pMSG->wParam == VK_NEXT   // 3
  285. || pMSG->wParam == VK_LEFT   // 4
  286. || pMSG->wParam == 0x0C      // 5, VK_CLEAR
  287. || pMSG->wParam == VK_RIGHT  // 8
  288. || pMSG->wParam == VK_HOME   // 7
  289. || pMSG->wParam == VK_UP     // 8
  290. || pMSG->wParam == VK_PRIOR  // 9
  291. )
  292. )
  293. )
  294. && ( GetStyle() & (WS_CHILD|WS_VISIBLE) ) == WS_VISIBLE
  295. && PreTranslateMessage( pMSG )
  296. )
  297. return true;
  298. return CExtHookSpy::OnHookSpyKeyMsg( pMSG );
  299. }
  300. LRESULT CExtResizableDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  301. {
  302. if( message == WM_ENTERSIZEMOVE )
  303. m_bHelperSizingMoving = true;
  304. else if( message == WM_EXITSIZEMOVE )
  305. m_bHelperSizingMoving = false;
  306. else if( message == WM_SETFOCUS && GetSafeHwnd() != NULL)
  307. {
  308. if( m_bAllowLongFocusJumpFix
  309. && g_bProcessingLongFocusJump
  310. )
  311. {
  312. HWND hWnd = stat_GetNextItemZ( m_hWnd, m_hWnd, NULL, g_bProcessingLongFocusJumpToPrevDir ? TRUE : FALSE );
  313. if( hWnd != NULL )
  314. {
  315. //CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
  316. ::SetFocus( hWnd );
  317. //pWnd;
  318. }
  319. return 0;
  320. }
  321. if( m_hWndFocus == NULL
  322. || ( ! ::IsWindow( m_hWndFocus ) )
  323. || ( ! ::IsChild( m_hWnd, m_hWndFocus ) )
  324. || ::GetFocus() == m_hWndFocus
  325. )
  326. m_hWndFocus = NULL;
  327. else
  328. {
  329. ::SetFocus( m_hWndFocus );
  330. m_hWndFocus = NULL;
  331. return 0;
  332. }
  333. }
  334. else if( message == WM_DESTROY )
  335. m_bEnabledControlBarUpdate = false;
  336. bool bUpdateBarsOnThisMsg = false;
  337. if( m_bEnabledControlBarUpdate )
  338. {
  339. CWinApp * pApp = AfxGetApp();
  340. ASSERT( pApp != NULL );
  341. BOOL bIdleMsg = pApp->IsIdleMessage(
  342. #if _MFC_VER < 0x700
  343. &pApp->m_msgCur
  344. #else
  345. &(::AfxGetThreadState()->m_msgCur)
  346. #endif
  347. );
  348. if( bIdleMsg )
  349. bUpdateBarsOnThisMsg = true;
  350. }
  351. HWND hWndThis = m_hWnd;
  352. LRESULT lResult =
  353. CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::WindowProc(message, wParam, lParam);
  354. if( hWndThis == NULL
  355. || ( ! ::IsWindow(hWndThis) )
  356. )
  357. bUpdateBarsOnThisMsg = false;
  358. if( bUpdateBarsOnThisMsg
  359. && ( ! m_bInConrolBarUpdate )
  360. )
  361. {
  362. m_bInConrolBarUpdate = true;
  363. CExtControlBar::DoCustomModeUpdateControlBars( this );
  364. m_bInConrolBarUpdate = false;
  365. }
  366. return lResult;
  367. }
  368. void CExtResizableDialog::PreSubclassWindow() 
  369. {
  370. m_bHelperSizingMoving = false;
  371. CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::PreSubclassWindow();
  372. HookSpyRegister( __EHSEF_MOUSE_ALL_WITHOUT_WHEEL|__EHSEF_WND_PROC_IN|__EHSEF_WND_PROC_IN|__EHSEF_PRE_TRANSLATION );
  373. m_bEnabledControlBarUpdate = true;
  374. EnableToolTips();
  375. }
  376. void CExtResizableDialog::PostNcDestroy()
  377. {
  378. m_bHelperSizingMoving = false;
  379. HookSpyUnregister();
  380. CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::PostNcDestroy();
  381. }
  382. BOOL CExtResizableDialog::PreTranslateMessage(MSG* pMsg) 
  383. {
  384. if( WM_KEYFIRST <= pMsg->message
  385. && pMsg->message <= WM_KEYLAST
  386. && GetSafeHwnd() != NULL
  387. && ( pMsg->hwnd == m_hWnd || ::IsChild( m_hWnd, pMsg->hwnd ) )
  388. && (GetStyle()&(WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE
  389. )
  390. { // pre translating keyboard input (if enabled/visible dialog)
  391. if( pMsg->wParam == VK_TAB )
  392. {
  393. if( m_bAllowLongFocusJumpFix )
  394. {
  395. if( pMsg->message == WM_KEYDOWN )
  396. {
  397. HWND hWnd = ::GetFocus();
  398. if( hWnd != NULL )
  399. {
  400. bool bWantsTab = ( ( ::SendMessage( hWnd, WM_GETDLGCODE, VK_TAB, 0 ) & DLGC_WANTTAB ) != 0 ) ? true : false;
  401. if( bWantsTab )
  402. {
  403. CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
  404. if( pWnd != NULL
  405. && ( pWnd->IsKindOf( RUNTIME_CLASS(CDialog) )
  406. #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
  407. || pWnd->IsKindOf( RUNTIME_CLASS(CExtTabPageContainerWnd) )
  408. #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
  409. )
  410. )
  411. bWantsTab = false;
  412. } // if( bWantsTab )
  413. if( ! bWantsTab )
  414. {
  415. HWND hWndMain = m_hWnd;
  416. if( ( __EXT_MFC_GetWindowLong( hWndMain, GWL_STYLE ) & WS_CHILD ) != 0 )
  417. hWndMain = ::GetParent( m_hWnd );
  418. for( ; ( __EXT_MFC_GetWindowLong( hWndMain, GWL_STYLE ) & WS_CHILD ) != 0 ; )
  419. hWndMain = ::GetParent( hWndMain );
  420. if( hWndMain != NULL )
  421. {
  422. BOOL bPrevious = CExtPopupMenuWnd::IsKeyPressed( VK_SHIFT );
  423. hWnd = stat_GetNextItemZ( hWndMain, m_hWnd, hWnd, bPrevious );
  424. //hWnd = ::GetNextDlgTabItem( m_hWnd, hWnd, CExtPopupMenuWnd::IsKeyPressed( VK_SHIFT ) );
  425. if( hWnd != NULL )
  426. {
  427. //CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
  428. g_bProcessingLongFocusJump = true;
  429. g_bProcessingLongFocusJumpToPrevDir = bPrevious ? true : false;
  430. ::SetFocus( hWnd );
  431. if( ::SendMessage( hWnd, WM_GETDLGCODE, WPARAM(VK_TAB), LPARAM(pMsg) ) )
  432. ::SendMessage( hWnd, EM_SETSEL, WPARAM(0L), LPARAM(-1L) );
  433. g_bProcessingLongFocusJump = false;
  434. //pWnd;
  435. }
  436. }
  437. } // if( ! bWantsTab )
  438. else
  439. return FALSE;
  440. } // if( hWnd != NULL )
  441. } // if( pMsg->message == WM_KEYDOWN )
  442. return TRUE;
  443. } // if( m_bAllowLongFocusJumpFix )
  444. } // if( pMsg->wParam == VK_TAB )
  445. else
  446. {
  447. if( (GetStyle()&(WS_VISIBLE|WS_CHILD)) == (WS_VISIBLE|WS_CHILD) )
  448. { // if child/visible dialog
  449. HWND hWndParent = ::GetParent( m_hWnd );
  450. CWnd * pWndParentPermanent = CWnd::FromHandlePermanent( hWndParent );
  451. if( pWndParentPermanent != NULL
  452. && ( pWndParentPermanent->IsKindOf( RUNTIME_CLASS(CExtControlBar) )
  453. #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  454. || pWndParentPermanent->IsKindOf( RUNTIME_CLASS(CExtDynAutoHideSlider) )
  455. #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  456. )
  457. && pWndParentPermanent->PreTranslateMessage(pMsg)
  458. )
  459. return TRUE;
  460. } // if child/visible dialog
  461. } // else from if( pMsg->wParam == VK_TAB )
  462. HWND hWndFocus = ::GetFocus();
  463. if( hWndFocus != NULL
  464. && ::GetParent( hWndFocus ) == m_hWnd
  465. //&& ( ::SendMessage( hWndFocus, WM_GETDLGCODE, 0L, 0L ) & (DLGC_WANTCHARS|DLGC_WANTALLKEYS) == 0 )
  466. )
  467. {
  468. bool bProcessKey = false;
  469. BOOL bAlt = HIWORD(pMsg->lParam) & KF_ALTDOWN;
  470. LRESULT lRDC = ::SendMessage( hWndFocus, WM_GETDLGCODE, pMsg->wParam, 0L );
  471. if( ( lRDC & DLGC_WANTALLKEYS ) == 0
  472. && ( ( lRDC & DLGC_WANTCHARS ) == 0
  473. || bAlt
  474. )
  475. )
  476. {
  477. bProcessKey = true;
  478. }
  479. if( bProcessKey )
  480. {
  481. //BOOL bKeyUp = ( pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYUP) ? TRUE : FALSE;
  482. BOOL bCtrl = GetKeyState(VK_CONTROL) & 0x80000000;
  483. BOOL bShift = GetKeyState(VK_SHIFT) & 0x80000000;
  484. if( ! ( bCtrl || bShift ) )
  485. {
  486. TCHAR vkTCHAR = (TCHAR)pMsg->wParam;
  487. BYTE lpKeyState[256];
  488. ::GetKeyboardState( lpKeyState );
  489. UINT wScanCode = ::MapVirtualKey( vkTCHAR, 0 );
  490. HKL hKeyboardLayout =
  491. ::GetKeyboardLayout(
  492. ( ::AfxGetThread() ) -> m_nThreadID
  493. );
  494. #if (defined _UNICODE)
  495. TCHAR szChar[2] = { _T(''), _T('') };
  496. ::ToUnicodeEx(
  497. vkTCHAR,
  498. wScanCode,
  499. lpKeyState,
  500. szChar, 1,
  501. 1,
  502. hKeyboardLayout
  503. );
  504. #else
  505. WORD nMapped = 0;
  506. ::ToAsciiEx(
  507. vkTCHAR,
  508. wScanCode,
  509. lpKeyState,
  510. &nMapped,
  511. 1,
  512. hKeyboardLayout
  513. );
  514. TCHAR szChar[2] = { (TCHAR)nMapped, _T('') };
  515. #endif
  516. ::CharUpper( szChar );
  517. if( szChar[0] != 0 )
  518. {
  519. HWND hWnd = ::GetWindow( m_hWnd, GW_CHILD );
  520. for( ; hWnd != NULL; hWnd = ::GetWindow( hWnd, GW_HWNDNEXT ) )
  521. {
  522. CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
  523. if( pWnd == NULL )
  524. continue;
  525. if( (pWnd->GetStyle()&(WS_VISIBLE|WS_DISABLED)) != WS_VISIBLE )
  526. continue;
  527. CExtButton * pExtButton = DYNAMIC_DOWNCAST( CExtButton, pWnd );
  528. if( pExtButton == NULL )
  529. continue;
  530. if( pExtButton->m_bQuickActivationEnabled
  531. && pExtButton->_QuickActivationCheck( DWORD(vkTCHAR) )
  532. )
  533. {
  534. if( pMsg->message == WM_KEYDOWN
  535. || pMsg->message == WM_SYSKEYDOWN
  536. )
  537. {
  538. if( hWndFocus != pExtButton->m_hWnd )
  539. pExtButton->SetFocus();
  540. }
  541. if( pMsg->message == WM_KEYUP
  542. || pMsg->message == WM_SYSKEYUP
  543. )
  544. {
  545. if( pExtButton->PreTranslateMessage( pMsg ) )
  546. return TRUE;
  547. }
  548. //break;
  549. return TRUE;
  550. }
  551. }
  552. }
  553. } // if( ! ( bCtrl || bShift ) )
  554. } // if( bProcessKey )
  555. } // if( hWndFocus != NULL && ::GetParent( hWndFocus ) == m_hWnd ...
  556. } // pre translating keyboard input (if enabled/visible dialog)
  557. if( ( GetStyle() & WS_VISIBLE ) != 0
  558. && CExtControlBar::DoCustomModePreTranslateMessage( this, pMsg )
  559. )
  560. return TRUE;
  561. if( pMsg->message == WM_LBUTTONDOWN )
  562. return FALSE;
  563. return CExtWA < CExtWS < __BASEOF_CExtResizableDialog__ > >::PreTranslateMessage(pMsg);
  564. }
  565. //////////////////////////////////////////////////////////////////////////
  566. // CExtResizablePropertyPage
  567. IMPLEMENT_DYNCREATE( CExtResizablePropertyPage, CExtResPP )
  568. CExtResizablePropertyPage::CExtResizablePropertyPage()
  569. : m_bEnabledControlBarUpdate( false )
  570. , m_bInConrolBarUpdate( false )
  571. {
  572. m_bShowResizingGripper = false;
  573. }
  574. CExtResizablePropertyPage::CExtResizablePropertyPage(
  575. UINT nIDTemplate,
  576. UINT nIDCaption // = 0 
  577. )
  578. : CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > > ( nIDTemplate, nIDCaption )
  579. , m_bEnabledControlBarUpdate( false )
  580. , m_bInConrolBarUpdate( false )
  581. {
  582. m_bShowResizingGripper = false;
  583. }
  584. CExtResizablePropertyPage::CExtResizablePropertyPage(
  585. __EXT_MFC_SAFE_LPCTSTR lpszTemplateName,
  586. UINT nIDCaption // = 0 
  587. )
  588. : CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > > ( lpszTemplateName, nIDCaption )
  589. , m_bEnabledControlBarUpdate( false )
  590. , m_bInConrolBarUpdate( false )
  591. {
  592. m_bShowResizingGripper = false;
  593. }
  594. CExtResizablePropertyPage::~CExtResizablePropertyPage()
  595. {
  596. }
  597. __EXT_MFC_SAFE_LPCTSTR CExtResizablePropertyPage::OnQuerySkinnedFontParmName() const
  598. {
  599. ASSERT_VALID( this );
  600. return _T("Dialog");
  601. }
  602. BEGIN_MESSAGE_MAP( CExtResizablePropertyPage, CExtResPP )
  603. //{{AFX_MSG_MAP(CExtResizablePropertyPage)
  604. //}}AFX_MSG_MAP
  605. END_MESSAGE_MAP()
  606. /////////////////////////////////////////////////////////////////////////////
  607. // CExtResizablePropertyPage message handlers
  608. void CExtResizablePropertyPage::OnOK()
  609. {
  610. DWORD dwStyle = GetStyle();
  611. if( (dwStyle & WS_CHILD) == 0 )
  612. CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >::OnOK();
  613. }
  614. void CExtResizablePropertyPage::OnCancel()
  615. {
  616. DWORD dwStyle = GetStyle();
  617. if( (dwStyle & WS_CHILD) == 0 )
  618. CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >::OnCancel();
  619. }
  620. bool CExtResizablePropertyPage::OnHookWndMsg(
  621. LRESULT & lResult,
  622. HWND hWndHooked,
  623. UINT nMessage,
  624. WPARAM & wParam,
  625. LPARAM & lParam
  626. )
  627. {
  628. __PROF_UIS_MANAGE_STATE;
  629. if( GetSafeHwnd() != NULL
  630. && hWndHooked == m_hWnd
  631. )
  632. {
  633. //if( (m_psh.dwFlags&(__EXT_MFC_PSH_WIZARD97_MASK)) != 0 )
  634. {
  635. switch( nMessage )
  636. {
  637. case WM_ERASEBKGND:
  638. {
  639. ASSERT_VALID( this );
  640. // look through the message map to see 
  641. // if this message is handled by user
  642. const AFX_MSGMAP_ENTRY * lpEntry = 
  643. _FindMessageMapHandler(
  644. nMessage,
  645. 0, 0
  646. );
  647. if( lpEntry != NULL )
  648. {
  649. // invoke the user defined message handler
  650. union 
  651. {
  652. AFX_PMSG pfn;
  653. BOOL (AFX_MSG_CALL CWnd::*pfn_bD)( CDC* );
  654. } mmf;
  655. mmf.pfn = lpEntry->pfn;
  656. LRESULT lResult = 
  657. (this->*mmf.pfn_bD)( CDC::FromHandle( ( HDC ) wParam ) );
  658. return lResult > 0L ? true : false;
  659. } // if( lpEntry != NULL )
  660. HDC hDC = reinterpret_cast < HDC > (wParam);
  661. ASSERT( hDC != NULL );
  662. HWND hWnd = ::WindowFromDC( hDC );
  663. if( hWnd != NULL
  664. && hWnd != m_hWnd
  665. )
  666. return 
  667. CExtHookSink::OnHookWndMsg(
  668. lResult,
  669. hWndHooked,
  670. nMessage,
  671. wParam,
  672. lParam
  673. );
  674. if( (GetStyle() & WS_CLIPCHILDREN) != 0
  675. && PmBridge_GetPM()->GetCb2DbTransparentMode(this)
  676. )
  677. return (!0L);
  678. CExtPaintManager::stat_ExcludeChildAreas(
  679. hDC,
  680. GetSafeHwnd(),
  681. CExtPaintManager::stat_DefExcludeChildAreaCallback
  682. );
  683. return (!0L);
  684. } // case WM_ERASEBKGND
  685. case WM_PAINT:
  686. {
  687. ASSERT_VALID( this );
  688. bool bDlg = IsKindOf(RUNTIME_CLASS(CDialog)) ? true : false;
  689. if( !bDlg )
  690. {
  691. TCHAR strClassName[ _MAX_PATH + 1 ] = _T("");
  692. ::GetClassName( m_hWnd, strClassName, _MAX_PATH );
  693. __EXT_MFC_STRLWR( strClassName, _MAX_PATH + 1 );
  694. if( _tcsstr( strClassName, _T("#") ) != NULL )
  695. bDlg = true;
  696. }
  697. // look through the message map to see 
  698. // if this message is handled by user
  699. const AFX_MSGMAP_ENTRY * lpEntry = 
  700. _FindMessageMapHandler(
  701. nMessage,
  702. 0, 0
  703. );
  704. bool bPainted = false;
  705. if( !bDlg ) 
  706. {
  707. if( lpEntry != NULL )
  708. {
  709. // invoke the user defined message handler
  710. union 
  711. {
  712. AFX_PMSG pfn;
  713. void (AFX_MSG_CALL CCmdTarget::*pfn_COMMAND)();
  714. } mmf;
  715. mmf.pfn = lpEntry->pfn;
  716. (this->*mmf.pfn_COMMAND)();
  717. // return 0L;
  718. bPainted = true;
  719. } // if( lpEntry != NULL )
  720. }
  721. if( !bPainted )
  722. {
  723. CPaintDC dc( this );
  724. COLORREF clrBackground = GetBkColor();
  725. bool bTransparent = false;
  726. if( PmBridge_GetPM()->GetCb2DbTransparentMode(this)
  727. && ( clrBackground == COLORREF(-1L) )
  728. )
  729. {
  730. CExtPaintManager::stat_ExcludeChildAreas(
  731. dc,
  732. GetSafeHwnd(),
  733. CExtPaintManager::stat_DefExcludeChildAreaCallback
  734. );
  735. if( PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) )
  736. bTransparent = true;
  737. }
  738. if( ! bTransparent )
  739. {
  740. CRect rcClient;
  741. GetClientRect( &rcClient );
  742. dc.FillSolidRect(
  743. &rcClient,
  744. clrBackground != COLORREF(-1L)
  745. ? clrBackground
  746. : PmBridge_GetPM()->GetColor( CExtPaintManager::CLR_3DFACE_OUT, this )
  747. );
  748. }
  749. #if _MFC_VER >= 0x700
  750. if( (m_psp.dwFlags&PSP_HIDEHEADER) != 0 )
  751. {
  752. CWnd * pWnd = GetParent();
  753. ASSERT_VALID( pWnd );
  754. ASSERT( pWnd->GetSafeHwnd() != NULL );
  755. CExtResizablePropertySheet * pRPS =
  756. DYNAMIC_DOWNCAST( CExtResizablePropertySheet, pWnd );
  757. if( pRPS != NULL
  758. && (pRPS->m_psh.dwFlags&PSH_HEADER) != 0
  759. && pRPS->m_psh.pszbmWatermark != NULL
  760. )
  761. {
  762. CExtBitmap _bmp;
  763. if( g_ResourceManager->LoadBitmap(
  764. _bmp,
  765. pRPS->m_psh.pszbmWatermark
  766. )
  767. )
  768. {
  769. CSize _size = _bmp.GetSize();
  770.   CRect rcDraw( 0, 0, _size.cx, _size.cy );
  771. _bmp.Draw( dc.m_hDC, rcDraw );
  772. }
  773. }
  774. } // if( (m_psp.dwFlags&PSP_HIDEHEADER) != 0 )
  775. #endif // #if _MFC_VER >= 0x700
  776. PmBridge_GetPM()->OnPaintSessionComplete( this );
  777. }
  778. if( bDlg ) 
  779. {
  780. if( lpEntry != NULL )
  781. {
  782. // invoke the user defined message handler
  783. union 
  784. {
  785. AFX_PMSG pfn;
  786. void (AFX_MSG_CALL CCmdTarget::*pfn_COMMAND)();
  787. } mmf;
  788. mmf.pfn = lpEntry->pfn;
  789. (this->*mmf.pfn_COMMAND)();
  790. return 0L;
  791. } // if( lpEntry != NULL )
  792. }
  793. return TRUE;
  794. } // case WM_PAINT
  795. } // switch( nMessage )
  796. } // if( (m_psh.dwFlags&(__EXT_MFC_PSH_WIZARD97_MASK)) != 0 )
  797. }
  798. return
  799. CExtHookSink::OnHookWndMsg(
  800. lResult,
  801. hWndHooked,
  802. nMessage,
  803. wParam,
  804. lParam
  805. );
  806. }
  807. LRESULT CExtResizablePropertyPage::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  808. {
  809. //TRACE1( "--CExtResizablePropertyPage::WindowProc(0x%08X)n", message );
  810. if( message == WM_DESTROY )
  811. m_bEnabledControlBarUpdate = false;
  812. bool bUpdateBarsOnThisMsg = false;
  813. if( m_bEnabledControlBarUpdate )
  814. {
  815. CWinApp * pApp = AfxGetApp();
  816. ASSERT( pApp != NULL );
  817. BOOL bIdleMsg = pApp->IsIdleMessage(
  818. #if _MFC_VER < 0x700
  819. &pApp->m_msgCur
  820. #else
  821. &(::AfxGetThreadState()->m_msgCur)
  822. #endif
  823. );
  824. if( bIdleMsg )
  825. bUpdateBarsOnThisMsg = true;
  826. }
  827. LRESULT lResult =
  828. CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >::WindowProc(message, wParam, lParam);
  829. switch( message )
  830. {
  831. /*
  832. #if _MFC_VER >= 0x700
  833. case WM_PAINT:
  834. {
  835. CWnd * pWnd = GetParent();
  836. ASSERT_VALID( pWnd );
  837. ASSERT( pWnd->GetSafeHwnd() != NULL );
  838. CExtResizablePropertySheet * pRPS =
  839. DYNAMIC_DOWNCAST( CExtResizablePropertySheet, pWnd );
  840. if( pRPS != NULL
  841. && (pRPS->m_psh.dwFlags&PSH_HEADER) != 0
  842. && pRPS->m_psh.pszbmHeader != NULL
  843. )
  844. {
  845. HBITMAP hBmpHeader =
  846. g_ResourceManager->LoadBitmap(
  847. pRPS->m_psh.pszbmHeader
  848. );
  849. if( hBmpHeader != NULL )
  850. {
  851. CExtBitmap bmp;
  852. if( bmp.FromBitmap( hBmpHeader ) )
  853. {
  854. CSize _size = bmp.GetSize();
  855.   CRect rcDraw( 0, 0, _size.cx, _size.cy );
  856. CClientDC dc( this );
  857. bmp.Draw( dc.m_hDC, rcDraw );
  858. }
  859. ::DeleteObject( hBmpHeader );
  860. }
  861. }
  862. }
  863. break;
  864. #endif
  865. */
  866. //case WM_NCCREATE:
  867. case WM_INITDIALOG:
  868. {
  869. CWnd * pWndParent = GetParent();
  870. ASSERT_VALID( pWndParent );
  871. CExtResizablePropertySheet * pRPS =
  872. DYNAMIC_DOWNCAST( CExtResizablePropertySheet, pWndParent );
  873. if( pRPS != NULL
  874. && pRPS->GetActiveIndex() != 0
  875. )
  876. {
  877. pRPS->_SyncActivePage( this );
  878. }
  879. ::PostMessage( m_hWnd, (WM_USER+10), 0, 0 );
  880. }
  881. break;
  882. case (WM_USER+10):
  883. SetupHookWndSink( m_hWnd );
  884. break;
  885. case WM_DESTROY:
  886. RemoveAllWndHooks();
  887. break;
  888. case WM_SHOWWINDOW:
  889. case WM_WINDOWPOSCHANGED:
  890. if( GetStyle() & WS_VISIBLE )
  891. {
  892. CWnd * pWndParent = GetParent();
  893. if( pWndParent != NULL
  894. && pWndParent->IsKindOf(
  895. RUNTIME_CLASS(CExtResizablePropertySheet)
  896. )
  897. )
  898. {
  899. //((CExtResizablePropertySheet*)pWndParent)->ArrangeLayout();
  900. ((CExtResizablePropertySheet*)pWndParent)->_SyncActivePage();
  901. }
  902. ArrangeLayout();
  903. }
  904. break;
  905. } // switch( message )
  906. if( bUpdateBarsOnThisMsg && (!m_bInConrolBarUpdate) )
  907. {
  908. m_bInConrolBarUpdate = true;
  909. CExtControlBar::DoCustomModeUpdateControlBars( this );
  910. m_bInConrolBarUpdate = false;
  911. }
  912. return lResult;
  913. }
  914. void CExtResizablePropertyPage::PreSubclassWindow() 
  915. {
  916. CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >::PreSubclassWindow();
  917. m_bEnabledControlBarUpdate = true;
  918. EnableToolTips();
  919. }
  920. BOOL CExtResizablePropertyPage::PreTranslateMessage(MSG* pMsg) 
  921. {
  922. if( ( GetStyle() & WS_VISIBLE ) != 0
  923. && CExtControlBar::DoCustomModePreTranslateMessage( this, pMsg )
  924. )
  925. return TRUE;
  926. return CExtWA < CExtWS < __BASEOF_CExtResizablePropertyPage__ > >::PreTranslateMessage(pMsg);
  927. }
  928. /////////////////////////////////////////////////////////////////////////////
  929. // CExtResizablePropertySheet
  930. IMPLEMENT_DYNCREATE( CExtResizablePropertySheet, CExtResPS )
  931. CExtResizablePropertySheet::CExtResizablePropertySheet()
  932. : m_bSheetInitialized( false )
  933. //, m_bAllowTabSwitchingLoop( false )
  934. {
  935. m_bShowResizingGripper = true;
  936. }
  937. CExtResizablePropertySheet::CExtResizablePropertySheet(
  938. UINT nIDCaption,
  939. CWnd *pParentWnd, // = NULL
  940. UINT iSelectPage  // = 0
  941. )
  942. : CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > > ( nIDCaption, pParentWnd, iSelectPage  )
  943. , m_bSheetInitialized( false )
  944. //, m_bAllowTabSwitchingLoop( false )
  945. {
  946. m_bShowResizingGripper = true;
  947. }
  948. CExtResizablePropertySheet::CExtResizablePropertySheet(
  949. __EXT_MFC_SAFE_LPCTSTR pszCaption,
  950. CWnd *pParentWnd, // = NULL
  951. UINT iSelectPage  // = 0
  952. )
  953. : CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > > ( pszCaption, pParentWnd, iSelectPage  )
  954. , m_bSheetInitialized( false )
  955. //, m_bAllowTabSwitchingLoop( false )
  956. {
  957. m_bShowResizingGripper = true;
  958. }
  959. CExtResizablePropertySheet::~CExtResizablePropertySheet()
  960. {
  961. }
  962. __EXT_MFC_SAFE_LPCTSTR CExtResizablePropertySheet::OnQuerySkinnedFontParmName() const
  963. {
  964. ASSERT_VALID( this );
  965. return _T("Dialog");
  966. }
  967. BEGIN_MESSAGE_MAP( CExtResizablePropertySheet, CExtResPS )
  968. //{{AFX_MSG_MAP(CExtResizablePropertySheet)
  969. ON_WM_SIZE()
  970. ON_WM_WINDOWPOSCHANGED()
  971. //}}AFX_MSG_MAP
  972. END_MESSAGE_MAP()
  973. /////////////////////////////////////////////////////////////////////////////
  974. // CExtResizablePropertySheet message handlers
  975. void CExtResizablePropertySheet::PreSubclassWindow() 
  976. {
  977. CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > >::PreSubclassWindow();
  978. EnableToolTips();
  979. }
  980. void CExtResizablePropertySheet::_SyncActivePage(
  981. CPropertyPage * pActivePage // = NULL
  982. )
  983. {
  984. CTabCtrl * pTabCtrl = NULL;
  985. if( (m_psh.dwFlags&(__EXT_MFC_PSH_WIZARD97_MASK)) == 0 && ( (m_psh.dwFlags&PSH_WIZARD) == 0 ) )
  986. pTabCtrl = GetTabControl();
  987. if( pTabCtrl != NULL )
  988. {
  989. RECT rcMove;
  990. pTabCtrl->GetWindowRect( &rcMove );
  991. ScreenToClient( &rcMove );
  992. pTabCtrl->AdjustRect( FALSE, &rcMove );
  993. CWnd * pWnd = GetWindow( GW_CHILD );
  994. for( ; pWnd != NULL; pWnd = pWnd->GetWindow( GW_HWNDNEXT ) )
  995. {
  996. if( ! pWnd->IsKindOf( RUNTIME_CLASS( CPropertyPage ) ) )
  997. continue;
  998. RemoveAnchor( pWnd->m_hWnd );
  999. pWnd->MoveWindow( &rcMove );
  1000. AddAnchor( pWnd->m_hWnd, __RDA_LT, __RDA_RB );
  1001. }
  1002. }
  1003. else
  1004. {
  1005. CPropertyPage * pWnd = ( pActivePage->GetSafeHwnd() != NULL ) ? pActivePage : CExtResPS::GetActivePage();
  1006. if( pWnd->GetSafeHwnd() != NULL )
  1007. {
  1008. RDI_t _val;
  1009. if( ! m_mapRDI.Lookup( pWnd->GetSafeHwnd(), _val ) )
  1010. {
  1011. POSITION pos;
  1012. for( pos = m_mapRDI.GetStartPosition(); pos != NULL; )
  1013. {
  1014. HWND _hWnd;
  1015. RDI_t _rdi;
  1016. m_mapRDI.GetNextAssoc( pos, _hWnd, _rdi );
  1017. ASSERT( _hWnd != NULL );
  1018. if( ! ::IsWindow( _hWnd ) )
  1019. continue;
  1020. CWnd * _pWnd = CWnd::FromHandlePermanent( _hWnd );
  1021. if( _pWnd == NULL )
  1022. continue;
  1023. if( _pWnd->IsKindOf(RUNTIME_CLASS(CPropertyPage)) )
  1024. {
  1025. RECT rcMove;
  1026. _pWnd->GetWindowRect( &rcMove );
  1027. ScreenToClient( &rcMove );
  1028. //RemoveAnchor( pWnd->m_hWnd );
  1029. pWnd->MoveWindow( &rcMove );
  1030. //AddAnchor( pWnd->m_hWnd, __RDA_LT, __RDA_RB );
  1031. break;
  1032. } // if( _pWnd->IsKindOf(RUNTIME_CLASS(CPropertyPage)) )
  1033. } // for( POSITION pos = m_mapRDI.GetStartPosition(); pos != NULL; )
  1034. AddAnchor( pWnd->GetSafeHwnd(), __RDA_LT, __RDA_RB );
  1035. }
  1036. }
  1037. }
  1038. ArrangeLayout();
  1039. }
  1040. void CExtResizablePropertySheet::OnRenderWizardWatermarkArea(
  1041. CDC & dc,
  1042. const RECT & rcWaterMark,
  1043. const CExtBitmap & _bitmapWatermark // can be empty
  1044. )
  1045. {
  1046. __PROF_UIS_MANAGE_STATE;
  1047. ASSERT_VALID( this );
  1048. //
  1049. // STEP 1: draw tiled watermark bitmap
  1050. //
  1051. if( ! _bitmapWatermark.IsEmpty() )
  1052. {
  1053. CSize _size = _bitmapWatermark.GetSize();
  1054. CRect rcWalkStart(
  1055. rcWaterMark.left,
  1056. rcWaterMark.top,
  1057. rcWaterMark.left + _size.cx,
  1058. rcWaterMark.top + _size.cy
  1059. );
  1060. for( ; rcWalkStart.top < rcWaterMark.bottom; rcWalkStart.OffsetRect( 0, _size.cy ) )
  1061. {
  1062. CRect rcWalk = rcWalkStart;
  1063. for( ; rcWalk.left < rcWaterMark.right; rcWalk.OffsetRect( _size.cx, 0 ) )
  1064. {
  1065. _bitmapWatermark.Draw(
  1066. dc.GetSafeHdc(),
  1067. rcWalk.left,
  1068. rcWalk.top,
  1069. _size.cx,
  1070. _size.cy
  1071. );
  1072. }
  1073. }
  1074. } // if( ! _bitmapWatermark.IsEmpty() )
  1075. #if _MFC_VER >= 0x700
  1076. //
  1077. // STEP 2: draw title and subtitle
  1078. //
  1079. int nActiveIndex = GetActiveIndex();
  1080. CPropertyPage * pPP = ( nActiveIndex >= 0 ) ? GetPage( nActiveIndex ) : NULL;
  1081. if( pPP != NULL )
  1082. {
  1083. LPCTSTR strTitle = pPP->m_psp.pszHeaderTitle;
  1084. int nLenTitle = 0;
  1085. if( strTitle != NULL )
  1086. {
  1087. nLenTitle = int( _tcslen( strTitle ) );
  1088. if( nLenTitle == 0 )
  1089. strTitle = NULL;
  1090. }
  1091. LPCTSTR strSubTitle = pPP->m_psp.pszHeaderSubTitle;
  1092. int nLenSubTitle = 0;
  1093. if( strSubTitle != NULL )
  1094. {
  1095. nLenSubTitle = int( _tcslen( strSubTitle ) );
  1096. if( nLenSubTitle == 0 )
  1097. strSubTitle = NULL;
  1098. }
  1099. if( strTitle != NULL && strSubTitle != NULL )
  1100. {
  1101. int nOldBkMode = dc.SetBkMode( TRANSPARENT );
  1102. COLORREF clrOldTextColor =
  1103. dc.SetTextColor( PmBridge_GetPM()->GetColor( COLOR_BTNTEXT ) );
  1104. CFont * pFontTitle = &(PmBridge_GetPM()->m_FontBold);
  1105. CFont * pFontSubTitle = &(PmBridge_GetPM()->m_FontNormal);
  1106. TEXTMETRIC _tmTitle, _tmSubTitle;
  1107. ::memset( &_tmTitle, 0, sizeof(TEXTMETRIC) );
  1108. ::memset( &_tmSubTitle, 0, sizeof(TEXTMETRIC) );
  1109. CFont * pOldFont = dc.SelectObject( pFontTitle );
  1110. dc.GetTextMetrics( &_tmTitle );
  1111. dc.SelectObject( pFontSubTitle );
  1112. dc.GetTextMetrics( &_tmSubTitle );
  1113. static const int nPxDistanceBetweenTitleAndSubTitle = 4;
  1114. static const int nPxLeftOffsetTitle = 23;
  1115. static const int nPxLeftOffsetSubTitle = 22;
  1116. int nSummaryHieght =
  1117. int(_tmTitle.tmHeight)
  1118. + nPxDistanceBetweenTitleAndSubTitle
  1119. + int(_tmSubTitle.tmHeight);
  1120. CRect rcTitle(
  1121. rcWaterMark.left + nPxLeftOffsetTitle,
  1122. rcWaterMark.top,
  1123. rcWaterMark.right,
  1124. rcWaterMark.top + _tmTitle.tmHeight
  1125. );
  1126. rcTitle.OffsetRect(
  1127. 0,
  1128. ( rcWaterMark.bottom - rcWaterMark.top - nSummaryHieght ) / 2
  1129. );
  1130. CRect rcSubTitle(
  1131. rcTitle.left + nPxLeftOffsetSubTitle,
  1132. rcTitle.bottom + nPxDistanceBetweenTitleAndSubTitle,
  1133. rcWaterMark.right,
  1134. rcTitle.bottom + nPxDistanceBetweenTitleAndSubTitle + _tmSubTitle.tmHeight
  1135. );
  1136. if( strTitle != NULL )
  1137. {
  1138. ASSERT( nLenTitle > 0 );
  1139. dc.SelectObject( pFontTitle );
  1140. dc.DrawText(
  1141. strTitle,
  1142. nLenTitle,
  1143. &rcTitle,
  1144. DT_SINGLELINE|DT_LEFT|DT_TOP|DT_END_ELLIPSIS
  1145. );
  1146. } // if( strTitle != NULL )
  1147. if( strSubTitle != NULL )
  1148. {
  1149. ASSERT( nLenSubTitle > 0 );
  1150. dc.SelectObject( pFontSubTitle );
  1151. dc.DrawText(
  1152. strSubTitle,
  1153. nLenSubTitle,
  1154. &rcSubTitle,
  1155. DT_SINGLELINE|DT_LEFT|DT_TOP|DT_END_ELLIPSIS
  1156. );
  1157. } // if( strSubTitle != NULL )
  1158. dc.SelectObject( pOldFont );
  1159. dc.SetBkMode( nOldBkMode );
  1160. dc.SetTextColor( clrOldTextColor );
  1161. } // if( strTitle != NULL && strSubTitle != NULL )
  1162. } // if( pPP != NULL )
  1163. #endif // #if _MFC_VER >= 0x700
  1164. }
  1165. bool CExtResizablePropertySheet::OnHookWndMsg(
  1166. LRESULT & lResult,
  1167. HWND hWndHooked,
  1168. UINT nMessage,
  1169. WPARAM & wParam,
  1170. LPARAM & lParam
  1171. )
  1172. {
  1173. __PROF_UIS_MANAGE_STATE;
  1174. if( GetSafeHwnd() != NULL
  1175. && hWndHooked == m_hWnd
  1176. )
  1177. {
  1178. if( (m_psh.dwFlags&(__EXT_MFC_PSH_WIZARD97_MASK)) != 0 )
  1179. {
  1180. switch( nMessage )
  1181. {
  1182. case WM_ERASEBKGND:
  1183. {
  1184. ASSERT_VALID( this );
  1185. // look through the message map to see 
  1186. // if this message is handled by user
  1187. const AFX_MSGMAP_ENTRY * lpEntry = 
  1188. _FindMessageMapHandler(
  1189. nMessage,
  1190. 0, 0
  1191. );
  1192. if( lpEntry != NULL )
  1193. {
  1194. // invoke the user defined message handler
  1195. union 
  1196. {
  1197. AFX_PMSG pfn;
  1198. BOOL (AFX_MSG_CALL CWnd::*pfn_bD)( CDC* );
  1199. } mmf;
  1200. mmf.pfn = lpEntry->pfn;
  1201. LRESULT lResult = 
  1202. (this->*mmf.pfn_bD)( CDC::FromHandle( ( HDC ) wParam ) );
  1203. return lResult > 0L ? true : false;
  1204. } // if( lpEntry != NULL )
  1205. if( (GetStyle() & WS_CLIPCHILDREN) != 0
  1206. && PmBridge_GetPM()->GetCb2DbTransparentMode(this)
  1207. )
  1208. return (!0L);
  1209. HDC hDC = reinterpret_cast < HDC > (wParam);
  1210. ASSERT( hDC != NULL );
  1211. CExtPaintManager::stat_ExcludeChildAreas(
  1212. hDC,
  1213. GetSafeHwnd(),
  1214. CExtPaintManager::stat_DefExcludeChildAreaCallback
  1215. );
  1216. return (!0L);
  1217. } // case WM_ERASEBKGND
  1218. case WM_PAINT:
  1219. {
  1220. ASSERT_VALID( this );
  1221. bool bDlg = IsKindOf(RUNTIME_CLASS(CDialog)) ? true : false;
  1222. if( !bDlg )
  1223. {
  1224. TCHAR strClassName[ _MAX_PATH + 1 ] = _T("");
  1225. ::GetClassName( m_hWnd, strClassName, _MAX_PATH );
  1226. __EXT_MFC_STRLWR( strClassName, _MAX_PATH + 1 );
  1227. if( _tcsstr( strClassName, _T("#") ) != NULL )
  1228. bDlg = true;
  1229. }
  1230. // look through the message map to see 
  1231. // if this message is handled by user
  1232. const AFX_MSGMAP_ENTRY * lpEntry = 
  1233. _FindMessageMapHandler(
  1234. nMessage,
  1235. 0, 0
  1236. );
  1237. bool bPainted = false;
  1238. if( !bDlg ) 
  1239. {
  1240. if( lpEntry != NULL )
  1241. {
  1242. // invoke the user defined message handler
  1243. union 
  1244. {
  1245. AFX_PMSG pfn;
  1246. void (AFX_MSG_CALL CCmdTarget::*pfn_COMMAND)();
  1247. } mmf;
  1248. mmf.pfn = lpEntry->pfn;
  1249. (this->*mmf.pfn_COMMAND)();
  1250. // return 0L;
  1251. bPainted = true;
  1252. } // if( lpEntry != NULL )
  1253. }
  1254. if( !bPainted )
  1255. {
  1256. CPaintDC dc( this );
  1257. COLORREF clrBackground = GetBkColor();
  1258. bool bTransparent = false;
  1259. if( PmBridge_GetPM()->GetCb2DbTransparentMode(this)
  1260. && ( clrBackground == COLORREF(-1L) )
  1261. )
  1262. {
  1263. CExtPaintManager::stat_ExcludeChildAreas(
  1264. dc,
  1265. GetSafeHwnd(),
  1266. CExtPaintManager::stat_DefExcludeChildAreaCallback
  1267. );
  1268. if( PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) )
  1269. bTransparent = true;
  1270. }
  1271. CRect rcClient;
  1272. GetClientRect( &rcClient );
  1273. if( ! bTransparent )
  1274. {
  1275. dc.FillSolidRect(
  1276. &rcClient,
  1277. clrBackground != COLORREF(-1L)
  1278. ? clrBackground
  1279. : PmBridge_GetPM()->GetColor( CExtPaintManager::CLR_3DFACE_OUT, this )
  1280. );
  1281. }
  1282. CExtBitmap _bitmapWatermark;
  1283. #if _MFC_VER >= 0x700
  1284. if( (m_psh.dwFlags&(PSH_WATERMARK)) == (PSH_WATERMARK) )
  1285. g_ResourceManager->LoadBitmap(
  1286. _bitmapWatermark,
  1287. m_psh.pszbmWatermark
  1288. );
  1289. #endif // #if _MFC_VER >= 0x700
  1290. CRect rcWaterMark = rcClient;
  1291. HWND hWndChild = ::GetWindow( m_hWnd, GW_CHILD );
  1292. for( ; hWndChild != NULL; hWndChild = ::GetWindow( hWndChild, GW_HWNDNEXT ) )
  1293. {
  1294. CRect rcTemp;
  1295. ::GetWindowRect( hWndChild, &rcTemp );
  1296. ScreenToClient( &rcTemp );
  1297. rcWaterMark.bottom = min( rcWaterMark.bottom, rcTemp.top );
  1298. } // for( ; hWndChild != NULL; hWndChild = ::GetWindow( hWndChild, GW_HWNDNEXT ) )
  1299. CRgn _rgn;
  1300. if( _rgn.CreateRectRgnIndirect( &rcWaterMark ) )
  1301. dc.SelectClipRgn( &_rgn );
  1302. OnRenderWizardWatermarkArea(
  1303. dc,
  1304. rcWaterMark,
  1305. _bitmapWatermark
  1306. );
  1307. dc.SelectClipRgn( NULL );
  1308. PmBridge_GetPM()->OnPaintSessionComplete( this );
  1309. }
  1310. if( bDlg ) 
  1311. {
  1312. if( lpEntry != NULL )
  1313. {
  1314. // invoke the user defined message handler
  1315. union 
  1316. {
  1317. AFX_PMSG pfn;
  1318. void (AFX_MSG_CALL CCmdTarget::*pfn_COMMAND)();
  1319. } mmf;
  1320. mmf.pfn = lpEntry->pfn;
  1321. (this->*mmf.pfn_COMMAND)();
  1322. return 0L;
  1323. } // if( lpEntry != NULL )
  1324. }
  1325. return TRUE;
  1326. } // case WM_PAINT
  1327. } // switch( nMessage )
  1328. } // if( (m_psh.dwFlags&(__EXT_MFC_PSH_WIZARD97_MASK)) != 0 )
  1329. }
  1330. return
  1331. CExtHookSink::OnHookWndMsg(
  1332. lResult,
  1333. hWndHooked,
  1334. nMessage,
  1335. wParam,
  1336. lParam
  1337. );
  1338. }
  1339. LRESULT CExtResizablePropertySheet::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  1340. {
  1341. CPropertyPage * pWndPrevActivePage = NULL;
  1342. switch( message )
  1343. {
  1344. case WM_CLOSE:
  1345. if( m_bEnableSaveRestore )
  1346. SaveWindowRect();
  1347. break;
  1348. case WM_SYSCOMMAND:
  1349. if( wParam == SC_CLOSE )
  1350. {
  1351. if( m_bEnableSaveRestore )
  1352. SaveWindowRect();
  1353. }
  1354. break;
  1355. case WM_COMMAND:
  1356. if( wParam == IDOK || wParam == IDCANCEL )
  1357. {
  1358. if( m_bEnableSaveRestore )
  1359. SaveWindowRect();
  1360. }
  1361. else if( wParam == ID_WIZBACK || wParam == ID_WIZNEXT )
  1362. {
  1363. pWndPrevActivePage = CExtResPS::GetActivePage();
  1364. }
  1365. break;
  1366. case WM_DESTROY:
  1367. RemoveAllWndHooks();
  1368. case WM_NCDESTROY:
  1369. m_bSheetInitialized = false;
  1370. break;
  1371. //  case WM_SIZE:
  1372. //  _SyncActivePage();
  1373. //  break;
  1374. } // switch( message )
  1375. LRESULT lResult =
  1376. m_bSheetInitialized
  1377. ? CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > > :: WindowProc(message,wParam,lParam)
  1378. : CExtResPS :: WindowProc(message,wParam,lParam)
  1379. ;
  1380. switch( message )
  1381. {
  1382. case WM_SIZE:
  1383. _SyncActivePage();
  1384. break;
  1385. case WM_CREATE:
  1386. {
  1387. // window should be resizable
  1388. ModifyStyle(
  1389. 0,
  1390. WS_THICKFRAME | WS_CLIPCHILDREN
  1391. );
  1392. ::PostMessage( m_hWnd, (WM_USER+10), 0, 0 );
  1393. }
  1394. break;
  1395. case (WM_USER+10):
  1396. {
  1397. if( m_bSheetInitialized )
  1398. break;
  1399. CWnd * pTabCtrl = NULL; // GetTabControl();
  1400. CWnd * pWnd = GetWindow( GW_CHILD );
  1401. for( ; pWnd != NULL; pWnd = pWnd->GetWindow( GW_HWNDNEXT ) )
  1402. {
  1403. CExtSafeString sClassName;
  1404. ::GetClassName(
  1405. pWnd->GetSafeHwnd(),
  1406. sClassName.GetBuffer( _MAX_PATH+1 ),
  1407. _MAX_PATH
  1408. );
  1409. sClassName.ReleaseBuffer();
  1410. sClassName.MakeLower();
  1411. if( sClassName == WC_TABCONTROL )
  1412. {
  1413. pTabCtrl = pWnd;
  1414. break;
  1415. }
  1416. }
  1417. if( GetActiveIndex() > 0 )
  1418. {
  1419. CRect rcAlignPages( 0, 0, 0, 0 );
  1420. if( pTabCtrl != NULL && (m_psh.dwFlags&PSH_WIZARD) == 0 )
  1421. {
  1422. pTabCtrl->GetWindowRect( &rcAlignPages );
  1423. ScreenToClient( &rcAlignPages );
  1424. CExtPaintManager * pPM = PmBridge_GetPM();
  1425. ASSERT_VALID( pPM );
  1426. rcAlignPages.DeflateRect(
  1427. pPM->UiScalingDo(  3, CExtPaintManager::__EUIST_X ),
  1428. pPM->UiScalingDo( 22, CExtPaintManager::__EUIST_Y ),
  1429. pPM->UiScalingDo(  4, CExtPaintManager::__EUIST_X ),
  1430. pPM->UiScalingDo(  4, CExtPaintManager::__EUIST_Y )
  1431. );
  1432. // pTabCtrl->SendMessage( TCM_ADJUSTRECT, FALSE, (LPARAM)&rcAlignPages );
  1433. } // if( pTabCtrl != NULL && (m_psh.dwFlags&PSH_WIZARD) == 0 )
  1434. else if( (m_psh.dwFlags&PSH_WIZARD) != 0 )
  1435. {
  1436. GetClientRect( &rcAlignPages );
  1437. CExtPaintManager * pPM = PmBridge_GetPM();
  1438. ASSERT_VALID( pPM );
  1439. rcAlignPages.DeflateRect(
  1440. pPM->UiScalingDo( 11, CExtPaintManager::__EUIST_X ),
  1441. pPM->UiScalingDo( 11, CExtPaintManager::__EUIST_Y ),
  1442. 0, //pPM->UiScalingDo(  8, CExtPaintManager::__EUIST_X ),
  1443. pPM->UiScalingDo( 57, CExtPaintManager::__EUIST_Y )
  1444. );
  1445. } // else if( (m_psh.dwFlags&PSH_WIZARD) != 0 )
  1446. if( ! rcAlignPages.IsRectEmpty() )
  1447. {
  1448. pWnd = GetWindow( GW_CHILD );
  1449. for( ; pWnd != NULL; pWnd = pWnd->GetWindow( GW_HWNDNEXT ) )
  1450. {
  1451. if( ! pWnd->IsKindOf( RUNTIME_CLASS(CExtResizablePropertyPage) ) )
  1452. continue;
  1453. CRect rcFoundPage;
  1454. pWnd->GetWindowRect( &rcFoundPage );
  1455. ScreenToClient( &rcFoundPage );
  1456. if( rcFoundPage == rcAlignPages )
  1457. continue;
  1458. RemoveAnchor( pWnd->m_hWnd );
  1459. pWnd->MoveWindow( &rcAlignPages );
  1460. AddAnchor( pWnd->m_hWnd, __RDA_LT, __RDA_RB );
  1461. }
  1462. } // if( ! rcAlignPages.IsRectEmpty() )
  1463. } // if( GetActiveIndex() > 0 )
  1464. m_bSheetInitialized = true;
  1465. SetupHookWndSink( m_hWnd );
  1466. Invalidate();
  1467. CRect rcWnd;
  1468. GetWindowRect( &rcWnd );
  1469. CSize sizeWnd = rcWnd.Size();
  1470. SetMinTrackSize( sizeWnd );
  1471. ::SetWindowPos(
  1472. m_hWnd, NULL, 0,0,0,0,
  1473. SWP_NOSIZE|SWP_NOMOVE
  1474. |SWP_NOZORDER|SWP_NOOWNERZORDER
  1475. |SWP_NOREPOSITION
  1476. |SWP_FRAMECHANGED
  1477. );
  1478. // CTabCtrl * pTabCtrl = CExtResPS::GetTabControl();
  1479. pWnd = GetWindow( GW_CHILD );
  1480. for( ; pWnd != NULL; pWnd = pWnd->GetWindow(GW_HWNDNEXT)  )
  1481. {
  1482. if( pTabCtrl == pWnd )
  1483. {
  1484. pTabCtrl->ModifyStyle( 0, WS_CLIPSIBLINGS );
  1485. AddAnchor( pTabCtrl->GetSafeHwnd(), __RDA_LT, __RDA_RB );
  1486. continue;
  1487. }
  1488. CExtSafeString sClassName;
  1489. ::GetClassName( pWnd->GetSafeHwnd(), sClassName.GetBuffer( _MAX_PATH+1 ), _MAX_PATH );
  1490. sClassName.ReleaseBuffer();
  1491. sClassName.MakeLower();
  1492. if( sClassName == LPCTSTR( _T("static") ) )
  1493. {
  1494. pWnd->ModifyStyle( 0, WS_CLIPSIBLINGS );
  1495. #if _MFC_VER >= 0x700
  1496. if( (m_psh.dwFlags&__EXT_MFC_PSH_WIZARD97_MASK) != 0 )
  1497. {
  1498. if( pWnd->GetDlgCtrlID() == 0x3027 )
  1499. {
  1500. AddAnchor( pWnd->GetSafeHwnd(), __RDA_LT, __RDA_RT );
  1501. continue;
  1502. }
  1503. }
  1504. #endif // #if _MFC_VER >= 0x700
  1505. AddAnchor( pWnd->GetSafeHwnd(), __RDA_LB, __RDA_RB );
  1506. continue;
  1507. }
  1508. if( sClassName == LPCTSTR( _T("button") ) )
  1509. {
  1510. CRect rcWndButton;
  1511. pWnd->GetWindowRect( &rcWndButton );
  1512. ScreenToClient( &rcWndButton );
  1513. if( g_PaintManager.m_bIsWinVistaOrLater
  1514. && g_PaintManager.m_UxTheme.IsControlsThemed()
  1515. )
  1516. rcWndButton.OffsetRect( -14, -5 );
  1517. else
  1518. rcWndButton.OffsetRect( -10, 0 );
  1519. pWnd->MoveWindow( &rcWndButton );
  1520. pWnd->ModifyStyle( 0, WS_CLIPSIBLINGS );
  1521. AddAnchor( pWnd->GetSafeHwnd(), __RDA_RB );
  1522. if( this->FromHandlePermanent( pWnd->GetSafeHwnd() ) == NULL )
  1523. {
  1524. CButtonInSheetHook * pBtn = new CButtonInSheetHook;
  1525. VERIFY( pBtn->SubclassWindow( pWnd->GetSafeHwnd() ) );
  1526. }
  1527. continue;
  1528. }
  1529. if( sClassName == LPCTSTR( _T("systabcontrol32") ) )
  1530. {
  1531. #if (!defined __EXT_MFC_NO_TAB_CTRL)
  1532. CExtThemedTabCtrl * pTabs = new CExtThemedTabCtrl;
  1533. pTabs->m_bAutoDestroyWindow = true;
  1534. VERIFY( pTabs->SubclassWindow( pWnd->GetSafeHwnd() ) );
  1535. #endif // (!defined __EXT_MFC_NO_TAB_CTRL)
  1536. AddAnchor( pWnd->GetSafeHwnd(), __RDA_LT, __RDA_RB );
  1537. continue;
  1538. }
  1539. } // for( ; pWnd != NULL; pWnd = pWnd->GetWindow(GW_HWNDNEXT)  )
  1540. _SyncActivePage();
  1541. CExtPaintManager::monitor_parms_t _mp;
  1542. CExtPaintManager::stat_GetMonitorParms( _mp, this );
  1543. SetMaximizedRect( &_mp.m_rcWorkArea );
  1544. SetMaxTrackSize( _mp.m_rcWorkArea.Size() );
  1545. CRect _rcWnd;
  1546. GetWindowRect( &_rcWnd );;
  1547. CSize _size = _rcWnd.Size();
  1548. ::SendMessage(
  1549. m_hWnd, WM_SIZE,
  1550. WPARAM(SIZE_RESTORED),
  1551. MAKELPARAM( _size.cx, _size.cy )
  1552. );
  1553. if( GetStyle() & WS_VISIBLE )
  1554. RedrawWindow();
  1555. OnResizablePropertySheetInitialized();
  1556. }
  1557. break;
  1558. case WM_COMMAND:
  1559. if( wParam == ID_WIZBACK || wParam == ID_WIZNEXT )
  1560. {
  1561. if( !m_bSheetInitialized )
  1562. break;
  1563. if( pWndPrevActivePage != NULL )
  1564. {
  1565. CPropertyPage * pWndNewActivePage = CExtResPS::GetActivePage();
  1566. if( pWndPrevActivePage != pWndNewActivePage )
  1567. {
  1568. CRect rcWndPage;
  1569. pWndPrevActivePage->GetWindowRect( &rcWndPage );
  1570. ScreenToClient( &rcWndPage );
  1571. pWndNewActivePage->MoveWindow( &rcWndPage );
  1572. }
  1573. }
  1574. _SyncActivePage();
  1575. //ArrangeLayout();
  1576. }
  1577. break;
  1578. } // switch( message )
  1579. return lResult;
  1580. }
  1581. BOOL CExtResizablePropertySheet::PreCreateWindow(CREATESTRUCT& cs)
  1582. {
  1583. if( ! ( CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > > :: PreCreateWindow(cs) ) )
  1584. {
  1585. ASSERT( FALSE );
  1586. return FALSE;
  1587. }
  1588. return TRUE;
  1589. }
  1590. BOOL CExtResizablePropertySheet::PreTranslateMessage(MSG* pMsg)
  1591. {
  1592. if( GetSafeHwnd() != NULL
  1593. && ::IsWindow( GetSafeHwnd() )
  1594. //&& ( GetStyle() & WS_CHILD ) != 0
  1595. )
  1596. { // if valid sheet
  1597. if( pMsg->message == WM_KEYDOWN
  1598. && pMsg->wParam == VK_TAB
  1599. )
  1600. { // if WM_KEYDOWN with VK_TAB
  1601. HWND hWndFocus = ::GetFocus();
  1602. if( hWndFocus != NULL
  1603. && GetSafeHwnd() != NULL
  1604. && ( hWndFocus == m_hWnd || ::IsChild( m_hWnd, hWndFocus ) )
  1605. )
  1606. {
  1607. BOOL bShift = CExtPopupMenuWnd::IsKeyPressed(VK_SHIFT);
  1608. BOOL bCtrl = CExtPopupMenuWnd::IsKeyPressed(VK_CONTROL);
  1609. if( !bCtrl )
  1610. {
  1611. SendMessage( WM_NEXTDLGCTL, bShift, 0 );
  1612. return TRUE;
  1613. }
  1614. // + (2.25)
  1615. if( bShift )
  1616. {
  1617. if( GetActiveIndex() == 0 )
  1618. return TRUE;
  1619. SendMessage( WM_COMMAND, ID_WIZBACK );
  1620. } // if( bShift )
  1621. else
  1622. {
  1623. if( GetActiveIndex() == (GetPageCount() - 1) )
  1624. return TRUE;
  1625. SendMessage( WM_COMMAND, ID_WIZNEXT );
  1626. } // else from if( bShift )
  1627. return TRUE;
  1628. // - (2.25)
  1629. // CTabCtrl * pTabCtrl = CExtResPS::GetTabControl();
  1630. // if( pTabCtrl != NULL )
  1631. // {
  1632. // int nItemCount = pTabCtrl->GetItemCount();
  1633. // if( nItemCount > 1 )
  1634. // {
  1635. // int nCurSel = pTabCtrl->GetCurSel();
  1636. // nCurSel += bShift ? -1 : 1;
  1637. // if( nCurSel < 0 || nCurSel == nItemCount )
  1638. // {
  1639. // if( ! m_bAllowTabSwitchingLoop )
  1640. // return TRUE;
  1641. // if( nCurSel < 0 )
  1642. // nCurSel = nItemCount - 1;
  1643. // else
  1644. // {
  1645. // ASSERT( nCurSel == nItemCount );
  1646. // nCurSel = 0;
  1647. // }
  1648. // } // if( nCurSel == nItemCount )
  1649. // if( (pTabCtrl->GetStyle()&WS_VISIBLE) != 0 )
  1650. // {
  1651. // //pTabCtrl->SetCurSel( nCurSel );
  1652. // pTabCtrl->SetFocus();
  1653. // } // if( (pTabCtrl->GetStyle()&WS_VISIBLE) != 0 )
  1654. // SetActivePage( nCurSel );
  1655. // _SyncActivePage();
  1656. // }
  1657. // _TrickSyncActviveChild();
  1658. // } // valid sheet
  1659. // return TRUE;
  1660. }
  1661. } // if WM_KEYDOWN with VK_TAB
  1662. } // if valid sheet
  1663. return CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > > :: PreTranslateMessage(pMsg);
  1664. }
  1665. BOOL CExtResizablePropertySheet::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  1666. {
  1667. if( GetSafeHwnd() != NULL
  1668. && ::IsWindow( GetSafeHwnd() )
  1669. )
  1670. { // if valid sheet
  1671. if( nID == ID_WIZNEXT || nID == ID_WIZBACK )
  1672. {
  1673. BOOL bRetVal =
  1674. CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > >
  1675. :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
  1676. if( nCode == CN_COMMAND )
  1677. _SyncActivePage();
  1678. return bRetVal;
  1679. } // if( nID == ID_WIZNEXT || nID == ID_WIZBACK )
  1680. if( ( GetStyle() & WS_CHILD ) != 0 )
  1681. { // if valid child sheet
  1682. if( CWnd::OnCmdMsg( nID, nCode, pExtra, pHandlerInfo ) )
  1683. return TRUE;
  1684. if( ( nCode != CN_COMMAND
  1685. && nCode != CN_UPDATE_COMMAND_UI
  1686. )
  1687. || ( ((nID) & 0x8000) == 0 )
  1688. || nID >= 0xf000
  1689. )
  1690. return FALSE;
  1691. // last crack goes to the current CWinThread object
  1692. CWinThread* pThread = AfxGetThread();
  1693. if( pThread != NULL )
  1694. {
  1695. #ifdef _DEBUG
  1696. if (afxTraceFlags & traceCmdRouting)
  1697. TRACE1("Routing command id 0x%04X to app.n", nID);
  1698. #endif
  1699. if (pThread->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  1700. return TRUE;
  1701. }
  1702. #ifdef _DEBUG
  1703. if (afxTraceFlags & traceCmdRouting)
  1704. {
  1705. TRACE2("IGNORING command id 0x%04X sent to %hs dialog.n", nID,
  1706. GetRuntimeClass()->m_lpszClassName);
  1707. }
  1708. #endif
  1709. return FALSE;
  1710. } // if valid child sheet
  1711. } // if valid sheet
  1712. return
  1713. CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > >
  1714. :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
  1715. }
  1716. void CExtResizablePropertySheet::OnSize(UINT nType, int cx, int cy) 
  1717. {
  1718. CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > >
  1719. :: OnSize( nType, cx, cy );
  1720. if( GetSafeHwnd() != NULL
  1721. && ::IsWindow( GetSafeHwnd() )
  1722. )
  1723. { // if valid window
  1724. DWORD dwStyle = GetStyle();
  1725. if( (dwStyle&WS_CHILD) != 0 )
  1726. { // if child sheet window
  1727. CTabCtrl * pTabCtrl = GetTabControl();
  1728. if( pTabCtrl != NULL )
  1729. {
  1730. int nAdjustTabWndDY =
  1731. ( (dwStyle&WS_CAPTION) == 0 )
  1732. ? ( ::GetSystemMetrics( SM_CYCAPTION )
  1733. + ::GetSystemMetrics( SM_CYDLGFRAME )
  1734.   * 2
  1735.   )
  1736. : 0
  1737. ;
  1738. pTabCtrl->MoveWindow(
  1739. 0,
  1740. 0,
  1741. cx,
  1742. cy - nAdjustTabWndDY,
  1743. FALSE
  1744. );
  1745. //ArrangeLayout();
  1746. _SyncActivePage();
  1747. _TrickSyncActviveChild();
  1748. } // if( pTabCtrl != NULL )
  1749. } // if child sheet window
  1750. } // if valid window
  1751. }
  1752. void CExtResizablePropertySheet::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
  1753. {
  1754. CExtWA < CExtWS < __BASEOF_CExtResizablePropertySheet__ > > :: OnWindowPosChanged(lpwndpos);
  1755. // if( GetSafeHwnd() != NULL
  1756. // && ( GetStyle() & (WS_CHILD|WS_VISIBLE) ) == (WS_CHILD|WS_VISIBLE)
  1757. // )
  1758. // { // if valid visible sheet
  1759. // CTabCtrl * pTabCtrl = GetTabControl();
  1760. // if( pTabCtrl != NULL )
  1761. // {
  1762. // CRect rcClient;
  1763. // GetClientRect( &rcClient );
  1764. // pTabCtrl->MoveWindow( 0, 0, rcClient.Width(), rcClient.Height(), FALSE );
  1765. // //ArrangeLayout();
  1766. // //_TrickSyncActviveChild();
  1767. // } // if( pTabCtrl != NULL )
  1768. _SyncActivePage();
  1769. _TrickSyncActviveChild();
  1770. // } // if valid visible sheet
  1771. }
  1772. void CExtResizablePropertySheet::OnResizablePropertySheetInitialized()
  1773. {
  1774. _InitSizeGripper();
  1775. if( ( GetStyle() & WS_CHILD ) != 0 )
  1776. {
  1777. _TrickSyncActviveChild();
  1778. } // if( ( GetStyle() & WS_CHILD ) != 0 )
  1779. else
  1780. {
  1781. // + (2.25)
  1782. ModifyStyle( 0, WS_CLIPCHILDREN );
  1783. if( m_bEnableSaveRestore )
  1784. LoadWindowRect();
  1785. } // else from if( ( GetStyle() & WS_CHILD ) != 0 )
  1786. SetWindowPos(
  1787. NULL, 0, 0, 0, 0,
  1788. SWP_NOSIZE|SWP_NOMOVE
  1789. |SWP_NOCOPYBITS
  1790. |SWP_NOZORDER|SWP_NOOWNERZORDER
  1791. |SWP_FRAMECHANGED
  1792. );
  1793. //CTabCtrl * pTabCtrl = CPropertySheet::GetTabControl();
  1794. // if( pTabCtrl != NULL
  1795. // && pTabCtrl->GetSafeHwnd() != NULL
  1796. // )
  1797. // pTabCtrl->ModifyStyle( TCS_MULTILINE, 0, SWP_FRAMECHANGED );
  1798. //ArrangeLayout();
  1799. _SyncActivePage();
  1800. }
  1801. void CExtResizablePropertySheet::_TrickSyncActviveChild()
  1802. {
  1803. }