1 ////////////////////////////////////////////////////
\r
6 #include "resource.h"
\r
9 // Definitions for the CMainFrame class
\r
10 CMainFrame::CMainFrame() : m_nColor(IDM_BLUE), m_bUseThemes(TRUE), m_bBandColors(TRUE), m_bFlatStyle(FALSE),
\r
11 m_bBandsLeft(TRUE), m_bLockMenuBand(TRUE), m_bRoundBorders(TRUE),
\r
12 m_bShortBands(TRUE), m_bUseLines(FALSE), m_bShowArrows(TRUE), m_bShowCards(TRUE)
\r
14 // Constructor for CMainFrame. Its called after CFrame's constructor
\r
16 //Set m_View as the view window of the frame
\r
19 // Set the registry key name, and load the initial window position
\r
20 // Use a registry key name like "CompanyName\\Application"
\r
21 LoadRegistrySettings(_T("Win32++\\Themes Sample"));
\r
24 CMainFrame::~CMainFrame()
\r
26 // Destructor for CMainFrame.
\r
29 void CMainFrame::AddCombo()
\r
31 // We'll be placing the ComboBoxEx control over the 'File Save' toolbar button
\r
32 int nComboWidth = 120;
\r
33 CToolBar& TB = GetToolBar();
\r
34 if (TB.CommandToIndex(IDM_FILE_SAVE) < 0) return;
\r
36 TB.SetButtonStyle(IDM_FILE_SAVE, TBSTYLE_SEP); // Convert the button to a separator
\r
37 TB.SetButtonWidth(IDM_FILE_SAVE, nComboWidth);
\r
39 // Determine the size and position of the ComboBox
\r
40 int nIndex = TB.CommandToIndex(IDM_FILE_SAVE);
\r
41 CRect rc = TB.GetItemRect(nIndex);
\r
43 // Create and position the ComboboxEx window
\r
44 m_ComboBoxEx.Create(&TB);
\r
45 m_ComboBoxEx.SetWindowPos(NULL, rc, SWP_NOACTIVATE);
\r
47 // Set ComboBox Height
\r
48 m_ComboBoxEx.SendMessage(CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)rc.Height()-6);
\r
50 m_ComboBoxEx.AddItems();
\r
54 void CMainFrame::ChooseColor(UINT nColor)
\r
56 CToolBar& TB = GetToolBar();
\r
57 CMenuBar& MB = GetMenuBar();
\r
64 SetReBarTheme( RGB(225, 230, 255), RGB(240, 242, 250), RGB(248, 248, 248), RGB(180, 200, 230) );
\r
66 ToolBarTheme tt = {TRUE, RGB(180, 250, 255), RGB(140, 190, 255), RGB(150, 220, 255), RGB(80, 100, 255), RGB(127, 127, 255)};
\r
67 TB.SetToolBarTheme(tt);
\r
68 Arrows.SetToolBarTheme(tt);
\r
69 Cards.SetToolBarTheme(tt);
\r
71 MenuTheme mt = {TRUE, RGB(180, 250, 255), RGB(140, 190, 255), RGB(240, 250, 255), RGB(120, 170, 220), RGB(127, 127, 255)};
\r
72 MB.SetMenuBarTheme(mt);
\r
76 case IDM_BLUE: // ICY_BLUE Theme
\r
78 SetReBarTheme( RGB(150,190,245), RGB(196,215,250), RGB(220,230,250), RGB( 70,130,220) );
\r
80 ToolBarTheme tt = {TRUE, RGB(255, 230, 190), RGB(255, 190, 100), RGB(255, 140, 40), RGB(255, 180, 80), RGB(128, 128, 255)};
\r
81 TB.SetToolBarTheme(tt);
\r
82 Arrows.SetToolBarTheme(tt);
\r
83 Cards.SetToolBarTheme(tt);
\r
85 MenuTheme mt = {TRUE, RGB(255, 230, 190), RGB(255, 190, 100), RGB(150,190,245), RGB(220,230,250), RGB(128, 128, 200)};
\r
86 MB.SetMenuBarTheme(mt);
\r
90 case IDM_GREY: // Grey Theme
\r
92 SetReBarTheme( RGB(210, 210, 200), RGB(238, 236, 224), RGB(248, 247, 243), RGB(195, 195, 172) );
\r
94 ToolBarTheme tt = {TRUE, RGB(192, 210, 238), RGB(192, 210, 238), RGB(152, 181, 226), RGB(152, 181, 226), RGB(49, 106, 197)};
\r
95 TB.SetToolBarTheme(tt);
\r
96 Arrows.SetToolBarTheme(tt);
\r
97 Cards.SetToolBarTheme(tt);
\r
99 MenuTheme mt = {TRUE, RGB(196, 215, 250), RGB( 120, 180, 220), RGB(210, 210, 200), RGB(248, 247, 243), RGB(128, 128, 200)};
\r
100 MB.SetMenuBarTheme(mt);
\r
106 SetReBarTheme( RGB(160, 180, 80), RGB(180, 200, 100), RGB(200, 220, 120), RGB(80, 159, 78) );
\r
108 ToolBarTheme tt = {TRUE, RGB(255, 230, 190), RGB(255, 190, 100), RGB(255, 140, 40), RGB(255, 180, 80), RGB(128, 128, 255)};
\r
109 TB.SetToolBarTheme(tt);
\r
110 Arrows.SetToolBarTheme(tt);
\r
111 Cards.SetToolBarTheme(tt);
\r
113 MenuTheme mt = {TRUE, RGB(255, 200, 190), RGB(255, 210, 90), RGB(255, 230, 190), RGB(230, 160, 190), RGB(128, 128, 128)};
\r
114 MB.SetMenuBarTheme(mt);
\r
120 SetReBarTheme( RGB(230, 180, 0), RGB(240, 210, 90), RGB(255, 240, 150), RGB(180, 140, 50) );
\r
122 ToolBarTheme tt = {TRUE, RGB(192, 210, 238), RGB(192, 210, 238), RGB(152, 181, 226), RGB(152, 181, 226), RGB(49, 106, 197)};
\r
123 TB.SetToolBarTheme(tt);
\r
124 Arrows.SetToolBarTheme(tt);
\r
125 Cards.SetToolBarTheme(tt);
\r
127 MenuTheme mt = {TRUE, RGB(196, 215, 250), RGB( 120, 180, 220), RGB(240, 210, 90), RGB(255, 240, 150), RGB(128, 128, 128)};
\r
128 MB.SetMenuBarTheme(mt);
\r
134 SetReBarTheme( RGB(248, 132, 12), RGB(248, 198, 10), RGB(248, 210, 20), RGB(248, 141, 6) );
\r
136 ToolBarTheme tt = {TRUE, RGB(192, 210, 238), RGB(192, 210, 238), RGB(152, 181, 226), RGB(152, 181, 226), RGB(49, 106, 197)};
\r
137 TB.SetToolBarTheme(tt);
\r
138 Arrows.SetToolBarTheme(tt);
\r
139 Cards.SetToolBarTheme(tt);
\r
141 MenuTheme mt = {TRUE, RGB(196, 215, 250), RGB( 120, 180, 220), RGB(150,190,245), RGB(220,230,250), RGB(128, 128, 128)};
\r
142 MB.SetMenuBarTheme(mt);
\r
148 SetReBarTheme( RGB(255, 130, 190), RGB(250, 205, 235), RGB(250, 205, 235), RGB(255, 120, 170) );
\r
150 ToolBarTheme tt = {TRUE, RGB(192, 210, 238), RGB(192, 210, 238), RGB(248, 147, 220), RGB(248, 153, 179), RGB(49, 106, 197)};
\r
151 TB.SetToolBarTheme(tt);
\r
152 Arrows.SetToolBarTheme(tt);
\r
153 Cards.SetToolBarTheme(tt);
\r
155 MenuTheme mt = {TRUE, RGB(196, 215, 250), RGB( 120, 180, 220), RGB(255, 130, 190), RGB(250, 205, 235), RGB(128, 128, 128)};
\r
156 MB.SetMenuBarTheme(mt);
\r
162 SetReBarTheme( RGB(210, 128, 155), RGB(230, 160, 190), RGB(230, 158, 188), RGB(110, 100, 125) );
\r
164 ToolBarTheme tt = {TRUE, RGB(192, 210, 238), RGB(192, 210, 238), RGB(152, 181, 226), RGB(152, 181, 226), RGB(49, 106, 197)};
\r
165 TB.SetToolBarTheme(tt);
\r
166 Arrows.SetToolBarTheme(tt);
\r
167 Cards.SetToolBarTheme(tt);
\r
169 MenuTheme mt = {TRUE, RGB(196, 215, 250), RGB( 120, 180, 220), RGB(150,190,245), RGB(220,230,250), RGB(128, 128, 128)};
\r
170 MB.SetMenuBarTheme(mt);
\r
176 SetReBarTheme( RGB(128, 138 ,176), RGB(98, 108 ,136), RGB(77, 87, 97), RGB(7, 17, 27) );
\r
178 ToolBarTheme tt = {TRUE, RGB(49, 106, 197), RGB(64,177,230), RGB(27,65, 160), RGB(64,177,230), RGB(49, 106, 197)};
\r
179 TB.SetToolBarTheme(tt);
\r
180 Arrows.SetToolBarTheme(tt);
\r
181 Cards.SetToolBarTheme(tt);
\r
183 MenuTheme mt = {TRUE, RGB(84,197,240), RGB(89, 136, 217), RGB(59, 126, 197), RGB(94,187,230), RGB(128, 128, 128)};
\r
184 MB.SetMenuBarTheme(mt);
\r
189 // Check the appropriate menu item
\r
190 int nFileItem = GetMenuItemPos(GetFrameMenu(), _T("Theme"));
\r
191 if (nFileItem >= 0)
\r
193 CMenu* pThemeMenu = GetFrameMenu().GetSubMenu(nFileItem);
\r
194 pThemeMenu->CheckMenuRadioItem(IDM_BLUE, IDM_MODERN, nColor, 0);
\r
197 GetFrameMenu().CheckMenuItem(IDM_USE_THEMES, m_bUseThemes? MF_CHECKED : MF_UNCHECKED);
\r
198 GetFrameMenu().CheckMenuItem(IDM_BAND_COLORS, m_bBandColors? MF_CHECKED : MF_UNCHECKED);
\r
199 GetFrameMenu().CheckMenuItem(IDM_FLAT_STYLE, m_bFlatStyle? MF_CHECKED : MF_UNCHECKED);
\r
200 GetFrameMenu().CheckMenuItem(IDM_LEFT_BANDS, m_bBandsLeft? MF_CHECKED : MF_UNCHECKED);
\r
201 GetFrameMenu().CheckMenuItem(IDM_LOCK_MENUBAR, m_bLockMenuBand? MF_CHECKED : MF_UNCHECKED);
\r
202 GetFrameMenu().CheckMenuItem(IDM_ROUND_BORDERS, m_bRoundBorders? MF_CHECKED : MF_UNCHECKED);
\r
203 GetFrameMenu().CheckMenuItem(IDM_SHORT_BANDS, m_bShortBands? MF_CHECKED : MF_UNCHECKED);
\r
204 GetFrameMenu().CheckMenuItem(IDM_USE_LINES, m_bUseLines? MF_CHECKED : MF_UNCHECKED);
\r
208 DWORD CMainFrame::GetRegDwordFromOpenKey(HKEY hKey, LPCTSTR pName)
\r
211 DWORD dwCount = sizeof(DWORD);
\r
213 if (ERROR_SUCCESS == RegQueryValueEx(hKey, pName, NULL, &dwType, (LPBYTE)&dwValue, &dwCount))
\r
219 BOOL CMainFrame::LoadRegistrySettings(LPCTSTR szKeyName)
\r
221 CFrame::LoadRegistrySettings(szKeyName);
\r
224 CString strKey = _T("Software\\");
\r
225 strKey += szKeyName;
\r
226 strKey += (_T("\\Theme Settings"));
\r
228 if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, strKey, 0, KEY_READ, &hKey))
\r
230 m_nColor = GetRegDwordFromOpenKey(hKey, _T("ColorStyle"));
\r
231 m_bUseThemes = GetRegDwordFromOpenKey(hKey, _T("UseThemes")) & 1;
\r
232 m_bBandColors = GetRegDwordFromOpenKey(hKey, _T("UseBandColors")) & 1;
\r
233 m_bFlatStyle = GetRegDwordFromOpenKey(hKey, _T("UseFlatStyle")) & 1;
\r
234 m_bBandsLeft = GetRegDwordFromOpenKey(hKey, _T("PutBandsLeft")) & 1;
\r
235 m_bLockMenuBand = GetRegDwordFromOpenKey(hKey, _T("LockMenuBand")) & 1;
\r
236 m_bRoundBorders = GetRegDwordFromOpenKey(hKey, _T("UseRoundBorders")) & 1;
\r
237 m_bShortBands = GetRegDwordFromOpenKey(hKey, _T("UseShortBands")) & 1;
\r
238 m_bUseLines = GetRegDwordFromOpenKey(hKey, _T("UseLines")) & 1;
\r
239 m_bShowArrows = GetRegDwordFromOpenKey(hKey, _T("ShowArrows")) & 1;
\r
240 m_bShowCards = GetRegDwordFromOpenKey(hKey, _T("ShowCards")) & 1;
\r
241 int nBands = GetRegDwordFromOpenKey(hKey, _T("NumBands"));
\r
243 // Retrieve the band styles and IDs
\r
244 for (int i = 0; i < nBands; ++i)
\r
246 TCHAR szSubKey[16];
\r
247 wsprintf(szSubKey, _T("Band ID %d\0"), i+1);
\r
248 UINT nID = GetRegDwordFromOpenKey(hKey, szSubKey);
\r
249 m_vBandIDs.push_back(nID);
\r
251 wsprintf(szSubKey, _T("Band Style %d\0"), i+1);
\r
252 UINT nStyle = GetRegDwordFromOpenKey(hKey, szSubKey);
\r
253 m_vBandStyles.push_back(nStyle);
\r
260 // Choose reasonable default values
\r
261 m_nColor = IDM_OLIVE;
\r
262 m_bUseThemes = TRUE;
\r
263 m_bBandColors = TRUE;
\r
264 m_bFlatStyle = FALSE;
\r
265 m_bBandsLeft = TRUE;
\r
266 m_bLockMenuBand = TRUE;
\r
267 m_bRoundBorders = TRUE;
\r
268 m_bShortBands = TRUE;
\r
269 m_bUseLines = FALSE;;
\r
270 m_bShowArrows = TRUE;
\r
271 m_bShowCards = TRUE;
\r
277 BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
\r
279 // OnCommand responds to menu and and toolbar input
\r
281 UNREFERENCED_PARAMETER(lParam);
\r
283 switch(LOWORD(wParam))
\r
285 case IDM_FILE_EXIT:
\r
286 // End the application
\r
287 ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
\r
290 ChooseColor(IDM_MODERN);
\r
293 ChooseColor(IDM_BLUE);
\r
296 ChooseColor(IDM_GREY);
\r
299 ChooseColor(IDM_OLIVE);
\r
302 ChooseColor(IDM_OCHRE);
\r
305 ChooseColor(IDM_MAUVE);
\r
308 ChooseColor(IDM_PINK);
\r
311 ChooseColor(IDM_GOLD);
\r
314 ChooseColor(IDM_BLACK);
\r
316 case IDM_USE_THEMES:
\r
319 case IDM_BAND_COLORS:
\r
322 case IDM_FLAT_STYLE:
\r
325 case IDM_LEFT_BANDS:
\r
328 case IDM_LOCK_MENUBAR:
\r
331 case IDM_ROUND_BORDERS:
\r
334 case IDM_SHORT_BANDS:
\r
337 case IDM_USE_LINES:
\r
340 case IDM_VIEW_ARROWS:
\r
343 case IDM_VIEW_CARDS:
\r
346 case IDW_VIEW_STATUSBAR:
\r
349 case IDW_VIEW_TOOLBAR:
\r
352 case IDM_HELP_ABOUT:
\r
353 // Display the help dialog
\r
361 void CMainFrame::OnCreate()
\r
363 // OnCreate controls the way the frame is created.
\r
364 // Overriding CFrame::Oncreate is optional.
\r
365 // The default for the following variables is TRUE
\r
367 // m_bShowIndicatorStatus = FALSE; // Don't show statusbar indicators
\r
368 // m_bShowMenuStatus = FALSE; // Don't show toolbar or menu status
\r
369 // m_bUseReBar = FALSE; // Don't use rebars
\r
370 // m_bUseThemes = FALSE; // Don't use themes
\r
371 // m_bUseToolBar = FALSE; // Don't use a toolbar
\r
372 // m_bUseCustomDraw = FALSE; // Don't use custom draw for menu items
\r
374 // call the base class function
\r
375 CFrame::OnCreate();
\r
377 if (IsReBarSupported())
\r
379 //Set our theme colors
\r
380 ChooseColor(m_nColor);
\r
382 // Set the band styles and positions
\r
383 for (int i = 0; i < GetReBar().GetBandCount(); ++i)
\r
385 if (i < (int)m_vBandStyles.size())
\r
387 // Move the band to the correct position
\r
388 int iFrom = GetReBar().IDToIndex(m_vBandIDs[i]);
\r
389 GetReBar().MoveBand(iFrom, i);
\r
391 // Set the band's style
\r
392 REBARBANDINFO rbbi = {0};
\r
393 rbbi.fMask = RBBIM_STYLE;
\r
394 rbbi.fStyle = m_vBandStyles[i];
\r
395 GetReBar().SetBandInfo(i, rbbi);
\r
399 ShowArrows(m_bShowArrows);
\r
400 ShowCards(m_bShowCards);
\r
403 MessageBox(_T("Some Theme features are not supported on this Operating System"), _T("Warning"), MB_ICONWARNING);
\r
406 void CMainFrame::OnInitialUpdate()
\r
408 // The frame is now created.
\r
409 // Place any additional startup code here.
\r
411 TRACE(_T("Frame created\n"));
\r
414 LRESULT CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam)
\r
416 // Process notification messages sent by child windows
\r
417 // switch(((LPNMHDR)lParam)->code)
\r
419 //Add case statments for each notification message here
\r
422 // Pass any unhandled messages on for default processing
\r
423 return CFrame::OnNotify(wParam, lParam);
\r
426 void CMainFrame::OnUseThemes()
\r
428 if (IsReBarSupported())
\r
430 m_bUseThemes = !m_bUseThemes;
\r
431 BOOL bCheck = m_bUseThemes;
\r
432 GetFrameMenu().CheckMenuItem(IDM_USE_THEMES, MF_BYCOMMAND | (bCheck ? MF_CHECKED : MF_UNCHECKED));
\r
433 ReBarTheme rt = GetReBar().GetReBarTheme();
\r
434 rt.UseThemes = m_bUseThemes;
\r
435 GetReBar().SetReBarTheme(rt);
\r
436 int nBand = GetReBar().GetBand(GetMenuBar());
\r
437 GetReBar().ShowGripper(nBand, !m_bUseThemes);
\r
439 GetReBar().RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
\r
444 void CMainFrame::OnBandColors()
\r
446 if (IsReBarSupported())
\r
448 m_bBandColors = !m_bBandColors;
\r
449 BOOL bCheck = m_bBandColors;
\r
450 GetFrameMenu().CheckMenuItem(IDM_BAND_COLORS, MF_BYCOMMAND | (bCheck ? MF_CHECKED : MF_UNCHECKED));
\r
451 ChooseColor(m_nColor);
\r
453 GetReBar().RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
\r
457 void CMainFrame::OnFlatStyle()
\r
459 if (IsReBarSupported())
\r
461 m_bFlatStyle = !m_bFlatStyle;
\r
462 BOOL bCheck = m_bFlatStyle;
\r
463 GetFrameMenu().CheckMenuItem(IDM_FLAT_STYLE, MF_BYCOMMAND | (bCheck ? MF_CHECKED : MF_UNCHECKED));
\r
464 ReBarTheme rt = GetReBar().GetReBarTheme();
\r
465 rt.FlatStyle = m_bFlatStyle;
\r
466 GetReBar().SetReBarTheme(rt);
\r
468 GetReBar().RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
\r
472 void CMainFrame::OnLeftBands()
\r
474 if (IsReBarSupported())
\r
476 m_bBandsLeft = !m_bBandsLeft;
\r
477 BOOL bCheck = m_bBandsLeft;
\r
478 GetFrameMenu().CheckMenuItem(IDM_LEFT_BANDS, MF_BYCOMMAND | (bCheck ? MF_CHECKED : MF_UNCHECKED));
\r
479 ReBarTheme rt = GetReBar().GetReBarTheme();
\r
480 rt.BandsLeft = m_bBandsLeft;
\r
481 GetReBar().SetReBarTheme(rt);
\r
483 GetReBar().RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
\r
487 void CMainFrame::OnLockMenuBar()
\r
489 if (IsReBarSupported())
\r
491 m_bLockMenuBand = !m_bLockMenuBand;
\r
492 BOOL bCheck = m_bLockMenuBand;
\r
493 GetFrameMenu().CheckMenuItem(IDM_LOCK_MENUBAR, MF_BYCOMMAND | (bCheck ? MF_CHECKED : MF_UNCHECKED));
\r
494 ReBarTheme rt = GetReBar().GetReBarTheme();
\r
495 rt.LockMenuBand = m_bLockMenuBand;
\r
496 GetReBar().SetReBarTheme(rt);
\r
497 GetReBar().MoveBand(GetReBar().GetBand(GetMenuBar()), 0); // Move the MenuBar to band 0
\r
499 GetReBar().RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
\r
503 void CMainFrame::OnRoundBorders()
\r
505 if (IsReBarSupported())
\r
507 m_bRoundBorders = !m_bRoundBorders;
\r
508 BOOL bCheck = m_bRoundBorders;
\r
509 GetFrameMenu().CheckMenuItem(IDM_ROUND_BORDERS, MF_BYCOMMAND | (bCheck ? MF_CHECKED : MF_UNCHECKED));
\r
510 ReBarTheme rt = GetReBar().GetReBarTheme();
\r
511 rt.RoundBorders = m_bRoundBorders;
\r
512 GetReBar().SetReBarTheme(rt);
\r
514 GetReBar().RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
\r
518 void CMainFrame::OnShortBands()
\r
520 if (IsReBarSupported())
\r
522 m_bShortBands = !m_bShortBands;
\r
523 BOOL bCheck = m_bShortBands;
\r
524 GetFrameMenu().CheckMenuItem(IDM_SHORT_BANDS, MF_BYCOMMAND | (bCheck ? MF_CHECKED : MF_UNCHECKED));
\r
525 ReBarTheme rt = GetReBar().GetReBarTheme();
\r
526 rt.ShortBands = m_bShortBands;
\r
527 GetReBar().SetReBarTheme(rt);
\r
529 GetReBar().RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
\r
533 void CMainFrame::OnUseLines()
\r
535 if (IsReBarSupported())
\r
537 m_bUseLines = !m_bUseLines;
\r
538 BOOL bCheck = m_bUseLines;
\r
539 GetFrameMenu().CheckMenuItem(IDM_USE_LINES, MF_BYCOMMAND | (bCheck ? MF_CHECKED : MF_UNCHECKED));
\r
540 ReBarTheme rt = GetReBar().GetReBarTheme();
\r
541 rt.UseLines = m_bUseLines;
\r
542 GetReBar().SetReBarTheme(rt);
\r
544 GetReBar().RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN);
\r
549 void CMainFrame::OnViewArrows()
\r
551 if (IsReBarSupported())
\r
553 m_bShowArrows = !m_bShowArrows;
\r
554 ShowArrows(m_bShowArrows);
\r
558 void CMainFrame::OnViewCards()
\r
560 if (IsReBarSupported())
\r
562 m_bShowCards = !m_bShowCards;
\r
563 ShowCards(m_bShowCards);
\r
567 BOOL CMainFrame::SaveRegistrySettings()
\r
569 if (IsReBarSupported())
\r
571 CFrame::SaveRegistrySettings();
\r
574 CString strKeyName = GetRegistryKeyName();
\r
575 CString strKey = _T("Software\\");
\r
576 strKey += strKeyName + (_T("\\Theme Settings"));
\r
577 int nBands = GetReBar().GetBandCount();
\r
579 RegCreateKeyEx(HKEY_CURRENT_USER, strKey, 0, NULL,
\r
580 REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL);
\r
582 // Save the theme settings
\r
583 RegSetValueEx(hKey, _T("ColorStyle"), 0, REG_DWORD, (LPBYTE)&m_nColor, sizeof(DWORD));
\r
584 RegSetValueEx(hKey, _T("UseThemes"), 0, REG_DWORD, (LPBYTE)&m_bUseThemes, sizeof(DWORD));
\r
585 RegSetValueEx(hKey, _T("UseBandColors"), 0, REG_DWORD, (LPBYTE)&m_bBandColors, sizeof(DWORD));
\r
586 RegSetValueEx(hKey, _T("UseFlatStyle"), 0, REG_DWORD, (LPBYTE)&m_bFlatStyle, sizeof(DWORD));
\r
587 RegSetValueEx(hKey, _T("PutBandsLeft"), 0, REG_DWORD, (LPBYTE)&m_bBandsLeft, sizeof(DWORD));
\r
588 RegSetValueEx(hKey, _T("LockMenuBand"), 0, REG_DWORD, (LPBYTE)&m_bLockMenuBand, sizeof(DWORD));
\r
589 RegSetValueEx(hKey, _T("UseRoundBorders"), 0, REG_DWORD, (LPBYTE)&m_bRoundBorders, sizeof(DWORD));
\r
590 RegSetValueEx(hKey, _T("UseShortBands"), 0, REG_DWORD, (LPBYTE)&m_bShortBands, sizeof(DWORD));
\r
591 RegSetValueEx(hKey, _T("UseLines"), 0, REG_DWORD, (LPBYTE)&m_bUseLines, sizeof(DWORD));
\r
592 RegSetValueEx(hKey, _T("ShowArrows"), 0, REG_DWORD, (LPBYTE)&m_bShowArrows, sizeof(DWORD));
\r
593 RegSetValueEx(hKey, _T("ShowCards"), 0, REG_DWORD, (LPBYTE)&m_bShowCards, sizeof(DWORD));
\r
594 RegSetValueEx(hKey, _T("NumBands"), 0, REG_DWORD, (LPBYTE)&nBands, sizeof(DWORD));
\r
596 // Save the rebar band settings
\r
597 REBARBANDINFO rbbi = {0};
\r
598 rbbi.fMask = RBBIM_ID|RBBIM_STYLE;
\r
600 for (int i = 0; i < nBands; i++)
\r
602 GetReBar().GetBandInfo(i, rbbi);
\r
603 UINT nID = rbbi.wID;
\r
604 UINT nStyle = rbbi.fStyle;
\r
606 TCHAR szSubKey[16];
\r
607 wsprintf(szSubKey, _T("Band ID %d\0"), i+1);
\r
608 RegSetValueEx(hKey, szSubKey, 0, REG_DWORD, (LPBYTE)&nID, sizeof(DWORD));
\r
609 wsprintf(szSubKey, _T("Band Style %d\0"), i+1);
\r
610 RegSetValueEx(hKey, szSubKey, 0, REG_DWORD, (LPBYTE)&nStyle, sizeof(DWORD));
\r
619 void CMainFrame::SetReBarTheme(COLORREF clrBkGnd1, COLORREF clrBkGnd2, COLORREF clrBand1, COLORREF clrBand2)
\r
621 if (IsReBarSupported())
\r
623 ReBarTheme rt = {0};
\r
624 rt.UseThemes = m_bUseThemes;
\r
625 rt.clrBkgnd1 = clrBkGnd1;
\r
626 rt.clrBkgnd2 = clrBkGnd2;
\r
627 rt.clrBand1 = clrBand1;
\r
628 rt.clrBand2 = clrBand2;
\r
629 rt.FlatStyle = m_bFlatStyle;
\r
630 rt.BandsLeft = m_bBandsLeft;
\r
631 rt.LockMenuBand = m_bLockMenuBand;
\r
632 rt.RoundBorders = m_bRoundBorders;
\r
633 rt.ShortBands = m_bShortBands;
\r
634 rt.UseLines = m_bUseLines;
\r
636 if (!m_bBandColors)
\r
642 GetReBar().SetReBarTheme(rt);
\r
646 void CMainFrame::SetupToolBar()
\r
648 // Set the Resource IDs for the first toolbar buttons
\r
649 AddToolBarButton( IDM_FILE_NEW );
\r
650 AddToolBarButton( IDM_FILE_OPEN );
\r
651 AddToolBarButton( 0 ); // Separator
\r
652 AddToolBarButton( IDM_FILE_SAVE );
\r
653 AddToolBarButton( 0 ); // Separator
\r
654 AddToolBarButton( IDM_EDIT_CUT );
\r
655 AddToolBarButton( IDM_EDIT_COPY );
\r
656 AddToolBarButton( IDM_EDIT_PASTE );
\r
657 AddToolBarButton( 0 ); // Separator
\r
658 AddToolBarButton( IDM_FILE_PRINT );
\r
659 AddToolBarButton( 0 ); // Separator
\r
660 AddToolBarButton( IDM_HELP_ABOUT );
\r
662 // Set the three image lists for the first toolbar
\r
663 SetToolBarImages(RGB(255, 0, 255), IDB_TOOLBAR_NORM, IDB_TOOLBAR_HOT, IDB_TOOLBAR_DIS);
\r
665 // Add the two other toolbars if we can use rebars (Need Win95 and IE 4 or better)
\r
666 if (IsReBarSupported())
\r
668 // Add the Arrows toolbar
\r
669 AddToolBarBand(Arrows, 0, IDC_ARROWS);
\r
670 Arrows.AddButton(IDM_ARROW_LEFT);
\r
671 Arrows.AddButton(IDM_ARROW_RIGHT);
\r
672 Arrows.SetImages(RGB(255,0,255), IDB_ARROWS, 0, 0);
\r
674 // Add the Cards toolbar
\r
675 AddToolBarBand(Cards, 0, IDC_CARDS);
\r
676 Cards.AddButton(IDM_CARD_CLUB);
\r
677 Cards.AddButton(IDM_CARD_DIAMOND);
\r
678 Cards.AddButton(IDM_CARD_HEART);
\r
679 Cards.AddButton(IDM_CARD_SPADE);
\r
680 Cards.SetImages(RGB(255,0,255), IDB_CARDS, 0, 0);
\r
686 void CMainFrame::ShowArrows(BOOL bShow)
\r
688 if (IsReBarSupported())
\r
690 UINT uCheck = bShow? MF_CHECKED: MF_UNCHECKED;
\r
692 GetFrameMenu().CheckMenuItem(IDM_VIEW_ARROWS, uCheck);
\r
693 GetReBar().SendMessage(RB_SHOWBAND, GetReBar().GetBand(Arrows), bShow);
\r
695 if (GetReBar().GetReBarTheme().UseThemes && GetReBar().GetReBarTheme().BandsLeft)
\r
696 GetReBar().MoveBandsLeft();
\r
700 void CMainFrame::ShowCards(BOOL bShow)
\r
702 if (IsReBarSupported())
\r
704 UINT uCheck = bShow? MF_CHECKED: MF_UNCHECKED;
\r
706 GetFrameMenu().CheckMenuItem(IDM_VIEW_CARDS, uCheck);
\r
707 GetReBar().SendMessage(RB_SHOWBAND, GetReBar().GetBand(Cards), bShow);
\r
709 if (GetReBar().GetReBarTheme().UseThemes && GetReBar().GetReBarTheme().BandsLeft)
\r
710 GetReBar().MoveBandsLeft();
\r
714 LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
718 // Add case statements for each messages to be handled here
\r
721 // pass unhandled messages on for default processing
\r
722 return WndProcDefault(uMsg, wParam, lParam);
\r