⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 ISO9000质量管理小程序
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "Ex07b.h"
#include "ScrollView.h"
#include "Ex07bView.h"
#include "Tuxing.h"
#include "ZhifangTuxing.h"
#include "SbtTuxing.h"

#include "MainFrm.h"
#include "Splash.h"

extern CEx07bApp theApp;  //跨文件使用
extern BOOL m_pmenu;
extern BOOL m_smenu;
extern BOOL m_zmenu;

#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_BN_CLICKED(IDC_TUXING, OnTuxing)
	ON_COMMAND(ID_XIANSHI, OnXianshi)
	ON_WM_TIMER()
	ON_COMMAND(ID_XIANSHIZFT, OnXianshizft)
	ON_COMMAND(ID_XIANSHISBT, OnXianshisbt)
	ON_WM_DESTROY()
	ON_WM_CLOSE()
	ON_UPDATE_COMMAND_UI(ID_XIANSHI, OnUpdateXianshi)
	ON_UPDATE_COMMAND_UI(ID_XIANSHISBT, OnUpdateXianshisbt)
	ON_UPDATE_COMMAND_UI(ID_XIANSHIZFT, OnUpdateXianshizft)
	//}}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,5,NULL);//添加ID号为1 的WM_TIMER事件,响应频率不宜过大;
//	splash = new CSplashDlg();
	//可以添加播放WAV声音的代码;
	//sndPlaySound("welcome.wav",SND_ASYNC);
	//PlaySound("welcome.wav",NULL,SND_ASYNC);

//	splash->Create(IDD_DIALOG3);
//	splash->ShowWindow(SW_SHOW);
//	splash->UpdateWindow();

	m_animIcon.SetImageList(IDB_ANIM_IMGLIST,3,RGB(0,0,0));
	m_timerID=this->SetTimer(2,500,NULL);



	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
	}

	// 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);

	LoadBarState("Control Bar States");

	// 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.cx=720;
	cs.cy=550;
	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::CreateOrActivateFrame(CDocTemplate *pTemplate,
			CRuntimeClass * pViewClass)
{
	CMDIChildWnd * pMDIActive = MDIGetActive();
	ASSERT(pMDIActive != NULL);
		CDocument *pDoc=pMDIActive->GetActiveDocument();

	ASSERT(pDoc!=NULL);

	CView * pView;
	POSITION pos=pDoc->GetFirstViewPosition();

	while(pos!=NULL)
	{
		pView = pDoc->GetNextView(pos);
		if(pView->IsKindOf(pViewClass))
		{
			pView->GetParentFrame()->ActivateFrame();
			return;
		}
	}


	CMDIChildWnd * pNewFrame = (CMDIChildWnd *) (pTemplate->CreateNewFrame(pDoc,NULL));
	if(pNewFrame==NULL)
			return;
	ASSERT_KINDOF(CMDIChildWnd,pNewFrame);
	pTemplate->InitialUpdateFrame(pNewFrame,pDoc);
	MDITile(MDITILE_HORIZONTAL);
}



void CMainFrame::OnTuxing()
{
	CreateOrActivateFrame(theApp.m_pTuxingDocTemplate,
		RUNTIME_CLASS(Tuxing));
}

void CMainFrame::OnXianshi() 
{
	// TODO: Add your command handler code here
//	MessageBox("alskjf");
	CreateOrActivateFrame(theApp.m_pTuxingDocTemplate,
		RUNTIME_CLASS(Tuxing));
}

void CMainFrame::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default

	if (nIDEvent==2)
	{
		m_animIcon.ShowNextImage();
		CFrameWnd::OnTimer(nIDEvent);
	}

/*	if (nIDEvent==1)
	{
	CWnd *m_Wnd=NULL;
	m_Wnd=GetDlgItem(IDC_TONGJI);
	m_Wnd->EnableWindow();

	}
	*/
//	if (nIDEvent == 1){
//		if (splash->IsWindowVisible()){
			//启动封面设置为当前活动窗口;
//			splash->SetActiveWindow();
//			splash->UpdateWindow();
			//启动封面停留时间;
//			Sleep(2000);
//			splash->SendMessage(WM_CLOSE);
//		}
//		else{
			//应用程序窗口设置为当前活动窗口;
//			SetActiveWindow();
			//清除WM_TIMER事件;
//			KillTimer(1);
//		}
//	}
	

//	CMDIFrameWnd::OnTimer(nIDEvent);
}

void CMainFrame::OnXianshizft() 
{
	// TODO: Add your command handler code here
	CreateOrActivateFrame(theApp.m_zTuxingDocTemplate,
		RUNTIME_CLASS(CZhifangTuxing));	
}

void CMainFrame::OnXianshisbt() 
{
	// TODO: Add your command handler code here
	CreateOrActivateFrame(theApp.m_sTuxingDocTemplate,
		RUNTIME_CLASS(CSbtTuxing));	
}


void CMainFrame::OnDestroy() 
{
	CMDIFrameWnd::OnDestroy();
	
	// TODO: Add your message handler code here
	if(m_timerID != 0)
		KillTimer(m_timerID);
	
}

void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	//保存控件条状态
	SaveBarState("Control Bar States");
	//保存屏幕大小
	HKEY key;
	DWORD size, type, disposition;
	WINDOWPLACEMENT wp;
	if (RegOpenKeyEx( HKEY_CURRENT_USER,SETTING_KEY,0,
           KEY_WRITE,&key)!=ERROR_SUCCESS)
	{
		RegCreateKeyEx( HKEY_CURRENT_USER,SETTING_KEY,0,"",
        		REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,
					&key,&disposition);
	}
	type = REG_BINARY;
	size=sizeof(WINDOWPLACEMENT);
	GetWindowPlacement(&wp);
	RegSetValueEx( key,WINDOWPLACEMENT_KEY,0,type,(LPBYTE)&wp,size );
	RegCloseKey( key );
	
	CMDIFrameWnd::OnClose();
}

void CMainFrame::OnUpdateXianshi(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
    pCmdUI->Enable(m_pmenu);		
}

void CMainFrame::OnUpdateXianshisbt(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
   pCmdUI->Enable(m_smenu);	
}

void CMainFrame::OnUpdateXianshizft(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
   pCmdUI->Enable(m_zmenu);	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -