/*[]=====================================================================[]*/ /*[] LEADTOOLS for Windows(Class Library) - Version 11 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2000 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ /*------(SetTools)--------------------------------------------------------------- We have made the assumption that the user has the knowledge of Object Oriented programing of C under Windows. This example will: 1. load the image from a file, whose name is sent through the command line. 2. display the image will be automatic.since we use LBitmapWindow class. 3. after that you can use the menu Items to change between the diferent Tools that LBitmapWindow support like(pan image tool,zoom rect tool, zoom in mouse tool,and also if you use or region tool you can change between region type like polygon,rect, free hande.....). Usage: CLRSPACE ----------------------------------------------------------------------------------*/ // StTlView.cpp : implementation of the CSetToolView class #include "stdafx.h" #include "SetTool.h" #include "SetTDoc.h" #include "SetTVw.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSetToolView IMPLEMENT_DYNCREATE(CSetToolView, CView) BEGIN_MESSAGE_MAP(CSetToolView, CView) //{{AFX_MSG_MAP(CSetToolView) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! ON_COMMAND_RANGE( IDM_TOOL_NONE, IDM_TOOL_ZOOM_IN_MOUSE, OnCmd) ON_COMMAND_RANGE( IDM_RGN_ANIMFRAME, IDM_RGN_NONEFRAME, OnCmdFrm) ON_UPDATE_COMMAND_UI_RANGE( IDM_TOOL_NONE, IDM_RGN_NONEFRAME, OnUpdateFunction) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSetToolView construction/destruction CSetToolView::CSetToolView() { // TODO: add construction code here } CSetToolView::~CSetToolView() { } BOOL CSetToolView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CSetToolView drawing void CSetToolView::OnDraw(CDC* pDC) { CSetToolDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } ///////////////////////////////////////////////////////////////////////////// // CSetToolView diagnostics #ifdef _DEBUG void CSetToolView::AssertValid() const { CView::AssertValid(); } void CSetToolView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CSetToolDoc* CSetToolView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSetToolDoc))); return (CSetToolDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CSetToolView message handlers void CSetToolView::OnInitialUpdate() { CView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class m_LBitmapWnd.SetWndHandle( GetSafeHwnd() ); CSetToolApp* pCApp =(CSetToolApp*) AfxGetApp(); L_INT nRet = m_LBitmapWnd.Load((L_TCHAR*)(LPCTSTR)pCApp->m_strFileName); if( nRet !=SUCCESS ) { LBase::DisplayError(AfxGetMainWnd()->m_hWnd, nRet); exit(EXIT_FAILURE); } //initialize Default Settings of Tool & Frame m_LBitmapWnd.SetToolType(TOOL_USERMODE); m_LBitmapWnd.SetRgnFrameType(RGNFRAME_ANIMATED); } void CSetToolView::OnUpdateFunction(CCmdUI* pCMD) { if(pCMD->m_nID == IDM_RGN_CANCEL) { pCMD->Enable( m_LBitmapWnd.HasFloater() ); return; } if(pCMD->m_nID == m_nChecked) pCMD->SetCheck(TRUE); else if(pCMD->m_nID ==m_nCheckedFrm) pCMD->SetCheck(TRUE); else pCMD->SetCheck(FALSE); } void CSetToolView::OnCmd(L_UINT uId) { switch(uId) { case IDM_TOOL_NONE: m_LBitmapWnd.SetToolType(TOOL_USERMODE); break; case IDM_RGN_TRIANGLE: m_LBitmapWnd.SetToolType(TOOL_REGION); m_LBitmapWnd.SetRegionType(REGION_TYPE_TRIANGLE); break; case IDM_RGN_RECTANGLE: m_LBitmapWnd.SetToolType(TOOL_REGION); m_LBitmapWnd.SetRegionType(REGION_TYPE_RECT); break; case IDM_RGN_RNDRECT: m_LBitmapWnd.SetToolType(TOOL_REGION); m_LBitmapWnd.SetRegionType(REGION_TYPE_ROUNDRECT); break; case IDM_RGN_ELLIPSE: m_LBitmapWnd.SetToolType(TOOL_REGION); m_LBitmapWnd.SetRegionType(REGION_TYPE_ELIPSE); break; case IDM_RGN_FREEHAND: m_LBitmapWnd.SetToolType(TOOL_REGION); m_LBitmapWnd.SetRegionType(REGION_TYPE_FREE_HAND); break; case IDM_RGN_POLYGON: m_LBitmapWnd.SetToolType(TOOL_REGION); m_LBitmapWnd.SetRegionType(REGION_TYPE_POLYGON); break; case IDM_TOOL_PANIMAGE: m_LBitmapWnd.SetToolType(TOOL_PANIMAGE); break; case IDM_TOOL_ZOOMRECT: m_LBitmapWnd.SetToolType(TOOL_ZOOMRECT); break; case IDM_RGN_CANCEL: m_LBitmapWnd.CancelRgn(); m_LBitmapWnd.SetToolType(TOOL_USERMODE); break; case IDM_TOOL_ZOOM_IN_MOUSE: m_LBitmapWnd.SetToolType(TOOL_ZOOM_ON_MOUSECLICK); break; } m_nChecked = uId; } void CSetToolView::OnCmdFrm(L_UINT uId) { switch(uId) { case IDM_RGN_STATICFRAME: m_LBitmapWnd.SetRgnFrameType(RGNFRAME_STATIC); break; case IDM_RGN_NONEFRAME: m_LBitmapWnd.SetRgnFrameType(RGNFRAME_NONE); break; case IDM_RGN_ANIMFRAME: m_LBitmapWnd.SetRgnFrameType(RGNFRAME_ANIMATED); break; } m_nCheckedFrm = uId; } void CSetToolView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) { // TODO: Add your specialized code here and/or call the base class CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd(); // TODO: Add your specialized code here and/or call the base class if(bActivate==TRUE&&pActivateView==this) m_LBitmapWnd.HandlePalette(WM_QUERYNEWPALETTE, 0, 0); CView::OnActivateView(bActivate, pActivateView, pDeactiveView); }