// MainFrm.cpp : implementation of the CMainFrame class // #include "stdafx.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_WM_SIZE() //}}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() { // TODO: add member initialization code here } CMainFrame::~CMainFrame() { } static const WCHAR BASED_CODE _szLicString[] = L"LEADTOOLS OCX Copyright (c) 1991-2004 LEAD Technologies, Inc."; 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; BSTR lpLic = SysAllocString(_szLicString); ILEADRasterFactory *pFactory=NULL; CoCreateInstance(CLSID_LEADRasterFactory, NULL, CLSCTX_ALL, IID_ILEADRasterFactory, (void**)&pFactory); if(!pFactory) { AfxMessageBox(TEXT("Failed to create Raster Class Factory\nThe demo will now abort.")); return -1; // fail to create } #if _MSC_VER < 1200 m_pRaster = (ILEADRaster*)pFactory->CreateObject("LEADRaster.LEADRaster.140", lpLic); #else ILEADRasterPtr spLEADRaster=NULL; #ifndef _UNICODE spLEADRaster = pFactory->CreateObject(TEXT("LEADRaster.LEADRaster.140"), lpLic); #else spLEADRaster = pFactory->CreateObject(TEXT("LEADRaster_U.LEADRaster_U.140"), lpLic); #endif m_pRaster = spLEADRaster; m_pRaster->AddRef();//because when spLEADRaster goes out of scope, it will auto Release()! #endif pFactory->Release(); SysFreeString(lpLic); return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; cs.style = WS_OVERLAPPEDWINDOW | WS_CAPTION; cs.lpszName = TEXT("COM Image Processing Feature 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::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; } }