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

界面编程

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "Skinable.h"
  5. #include "MainFrm.h"
  6. #if (!defined __EXT_MFC_NO_SHELL)
  7. #if (!defined __EXT_CONTROLS_SHELL_H)
  8. #include <ExtControlsShell.h>
  9. #endif
  10. #endif
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CDialogThemes
  18. CDialogThemes::CDialogThemes()
  19. : CExtResizableDialog( CDialogThemes::IDD )
  20. {
  21. //{{AFX_DATA_INIT(CDialogThemes)
  22. //}}AFX_DATA_INIT
  23. }
  24. CDialogThemes::~CDialogThemes()
  25. {
  26. }
  27. bool CDialogThemes::CreateInsideBar(
  28. CExtControlBar * pBar
  29. )
  30. {
  31. ASSERT_VALID( this );
  32. ASSERT_VALID( pBar );
  33. ASSERT( GetSafeHwnd() == NULL );
  34. ASSERT( pBar->GetSafeHwnd() != NULL );
  35. if( ! CExtResizableDialog::Create( IDD, pBar ) )
  36. return false;
  37. return true;
  38. }
  39. void CDialogThemes::InvokeMainFrameCommand( UINT nCmdID )
  40. {
  41. ASSERT_VALID( this );
  42. ASSERT( GetSafeHwnd() != NULL );
  43. CFrameWnd * pFrame = GetParentFrame();
  44. ASSERT_VALID( pFrame );
  45. CMainFrame * pMainFrame = DYNAMIC_DOWNCAST( CMainFrame, pFrame );
  46. if( pMainFrame == NULL )
  47. {
  48. pFrame = pFrame->GetParentFrame();
  49. ASSERT_VALID( pFrame );
  50. pMainFrame = STATIC_DOWNCAST( CMainFrame, pFrame );
  51. }
  52. pMainFrame->SendMessage( WM_COMMAND, WPARAM(nCmdID) );
  53. }
  54. void CDialogThemes::DoDataExchange( CDataExchange * pDX )
  55. {
  56. CExtResizableDialog::DoDataExchange( pDX );
  57. //{{AFX_DATA_MAP(CDialogThemes)
  58. DDX_Control(pDX, IDC_BUTTON_THEME_2005, m_wndButtonInstallTheme2005);
  59. DDX_Control(pDX, IDC_BUTTON_THEME_2003, m_wndButtonInstallTheme2003);
  60. DDX_Control(pDX, IDC_BUTTON_THEME_XP, m_wndButtonInstallThemeXP);
  61. DDX_Control(pDX, IDC_BUTTON_THEME_2000, m_wndButtonInstallTheme2000);
  62. DDX_Control(pDX, IDC_BUTTON_LOAD_THEME_BIN, m_wndButtonLoadThemeBIN);
  63. DDX_Control(pDX, IDC_BUTTON_LOAD_THEME_XML, m_wndButtonLoadThemeXML);
  64. //}}AFX_DATA_MAP
  65. }
  66. BEGIN_MESSAGE_MAP( CDialogThemes, CExtResizableDialog )
  67. //{{AFX_MSG_MAP(CDialogThemes)
  68. ON_BN_CLICKED(IDC_BUTTON_LOAD_THEME_XML, OnButtonLoadThemeXml)
  69. ON_BN_CLICKED(IDC_BUTTON_LOAD_THEME_BIN, OnButtonLoadThemeBin)
  70. ON_BN_CLICKED(IDC_BUTTON_THEME_2005, OnButtonTheme2005)
  71. ON_BN_CLICKED(IDC_BUTTON_THEME_2003, OnButtonTheme2003)
  72. ON_BN_CLICKED(IDC_BUTTON_THEME_XP, OnButtonThemeXp)
  73. ON_BN_CLICKED(IDC_BUTTON_THEME_2000, OnButtonTheme2000)
  74. //}}AFX_MSG_MAP
  75. END_MESSAGE_MAP()
  76. BOOL CDialogThemes::OnInitDialog() 
  77. {
  78. if( ! CExtResizableDialog::OnInitDialog() )
  79. return FALSE;
  80. ShowSizeGrip( FALSE );
  81. m_wndButtonInstallTheme2005.m_bUseStdCommandNotification = true;
  82. m_wndButtonInstallTheme2003.m_bUseStdCommandNotification = true;
  83. m_wndButtonInstallThemeXP.m_bUseStdCommandNotification = true;
  84. m_wndButtonInstallTheme2000.m_bUseStdCommandNotification = true;
  85. m_wndButtonLoadThemeBIN.m_bUseStdCommandNotification = true;
  86. m_wndButtonLoadThemeXML.m_bUseStdCommandNotification = true;
  87. return TRUE;
  88. }
  89. void CDialogThemes::OnButtonLoadThemeXml() 
  90. {
  91. InvokeMainFrameCommand( IDC_THEME_LOAD_SKIN_XML );
  92. }
  93. void CDialogThemes::OnButtonLoadThemeBin() 
  94. {
  95. InvokeMainFrameCommand( IDC_THEME_LOAD_SKIN_BIN );
  96. }
  97. void CDialogThemes::OnButtonTheme2005() 
  98. {
  99. InvokeMainFrameCommand( IDC_THEME_2005 );
  100. }
  101. void CDialogThemes::OnButtonTheme2003() 
  102. {
  103. InvokeMainFrameCommand( IDC_THEME_2003 );
  104. }
  105. void CDialogThemes::OnButtonThemeXp() 
  106. {
  107. InvokeMainFrameCommand( IDC_THEME_XP );
  108. }
  109. void CDialogThemes::OnButtonTheme2000() 
  110. {
  111. InvokeMainFrameCommand( IDC_THEME_2000 );
  112. }
  113. /////////////////////////////////////////////////////////////////////////////
  114. // CDialogInvokeModalDialogs
  115. CDialogInvokeModalDialogs::CDialogInvokeModalDialogs()
  116. : CExtResizableDialog( CDialogInvokeModalDialogs::IDD )
  117. {
  118. //{{AFX_DATA_INIT(CDialogInvokeModalDialogs)
  119. //}}AFX_DATA_INIT
  120. }
  121. CDialogInvokeModalDialogs::~CDialogInvokeModalDialogs()
  122. {
  123. }
  124. bool CDialogInvokeModalDialogs::CreateInsideBar(
  125. CExtControlBar * pBar
  126. )
  127. {
  128. ASSERT_VALID( this );
  129. ASSERT_VALID( pBar );
  130. ASSERT( GetSafeHwnd() == NULL );
  131. ASSERT( pBar->GetSafeHwnd() != NULL );
  132. if( ! CExtResizableDialog::Create( IDD, pBar ) )
  133. return false;
  134. return true;
  135. }
  136. void CDialogInvokeModalDialogs::DoDataExchange( CDataExchange * pDX )
  137. {
  138. CExtResizableDialog::DoDataExchange( pDX );
  139. //{{AFX_DATA_MAP(CDialogInvokeModalDialogs)
  140. DDX_Control(pDX, IDC_BUTTON_INVOKE_ICON_EDITOR_DIALOG, m_wndButtonInvokeDialogIconEditor);
  141. DDX_Control(pDX, IDC_BUTTON_INVOKE_COLOR_DIALOG, m_wndButtonInvokeDialogColor);
  142. DDX_Control(pDX, IDC_BUTTON_INVOKE_ABOUT_DIALOG, m_wndButtonInvokeDialogAbout);
  143. DDX_Control(pDX, IDC_BUTTON_INVOKE_FILE_DIALOG, m_wndButtonInvokeFileDialog);
  144. DDX_Control(pDX, IDC_BUTTON_INVOKE_BFF_DIALOG, m_wndButtonInvokeBffDialog);
  145. //}}AFX_DATA_MAP
  146. }
  147. BEGIN_MESSAGE_MAP( CDialogInvokeModalDialogs, CExtResizableDialog )
  148. //{{AFX_MSG_MAP(CDialogInvokeModalDialogs)
  149. ON_BN_CLICKED(IDC_BUTTON_INVOKE_COLOR_DIALOG, OnButtonInvokeColorDialog)
  150. ON_BN_CLICKED(IDC_BUTTON_INVOKE_ICON_EDITOR_DIALOG, OnButtonInvokeIconEditorDialog)
  151. ON_BN_CLICKED(IDC_BUTTON_INVOKE_ABOUT_DIALOG, OnButtonInvokeAboutDialog)
  152. ON_BN_CLICKED(IDC_BUTTON_INVOKE_FILE_DIALOG, OnButtonInvokeFileDialog)
  153. ON_BN_CLICKED(IDC_BUTTON_INVOKE_BFF_DIALOG, OnButtonInvokeBffDialog)
  154. //}}AFX_MSG_MAP
  155. END_MESSAGE_MAP()
  156. BOOL CDialogInvokeModalDialogs::OnInitDialog() 
  157. {
  158. if( ! CExtResizableDialog::OnInitDialog() )
  159. return FALSE;
  160. ShowSizeGrip( FALSE );
  161. m_wndButtonInvokeDialogIconEditor.m_bUseStdCommandNotification = true;
  162. m_wndButtonInvokeDialogColor.m_bUseStdCommandNotification = true;
  163. m_wndButtonInvokeDialogAbout.m_bUseStdCommandNotification = true;
  164. m_wndButtonInvokeFileDialog.m_bUseStdCommandNotification = true;
  165. m_wndButtonInvokeBffDialog.m_bUseStdCommandNotification = true;
  166. return TRUE;
  167. }
  168. void CDialogInvokeModalDialogs::OnButtonInvokeColorDialog() 
  169. {
  170. CExtColorDlg dlgColor;
  171. dlgColor.DoModal();
  172. }
  173. void CDialogInvokeModalDialogs::OnButtonInvokeIconEditorDialog() 
  174. {
  175. #if (defined __EXT_MFC_NO_ICONEDITDLG)
  176. ::AfxMessageBox( _T("The CExtIconEditDlg class is not avaliable."), MB_ICONERROR );
  177. #else // (defined __EXT_MFC_NO_ICONEDITDLG)
  178. CExtIconEditDlg dlgIconEdit;
  179. dlgIconEdit.m_icon.AssignFromHICON(
  180. ::AfxGetApp()->LoadIcon( IDR_MAINFRAME ),
  181. false
  182. );
  183. dlgIconEdit.DoModal();
  184. #endif // else from (defined __EXT_MFC_NO_ICONEDITDLG)
  185. }
  186. void CDialogInvokeModalDialogs::OnButtonInvokeAboutDialog() 
  187. {
  188. VERIFY( ProfUISAbout() );
  189. }
  190. void CDialogInvokeModalDialogs::OnButtonInvokeFileDialog() 
  191. {
  192. #if (defined __EXT_MFC_NO_SHELL_DIALOG_FILE)
  193. ::AfxMessageBox( _T("The CExtShellDialogFile class is not avaliable."), MB_ICONERROR );
  194. #else // (defined __EXT_MFC_NO_SHELL_DIALOG_FILE)
  195. CExtShellDialogFile dlgShellFile;
  196. dlgShellFile.m_bEnableCollapsing = true;
  197. dlgShellFile.DoModal();
  198. #endif // else from (defined __EXT_MFC_NO_SHELL_DIALOG_FILE)
  199. }
  200. void CDialogInvokeModalDialogs::OnButtonInvokeBffDialog() 
  201. {
  202. #if (defined __EXT_MFC_NO_SHELL_DIALOG_BFF)
  203. ::AfxMessageBox( _T("The CExtShellDialogBrowseFor class is not avaliable."), MB_ICONERROR );
  204. #else // (defined __EXT_MFC_NO_SHELL_DIALOG_BFF)
  205. CExtShellDialogBrowseFor dlgShellBrowseFor;
  206. dlgShellBrowseFor.DoModal();
  207. #endif // else from (defined __EXT_MFC_NO_SHELL_DIALOG_BFF)
  208. }
  209. /////////////////////////////////////////////////////////////////////////////
  210. // CDialogInputFields
  211. CDialogInputFields::CDialogInputFields()
  212. : CExtResizableDialog( CDialogInputFields::IDD )
  213. {
  214. //{{AFX_DATA_INIT(CDialogInputFields)
  215. //}}AFX_DATA_INIT
  216. }
  217. CDialogInputFields::~CDialogInputFields()
  218. {
  219. }
  220. bool CDialogInputFields::CreateInsideBar(
  221. CExtControlBar * pBar
  222. )
  223. {
  224. ASSERT_VALID( this );
  225. ASSERT_VALID( pBar );
  226. ASSERT( GetSafeHwnd() == NULL );
  227. ASSERT( pBar->GetSafeHwnd() != NULL );
  228. if( ! CExtResizableDialog::Create( IDD, pBar ) )
  229. return false;
  230. return true;
  231. }
  232. void CDialogInputFields::DoDataExchange( CDataExchange * pDX )
  233. {
  234. CExtResizableDialog::DoDataExchange( pDX );
  235. //{{AFX_DATA_MAP(CDialogInputFields)
  236. DDX_Control(pDX, IDC_SPIN6, m_wndSpin6);
  237. DDX_Control(pDX, IDC_SPIN5, m_wndSpin5);
  238. DDX_Control(pDX, IDC_SPIN4, m_wndSpin4);
  239. DDX_Control(pDX, IDC_SPIN3, m_wndSpin3);
  240. DDX_Control(pDX, IDC_EDIT6, m_wndEdit6);
  241. DDX_Control(pDX, IDC_EDIT5, m_wndEdit5);
  242. DDX_Control(pDX, IDC_EDIT4, m_wndEdit4);
  243. DDX_Control(pDX, IDC_EDIT3, m_wndEdit3);
  244. DDX_Control(pDX, IDC_EDIT2, m_wndEdit2);
  245. DDX_Control(pDX, IDC_EDIT1, m_wndEdit1);
  246. DDX_Control(pDX, IDC_STATIC6, m_wndLabel6);
  247. DDX_Control(pDX, IDC_STATIC5, m_wndLabel5);
  248. DDX_Control(pDX, IDC_STATIC4, m_wndLabel4);
  249. DDX_Control(pDX, IDC_STATIC3, m_wndLabel3);
  250. DDX_Control(pDX, IDC_STATIC2, m_wndLabel2);
  251. DDX_Control(pDX, IDC_STATIC1, m_wndLabel1);
  252. DDX_Control(pDX, IDC_COMBO4, m_wndCombo4);
  253. DDX_Control(pDX, IDC_COMBO3, m_wndCombo3);
  254. DDX_Control(pDX, IDC_COMBO2, m_wndCombo2);
  255. DDX_Control(pDX, IDC_COMBO1, m_wndCombo1);
  256. //}}AFX_DATA_MAP
  257. }
  258. BEGIN_MESSAGE_MAP( CDialogInputFields, CExtResizableDialog )
  259. //{{AFX_MSG_MAP(CDialogInputFields)
  260. //}}AFX_MSG_MAP
  261. END_MESSAGE_MAP()
  262. BOOL CDialogInputFields::OnInitDialog() 
  263. {
  264. if( ! CExtResizableDialog::OnInitDialog() )
  265. return FALSE;
  266. ShowSizeGrip( FALSE );
  267. return TRUE;
  268. }
  269. #if (!defined __EXT_MFC_NO_DURATIONWND ) && (!defined __EXT_MFC_NO_DATETIMEWND)
  270. /////////////////////////////////////////////////////////////////////////////
  271. // CDialogDateTimeDuration message handlers
  272. CDialogDateTimeDuration::CDialogDateTimeDuration(CWnd* pParent /*=NULL*/)
  273. : CExtResizableDialog(CDialogDateTimeDuration::IDD, pParent)
  274. , m_bInitComplete( false )
  275. {
  276. //{{AFX_DATA_INIT(CDialogDateTimeDuration)
  277. m_nTimeFormat = -1;
  278. m_nMode = -1;
  279. //}}AFX_DATA_INIT
  280. }
  281. bool CDialogDateTimeDuration::CreateInsideBar(
  282. CExtControlBar * pBar
  283. )
  284. {
  285. ASSERT_VALID( this );
  286. ASSERT_VALID( pBar );
  287. ASSERT( GetSafeHwnd() == NULL );
  288. ASSERT( pBar->GetSafeHwnd() != NULL );
  289. if( ! CExtResizableDialog::Create( IDD, pBar ) )
  290. return false;
  291. return true;
  292. }
  293. void CDialogDateTimeDuration::DoDataExchange(CDataExchange* pDX)
  294. {
  295. CExtResizableDialog::DoDataExchange(pDX);
  296. //{{AFX_DATA_MAP(CDialogDateTimeDuration)
  297. DDX_Control(pDX, IDC_CHECK_DISABLED_DURATION, m_wndDisabledDuration);
  298. DDX_Control(pDX, IDC_CHECK_DISABLED_DATETIME, m_wndDisabledDateTime);
  299. DDX_Control(pDX, IDC_CHECK_MODE_SECONDS, m_wndModeSeconds);
  300. DDX_Control(pDX, IDC_CHECK_MODE_MINUTES, m_wndModeMinutes);
  301. DDX_Control(pDX, IDC_CHECK_MODE_HOURS, m_wndModeHours);
  302. DDX_Control(pDX, IDC_CHECK_MODE_DAYS, m_wndModeDays);
  303. DDX_Control(pDX, IDC_STATIC_NOTIFICATIONS, m_wndLabelNotifications);
  304. DDX_Control(pDX, IDC_CHECK_CONTINUOUS_DATETIME, m_wndContinuousDateTime);
  305. DDX_Control(pDX, IDC_CHECK_CONTINUOUS_DURATION, m_wndContinuousDuration);
  306. DDX_Control(pDX, IDC_STATIC_TIME_FORMAT, m_wndBoxTimeFormat);
  307. DDX_Control(pDX, IDC_STATIC_MODE_DATETIME, m_wndBoxModeDateTime);
  308. DDX_Control(pDX, IDC_STATIC_MODE_DURATION, m_wndBoxModeDuration);
  309. DDX_Control(pDX, IDC_CHECK_BTN_SPIN_DATETIME, m_wndBtnSpinDateTime);
  310. DDX_Control(pDX, IDC_CHECK_BTN_SPIN_DURATION, m_wndBtnSpinDuration);
  311. DDX_Control(pDX, IDC_CHECK_BTN_DROP_DOWN, m_wndBtnDropDown);
  312. DDX_Control(pDX, IDC_NOTIFICATIONS, m_wndNotifications);
  313. DDX_Control(pDX, IDC_TEXT_COLOR_DATETIME, m_wndColorTextDateTime);
  314. DDX_Control(pDX, IDC_BACK_COLOR_DATETIME, m_wndColorBackDateTime);
  315. DDX_Control(pDX, IDC_ADJUST_SIZE_DATETIME, m_wndAdjustSizeDateTime);
  316. DDX_Control(pDX, IDC_TEXT_COLOR_DURATION, m_wndColorTextDuration);
  317. DDX_Control(pDX, IDC_BACK_COLOR_DURATION, m_wndColorBackDuration);
  318. DDX_Control(pDX, IDC_ADJUST_SIZE_DURATION, m_wndAdjustSizeDuration);
  319. DDX_Control(pDX, IDC_STATIC_DURATION, m_wndBoxDuration);
  320. DDX_Control(pDX, IDC_STATIC_DATE_TIME, m_wndBoxDateTime);
  321. DDX_Control(pDX, IDC_DURATION, m_wndDuration);
  322. DDX_Control(pDX, IDC_DATETIME, m_wndDateTime);
  323. DDX_Radio(pDX, IDC_TIME_FORMAT_AUTO, m_nTimeFormat);
  324. DDX_Radio(pDX, IDC_MODE_TIME, m_nMode);
  325. DDX_Control(pDX, IDC_TIME_FORMAT_AUTO, m_wndTimeFormatAuto);
  326. DDX_Control(pDX, IDC_TIME_FORMAT_H12, m_wndTimeFormatH12);
  327. DDX_Control(pDX, IDC_TIME_FORMAT_H24, m_wndTimeFormatH24);
  328. DDX_Control(pDX, IDC_MODE_TIME, m_wndModeTime);
  329. DDX_Control(pDX, IDC_MODE_DATE, m_wndModeDate);
  330. DDX_Control(pDX, IDC_MODE_DATE_TIME, m_wndModeDateTime);
  331. //}}AFX_DATA_MAP
  332. }
  333. BEGIN_MESSAGE_MAP(CDialogDateTimeDuration, CExtResizableDialog)
  334. //{{AFX_MSG_MAP(CDialogDateTimeDuration)
  335. //}}AFX_MSG_MAP
  336. ON_REGISTERED_MESSAGE(
  337. CExtDurationWnd::g_nMsgChangingNotification,
  338. OnSelChangedDuration
  339. )
  340. ON_REGISTERED_MESSAGE(
  341. CExtDateTimeWnd::g_nMsgChangingNotification,
  342. OnSelChangedDateTime
  343. )
  344. ON_REGISTERED_MESSAGE(
  345. CExtPopupColorMenuWnd::g_nMsgNotifyColorChangedFinally,
  346. OnColorChanged
  347. )
  348. END_MESSAGE_MAP()
  349. BOOL CDialogDateTimeDuration::OnInitDialog() 
  350. {
  351. if( ! CExtResizableDialog::OnInitDialog() )
  352. return FALSE;
  353. ShowSizeGrip( FALSE );
  354. m_wndColorTextDateTime.m_lParamCookie = LPARAM(IDC_TEXT_COLOR_DATETIME);
  355. m_wndColorBackDateTime.m_lParamCookie = LPARAM(IDC_BACK_COLOR_DATETIME);
  356. m_wndColorTextDateTime.m_clrDefault = 
  357. m_wndColorTextDateTime.m_clrSelected = m_wndDateTime.GetTextColor();
  358. m_wndColorBackDateTime.m_clrDefault = 
  359. m_wndColorBackDateTime.m_clrSelected = m_wndDateTime.GetBkColor();
  360. m_wndColorTextDuration.m_lParamCookie = LPARAM(IDC_TEXT_COLOR_DURATION);
  361. m_wndColorBackDuration.m_lParamCookie = LPARAM(IDC_BACK_COLOR_DURATION);
  362. m_wndColorTextDuration.m_clrDefault = 
  363. m_wndColorTextDuration.m_clrSelected = m_wndDuration.GetTextColor();
  364. m_wndColorBackDuration.m_clrDefault = 
  365. m_wndColorBackDuration.m_clrSelected = m_wndDuration.GetBkColor();
  366. m_wndDuration.m_lParamCookie = LPARAM(IDC_DURATION);
  367. m_wndDateTime.m_lParamCookie = LPARAM(IDC_DATETIME);
  368. m_wndDateTime.SetDateTime( COleDateTime::GetCurrentTime() );
  369. ::CheckDlgButton( 
  370. this->GetSafeHwnd(), 
  371. IDC_CHECK_DISABLED_DATETIME, 
  372. !m_wndDateTime.IsWindowEnabled()
  373. ? BST_CHECKED
  374. : BST_UNCHECKED
  375. );
  376. ::CheckDlgButton( 
  377. this->GetSafeHwnd(), 
  378. IDC_CHECK_DISABLED_DURATION, 
  379. !m_wndDuration.IsWindowEnabled()
  380. ? BST_CHECKED
  381. : BST_UNCHECKED
  382. );
  383. ::CheckDlgButton( 
  384. this->GetSafeHwnd(), 
  385. IDC_CHECK_CONTINUOUS_DATETIME, 
  386. m_wndDateTime.GetContinuousScrolling()
  387. );
  388. ::CheckDlgButton( 
  389. this->GetSafeHwnd(), 
  390. IDC_CHECK_CONTINUOUS_DURATION, 
  391. m_wndDuration.GetContinuousScrolling()
  392. );
  393. ::CheckDlgButton( 
  394. this->GetSafeHwnd(), 
  395. IDC_CHECK_BTN_DROP_DOWN, 
  396. m_wndDateTime.IsDropDownButtonVisible()
  397. );
  398. ::CheckDlgButton( 
  399. this->GetSafeHwnd(), 
  400. IDC_CHECK_BTN_SPIN_DATETIME, 
  401. m_wndDateTime.IsSpinButtonVisible()
  402. );
  403. ::CheckDlgButton( 
  404. this->GetSafeHwnd(), 
  405. IDC_CHECK_BTN_SPIN_DURATION, 
  406. m_wndDuration.IsSpinButtonVisible()
  407. );
  408. ::CheckDlgButton( 
  409. this->GetSafeHwnd(), 
  410. IDC_CHECK_MODE_DAYS, 
  411. m_wndDuration.IsItemVisible( CExtDurationWnd::day )
  412. );
  413. ::CheckDlgButton( 
  414. this->GetSafeHwnd(), 
  415. IDC_CHECK_MODE_HOURS, 
  416. m_wndDuration.IsItemVisible( CExtDurationWnd::hour )
  417. );
  418. ::CheckDlgButton( 
  419. this->GetSafeHwnd(), 
  420. IDC_CHECK_MODE_MINUTES, 
  421. m_wndDuration.IsItemVisible( CExtDurationWnd::minute )
  422. );
  423. ::CheckDlgButton( 
  424. this->GetSafeHwnd(), 
  425. IDC_CHECK_MODE_SECONDS, 
  426. m_wndDuration.IsItemVisible( CExtDurationWnd::second )
  427. );
  428. CExtDateTimeWnd::eMode_t eMode = m_wndDateTime.GetMode();
  429. switch( eMode ) 
  430. {
  431. case CExtDateTimeWnd::time:
  432. m_nMode = 0;
  433. break;
  434. case CExtDateTimeWnd::date:
  435. m_nMode = 1;
  436. break;
  437. case CExtDateTimeWnd::all:
  438. m_nMode = 2;
  439. break;
  440. }
  441. CExtDateTimeWnd::eTimeFormat_t eTimeFormat = m_wndDateTime.GetTimeFormat();
  442. switch( eTimeFormat ) 
  443. {
  444. case CExtDateTimeWnd::automatic:
  445. m_nTimeFormat = 0;
  446. break;
  447. case CExtDateTimeWnd::h24:
  448. m_nTimeFormat = 1;
  449. break;
  450. case CExtDateTimeWnd::h12:
  451. m_nTimeFormat = 2;
  452. break;
  453. }
  454. UpdateData( 0 );
  455. m_bInitComplete = true;
  456. return TRUE;  // return TRUE unless you set the focus to a control
  457.               // EXCEPTION: OCX Property Pages should return FALSE
  458. }
  459. LRESULT CDialogDateTimeDuration::OnSelChangedDuration( WPARAM wParam, LPARAM lParam )
  460. {
  461. ASSERT_VALID( this );
  462. lParam;
  463. const CExtDurationWnd::CHANGING_NOTIFICATION * pCN =
  464. CExtDurationWnd::CHANGING_NOTIFICATION::FromWPARAM( wParam );
  465. ASSERT( pCN != NULL );
  466. if( pCN->m_lParamCookie == LPARAM(IDC_DURATION) )
  467. {
  468. CString strMsg, strMsgAll;
  469. strMsg.Format(
  470. _T("Duration: %s (old - %d sec, new - %d sec)"),
  471. pCN->m_bChangedFinally ? _T("changed") : _T("changing"),
  472. (LONG) pCN->m_dtSpanOld.GetTotalSeconds(),
  473. (LONG) pCN->m_dtSpanNew.GetTotalSeconds()
  474. );
  475. strMsg += _T("rn");
  476. m_wndNotifications.GetWindowText( strMsgAll );
  477. m_wndNotifications.SetWindowText( strMsgAll + strMsg );
  478. int nCharCount = strMsgAll.GetLength() + strMsg.GetLength();
  479. m_wndNotifications.SetSel(nCharCount-1,nCharCount-1);
  480. }
  481. return 0L;
  482. }
  483. LRESULT CDialogDateTimeDuration::OnSelChangedDateTime( WPARAM wParam, LPARAM lParam )
  484. {
  485. ASSERT_VALID( this );
  486. lParam;
  487. const CExtDateTimeWnd::CHANGING_NOTIFICATION * pCN =
  488. CExtDateTimeWnd::CHANGING_NOTIFICATION::FromWPARAM( wParam );
  489. ASSERT( pCN != NULL );
  490. if( pCN->m_lParamCookie == LPARAM(IDC_DATETIME) )
  491. {
  492. CString strMsg, strMsgAll;
  493. strMsg.Format(
  494. _T("DateTime: %s (old - %s, new - %s)"),
  495. pCN->m_bChangedFinally ? _T("changed") : _T("changing"),
  496. pCN->m_dtDateTimeOld.Format(),
  497. pCN->m_dtDateTimeNew.Format()
  498. );
  499. strMsg += _T("rn");
  500. m_wndNotifications.GetWindowText( strMsgAll );
  501. m_wndNotifications.SetWindowText( strMsgAll + strMsg );
  502. int nCharCount = strMsgAll.GetLength() + strMsg.GetLength();
  503. m_wndNotifications.SetSel(nCharCount-1,nCharCount-1);
  504. }
  505. return 0L;
  506. }
  507. LRESULT CDialogDateTimeDuration::OnColorChanged(WPARAM wParam, LPARAM lParam)
  508. {
  509. COLORREF clrColor = COLORREF(wParam);
  510. switch( lParam )
  511. {
  512. case IDC_TEXT_COLOR_DATETIME:
  513. m_wndDateTime.SetTextColor( clrColor );
  514. break;
  515. case IDC_BACK_COLOR_DATETIME:
  516. m_wndDateTime.SetBkColor( clrColor );
  517. break;
  518. case IDC_TEXT_COLOR_DURATION:
  519. m_wndDuration.SetTextColor( clrColor );
  520. break;
  521. case IDC_BACK_COLOR_DURATION:
  522. m_wndDuration.SetBkColor( clrColor );
  523. break;
  524. default:
  525. break;
  526. } // switch( lParam )
  527. return 0;
  528. }
  529. BOOL CDialogDateTimeDuration::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  530. {
  531. if( !m_bInitComplete )
  532. return CExtResizableDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  533. if( nCode == CN_COMMAND )
  534. {
  535. bool bChecked = IsDlgButtonChecked( nID ) ? true : false;
  536. switch( nID )
  537. {
  538. case IDC_CHECK_DISABLED_DATETIME:
  539. m_wndDateTime.EnableWindow( !bChecked );
  540. break;
  541. case IDC_CHECK_DISABLED_DURATION:
  542. m_wndDuration.EnableWindow( !bChecked );
  543. break;
  544. case IDC_CHECK_CONTINUOUS_DATETIME:
  545. m_wndDateTime.SetContinuousScrolling( bChecked );
  546. break;
  547. case IDC_CHECK_CONTINUOUS_DURATION:
  548. m_wndDuration.SetContinuousScrolling( bChecked );
  549. break;
  550. case IDC_CHECK_BTN_DROP_DOWN:
  551. m_wndDateTime.ShowDropDownButton( bChecked );
  552. break;
  553. case IDC_CHECK_BTN_SPIN_DATETIME:
  554. m_wndDateTime.ShowSpinButton( bChecked );
  555. break;
  556. case IDC_CHECK_BTN_SPIN_DURATION:
  557. m_wndDuration.ShowSpinButton( bChecked );
  558. break;
  559. case IDC_ADJUST_SIZE_DATETIME:
  560. m_wndDateTime.AdjustSize();
  561. m_wndBoxDateTime.Invalidate();
  562. break;
  563. case IDC_ADJUST_SIZE_DURATION:
  564. m_wndDuration.AdjustSize();
  565. m_wndBoxDuration.Invalidate();
  566. break;
  567. case IDC_TIME_FORMAT_AUTO:
  568. case IDC_TIME_FORMAT_H24:
  569. case IDC_TIME_FORMAT_H12:
  570. {
  571. UpdateData();
  572. CExtDateTimeWnd::eTimeFormat_t eTimeFormat = CExtDateTimeWnd::automatic;
  573. switch( m_nTimeFormat ) 
  574. {
  575. case 0:
  576. eTimeFormat = CExtDateTimeWnd::automatic;
  577. break;
  578. case 1:
  579. eTimeFormat = CExtDateTimeWnd::h24;
  580. break;
  581. case 2:
  582. eTimeFormat = CExtDateTimeWnd::h12;
  583. break;
  584. }
  585. m_wndDateTime.SetTimeFormat( eTimeFormat );
  586. }
  587. break;
  588. case IDC_MODE_TIME:
  589. case IDC_MODE_DATE:
  590. case IDC_MODE_DATE_TIME:
  591. {
  592. UpdateData();
  593. CExtDateTimeWnd::eMode_t eMode = CExtDateTimeWnd::all;
  594. switch( m_nMode ) 
  595. {
  596. case 0:
  597. eMode = CExtDateTimeWnd::time;
  598. break;
  599. case 1:
  600. eMode = CExtDateTimeWnd::date;
  601. break;
  602. case 2:
  603. eMode = CExtDateTimeWnd::all;
  604. break;
  605. }
  606. m_wndDateTime.SetMode( eMode );
  607. }
  608. break;
  609. case IDC_CHECK_MODE_DAYS:
  610. m_wndDuration.SetShowItem( CExtDurationWnd::day, bChecked );
  611. break;
  612. case IDC_CHECK_MODE_HOURS:
  613. m_wndDuration.SetShowItem( CExtDurationWnd::hour, bChecked );
  614. break;
  615. case IDC_CHECK_MODE_MINUTES:
  616. m_wndDuration.SetShowItem( CExtDurationWnd::minute, bChecked );
  617. break;
  618. case IDC_CHECK_MODE_SECONDS:
  619. m_wndDuration.SetShowItem( CExtDurationWnd::second, bChecked );
  620. break;
  621. default:
  622. return CExtResizableDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  623. }
  624. return TRUE;
  625. }
  626. return CExtResizableDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  627. }
  628. #endif // (!defined __EXT_MFC_NO_DURATIONWND ) && (!defined __EXT_MFC_NO_DATETIMEWND)
  629. /////////////////////////////////////////////////////////////////////////////
  630. // CDialogButtons
  631. CDialogButtons::CDialogButtons()
  632. : CExtResizableDialog( CDialogButtons::IDD )
  633. {
  634. //{{AFX_DATA_INIT(CDialogButtons)
  635. //}}AFX_DATA_INIT
  636. }
  637. CDialogButtons::~CDialogButtons()
  638. {
  639. }
  640. bool CDialogButtons::CreateInsideBar(
  641. CExtControlBar * pBar
  642. )
  643. {
  644. ASSERT_VALID( this );
  645. ASSERT_VALID( pBar );
  646. ASSERT( GetSafeHwnd() == NULL );
  647. ASSERT( pBar->GetSafeHwnd() != NULL );
  648. if( ! CExtResizableDialog::Create( IDD, pBar ) )
  649. return false;
  650. return true;
  651. }
  652. void CDialogButtons::DoDataExchange( CDataExchange * pDX )
  653. {
  654. CExtResizableDialog::DoDataExchange( pDX );
  655. //{{AFX_DATA_MAP(CDialogButtons)
  656. DDX_Control( pDX, IDC_BUTTON_DISABLED_1, m_wndButtonDisabled1 );
  657. DDX_Control( pDX, IDC_BUTTON_NORMAL_1,   m_wndButtonNormal1 );
  658. DDX_Control( pDX, IDC_BUTTON_DEFAULT_1,  m_wndButtonDefault1 );
  659. DDX_Control( pDX, IDC_BUTTON_DISABLED_2, m_wndButtonDisabled2 );
  660. DDX_Control( pDX, IDC_BUTTON_NORMAL_2,   m_wndButtonNormal2 );
  661. DDX_Control( pDX, IDC_BUTTON_DEFAULT_2,  m_wndButtonDefault2 );
  662. DDX_Control( pDX, IDC_BUTTON_DISABLED_3, m_wndButtonDisabled3 );
  663. DDX_Control( pDX, IDC_BUTTON_NORMAL_3,   m_wndButtonNormal3 );
  664. DDX_Control( pDX, IDC_BUTTON_DEFAULT_3,  m_wndButtonDefault3 );
  665. DDX_Control( pDX, IDC_BUTTON_NORMAL_4,   m_wndButtonNormal4 );
  666. DDX_Control( pDX, IDC_BUTTON_DISABLED_4, m_wndButtonDefault4 );
  667. DDX_Control( pDX, IDC_BUTTON_DISABLED_5, m_wndButtonDisabled5 );
  668. DDX_Control( pDX, IDC_BUTTON_NORMAL_5,   m_wndButtonNormal5 );
  669. DDX_Control( pDX, IDC_BUTTON_DEFAULT_5,  m_wndButtonDefault5 );
  670. DDX_Control( pDX, IDC_BUTTON_DISABLED_6, m_wndButtonDisabled6 );
  671. DDX_Control( pDX, IDC_BUTTON_NORMAL_6,   m_wndButtonNormal6 );
  672. DDX_Control( pDX, IDC_BUTTON_DEFAULT_6,  m_wndButtonDefault6 );
  673. DDX_Control( pDX, IDC_BUTTON_CHECK_DIABLED,     m_wndCheckDisabled );
  674. DDX_Control( pDX, IDC_BUTTON_CHECK_THREE_STATE, m_wndCheckThreeState );
  675. DDX_Control( pDX, IDC_BUTTON_CHECK_TWO_STATE,   m_wndCheckTwoState );
  676. DDX_Control( pDX, IDC_BUTTON_RADIO_DISABLED,    m_wndRadioDisabled );
  677. DDX_Control( pDX, IDC_BUTTON_RADIO_2,           m_wndRadio2 );
  678. DDX_Control( pDX, IDC_BUTTON_RADIO_1,           m_wndRadio1 );
  679. DDX_Control( pDX, IDC_GROUP_BOX_1, m_wndGroupBox1 );
  680. DDX_Control( pDX, IDC_GROUP_BOX_2, m_wndGroupBox2 );
  681. DDX_Control( pDX, IDC_GROUP_BOX_3, m_wndGroupBox3 );
  682. DDX_Control( pDX, IDC_GROUP_BOX_4, m_wndGroupBox4 );
  683. DDX_Control( pDX, IDC_GROUP_BOX_5, m_wndGroupBox5 );
  684. DDX_Control( pDX, IDC_GROUP_BOX_6, m_wndGroupBox6 );
  685. DDX_Control( pDX, IDC_GROUP_BOX_7, m_wndGroupBox7 );
  686. DDX_Control( pDX, IDC_GROUP_BOX_8, m_wndGroupBox8 );
  687. DDX_Control( pDX, IDC_GROUP_BOX_9, m_wndGroupBox9 );
  688. //}}AFX_DATA_MAP
  689. }
  690. BEGIN_MESSAGE_MAP( CDialogButtons, CExtResizableDialog )
  691. //{{AFX_MSG_MAP(CDialogButtons)
  692. ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  693. ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  694. ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  695. //}}AFX_MSG_MAP
  696. END_MESSAGE_MAP()
  697. BOOL CDialogButtons::OnInitDialog() 
  698. {
  699. if( ! CExtResizableDialog::OnInitDialog() )
  700. return FALSE;
  701. ShowSizeGrip( FALSE );
  702. // m_wndButtonDisabled1.SetIcon( GetSmallIconForButton() );
  703. // m_wndButtonNormal1.SetIcon( GetSmallIconForButton() );
  704. // m_wndButtonDefault1.SetIcon( GetSmallIconForButton() );
  705. // m_wndButtonDisabled2.SetIcon( GetSmallIconForButton() );
  706. // m_wndButtonNormal2.SetIcon( GetSmallIconForButton() );
  707. // m_wndButtonDefault2.SetIcon( GetSmallIconForButton() );
  708. VERIFY( m_wndButtonDisabled2.m_menu.LoadMenu( IDR_MENU_IN_BUTTON ) );
  709. VERIFY( m_wndButtonNormal2.m_menu.LoadMenu( IDR_MENU_IN_BUTTON ) );
  710. VERIFY( m_wndButtonDefault2.m_menu.LoadMenu( IDR_MENU_IN_BUTTON ) );
  711. m_wndButtonDisabled3.SetIcon( GetSmallIconForButton() );
  712. m_wndButtonNormal3.SetIcon( GetSmallIconForButton() );
  713. m_wndButtonDefault3.SetIcon( GetSmallIconForButton() );
  714. VERIFY( m_wndButtonDisabled3.m_menu.LoadMenu( IDR_MENU_IN_BUTTON ) );
  715. VERIFY( m_wndButtonNormal3.m_menu.LoadMenu( IDR_MENU_IN_BUTTON ) );
  716. VERIFY( m_wndButtonDefault3.m_menu.LoadMenu( IDR_MENU_IN_BUTTON ) );
  717. m_wndButtonDisabled3.SetSeparatedDropDown();
  718. m_wndButtonNormal3.SetSeparatedDropDown();
  719. m_wndButtonDefault3.SetSeparatedDropDown();
  720. m_wndButtonNormal4.m_strURL = _T("http://www.Prof-UIS.com");
  721. m_wndButtonDisabled5.m_clrSelected = RGB(192,0,0);
  722. m_wndButtonNormal5.m_clrSelected = RGB(0,192,0);
  723. m_wndButtonDefault5.m_clrSelected = RGB(0,0,192);
  724. m_wndButtonDisabled6.m_clrSelected = RGB(192,192,0);
  725. m_wndButtonNormal6.m_clrSelected = RGB(192,0,192);
  726. m_wndButtonDefault6.m_clrSelected = RGB(0,192,192);
  727. m_wndButtonDisabled6.SetSeparatedDropDown();
  728. m_wndButtonNormal6.SetSeparatedDropDown();
  729. m_wndButtonDefault6.SetSeparatedDropDown();
  730. m_wndCheckTwoState.SetCheck( 1 );
  731. m_wndCheckThreeState.SetCheck( 2 );
  732. m_wndCheckDisabled.SetCheck( 1 );
  733. m_wndRadio1.SetCheck( 1 );
  734. m_wndRadioDisabled.SetCheck( 1 );
  735. return TRUE;
  736. }
  737. void CDialogButtons::OnEditCopy() 
  738. {
  739. ::AfxMessageBox( _T("CDialogButtons::OnEditCopy()") );
  740. }
  741. void CDialogButtons::OnEditCut() 
  742. {
  743. ::AfxMessageBox( _T("CDialogButtons::OnEditCut()") );
  744. }
  745. void CDialogButtons::OnEditPaste() 
  746. {
  747. ::AfxMessageBox( _T("CDialogButtons::OnEditPaste()") );
  748. }
  749. /////////////////////////////////////////////////////////////////////////////
  750. // CColorControlsView
  751. CColorControlsView::CColorControlsView()
  752. : m_bSyncingValues( false )
  753. , m_bColorControlsVisible( false )
  754. {
  755. }
  756. CColorControlsView::~CColorControlsView()
  757. {
  758. }
  759. bool CColorControlsView::CreateInsideBar(
  760. CExtControlBar * pBar
  761. )
  762. {
  763. ASSERT_VALID( this );
  764. ASSERT_VALID( pBar );
  765. ASSERT( GetSafeHwnd() == NULL );
  766. ASSERT( pBar->GetSafeHwnd() != NULL );
  767. if( ! CWnd::Create(
  768. NULL,
  769. NULL,
  770. WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
  771. CRect( 0, 0, 0, 0 ),
  772. pBar,
  773. UINT(IDC_STATIC)
  774. )
  775. )
  776. return false;
  777. return true;
  778. }
  779. BEGIN_MESSAGE_MAP(CColorControlsView,CWnd )
  780. //{{AFX_MSG_MAP(CColorControlsView)
  781. ON_WM_PAINT()
  782. ON_WM_ERASEBKGND()
  783. ON_WM_CREATE()
  784. //}}AFX_MSG_MAP
  785. ON_REGISTERED_MESSAGE(CExtColorCtrl::g_nMsgColorChanged,OnColorChanged)
  786. END_MESSAGE_MAP()
  787. /////////////////////////////////////////////////////////////////////////////
  788. // CColorControlsView message handlers
  789. BOOL CColorControlsView::PreCreateWindow(CREATESTRUCT& cs) 
  790. {
  791. if( ! CWnd::PreCreateWindow( cs ) )
  792. return FALSE;
  793. cs.lpszClass =
  794. ::AfxRegisterWndClass(
  795. CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, 
  796. ::LoadCursor( NULL, IDC_ARROW ),
  797. HBRUSH( COLOR_WINDOW + 1 ),
  798. NULL
  799. );
  800. return TRUE;
  801. }
  802. void CColorControlsView::OnPaint() 
  803. {
  804. CPaintDC dcPaint( this );
  805. CExtPaintManager::stat_ExcludeChildAreas(
  806. dcPaint.GetSafeHdc(),
  807. GetSafeHwnd()
  808. );
  809. CExtMemoryDC dc( &dcPaint );
  810. if( ! g_PaintManager->PaintDockerBkgnd(true,dc,this) )
  811. {
  812. CRect rcClient;
  813. GetClientRect( &rcClient );
  814. dc.FillSolidRect(
  815. &rcClient,
  816. g_PaintManager->GetColor( COLOR_3DFACE )
  817. );
  818. }
  819. }
  820. BOOL CColorControlsView::OnEraseBkgnd(CDC* pDC) 
  821. {
  822. pDC;
  823. return TRUE;
  824. }
  825. int CColorControlsView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  826. {
  827. if (CWnd ::OnCreate(lpCreateStruct) == -1)
  828. return -1;
  829. VERIFY(
  830. m_wndColorCtrlRoller.Create(
  831. _T("BUTTON"),
  832. _T(""),
  833. WS_CHILD|WS_VISIBLE,
  834. CRect(10,10,230,200),
  835. this,
  836. 0x1FF
  837. )
  838. );
  839. m_wndColorCtrlRoller = CExtColorCtrl::MODE_HSL_ROLLER;
  840. VERIFY(
  841. m_wndColorCtrlCubeRGB.Create(
  842. _T("BUTTON"),
  843. _T(""),
  844. WS_CHILD|WS_VISIBLE,
  845. CRect(10,210,230,410),
  846. this,
  847. 0x200
  848. )
  849. );
  850. m_wndColorCtrlCubeRGB = CExtColorCtrl::MODE_RGB_CUBE;
  851. VERIFY(
  852. m_wndColorCtrlCubeCMY.Create(
  853. _T("BUTTON"),
  854. _T(""),
  855. WS_CHILD|WS_VISIBLE,
  856. CRect(240,210,460,410),
  857. this,
  858. 0x201
  859. )
  860. );
  861. m_wndColorCtrlCubeCMY = CExtColorCtrl::MODE_CMY_CUBE;
  862. VERIFY(
  863. m_wndColorCtrlHSL.Create(
  864. _T("BUTTON"),
  865. _T(""),
  866. WS_CHILD|WS_VISIBLE,
  867. CRect(240,10,460,200),
  868. this,
  869. 0x202
  870. )
  871. );
  872. m_wndColorCtrlHSL = CExtColorCtrl::MODE_HSL_PANEL;
  873. VERIFY(
  874. m_wndColorCtrlMixerRGB.Create(
  875. _T("BUTTON"),
  876. _T(""),
  877. WS_CHILD|WS_VISIBLE,
  878. CRect(470,210,690,410),
  879. this,
  880. 0x203
  881. )
  882. );
  883. m_wndColorCtrlMixerRGB = CExtColorCtrl::MODE_RGB_MIX;
  884. VERIFY(
  885. m_wndColorCtrlMixerCMY.Create(
  886. _T("BUTTON"),
  887. _T(""),
  888. WS_CHILD|WS_VISIBLE,
  889. CRect(470,10,690,200),
  890. this,
  891. 0x204
  892. )
  893. );
  894. m_wndColorCtrlMixerCMY = CExtColorCtrl::MODE_CMY_MIX;
  895. COLORREF clrInit = RGB(196,128,64);
  896. m_wndColorCtrlCubeRGB.SetupColor(clrInit,false);
  897. m_wndColorCtrlCubeCMY.SetupColor(clrInit,false);
  898. m_wndColorCtrlMixerRGB.SetupColor(clrInit,false);
  899. m_wndColorCtrlMixerCMY.SetupColor(clrInit,false);
  900. m_wndColorCtrlHSL.SetupColor(clrInit,false);
  901. return 0;
  902. }
  903. LRESULT CColorControlsView::OnColorChanged(WPARAM wParam,LPARAM lParam)
  904. {
  905. if( m_bSyncingValues )
  906. return 0;
  907. m_bSyncingValues = true;
  908. CExtColorCtrl::selection_colors_t * pClrs =
  909. (CExtColorCtrl::selection_colors_t *)lParam;
  910. ASSERT( pClrs != NULL );
  911. COLORREF clrNew = pClrs->m_clrNew;
  912. HWND hWndColorCtrlFrom = (HWND)wParam;
  913. ASSERT( ::IsWindow(hWndColorCtrlFrom) );
  914. if( hWndColorCtrlFrom != m_wndColorCtrlRoller.GetSafeHwnd() )
  915. m_wndColorCtrlRoller.SetupColor(clrNew,false);
  916. if( hWndColorCtrlFrom != m_wndColorCtrlCubeRGB.GetSafeHwnd() )
  917. m_wndColorCtrlCubeRGB.SetupColor(clrNew,false);
  918. if( hWndColorCtrlFrom != m_wndColorCtrlCubeCMY.GetSafeHwnd() )
  919. m_wndColorCtrlCubeCMY.SetupColor(clrNew,false);
  920. if( hWndColorCtrlFrom != m_wndColorCtrlMixerRGB.GetSafeHwnd() )
  921. m_wndColorCtrlMixerRGB.SetupColor(clrNew,false);
  922. if( hWndColorCtrlFrom != m_wndColorCtrlMixerCMY.GetSafeHwnd() )
  923. m_wndColorCtrlMixerCMY.SetupColor(clrNew,false);
  924. if( hWndColorCtrlFrom != m_wndColorCtrlHSL.GetSafeHwnd() )
  925. m_wndColorCtrlHSL.SetupColor(clrNew,false);
  926. m_bSyncingValues = false;
  927. return 0;
  928. }
  929. /////////////////////////////////////////////////////////////////////////////
  930. // CMainFrame
  931. IMPLEMENT_DYNAMIC( CMainFrame, CMDIFrameWnd )
  932. BEGIN_MESSAGE_MAP( CMainFrame, CMDIFrameWnd )
  933. //{{AFX_MSG_MAP(CMainFrame)
  934. ON_WM_CREATE()
  935. ON_COMMAND(IDC_THEME_2000, OnTheme2000)
  936. ON_UPDATE_COMMAND_UI(IDC_THEME_2000, OnUpdateTheme2000)
  937. ON_COMMAND(IDC_THEME_XP, OnThemeXp)
  938. ON_UPDATE_COMMAND_UI(IDC_THEME_XP, OnUpdateThemeXp)
  939. ON_COMMAND(IDC_THEME_2003, OnTheme2003)
  940. ON_UPDATE_COMMAND_UI(IDC_THEME_2003, OnUpdateTheme2003)
  941. ON_COMMAND(IDC_THEME_2005, OnTheme2005)
  942. ON_UPDATE_COMMAND_UI(IDC_THEME_2005, OnUpdateTheme2005)
  943. ON_COMMAND(ID_FILE_NEW, OnFileNew)
  944. ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  945. ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  946. ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  947. ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  948. ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  949. ON_COMMAND(IDC_THEME_LOAD_SKIN_XML, OnThemeLoadSkinXml)
  950. ON_COMMAND(IDC_THEME_LOAD_SKIN_BIN, OnThemeLoadSkinBin)
  951. ON_COMMAND(ID_COMBO_BOX_IN_TOOLBAR, OnComboBoxInToolbar)
  952. //}}AFX_MSG_MAP
  953. ON_COMMAND_EX( ID_VIEW_MENUBAR, OnBarCheck )
  954. ON_UPDATE_COMMAND_UI( ID_VIEW_MENUBAR, OnUpdateControlBarMenu )
  955. ON_COMMAND_EX( ID_VIEW_TOOLBAR_THEMES, OnBarCheck )
  956. ON_UPDATE_COMMAND_UI( ID_VIEW_TOOLBAR_THEMES, OnUpdateControlBarMenu )
  957. ON_COMMAND_EX( ID_VIEW_TOOLBAR_SKINS, OnBarCheck )
  958. ON_UPDATE_COMMAND_UI( ID_VIEW_TOOLBAR_SKINS, OnUpdateControlBarMenu )
  959. ON_REGISTERED_MESSAGE(
  960. CExtPopupMenuWnd::g_nMsgPrepareMenu,
  961. OnExtMenuPrepare
  962. )
  963. END_MESSAGE_MAP()
  964. static UINT indicators[] =
  965. {
  966. ID_SEPARATOR,           // status line indicator
  967. ID_INDICATOR_CAPS,
  968. ID_INDICATOR_NUM,
  969. ID_INDICATOR_SCRL,
  970. };
  971. /////////////////////////////////////////////////////////////////////////////
  972. // CMainFrame construction/destruction
  973. CMainFrame::CMainFrame()
  974. : m_pBarButtons( NULL )
  975. , m_pBarInputFields( NULL )
  976. #if (!defined __EXT_MFC_NO_DURATIONWND ) && (!defined __EXT_MFC_NO_DATETIMEWND)
  977. , m_pBarDateTimeDuration( NULL )
  978. #endif // (!defined __EXT_MFC_NO_DURATIONWND ) && (!defined __EXT_MFC_NO_DATETIMEWND)
  979. , m_pBarColorControls( NULL )
  980. , m_pBarInvokeModalDialogs( NULL )
  981. , m_pBarThemes( NULL )
  982. {
  983. ::memset( &m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT) );
  984. m_dataFrameWP.showCmd = SW_HIDE;
  985. CWinApp * pApp = ::AfxGetApp();
  986. ASSERT( pApp != NULL );
  987. ASSERT( pApp->m_pszRegistryKey != NULL );
  988. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  989. ASSERT( pApp->m_pszProfileName != NULL );
  990. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  991. if( ! g_PaintManager.PaintManagerStateLoad(
  992. pApp->m_pszRegistryKey,
  993. pApp->m_pszProfileName,
  994. pApp->m_pszProfileName
  995. )
  996. )
  997. {
  998. CExtPaintManagerSkin * pPM = new CExtPaintManagerSkin;
  999. bool bLoaded = true;
  1000. if( ! pPM->m_Skin.SearchAndLoadSkinFile( _T("BlackDiamond.Skin"), false ) )
  1001. {
  1002. if( ! pPM->m_Skin.SearchAndLoadSkinFile( _T("..\..\Skins\Binary\BlackDiamond.Skin"), false ) )
  1003. {
  1004. bLoaded = false;
  1005. ::AfxMessageBox( _T("Failed to load initial skin.") );
  1006. delete pPM;
  1007. }
  1008. }
  1009. if( bLoaded )
  1010. g_PaintManager.InstallPaintManager( pPM );
  1011. }
  1012. }
  1013. CMainFrame::~CMainFrame()
  1014. {
  1015. }
  1016. #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  1017. void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
  1018. {
  1019. // CFrameWnd::OnUpdateControlBarMenu( pCmdUI );
  1020. CExtControlBar::DoFrameBarCheckUpdate(
  1021. this,
  1022. pCmdUI,
  1023. false
  1024. );
  1025. }
  1026. BOOL CMainFrame::OnBarCheck(UINT nID)
  1027. {
  1028. // return CFrameWnd::OnBarCheck( nID );
  1029. return
  1030. CExtControlBar::DoFrameBarCheckCmd(
  1031. this,
  1032. nID,
  1033. false
  1034. );
  1035. }
  1036. #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  1037. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  1038. {
  1039. CWinApp * pApp = ::AfxGetApp();
  1040. ASSERT( pApp != NULL );
  1041. ASSERT( pApp->m_pszRegistryKey != NULL );
  1042. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  1043. ASSERT( pApp->m_pszProfileName != NULL );
  1044. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  1045. if( CExtNCW < CMDIFrameWnd > :: OnCreate(lpCreateStruct) == -1 )
  1046. {
  1047. ASSERT( FALSE );
  1048. return -1;
  1049. }
  1050. VERIFY(
  1051. g_CmdManager->ProfileSetup(
  1052. pApp->m_pszProfileName,
  1053. GetSafeHwnd()
  1054. )
  1055. );
  1056. VERIFY(
  1057. g_CmdManager->UpdateFromMenu(
  1058. pApp->m_pszProfileName,
  1059. IDR_MAINFRAME
  1060. )
  1061. );
  1062. m_wndMenuBar.SetMdiWindowPopupName( _T("Window") );
  1063. if( ! m_wndMenuBar.Create(
  1064. NULL,
  1065. this,
  1066. ID_VIEW_MENUBAR
  1067. )
  1068. )
  1069.     {
  1070.         TRACE0("Failed to create menubarn");
  1071.         return -1;      // failed to create
  1072.     }
  1073. if( (! m_wndToolBarStandard.Create(
  1074. NULL,
  1075. this,
  1076. AFX_IDW_TOOLBAR
  1077. ) )
  1078. || (! m_wndToolBarStandard.LoadToolBar( IDR_MAINFRAME ) )
  1079. || (! m_wndComboInToolBar.Create(
  1080. WS_CHILD|WS_VISIBLE
  1081. |WS_CLIPCHILDREN|WS_CLIPSIBLINGS
  1082. |CBS_DROPDOWN|CBS_HASSTRINGS,
  1083. CRect( 0, 0, 120, 400 ),
  1084. &m_wndToolBarStandard,
  1085. ID_COMBO_BOX_IN_TOOLBAR
  1086. ) )
  1087. )
  1088. {
  1089. TRACE0("Failed to create standard toolbarn");
  1090. return -1;      // fail to create
  1091. }
  1092. int nComboButtonIndexInToolBar =
  1093. m_wndToolBarStandard.CommandToIndex( ID_COMBO_BOX_IN_TOOLBAR );
  1094. ASSERT( nComboButtonIndexInToolBar >= 0 );
  1095. m_wndToolBarStandard.SetButtonCtrl(
  1096. nComboButtonIndexInToolBar,
  1097. &m_wndComboInToolBar
  1098. );
  1099. m_wndComboInToolBar.SetFont(
  1100. CFont::FromHandle(
  1101. (HFONT) ::GetStockObject(DEFAULT_GUI_FONT)
  1102. )
  1103. );
  1104. m_wndComboInToolBar.AddString( _T("combobox") );
  1105. m_wndComboInToolBar.AddString( _T("1") );
  1106. m_wndComboInToolBar.AddString( _T("2") );
  1107. m_wndComboInToolBar.AddString( _T("3") );
  1108. m_wndComboInToolBar.AddString( _T("4") );
  1109. m_wndComboInToolBar.AddString( _T("5") );
  1110. m_wndComboInToolBar.SetCurSel( 0 );
  1111. static const UINT g_arrButtonsForToolBarThemes[]=
  1112. {
  1113. IDC_THEME_2000,
  1114. IDC_THEME_XP,
  1115. IDC_THEME_2003,
  1116. IDC_THEME_2005,
  1117. };
  1118. if( (! m_wndToolBarThemes.Create(
  1119. NULL,
  1120. this,
  1121. ID_VIEW_TOOLBAR_THEMES
  1122. ) )
  1123. || (! m_wndToolBarThemes.SetButtons(
  1124. g_arrButtonsForToolBarThemes,
  1125. sizeof(g_arrButtonsForToolBarThemes) / sizeof(g_arrButtonsForToolBarThemes[0])
  1126. ) )
  1127. )
  1128. {
  1129. TRACE0("Failed to create themes toolbarn");
  1130. return -1;      // fail to create
  1131. }
  1132. static const UINT g_arrButtonsForToolBarSkins[]=
  1133. {
  1134. IDC_THEME_LOAD_SKIN_XML,
  1135. IDC_THEME_LOAD_SKIN_BIN,
  1136. };
  1137. if( (! m_wndToolBarSkins.Create(
  1138. NULL,
  1139. this,
  1140. ID_VIEW_TOOLBAR_SKINS
  1141. ) )
  1142. || (! m_wndToolBarSkins.SetButtons(
  1143. g_arrButtonsForToolBarSkins,
  1144. sizeof(g_arrButtonsForToolBarSkins) / sizeof(g_arrButtonsForToolBarSkins[0])
  1145. ) )
  1146. )
  1147. {
  1148. TRACE0("Failed to create skins toolbarn");
  1149. return -1;      // fail to create
  1150. }
  1151. m_wndStatusBar.m_bDrawPaneSeparatorsInsteadOfBorders = true;
  1152. if( (! m_wndStatusBar.Create(this) )
  1153. || (! m_wndStatusBar.SetIndicators(
  1154. indicators,
  1155. sizeof(indicators) / sizeof(UINT)
  1156. ) )
  1157. )
  1158. {
  1159. TRACE0("Failed to create status barn");
  1160. return -1;      // fail to create
  1161. }
  1162. static const UINT g_arrButtonsToSetToolBarText[]=
  1163. {
  1164. IDC_THEME_2000,
  1165. IDC_THEME_XP,
  1166. IDC_THEME_2003,
  1167. IDC_THEME_2005,
  1168. IDC_THEME_LOAD_SKIN_XML,
  1169. IDC_THEME_LOAD_SKIN_BIN,
  1170. ID_FILE_NEW,
  1171. ID_FILE_OPEN,
  1172. ID_FILE_SAVE,
  1173. ID_APP_ABOUT,
  1174. };
  1175. INT nCommandIndex, nCommandCount = sizeof(g_arrButtonsToSetToolBarText) / sizeof(g_arrButtonsToSetToolBarText[0]);
  1176. for( nCommandIndex = 0; nCommandIndex < nCommandCount; nCommandIndex++ )
  1177. {
  1178. UINT nCmdID = g_arrButtonsToSetToolBarText[nCommandIndex];
  1179. CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr( pApp->m_pszProfileName, nCmdID );
  1180. ASSERT( pCmdItem != NULL );
  1181. pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
  1182. } // for( nCommandIndex = 0; nCommandIndex < nCommandCount; nCommandIndex++ )
  1183. m_wndMenuBar.EnableDocking( CBRS_ALIGN_ANY );
  1184. m_wndToolBarStandard.EnableDocking( CBRS_ALIGN_ANY );
  1185. m_wndToolBarThemes.EnableDocking( CBRS_ALIGN_ANY );
  1186. m_wndToolBarSkins.EnableDocking( CBRS_ALIGN_ANY );
  1187. if( !CExtControlBar::FrameEnableDocking(this) )
  1188. {
  1189. ASSERT( FALSE );
  1190. return -1;
  1191. }
  1192. #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  1193. if( !CExtControlBar::FrameInjectAutoHideAreas(this) )
  1194. {
  1195. ASSERT( FALSE );
  1196. return -1;
  1197. }
  1198. #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
  1199. static UINT statBasicCommands[] =
  1200. {
  1201. ID_FILE_NEW, 
  1202. ID_FILE_OPEN, 
  1203. ID_FILE_SAVE,
  1204. ID_EDIT_COPY,
  1205. ID_EDIT_CUT,
  1206. ID_EDIT_PASTE,
  1207. ID_APP_EXIT,
  1208. ID_APP_ABOUT,
  1209. ID_VIEW_TOOLBAR, 
  1210. ID_WINDOW_TILE_HORZ,
  1211. ID_WINDOW_CASCADE,
  1212. ID_WINDOW_ARRANGE,
  1213. IDC_THEME_2000,
  1214. IDC_THEME_XP,
  1215. IDC_THEME_2003,
  1216. IDC_THEME_2005,
  1217. 0 // end of commands list
  1218. }; // statBasicCommands array
  1219. VERIFY(
  1220. g_CmdManager->SetBasicCommands(
  1221. pApp->m_pszProfileName,
  1222. statBasicCommands
  1223. )
  1224. );
  1225. #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
  1226. if( ! m_wndMdiTabs.Create(
  1227. this,
  1228. CRect(0,0,0,0),
  1229. UINT(IDC_STATIC),
  1230. WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
  1231. ( __ETWS_MDI_DEFAULT|__ETWS_HIDE_ICONS|__ETWS_ITEM_DRAGGING
  1232. |__ETWS_SHOW_BTN_SCROLL_HOME
  1233. |__ETWS_ENABLED_BTN_SCROLL_HOME
  1234. |__ETWS_SHOW_BTN_SCROLL_END
  1235. |__ETWS_ENABLED_BTN_SCROLL_END
  1236. |__ETWS_SHOW_BTN_HELP
  1237. |__ETWS_ENABLED_BTN_HELP
  1238. |__ETWS_SHOW_BTN_CLOSE
  1239. |__ETWS_ENABLED_BTN_CLOSE
  1240. |__ETWS_SHOW_BTN_TAB_LIST
  1241. |__ETWS_ENABLED_BTN_TAB_LIST
  1242. ) & (~(__ETWS_AUTOHIDE_SCROLL))
  1243. )
  1244. )
  1245. {
  1246. ASSERT( FALSE );
  1247. return -1;
  1248. }
  1249. #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
  1250. // install dynamic bar site for this frame window
  1251. CExtDynamicBarSite::m_nBarListInMenusCmdID = ID_DYNAMIC_BARS_LIST;
  1252. CExtDynamicBarSite::Install( this );
  1253. // allocate and initialize one persistent bar
  1254. HICON hIcon = (HICON)
  1255. ::LoadImage(
  1256. ::AfxGetInstanceHandle(),
  1257. MAKEINTRESOURCE(IDR_MAINFRAME),
  1258. IMAGE_ICON,
  1259. 16,
  1260. 16,
  1261. 0
  1262. );
  1263. ASSERT( hIcon != NULL );
  1264. CExtCmdIcon icon;
  1265. icon.AssignFromHICON( hIcon, false );
  1266. m_pBarButtons =
  1267. CExtDynamicBarSite::BarAlloc(
  1268. _T("Buttons"),
  1269. icon,
  1270. 0,
  1271. NULL,
  1272. true
  1273. );
  1274. if( m_pBarButtons == NULL )
  1275. {
  1276. ASSERT( FALSE );
  1277. return -1;
  1278. }
  1279. m_pBarButtons->m_nMdiMenuResourceID =
  1280. IDR_MAINFRAME;
  1281. m_pBarButtons->m_nMdiAccelTableResourceID =
  1282. IDR_MAINFRAME;
  1283. UINT nCmdID = (UINT)m_pBarButtons->GetDlgCtrlID();
  1284. CExtCmdItem * pCmdItem =
  1285. g_CmdManager->CmdGetPtr(
  1286. pApp->m_pszProfileName,
  1287. nCmdID
  1288. );
  1289. ASSERT( pCmdItem != NULL );
  1290. pCmdItem->StateSetBasic();
  1291. if( ! m_dlgButtons.CreateInsideBar( m_pBarButtons ) )
  1292. {
  1293. ASSERT( FALSE );
  1294. return -1;
  1295. }
  1296. #if (!defined __EXT_MFC_NO_DURATIONWND ) && (!defined __EXT_MFC_NO_DATETIMEWND)
  1297. m_pBarDateTimeDuration =
  1298. CExtDynamicBarSite::BarAlloc(
  1299. _T("Date/Time/Duration"),
  1300. icon,
  1301. 0,
  1302. NULL,
  1303. true
  1304. );
  1305. if( m_pBarDateTimeDuration == NULL )
  1306. {
  1307. ASSERT( FALSE );
  1308. return -1;
  1309. }
  1310. m_pBarDateTimeDuration->m_nMdiMenuResourceID =
  1311. IDR_MAINFRAME;
  1312. m_pBarDateTimeDuration->m_nMdiAccelTableResourceID =
  1313. IDR_MAINFRAME;
  1314. nCmdID = (UINT)m_pBarDateTimeDuration->GetDlgCtrlID();
  1315. pCmdItem =
  1316. g_CmdManager->CmdGetPtr(
  1317. pApp->m_pszProfileName,
  1318. nCmdID
  1319. );
  1320. ASSERT( pCmdItem != NULL );
  1321. pCmdItem->StateSetBasic();
  1322. if( ! m_dlgDateTimeDuration.CreateInsideBar( m_pBarDateTimeDuration ) )
  1323. {
  1324. ASSERT( FALSE );
  1325. return -1;
  1326. }
  1327. #endif // (!defined __EXT_MFC_NO_DURATIONWND ) && (!defined __EXT_MFC_NO_DATETIMEWND)
  1328. m_pBarThemes =
  1329. CExtDynamicBarSite::BarAlloc(
  1330. _T("Themes"),
  1331. icon,
  1332. 0,
  1333. NULL,
  1334. true
  1335. );
  1336. if( m_pBarThemes == NULL )
  1337. {
  1338. ASSERT( FALSE );
  1339. return -1;
  1340. }
  1341. m_pBarThemes->m_nMdiMenuResourceID =
  1342. IDR_MAINFRAME;
  1343. m_pBarThemes->m_nMdiAccelTableResourceID =
  1344. IDR_MAINFRAME;
  1345. nCmdID = (UINT)m_pBarThemes->GetDlgCtrlID();
  1346. pCmdItem =
  1347. g_CmdManager->CmdGetPtr(
  1348. pApp->m_pszProfileName,
  1349. nCmdID
  1350. );
  1351. ASSERT( pCmdItem != NULL );
  1352. pCmdItem->StateSetBasic();
  1353. if( ! m_dlgThemes.CreateInsideBar( m_pBarThemes ) )
  1354. {
  1355. ASSERT( FALSE );
  1356. return -1;
  1357. }
  1358. m_pBarInvokeModalDialogs =
  1359. CExtDynamicBarSite::BarAlloc(
  1360. _T("Modal Dialogs"),
  1361. icon,
  1362. 0,
  1363. NULL,
  1364. true
  1365. );
  1366. if( m_pBarInvokeModalDialogs == NULL )
  1367. {
  1368. ASSERT( FALSE );
  1369. return -1;
  1370. }
  1371. m_pBarInvokeModalDialogs->m_nMdiMenuResourceID =
  1372. IDR_MAINFRAME;
  1373. m_pBarInvokeModalDialogs->m_nMdiAccelTableResourceID =
  1374. IDR_MAINFRAME;
  1375. nCmdID = (UINT)m_pBarInvokeModalDialogs->GetDlgCtrlID();
  1376. pCmdItem =
  1377. g_CmdManager->CmdGetPtr(
  1378. pApp->m_pszProfileName,
  1379. nCmdID
  1380. );
  1381. ASSERT( pCmdItem != NULL );
  1382. pCmdItem->StateSetBasic();
  1383. if( ! m_dlgInvokeModalDialogs.CreateInsideBar( m_pBarInvokeModalDialogs ) )
  1384. {
  1385. ASSERT( FALSE );
  1386. return -1;
  1387. }
  1388. m_pBarInputFields =
  1389. CExtDynamicBarSite::BarAlloc(
  1390. _T("Input Fields"),
  1391. icon,
  1392. 0,
  1393. NULL,
  1394. true
  1395. );
  1396. if( m_pBarInputFields == NULL )
  1397. {
  1398. ASSERT( FALSE );
  1399. return -1;
  1400. }
  1401. m_pBarInputFields->m_nMdiMenuResourceID =
  1402. IDR_MAINFRAME;
  1403. m_pBarInputFields->m_nMdiAccelTableResourceID =
  1404. IDR_MAINFRAME;
  1405. nCmdID = (UINT)m_pBarInputFields->GetDlgCtrlID();
  1406. pCmdItem =
  1407. g_CmdManager->CmdGetPtr(
  1408. pApp->m_pszProfileName,
  1409. nCmdID
  1410. );
  1411. ASSERT( pCmdItem != NULL );
  1412. pCmdItem->StateSetBasic();
  1413. if( ! m_dlgInputFields.CreateInsideBar( m_pBarInputFields ) )
  1414. {
  1415. ASSERT( FALSE );
  1416. return -1;
  1417. }
  1418. m_pBarColorControls =
  1419. CExtDynamicBarSite::BarAlloc(
  1420. _T("Color Controls"),
  1421. icon,
  1422. 0,
  1423. NULL,
  1424. true
  1425. );
  1426. if( m_pBarColorControls == NULL )
  1427. {
  1428. ASSERT( FALSE );
  1429. return -1;
  1430. }
  1431. m_pBarColorControls->m_nMdiMenuResourceID =
  1432. IDR_MAINFRAME;
  1433. m_pBarColorControls->m_nMdiAccelTableResourceID =
  1434. IDR_MAINFRAME;
  1435. nCmdID = (UINT)m_pBarColorControls->GetDlgCtrlID();
  1436. pCmdItem =
  1437. g_CmdManager->CmdGetPtr(
  1438. pApp->m_pszProfileName,
  1439. nCmdID
  1440. );
  1441. ASSERT( pCmdItem != NULL );
  1442. pCmdItem->StateSetBasic();
  1443. if( ! m_viewColorControls.CreateInsideBar( m_pBarColorControls ) )
  1444. {
  1445. ASSERT( FALSE );
  1446. return -1;
  1447. }
  1448. CExtDynamicBarSite::StateLoad(
  1449. pApp->m_pszRegistryKey,
  1450. pApp->m_pszProfileName,
  1451. pApp->m_pszProfileName
  1452. );
  1453. if( ! CExtControlBar::ProfileBarStateLoad(
  1454. this,
  1455. pApp->m_pszRegistryKey,
  1456. pApp->m_pszProfileName,
  1457. pApp->m_pszProfileName,
  1458. &m_dataFrameWP
  1459. )
  1460. )
  1461. {
  1462. DockControlBar( &m_wndMenuBar );
  1463. DockControlBar( &m_wndToolBarStandard );
  1464. DockControlBar( &m_wndToolBarThemes );
  1465. DockControlBar( &m_wndToolBarSkins );
  1466. m_pBarColorControls->BarStateSet(
  1467. CExtDynamicControlBar::__EDBS_DOCUMENT,
  1468. true
  1469. );
  1470. #if (!defined __EXT_MFC_NO_DURATIONWND ) && (!defined __EXT_MFC_NO_DATETIMEWND)
  1471. m_pBarDateTimeDuration->BarStateSet(
  1472. CExtDynamicControlBar::__EDBS_DOCUMENT,
  1473. true
  1474. );
  1475. #endif // (!defined __EXT_MFC_NO_DURATIONWND ) && (!defined __EXT_MFC_NO_DATETIMEWND)
  1476. m_pBarInputFields->BarStateSet(
  1477. CExtDynamicControlBar::__EDBS_DOCUMENT,
  1478. true
  1479. );
  1480. m_pBarButtons->BarStateSet(
  1481. CExtDynamicControlBar::__EDBS_DOCUMENT,
  1482. true
  1483. );
  1484. m_pBarInvokeModalDialogs->DockControlBarInnerOuter(
  1485. AFX_IDW_DOCKBAR_RIGHT,
  1486. true,
  1487. this,
  1488. false
  1489. );
  1490. ShowControlBar( m_pBarThemes, TRUE, TRUE );
  1491. m_pBarThemes->DockControlBarLTRB(
  1492. m_pBarInvokeModalDialogs,
  1493. AFX_IDW_DOCKBAR_BOTTOM,
  1494. true
  1495. );
  1496. }
  1497. g_CmdManager->SerializeState(
  1498. pApp->m_pszProfileName,
  1499. pApp->m_pszRegistryKey,
  1500. pApp->m_pszProfileName,
  1501. false
  1502. );
  1503. //m_wndToolBarStandard.FlashCaption( 65535, 250, RGB(128,0,0), RGB(255,255,64) );
  1504. //m_pBarButtons->FlashCaption( 65535, 250, RGB(128,0,0), RGB(255,255,64) );
  1505. //m_pBarInvokeModalDialogs->FlashCaption( 65535, 250, RGB(128,0,0), RGB(255,255,64) );
  1506. return 0;
  1507. }
  1508. BOOL CMainFrame::DestroyWindow() 
  1509. {
  1510. CWinApp * pApp = ::AfxGetApp();
  1511. ASSERT( pApp != NULL );
  1512. ASSERT( pApp->m_pszRegistryKey != NULL );
  1513. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  1514. ASSERT( pApp->m_pszProfileName != NULL );
  1515. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  1516. pApp;
  1517. VERIFY(
  1518. CExtControlBar::ProfileBarStateSave(
  1519. this,
  1520. pApp->m_pszRegistryKey,
  1521. pApp->m_pszProfileName,
  1522. pApp->m_pszProfileName,
  1523. &m_dataFrameWP
  1524. )
  1525. );
  1526. VERIFY(
  1527. CExtDynamicBarSite::StateSave(
  1528. pApp->m_pszRegistryKey,
  1529. pApp->m_pszProfileName,
  1530. pApp->m_pszProfileName
  1531. )
  1532. );
  1533. VERIFY(
  1534. g_CmdManager->SerializeState(
  1535. pApp->m_pszProfileName,
  1536. pApp->m_pszRegistryKey,
  1537. pApp->m_pszProfileName,
  1538. true
  1539. )
  1540. );
  1541. VERIFY(
  1542. g_PaintManager.PaintManagerStateSave(
  1543. pApp->m_pszRegistryKey,
  1544. pApp->m_pszProfileName,
  1545. pApp->m_pszProfileName
  1546. )
  1547. );
  1548. g_CmdManager->ProfileWndRemove( GetSafeHwnd() );
  1549. m_wndMenuBar.RemoveAllWndHooks();
  1550. return CExtNCW < CMDIFrameWnd > :: DestroyWindow();
  1551. }
  1552. void CMainFrame::ActivateFrame(int nCmdShow) 
  1553. {
  1554. if( m_dataFrameWP.showCmd != SW_HIDE )
  1555. {
  1556. SetWindowPlacement( &m_dataFrameWP );
  1557. CExtNCW < CMDIFrameWnd > :: ActivateFrame( m_dataFrameWP.showCmd );
  1558. m_dataFrameWP.showCmd = SW_HIDE;
  1559. return;
  1560. }
  1561. CExtNCW < CMDIFrameWnd > :: ActivateFrame(nCmdShow);
  1562. }
  1563. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  1564. {
  1565. if( ! CExtNCW < CMDIFrameWnd > :: PreCreateWindow(cs) )
  1566. return FALSE;
  1567. //cs.style |= WS_MAXIMIZE;
  1568. return TRUE;
  1569. }
  1570. /////////////////////////////////////////////////////////////////////////////
  1571. // CMainFrame diagnostics
  1572. #ifdef _DEBUG
  1573. void CMainFrame::AssertValid() const
  1574. {
  1575. CExtNCW < CMDIFrameWnd > :: AssertValid();
  1576. }
  1577. void CMainFrame::Dump( CDumpContext & dc ) const
  1578. {
  1579. CExtNCW < CMDIFrameWnd > :: Dump(dc);
  1580. }
  1581. #endif //_DEBUG
  1582. /////////////////////////////////////////////////////////////////////////////
  1583. // CMainFrame message handlers
  1584. BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) 
  1585. {
  1586. if( m_wndMenuBar.TranslateMainFrameMessage(pMsg) )
  1587. return TRUE;
  1588. return CExtNCW < CMDIFrameWnd > :: PreTranslateMessage(pMsg);
  1589. }
  1590. LRESULT CMainFrame::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam)
  1591. {
  1592. wParam;
  1593. lParam;
  1594. //////////////////////////////////////////////////////////////////////////
  1595. // Add "Windows..." command
  1596. //////////////////////////////////////////////////////////////////////////
  1597. CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
  1598. reinterpret_cast
  1599. < CExtPopupMenuWnd::MsgPrepareMenuData_t * >
  1600. ( wParam );
  1601. ASSERT( pData != NULL );
  1602. CExtPopupMenuWnd * pPopup = pData->m_pPopup;
  1603. ASSERT( pPopup != NULL );
  1604. INT nItemPos;
  1605. INT nNewPos = -1;
  1606. nItemPos = pPopup->ItemFindPosForCmdID( __ID_MDIWND_DLGWINDOWS );
  1607. if( nItemPos > 0 )
  1608. {
  1609. // "More Windows..." command found
  1610. pPopup->ItemRemove( nItemPos );
  1611. nNewPos = nItemPos;
  1612. }
  1613. else
  1614. {
  1615. int nMaxCmdID = 0;
  1616. for( int nCmdID = __ID_MDIWNDLIST_FIRST; nCmdID <= __ID_MDIWNDLIST_LAST; nCmdID++ ){
  1617. nItemPos = pPopup->ItemFindPosForCmdID( nCmdID );
  1618. if( nItemPos > 0 ){
  1619. if( nCmdID > nMaxCmdID ){
  1620. nMaxCmdID = nCmdID;
  1621. nNewPos = nItemPos;
  1622. }
  1623. }
  1624. }
  1625. if( nNewPos > 0 ){
  1626. pPopup->ItemInsert(
  1627. (UINT)CExtPopupMenuWnd::TYPE_SEPARATOR,
  1628. ++nNewPos
  1629. );
  1630. nNewPos++;
  1631. }
  1632. }
  1633. if( nNewPos > 0 )
  1634. {
  1635. UINT nCmdID = ID_WINDOWS_LIST;
  1636. CExtCmdItem * pCmdItem =
  1637. g_CmdManager->CmdGetPtr(
  1638. g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ),
  1639. nCmdID
  1640. );
  1641. if( pCmdItem == NULL ){
  1642. pCmdItem = 
  1643. g_CmdManager->CmdAllocPtr( 
  1644. g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ), 
  1645. nCmdID 
  1646. );
  1647. }
  1648. ASSERT( pCmdItem != NULL );
  1649. if( pCmdItem != NULL )
  1650. {
  1651. CExtSafeString sMoreWindows(_T("Windows..."));
  1652. CExtSafeString sManageWindows(_T("Manages the currently open windows"));
  1653. pCmdItem->m_sMenuText = sMoreWindows;
  1654. pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
  1655. pCmdItem->m_sTipTool = sManageWindows;
  1656. pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool;
  1657. pCmdItem->StateSetBasic( true );
  1658. pPopup->ItemInsert(
  1659. nCmdID,
  1660. nNewPos,
  1661. sMoreWindows,
  1662. NULL,
  1663. m_hWnd
  1664. );
  1665. }
  1666. }
  1667. return 1;
  1668. }
  1669. BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  1670. {
  1671. if( CExtDynamicBarSite::OnCmdMsg( nID, nCode, pExtra, pHandlerInfo ) )
  1672. return TRUE;
  1673. if( nCode == CN_COMMAND )
  1674. {
  1675. #ifndef __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG
  1676. if( nID == ID_WINDOWS_LIST )
  1677. {
  1678. CExtMdiWindowsListDlg dlgMdiWindowsList( this );
  1679. dlgMdiWindowsList.DoModal();
  1680. return TRUE;
  1681. }
  1682. #endif // #ifndef __EXT_MFC_NO_MDI_WINDOWS_LIST_DIALOG
  1683. }
  1684. return CExtNCW < CMDIFrameWnd > :: OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  1685. }
  1686. void CMainFrame::OnFileNew() 
  1687. {
  1688. ::AfxMessageBox( _T("CMainFrame::OnFileNew()") );
  1689. }
  1690. void CMainFrame::OnFileOpen() 
  1691. {
  1692. ::AfxMessageBox( _T("CMainFrame::OnFileOpen()") );
  1693. }
  1694. void CMainFrame::OnFileSave() 
  1695. {
  1696. ::AfxMessageBox( _T("CMainFrame::OnFileSave()") );
  1697. }
  1698. void CMainFrame::OnEditCopy() 
  1699. {
  1700. ::AfxMessageBox( _T("CMainFrame::OnThemeLoadSkinBin()") );
  1701. }
  1702. void CMainFrame::OnEditCut() 
  1703. {
  1704. ::AfxMessageBox( _T("CMainFrame::OnEditCopy()") );
  1705. }
  1706. void CMainFrame::OnEditPaste() 
  1707. {
  1708. ::AfxMessageBox( _T("CMainFrame::OnEditPaste()") );
  1709. }
  1710. void CMainFrame::OnComboBoxInToolbar() 
  1711. {
  1712. ::AfxMessageBox( _T("CMainFrame::OnComboBoxInToolbar()") );
  1713. }
  1714. void CMainFrame::OnTheme2000() 
  1715. {
  1716. if( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManager) )
  1717. && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) ) )
  1718. && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerSkin) ) )
  1719. )
  1720. return;
  1721. VERIFY(
  1722. g_PaintManager.InstallPaintManager( new CExtPaintManager )
  1723. );
  1724. RecalcLayout();
  1725. RedrawWindow(
  1726. NULL,
  1727. NULL,
  1728. RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE
  1729. | RDW_FRAME | RDW_ALLCHILDREN
  1730. );
  1731. CExtControlBar::stat_RedrawFloatingFrames( this );
  1732. CExtControlBar::stat_RecalcBarMetrics( this );
  1733. }
  1734. void CMainFrame::OnUpdateTheme2000(CCmdUI* pCmdUI) 
  1735. {
  1736. pCmdUI->Enable();
  1737. pCmdUI->SetRadio(
  1738. ( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManager) )
  1739. && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) ) )
  1740. && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerSkin) ) )
  1741. )
  1742. ? TRUE
  1743. : FALSE
  1744. );
  1745. }
  1746. void CMainFrame::OnThemeXp() 
  1747. {
  1748. if( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) )
  1749. && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) )
  1750. )
  1751. return;
  1752. VERIFY(
  1753. g_PaintManager.InstallPaintManager( new CExtPaintManagerXP )
  1754. );
  1755. RecalcLayout();
  1756. RedrawWindow(
  1757. NULL,
  1758. NULL,
  1759. RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE
  1760. | RDW_FRAME | RDW_ALLCHILDREN
  1761. );
  1762. CExtControlBar::stat_RedrawFloatingFrames( this );
  1763. CExtControlBar::stat_RecalcBarMetrics( this );
  1764. }
  1765. void CMainFrame::OnUpdateThemeXp(CCmdUI* pCmdUI) 
  1766. {
  1767. pCmdUI->Enable();
  1768. pCmdUI->SetRadio(
  1769. ( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) )
  1770. && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) )
  1771. ) ? TRUE
  1772. : FALSE
  1773. );
  1774. }
  1775. void CMainFrame::OnTheme2003() 
  1776. {
  1777. if( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) )
  1778. && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerStudio2005) ) )
  1779. )
  1780. return;
  1781. VERIFY(
  1782. g_PaintManager.InstallPaintManager( new CExtPaintManagerOffice2003 )
  1783. );
  1784. RecalcLayout();
  1785. RedrawWindow(
  1786. NULL,
  1787. NULL,
  1788. RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE
  1789. | RDW_FRAME | RDW_ALLCHILDREN
  1790. );
  1791. CExtControlBar::stat_RedrawFloatingFrames( this );
  1792. CExtControlBar::stat_RecalcBarMetrics( this );
  1793. }
  1794. void CMainFrame::OnUpdateTheme2003(CCmdUI* pCmdUI) 
  1795. {
  1796. pCmdUI->Enable();
  1797. pCmdUI->SetRadio(
  1798. ( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) )
  1799. && (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerStudio2005) ) )
  1800. )
  1801. ? TRUE
  1802. : FALSE
  1803. );
  1804. }
  1805. void CMainFrame::OnTheme2005() 
  1806. {
  1807. if( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerStudio2005) ) )
  1808. return;
  1809. VERIFY(
  1810. g_PaintManager.InstallPaintManager( new CExtPaintManagerStudio2005 )
  1811. );
  1812. RecalcLayout();
  1813. RedrawWindow(
  1814. NULL,
  1815. NULL,
  1816. RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE
  1817. | RDW_FRAME | RDW_ALLCHILDREN
  1818. );
  1819. CExtControlBar::stat_RedrawFloatingFrames( this );
  1820. CExtControlBar::stat_RecalcBarMetrics( this );
  1821. }
  1822. void CMainFrame::OnUpdateTheme2005(CCmdUI* pCmdUI) 
  1823. {
  1824. pCmdUI->Enable();
  1825. pCmdUI->SetRadio(
  1826. g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerStudio2005) )
  1827. ? TRUE
  1828. : FALSE
  1829. );
  1830. }
  1831. void CMainFrame::OnThemeLoadSkinXml() 
  1832. {
  1833. CString strPathName;
  1834. #if ( ! defined __EXT_MFC_NO_SHELL_DIALOG_FILE )
  1835. CExtShellDialogFile dlgShellFile(
  1836. NULL,
  1837. CExtShellDialogFile::__EFDT_OPEN_SINGLE
  1838. );
  1839. dlgShellFile.m_comboFileTypes.SetFilter(
  1840. _T("XML files (*.XML)|*.XML|")
  1841. _T("All files (*.*)|*.*|")
  1842. _T("|")
  1843. );
  1844. dlgShellFile.m_nInitialFileTypeIndex = 0;
  1845. dlgShellFile.m_bFilesMustExist = true;
  1846. dlgShellFile.m_strCustomDialogCaption = _T("Load XML skin");
  1847. if( dlgShellFile.DoModal() != IDOK )
  1848. return;
  1849. ASSERT( dlgShellFile.m_arrRetValNames.GetSize() == 1 );
  1850. strPathName = LPCTSTR(dlgShellFile.m_arrRetValNames[0]);
  1851. #else // ( ! defined __EXT_MFC_NO_SHELL_DIALOG_FILE )
  1852. CFileDialog _dlg(
  1853. TRUE,
  1854. _T("XML"),
  1855. NULL,
  1856. OFN_FILEMUSTEXIST
  1857. |OFN_PATHMUSTEXIST
  1858. |OFN_HIDEREADONLY
  1859. |OFN_LONGNAMES
  1860. |OFN_NOCHANGEDIR
  1861. ,
  1862. _T("XML files (*.XML)|*.XML|")
  1863. _T("All files (*.*)|*.*|")
  1864. _T("|")
  1865. ,
  1866. this
  1867. );
  1868. TCHAR strCurrDir[_MAX_PATH];
  1869. ::GetCurrentDirectory( _MAX_PATH, strCurrDir );
  1870. _dlg.m_ofn.lpstrInitialDir = strCurrDir;
  1871. _dlg.m_ofn.lpstrTitle = _T("Load XML skin");
  1872. if( _dlg.DoModal() != IDOK )
  1873. return;
  1874. strPathName = _dlg.GetPathName();
  1875. ASSERT( ! strPathName.IsEmpty() );
  1876. #endif // else from if ( ! defined __EXT_MFC_NO_SHELL_DIALOG_FILE )
  1877. CExtPaintManagerSkin * pPM = new CExtPaintManagerSkin;
  1878. if( ! pPM->m_Skin.Load( LPCTSTR(strPathName) ) )
  1879. {
  1880. ::AfxMessageBox( _T("Failed to load skin.") );
  1881. delete pPM;
  1882. return;
  1883. }
  1884. g_PaintManager.InstallPaintManager( pPM );
  1885. // VERIFY( pPM->m_Skin.SerializeFile( _T("Test.Skin"), true, false ) );
  1886. }
  1887. void CMainFrame::OnThemeLoadSkinBin() 
  1888. {
  1889. CString strPathName;
  1890. #if ( ! defined __EXT_MFC_NO_SHELL_DIALOG_FILE )
  1891. CExtShellDialogFile dlgShellFile(
  1892. NULL,
  1893. CExtShellDialogFile::__EFDT_OPEN_SINGLE
  1894. );
  1895. dlgShellFile.m_comboFileTypes.SetFilter(
  1896. _T("Skin files (*.skin)|*.skin|")
  1897. _T("All files (*.*)|*.*|")
  1898. _T("|")
  1899. );
  1900. dlgShellFile.m_nInitialFileTypeIndex = 0;
  1901. dlgShellFile.m_bFilesMustExist = true;
  1902. dlgShellFile.m_strCustomDialogCaption = _T("Load binary skin");
  1903. if( dlgShellFile.DoModal() != IDOK )
  1904. return;
  1905. ASSERT( dlgShellFile.m_arrRetValNames.GetSize() == 1 );
  1906. strPathName = LPCTSTR(dlgShellFile.m_arrRetValNames[0]);
  1907. #else // ( ! defined __EXT_MFC_NO_SHELL_DIALOG_FILE )
  1908. CFileDialog _dlg(
  1909. TRUE,
  1910. _T("skin"),
  1911. NULL,
  1912. OFN_FILEMUSTEXIST
  1913. |OFN_PATHMUSTEXIST
  1914. |OFN_HIDEREADONLY
  1915. |OFN_LONGNAMES
  1916. |OFN_NOCHANGEDIR
  1917. ,
  1918. _T("Skin files (*.skin)|*.skin|")
  1919. _T("All files (*.*)|*.*|")
  1920. _T("|")
  1921. ,
  1922. this
  1923. );
  1924. TCHAR strCurrDir[_MAX_PATH];
  1925. ::GetCurrentDirectory( _MAX_PATH, strCurrDir );
  1926. _dlg.m_ofn.lpstrInitialDir = strCurrDir;
  1927. _dlg.m_ofn.lpstrTitle = _T("Load binary skin");
  1928. if( _dlg.DoModal() != IDOK )
  1929. return;
  1930. strPathName = _dlg.GetPathName();
  1931. ASSERT( ! strPathName.IsEmpty() );
  1932. #endif // else from if ( ! defined __EXT_MFC_NO_SHELL_DIALOG_FILE )
  1933. CExtPaintManagerSkin * pPM = new CExtPaintManagerSkin;
  1934. if( ! pPM->m_Skin.SerializeFile( LPCTSTR(strPathName), false, false ) )
  1935. {
  1936. ::AfxMessageBox( _T("Failed to load skin.") );
  1937. delete pPM;
  1938. return;
  1939. }
  1940. g_PaintManager.InstallPaintManager( pPM );
  1941. }