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

📄 mainfrm.cpp

📁 一个好的旅游管理系统,分享一下.不错的啊 .
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "常州旅游管理系统.h"

#include "MainFrm.h"
#include "常州旅游管理系统Doc.h"
#include "常州旅游管理系统View.h"
#include "FormDlgView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_TIMER()
	ON_UPDATE_COMMAND_UI(ID_INDICATOR_TIME, OnUpdateIndicatorTime)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{   
    
	ID_SEPARATOR,           // status line indicator
    ID_INDICATOR_TIME,//<--新的指示器窗格
	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)
{
	if (CFrameWnd::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);
    this->SetTimer(1,500,NULL);
	 m_nIDTimer = ::SetTimer(NULL, 0, 1000, TimerProc);
	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

//重载该函数
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{

   
	m_splitter.CreateStatic(this,1,2);
	m_splitter.CreateView(0,0,RUNTIME_CLASS(FormDlgView),CSize(200,250),pContext);
	m_splitter.CreateView(0,1,RUNTIME_CLASS(CMyView),CSize(10,50),pContext);
	return TRUE;//在这里返回TRUE,则不需要调用基类的OnCreateClient(),否则基类将只重载分割类
   

//	return CFrameWnd::OnCreateClient(lpcs, pContext);
}
/*
void CMainFrame::OnContextMenu(CWnd* pWnd, CPoint point) 
{
  CMenu menu;
  menu.LoadMenu(IDR_MENU1);
  CMenu* popup=menu.GetSubMenu(0);
  popup->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this);
	




}
*/
void CALLBACK CMainFrame::TimerProc(HWND hwnd, UINT uMsg,
UINT uIDEvent, DWORD dwTime)
{
   CMainFrame *pMainWnd = (CMainFrame *)AfxGetApp()->m_pMainWnd;
   ASSERT(uIDEvent = pMainWnd->m_nIDTimer);
   CCmdUI cui;
  cui.m_nID = ID_INDICATOR_TIME;
  cui.m_nIndex = 4;
  cui.m_pMenu = NULL;
  cui.m_pOther = &pMainWnd->m_wndStatusBar;
  pMainWnd->OnUpdateIndicatorTime(&cui);//调用OnUpdateTime()函数,更新时间显示
}



void CMainFrame::OnTimer(UINT nIDEvent) 
{
	 static int icons[]={IDI_ICON1,IDI_ICON2,IDI_ICON3};
	static long index=0;
	HICON hIconOld;
	HICON hIconNew;
	hIconNew=AfxGetApp()->LoadIcon(icons[index++%3]);
	hIconOld=(HICON)GetClassLong(m_hWnd,GCL_HICON);
	ASSERT(hIconNew);
	ASSERT(hIconOld);
	if(hIconNew!=hIconOld)
	{
		DestroyIcon(hIconOld);
		SetClassLong(m_hWnd,GCL_HICON,(long)hIconNew);
		RedrawWindow(NULL,NULL,RDW_FRAME|RDW_ERASE);
	}
	CFrameWnd::OnTimer(nIDEvent);
}

void CMainFrame::OnUpdateIndicatorTime(CCmdUI* pCmdUI) 
{
   //状态条时间显示函数
   CTime t = CTime::GetCurrentTime();
   char szTime[6];
   int nHour = t.GetHour();
   int nMinute = t.GetMinute();
   int nSecond = t.GetSecond();
   if (nHour > 12) nHour = nHour - 12;//如要按24小时制显示,请将此行注释掉
   wsprintf(szTime, "%i:%02i:%02i", nHour, nMinute,nSecond);//分秒一般习惯用两位表示
   //把时间写到Pane
   m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex
   (ID_INDICATOR_TIME), LPCSTR(szTime));
   pCmdUI->Enable();
	
	
}

⌨️ 快捷键说明

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