1 ////////////////////////////////////////////////////
\r
5 #include "resource.h"
\r
9 // Definitions for the CMainFrame class
\r
10 CMainFrame::CMainFrame()
\r
12 // Constructor for CMainFrame. Its called after CFrame's constructor
\r
14 //Set m_View as the view window of the frame
\r
17 // Set the registry key name, and load the initial window position
\r
18 // Use a registry key name like "CompanyName\\Application"
\r
19 LoadRegistrySettings(_T("Win32++\\Picture Sample"));
\r
22 CMainFrame::~CMainFrame()
\r
24 // Destructor for CMainFrame.
\r
27 BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
\r
29 // OnCommand responds to menu and and toolbar input
\r
31 UNREFERENCED_PARAMETER(lParam);
\r
33 switch(LOWORD(wParam))
\r
44 case IDM_FILE_SAVEAS:
\r
48 // End the application
\r
49 ::PostMessage(m_hWnd, WM_CLOSE, 0, 0);
\r
51 case IDW_VIEW_STATUSBAR:
\r
54 case IDW_VIEW_TOOLBAR:
\r
57 case IDM_HELP_ABOUT:
\r
58 // Display the help dialog
\r
66 void CMainFrame::OnCreate()
\r
71 void CMainFrame::OnFileNew()
\r
73 m_View.NewPictureFile();
\r
76 void CMainFrame::OnFileOpen()
\r
78 TCHAR szFilter[] = _T("Supported Files Types(*.bmp;*.gif;*.jpg;*.ico;*.emf;*.wmf)\0*.bmp;*.gif;*.jpg;*.ico;*.emf;*.wmf\0Bitmaps (*.bmp)\0*.bmp\0GIF Files (*.gif)\0*.gif\0JPEG Files (*.jpg)\0*.jpg\0Icons (*.ico)\0*.ico\0Enhanced Metafiles (*.emf)\0*.emf\0Windows Metafiles (*.wmf)\0*.wmf\0\0");
\r
81 CString str = File.OpenFileDialog(0, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, szFilter, this);
\r
84 m_View.LoadPictureFile(str);
\r
85 CRect rcImage = m_View.GetImageRect();
\r
86 AdjustFrameRect(rcImage);
\r
90 void CMainFrame::OnFileSaveAs()
\r
92 if (m_View.GetPicture())
\r
94 TCHAR szFilter[] = _T("*.bmp\0");
\r
96 CString str = File.SaveFileDialog(0, OFN_SHOWHELP | OFN_OVERWRITEPROMPT, szFilter, _T("bmp"), this);
\r
100 m_View.SavePicture(str);
\r
105 void CMainFrame::SetupToolBar()
\r
107 // Set the Resource IDs for the toolbar buttons
\r
108 AddToolBarButton( IDM_FILE_NEW );
\r
109 AddToolBarButton( IDM_FILE_OPEN );
\r
110 AddToolBarButton( IDM_FILE_SAVE );
\r
112 AddToolBarButton( 0 ); // Separator
\r
113 AddToolBarButton( IDM_EDIT_CUT, FALSE );
\r
114 AddToolBarButton( IDM_EDIT_COPY, FALSE );
\r
115 AddToolBarButton( IDM_EDIT_PASTE, FALSE );
\r
117 AddToolBarButton( 0 ); // Separator
\r
118 AddToolBarButton( IDM_FILE_PRINT, FALSE );
\r
120 AddToolBarButton( 0 ); // Separator
\r
121 AddToolBarButton( IDM_HELP_ABOUT );
\r
123 // Set the image lists for normal, hot and disabled buttons
\r
124 SetToolBarImages(RGB(192,192,192), IDB_TOOLBAR_NORM, IDB_TOOLBAR_HOT, IDB_TOOLBAR_DIS);
\r
127 LRESULT CMainFrame::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
131 // Add case statements for each messages to be handled here
\r
134 // pass unhandled messages on for default processing
\r
135 return WndProcDefault(uMsg, wParam, lParam);
\r