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

📄 mainfrm.cpp

📁 电力监控系统。 使用VC实现
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "CurverDemo.h"

#include "resource.h"
#include "MainFrm.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_COMMAND(ID_COMM_EXIT, OnCommExit)
	ON_WM_CLOSE()
	//}}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)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	//自己创建富有个性的工具条 
	CreateToolBar(); 

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

	FindWindow("Shell_TrayWnd",NULL)->ShowWindow(SW_HIDE);//隐藏任务栏

	return 0;
}

//=================================
// 创建自定义工具条
//=================================
void CMainFrame::CreateToolBar()
{
	m_wndToolBar.CreateEx(this,TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);	
	
	//创建图形列表
	CImageList img;

	img.Create(IDB_COMMCOLD, 21, 0, RGB(255, 0, 255));
	m_wndToolBar.GetToolBarCtrl().SetImageList(&img);
	img.Detach();

	img.Create(IDB_COMMHOT, 21, 0, RGB(255, 0, 255));
	m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img);
	img.Detach();

	//设置工具条按钮宽度最小、最大值
	m_wndToolBar.GetToolBarCtrl().SetButtonWidth(70, 100);
	m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);

	m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
	m_wndToolBar.SetButtons(NULL, 4);//按钮个数 

	// 创建每个按钮
	CString str;
	str="主界面";
	m_wndToolBar.SetButtonInfo(0, ID_MAINBMP, TBSTYLE_BUTTON, 0);
	m_wndToolBar.SetButtonText(0, str);


	m_wndToolBar.SetButtonInfo(1, ID_MSGSEL, TBSTYLE_BUTTON, 1);
	str="信息选择";
	m_wndToolBar.SetButtonText(1, str);


	m_wndToolBar.SetButtonInfo(2, ID_ABOUT, TBSTYLE_BUTTON, 2); 
	str="关于信息"; 
	m_wndToolBar.SetButtonText(2, str); 

	m_wndToolBar.SetButtonInfo(3, ID_COMM_EXIT, TBSTYLE_BUTTON, 3);
	str="系统退出";
	m_wndToolBar.SetButtonText(3, str);
 
	CRect rectToolBar;
	//获取工具条按钮大小
	m_wndToolBar.GetItemRect(0, &rectToolBar);
	//设置工具条的按钮大小和图标大小
	m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(21,22)); 
} 

//===============================
// 程序退出
//=================================
void CMainFrame::OnCommExit() 
{ 
	OnClose(); 
}


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


void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	if(MessageBox("确定要退出曲线显示模块吗?","询问信息",MB_OKCANCEL|MB_ICONQUESTION) == IDOK)
	{
		CFrameWnd::OnClose();
		FindWindow("Shell_TrayWnd",NULL)->ShowWindow(SW_SHOW);//恢复任务栏
	}	
}

⌨️ 快捷键说明

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