www.pudn.com > TCPIPAnalyse1.rar > MainFrm.cpp


// MainFrm.cpp : implementation of the CMainFrame class 
// 
 
#include "stdafx.h" 
#include "IrisAnalyse.h" 
 
#include "MainFrm.h" 
#include "splash.h" 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CMainFrame 
 
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) 
 
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) 
	//{{AFX_MSG_MAP(CMainFrame) 
	ON_WM_CREATE() 
	ON_WM_PAINT() 
	ON_WM_TIMER() 
	//}}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 
	 
} 
 
CMainFrame::~CMainFrame() 
{ 
} 
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
	SetTimer(1,50,NULL); 
	splash = new CSplash; 
	splash ->Create(IDD_DIALOG_SPLASH); 
	splash ->ShowWindow(SW_SHOW); 
	splash ->UpdateWindow(); 
 
	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 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_wndStatusBar.SetPaneInfo(0, ID_SEPARATOR, m_wndStatusBar.GetPaneStyle(0), 10);  
	//add char to toolbar 
	CString str; 
	UINT id; 
	for (int i=0;ihwnd==m_hWndMDIClient && pMsg->message==WM_PAINT) 
	PostMessage(WM_PAINT); 
 
	return CMDIFrameWnd::PreTranslateMessage(pMsg); 
} 
 
void CMainFrame::OnPaint()  
{ 
	//PAINT MAINWINDOW BACKGROUND 
	//CPaintDC dc(this); // device context for painting 
	CDC dc, memdc; 
	dc.m_hDC=::GetDC(this->m_hWndMDIClient); 
	CRect rect; 
	CBitmap bitmap; 
	BITMAP szbitmap; 
	bitmap.LoadBitmap(IDB_BITMAP4); 
	bitmap.GetObject(sizeof(BITMAP),&szbitmap); 
	CSize size(szbitmap.bmWidth,szbitmap.bmHeight); 
	memdc.CreateCompatibleDC(&dc); 
	CBitmap *oldbitmap=memdc.SelectObject(&bitmap); 
	GetClientRect(&rect); 
	StretchBlt(dc.m_hDC,0,0,rect.Width(),rect.Height(), 
			   memdc.m_hDC,0,0,size.cx,size.cy,SRCCOPY); 
	memdc.SelectObject(oldbitmap); 
	memdc.DeleteDC(); 
	dc.DeleteDC(); 
	CMDIFrameWnd::OnPaint(); 
 
	// TODO: Add your message handler code here 
	 
	// Do not call CMDIFrameWnd::OnPaint() for painting messages 
} 
 
void CMainFrame::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
	//TODO:Add your message handler code here and/or call default 
	if (nIDEvent==1) 
	{ 
		if(splash->IsWindowVisible()) 
		{ 
			splash ->SetActiveWindow(); 
			splash ->UpdateWindow(); 
			//Sleep(2000); 
			splash->SendMessage(WM_CLOSE); 
		} 
		else 
		{ 
			SetActiveWindow(); 
			KillTimer(1); 
		} 
	} 
	CMDIFrameWnd::OnTimer(nIDEvent); 
}