// MainFrm.cpp : implementation of the CMainFrame class // #include "stdafx.h" #include "CLIPF32.h" #include "CLIPF32Doc.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() ON_COMMAND(ID_FILE_OPEN, OnFileOpen) ON_WM_SIZE() ON_WM_PALETTECHANGED() ON_WM_PALETTEISCHANGING() ON_WM_QUERYNEWPALETTE() ON_WM_SYSCOLORCHANGE() //}}AFX_MSG_MAP END_MESSAGE_MAP() static UINT indicators[] = { ID_INDICATOR_PROGRESS_PANE, ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() { LBase::LoadLibraries(LT_ALL_LEADLIB); LDialogBase::Initialize(DLG_INIT_COLOR); WRPUNLOCKSUPPORT(); } CMainFrame::~CMainFrame() { LDialogBase::Free(); LBase::UnloadLibraries(LT_ALL_LEADLIB); } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } m_bProgressCreated = FALSE; m_bAbortProcess = FALSE; m_bInProcess = FALSE; return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs cs.style = WS_OVERLAPPEDWINDOW | WS_CAPTION ; cs.lpszName = _T("Classlib Image Processing Functions Demo"); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers void CMainFrame::OnFileOpen() { OPENDLGPARAMS FOParm ; OPENFILENAME OpenFileName; memset ( &FOParm, 0, sizeof(OPENDLGPARAMS)) ; memset ( &OpenFileName, 0, sizeof(OPENFILENAME)) ; OpenFileName.lStructSize = sizeof(OPENFILENAME); OpenFileName.lpstrInitialDir = NULL; OpenFileName.Flags = OFN_EXPLORER; FOParm.uStructSize = sizeof(OPENDLGPARAMS); FOParm.uDlgFlags = DLG_OPEN_SHOW_PROGRESSIVE | DLG_OPEN_SHOW_MULTIPAGE | DLG_OPEN_SHOW_LOADROTATED | DLG_OPEN_SHOW_LOADCOMPRESSED | DLG_OPEN_SHOW_FILEINFO | DLG_OPEN_SHOW_DELPAGE | DLG_OPEN_VIEWTOTALPAGES ; FOParm.bPreviewEnabled = TRUE; m_LeadDlg.SetOpenParams(&FOParm) ; m_LeadDlg.SetOpenFileName(&OpenFileName) ; m_LeadDlg.EnablePreview(TRUE); if(m_LeadDlg.DoModalOpen(AfxGetMainWnd()->GetSafeHwnd()) == SUCCESS_DLG_OK) { memset(&m_szFileName, 0, sizeof(m_szFileName)); m_LeadDlg.GetFileName(m_szFileName, sizeof(m_szFileName)); POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition(); CDocTemplate* pDocTemplate = AfxGetApp()->GetNextDocTemplate(pos); pDocTemplate->OpenDocumentFile((LPCTSTR)m_szFileName); } } void CMainFrame::OnSize(UINT nType, int cx, int cy) { RECT MyRect; CFrameWnd::OnSize(nType, cx, cy); if (!IsWindow (m_wndStatusBar.m_hWnd)) return; m_wndStatusBar.GetItemRect(0, &MyRect); // if our progress bar pane not created then create it if (m_bProgressCreated == FALSE) { //Create the progress control BOOL bRet = m_Progress.Create(WS_VISIBLE|WS_CHILD, MyRect, &m_wndStatusBar, 1); m_Progress.SetRange(0, 100); //Set the range to between 0 and 100 m_Progress.SetStep(1); // Set the step amount m_bProgressCreated = TRUE; } } void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) { CFrameWnd::OnPaletteChanged(pFocusWnd); // TODO: Add your message handler code here CCLIPF32View* pCView ; pCView = (CCLIPF32View*) GetActiveView(); if(pCView) pCView->HandlePalette(WM_PALETTECHANGED,pFocusWnd->m_hWnd); } void CMainFrame::OnPaletteIsChanging(CWnd* pRealizeWnd) { OnPaletteChanged (pRealizeWnd); } BOOL CMainFrame::OnQueryNewPalette() { // TODO: Add your message handler code here and/or call default CCLIPF32View* pCView ; pCView = (CCLIPF32View*) GetActiveView(); if(pCView) pCView->HandlePalette(WM_QUERYNEWPALETTE,pCView->m_hWnd); return CFrameWnd::OnQueryNewPalette(); } void CMainFrame::OnSysColorChange() { OnQueryNewPalette(); }