Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MAINFRM.CPP
Package: openglsystem.rar [view]
Upload User: nthssl
Upload Date: 2022-04-05
Package Size: 25357k
Code Size: 12k
Category:
OpenCV
Development Platform:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "3DEditor.h"
- #include "MainFrm.h"
- #include "Splash.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- CStatusBar *statbar=0;
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_COMMAND(ID_VIEW_TBIMPEXP, OnViewTbimpexp)
- ON_UPDATE_COMMAND_UI(ID_VIEW_TBIMPEXP, OnUpdateViewTbimpexp)
- ON_COMMAND(ID_VIEW_TBLIGHT, OnViewTblight)
- ON_UPDATE_COMMAND_UI(ID_VIEW_TBLIGHT, OnUpdateViewTblight)
- ON_COMMAND(ID_VIEW_TBSELECT, OnViewTbselect)
- ON_UPDATE_COMMAND_UI(ID_VIEW_TBSELECT, OnUpdateViewTbselect)
- ON_COMMAND(ID_VIEW_TBVIEW, OnViewTbview)
- ON_UPDATE_COMMAND_UI(ID_VIEW_TBVIEW, OnUpdateViewTbview)
- ON_WM_DESTROY()
- ON_COMMAND(ID_VIEW_FULL_SCREEN, OnViewFullScreen)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FULL_SCREEN, OnUpdateViewFullScreen)
- ON_COMMAND(ID_VIEW_TBCAPTURE, OnViewTbcapture)
- ON_UPDATE_COMMAND_UI(ID_VIEW_TBCAPTURE, OnUpdateViewTbcapture)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- 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
- m_pToolBar_impexp=0;
- m_pToolBar_light=0;
- m_pToolBar_selectmode=0;
- m_pToolBar_viewmode=0;
- m_pToolBar_capture=0;
- m_bFullScreenMode=false;
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- statbar=&m_wndStatusBar;
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- // CG: The following line was added by the Splash Screen component. CSplashWnd::ShowSplashScreen(this);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CMDIFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- cs.cy = ::GetSystemMetrics(SM_CYSCREEN) ;
- cs.cx = ::GetSystemMetrics(SM_CXSCREEN) ;
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CMDIFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CMDIFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::OnViewTbimpexp()
- {
- // TODO: Add your command handler code here
- if (0 == m_pToolBar_impexp)
- {
- m_pToolBar_impexp = new CToolBar;
- CString ErrMsg;
- if (0 == m_pToolBar_impexp->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_CREATE);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- if (0 == m_pToolBar_impexp->LoadToolBar(IDR_TOOLBAR_IMPEXP))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_LOAD);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- m_pToolBar_impexp->EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(m_pToolBar_impexp);
- m_pToolBar_impexp->SetWindowText(_T("输入/输出"));
- }
- else
- // If the window is visible, hide it.
- if(m_pToolBar_impexp->IsWindowVisible() == TRUE)
- ShowControlBar(m_pToolBar_impexp, FALSE, FALSE);
- else
- // Otherwise, show it.
- ShowControlBar(m_pToolBar_impexp, TRUE, FALSE);
- }
- void CMainFrame::OnUpdateViewTbimpexp(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- if (0 == m_pToolBar_impexp)
- pCmdUI->SetCheck(FALSE);
- else
- if(m_pToolBar_impexp->IsWindowVisible() == TRUE)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMainFrame::OnViewTblight()
- {
- // TODO: Add your command handler code here
- if (0 == m_pToolBar_light)
- {
- m_pToolBar_light = new CToolBar;
- CString ErrMsg;
- if (0 == m_pToolBar_light->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_CREATE);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- if (0 == m_pToolBar_light->LoadToolBar(IDR_TOOLBAR_LIGHT))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_LOAD);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- m_pToolBar_light->EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(m_pToolBar_light);
- m_pToolBar_light->SetWindowText(_T("光照"));
- }
- else
- // If the window is visible, hide it.
- if(m_pToolBar_light->IsWindowVisible() == TRUE)
- ShowControlBar(m_pToolBar_light, FALSE, FALSE);
- else
- // Otherwise, show it.
- ShowControlBar(m_pToolBar_light, TRUE, FALSE);
- }
- void CMainFrame::OnUpdateViewTblight(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- if (0 == m_pToolBar_light)
- pCmdUI->SetCheck(FALSE);
- else
- if(m_pToolBar_light->IsWindowVisible() == TRUE)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMainFrame::OnViewTbselect()
- {
- // TODO: Add your command handler code here
- if (0 == m_pToolBar_selectmode)
- {
- m_pToolBar_selectmode = new CToolBar;
- CString ErrMsg;
- if (0 == m_pToolBar_selectmode->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_CREATE);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- if (0 == m_pToolBar_selectmode->LoadToolBar(IDR_TOOLBAR_SELECTMODE))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_LOAD);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- m_pToolBar_selectmode->EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(m_pToolBar_selectmode);
- m_pToolBar_selectmode->SetWindowText(_T("选择"));
- }
- else
- // If the window is visible, hide it.
- if(m_pToolBar_selectmode->IsWindowVisible() == TRUE)
- ShowControlBar(m_pToolBar_selectmode, FALSE, FALSE);
- else
- // Otherwise, show it.
- ShowControlBar(m_pToolBar_selectmode, TRUE, FALSE);
- }
- void CMainFrame::OnUpdateViewTbselect(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- if (0 == m_pToolBar_selectmode)
- pCmdUI->SetCheck(FALSE);
- else
- if(m_pToolBar_selectmode->IsWindowVisible() == TRUE)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMainFrame::OnViewTbview()
- {
- // TODO: Add your command handler code here
- if (0 == m_pToolBar_viewmode)
- {
- m_pToolBar_viewmode = new CToolBar;
- CString ErrMsg;
- if (0 == m_pToolBar_viewmode->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_CREATE);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- if (0 == m_pToolBar_viewmode->LoadToolBar(IDR_TOOLBAR_VIEWMODE))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_LOAD);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- m_pToolBar_viewmode->EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(m_pToolBar_viewmode);
- m_pToolBar_viewmode->SetWindowText(_T("显示"));
- }
- else
- // If the window is visible, hide it.
- if(m_pToolBar_viewmode->IsWindowVisible() == TRUE)
- ShowControlBar(m_pToolBar_viewmode, FALSE, FALSE);
- else
- // Otherwise, show it.
- ShowControlBar(m_pToolBar_viewmode, TRUE, FALSE);
- }
- void CMainFrame::OnUpdateViewTbview(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- if (0 == m_pToolBar_viewmode)
- pCmdUI->SetCheck(FALSE);
- else
- if(m_pToolBar_viewmode->IsWindowVisible() == TRUE)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMainFrame::OnDestroy()
- {
- CMDIFrameWnd::OnDestroy();
- // TODO: Add your message handler code here
- if (0 != m_pToolBar_impexp)
- {
- delete m_pToolBar_impexp;
- m_pToolBar_impexp = 0;
- }
- if (0 != m_pToolBar_light)
- {
- delete m_pToolBar_light;
- m_pToolBar_light = 0;
- }
- if (0 != m_pToolBar_selectmode)
- {
- delete m_pToolBar_selectmode;
- m_pToolBar_selectmode = 0;
- }
- if (0 != m_pToolBar_viewmode)
- {
- delete m_pToolBar_viewmode;
- m_pToolBar_viewmode = 0;
- }
- }
- void CMainFrame::OnViewFullScreen()
- {
- // TODO: Add your command handler code here
- if(m_bFullScreenMode)
- FullScreenModeOff();
- else FullScreenModeOn();
- }
- void CMainFrame::OnUpdateViewFullScreen(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->SetCheck(m_bFullScreenMode);
- }
- void CMainFrame::FullScreenModeOn()
- {
- // 获取当前活动文档的窗口
- CMDIChildWnd* pChild=MDIGetActive();
- if(!pChild) return;
- m_bToolBarWasVisible=(m_wndToolBar.IsWindowVisible()!=0);
- m_wndToolBar.ShowWindow(SW_HIDE);
- m_bStatusBarWasVisible=(m_wndStatusBar.IsWindowVisible()!=0);
- m_wndStatusBar.ShowWindow(SW_HIDE);
- // 保存主窗口和子窗口的位置
- GetWindowRect(&m_mainRect);
- // 移走主窗口的标题
- LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
- style&=~WS_CAPTION;
- ::SetWindowLong(m_hWnd,GWL_STYLE,style);
- int screenx=GetSystemMetrics(SM_CXSCREEN);
- int screeny=GetSystemMetrics(SM_CYSCREEN);
- // 设置窗口位置
- SetWindowPos(NULL,0,0,screenx,screeny,SWP_NOZORDER);
- style=::GetWindowLong(pChild->m_hWnd,GWL_STYLE);
- m_bChildMax=(style & WS_MAXIMIZE)?true:false;
- // 保存最初的菜单,并设置菜单为NULL
- ASSERT(m_OrgMenu.GetSafeHmenu()==NULL);
- CMenu* pOldMenu=GetMenu();
- m_OrgMenu.Attach(pOldMenu->Detach());
- SetMenu((CMenu*)NULL);
- // 最大化子窗口
- this->ShowWindow (SW_SHOWMAXIMIZED);
- style=::GetWindowLong(pChild->m_hWnd,GWL_STYLE);
- style&=~WS_CAPTION;
- ::SetWindowLong(pChild->m_hWnd,GWL_STYLE,style);
- pChild->ShowWindow(SW_SHOWMAXIMIZED);
- m_bFullScreenMode=true;
- }
- void CMainFrame::FullScreenModeOff()
- {
- ASSERT(m_OrgMenu.GetSafeHmenu()!=NULL);
- SetMenu(&m_OrgMenu);
- m_OrgMenu.Detach();
- LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
- style|=WS_CAPTION;
- ::SetWindowLong(m_hWnd,GWL_STYLE,style);
- if(m_bToolBarWasVisible)
- m_wndToolBar.ShowWindow(SW_SHOW);
- if(m_bStatusBarWasVisible)
- m_wndStatusBar.ShowWindow(SW_SHOW);
- MoveWindow(&m_mainRect);
- RecalcLayout();
- CMDIChildWnd* pChild=MDIGetActive();
- style=::GetWindowLong(pChild->m_hWnd,GWL_STYLE);
- style|=WS_CAPTION;
- ::SetWindowLong(pChild->m_hWnd,GWL_STYLE,style);
- if(pChild){
- if(m_bChildMax)
- MDIMaximize(pChild);
- else MDIRestore(pChild);
- }
- m_bFullScreenMode=false;
- }
- void CMainFrame::OnViewTbcapture()
- {
- // TODO: Add your command handler code here
- if (0 == m_pToolBar_capture)
- {
- m_pToolBar_capture = new CToolBar;
- CString ErrMsg;
- if (0 == m_pToolBar_capture->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_CREATE);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- if (0 == m_pToolBar_capture->LoadToolBar(IDR_TOOLBAR_CAPTURE))
- {
- ErrMsg.LoadString(IDS_TOOLBAR_LOAD);
- ::AfxMessageBox(ErrMsg);
- return;
- }
- m_pToolBar_capture->EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(m_pToolBar_capture);
- m_pToolBar_capture->SetWindowText(_T("录制"));
- }
- else
- // If the window is visible, hide it.
- if(m_pToolBar_capture->IsWindowVisible() == TRUE)
- ShowControlBar(m_pToolBar_capture, FALSE, FALSE);
- else
- // Otherwise, show it.
- ShowControlBar(m_pToolBar_capture, TRUE, FALSE);
- }
- void CMainFrame::OnUpdateViewTbcapture(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- if (0 == m_pToolBar_capture)
- pCmdUI->SetCheck(FALSE);
- else
- if(m_pToolBar_capture->IsWindowVisible() == TRUE)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }