www.pudn.com > vc5ͼÏñ²É¼¯ code.rar > MainFrm.cpp


// MainFrm.cpp : implementation of the CMainFrame class 
// 
 
#include "stdafx.h" 
#include "OkMfc.h" 
 
#include "MainFrm.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
#include "okapi32.h" 
 
extern	CStatusBar*		sBar; 
extern	BYTE		bActive; 
extern	HANDLE		hBoard; 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame 
 
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) 
 
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) 
	//{{AFX_MSG_MAP(CMainFrame) 
	ON_WM_CREATE() 
	ON_WM_ACTIVATEAPP() 
	ON_WM_MOVING() 
	ON_WM_SIZE() 
	ON_WM_INITMENUPOPUP() 
	//}}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() 
{ 
} 
 
CMainFrame::~CMainFrame() 
{ 
} 
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1) 
		return -1; 
	 
	if (!m_wndToolBar.Create(this) || 
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) 
	{ 
		TRACE0("Failed to create toolbar\n"); 
		return -1;      // fail to create 
	} 
 
	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_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | 
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); 
 
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 
	EnableDocking(CBRS_ALIGN_ANY); 
	DockControlBar(&m_wndToolBar); 
 
	return 0; 
} 
 
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	return CFrameWnd::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// 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::ActivateFrame(int nCmdShow)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
	sBar=(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_VIEW_STATUS_BAR,TRUE); 
	CFrameWnd::ActivateFrame(nCmdShow); 
} 
 
 
void CMainFrame::OnActivateApp(BOOL bActive, HTASK hTask)  
{ 
	CFrameWnd::OnActivateApp(bActive, hTask); 
	 
	// TODO: Add your message handler code here 
} 
 
void CMainFrame::OnMoving(UINT fwSide, LPRECT pRect)  
{ 
	CFrameWnd::OnMoving(fwSide, pRect); 
	 
	// TODO: Add your message handler code here 
	if(bActive) //to pause capturing 
		SendMessage(WM_COMMAND,IDM_FREEZE,0); 
} 
 
void CMainFrame::OnSize(UINT nType, int cx, int cy)  
{ 
	if(bActive) //to pause capturing 
		SendMessage(WM_COMMAND,IDM_FREEZE,0); 
	CFrameWnd::OnSize(nType, cx, cy); 
	 
	// TODO: Add your message handler code here 
} 
 
void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)  
{ 
	CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); 
	 
	// TODO: Add your message handler code here 
	if(bActive) 
		SendMessage(WM_COMMAND,IDM_FREEZE,0); 
} 
 
 
 
LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)  
{ 
	/*if (message == WM_SYSCOMMAND) 
	{ 
		if(wParam==SC_MINIMIZE || wParam==SC_RESTORE ) { 
			if(wParam==SC_MINIMIZE) 
				//if(bActive) 
					okStopCapture(hBoard);	 
			InvalidateRect(NULL, TRUE); 
		} 
	}*/ 
	 
	return CFrameWnd::WindowProc(message, wParam, lParam); 
}