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

📄 mainfrm.cpp

📁 VC++编写的论文管理系统
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "QQ.h"
#include "QQView.h"
#include "MainFrm.h"
#include "DialogSetOther.h"
#include "ShowDialog.h"
#include "Asy.h"
#include "global.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include <mmsystem.h>
#define WM_ICON_NOTIFY WM_USER+10  //自定义消息的宏定义


#include "NameSel.h"
#include "ThesisSel.h"
#include "KeyWord.h"
#include "Lookup.h"

SEL_TYPE showType;

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

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	ON_COMMAND_EX(CG_ID_VIEW_DIALOGBAR, OnBarCheck)
	ON_UPDATE_COMMAND_UI(CG_ID_VIEW_DIALOGBAR, OnUpdateControlBarMenu)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_CLOSE()
	ON_COMMAND(IDC_HELPTEXT, OnHelp)
	ON_COMMAND(IDC_GAOTEXT, OnGao)
	ON_COMMAND(IDC_EMAIL, OnEmail)
	ON_COMMAND(IDC_EXIT, OnExit)
	ON_COMMAND(IDC_APPWZD, OnAppWzd)
	ON_COMMAND(IDC_PRE, OnPre)
	ON_COMMAND(IDC_BACK, OnBack)
	ON_WM_SIZING()
	ON_COMMAND(ID_TCH_ASY, OnTchAsy)
	ON_COMMAND(ID_THESIS_TYPE, OnThesisType)
	ON_COMMAND(ID_ALL_ASY, OnAllAsy)
	//}}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
//	pView=CQQView::GetView();
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	//创建扩展工具栏
	if (!this->CreateExToolBar())
		return -1;
    /************************************************************************/
    /*                   在工具栏上添加数字时钟                                                                     */
    /************************************************************************/
	if(!m_clock.Create("",WS_CHILD|WS_VISIBLE,CRect(0,0,135,40),this,IDC_CLOCK))
	{
		return -1;
	}
	m_wndReBar.AddBar(&m_clock,NULL, NULL, RBBS_FIXEDSIZE | RBBS_FIXEDBMP);
	m_clock.SetStyle(CLEDClock::XDC_SECOND);
	/*--------------------------------------------------------------*/

	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
	}

    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
	cs.style |= WS_MAXIMIZE;
	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
//	new CFaderWnd(this,2000);
//	AfxGetMainWnd()->ShowWindow(SW_HIDE);
	CFrameWnd::OnClose();
}
BOOL CMainFrame::CreateExToolBar()
{
    CImageList img;
	CString str;
	
	if(!m_wndReBar.Create(this))
	{
		return -1;
	}
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
	{
		return -1;      
	}

	//下面的代码是设置按钮的宽度和长度
	m_wndToolBar.GetToolBarCtrl().SetButtonWidth(50,90);
	//下面的代码是设置"热"的位图
	img.Create(25, 25, ILC_COLOR16|ILC_MASK,2,2);
	img.SetBkColor(::GetSysColor(COLOR_BTNFACE));
	img.Add(AfxGetApp()->LoadIcon(IDI_WZD));//应用程序向导
    img.Add(AfxGetApp()->LoadIcon(IDI_PRE));//前台程序
	img.Add(AfxGetApp()->LoadIcon(IDI_BACK));//后台程序
	img.Add(AfxGetApp()->LoadIcon(IDI_HELP));//帮助
	img.Add(AfxGetApp()->LoadIcon(IDI_HELP));//帮助
    img.Add(AfxGetApp()->LoadIcon(IDI_EMAIL));//邮件
	img.Add(AfxGetApp()->LoadIcon(IDI_EXIT));//退出
    
	m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img);
	img.Detach();	
	
	//下面的代码是设置"冷"的位图
	img.Create(23, 23, ILC_COLOR16|ILC_MASK, 2,2);
	img.SetBkColor(::GetSysColor(COLOR_BTNFACE));
	img.Add(AfxGetApp()->LoadIcon(IDI_WZD));//应用程序向导
    img.Add(AfxGetApp()->LoadIcon(IDI_PRE));//前台程序
	img.Add(AfxGetApp()->LoadIcon(IDI_BACK));//后台程序
	img.Add(AfxGetApp()->LoadIcon(IDI_HELP));//帮助
	img.Add(AfxGetApp()->LoadIcon(IDI_HELP));//帮助
    img.Add(AfxGetApp()->LoadIcon(IDI_EMAIL));//邮件
	img.Add(AfxGetApp()->LoadIcon(IDI_EXIT));//退出
    
	m_wndToolBar.GetToolBarCtrl().SetImageList(&img);
	img.Detach();
	
	//改变属性
	m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT |CBRS_TOOLTIPS | TBSTYLE_TRANSPARENT|TBBS_CHECKBOX );
	m_wndToolBar.SetButtons(NULL,7);	
	// set up each toolbar button设置文字  
	m_wndToolBar.SetButtonInfo(0, IDC_APPWZD, TBSTYLE_BUTTON, 0);
	m_wndToolBar.SetButtonText(0, "显示全部");
    
	m_wndToolBar.SetButtonInfo(1, IDC_PRE, TBSTYLE_BUTTON, 1);
	m_wndToolBar.SetButtonText(1, "题目查询");

	m_wndToolBar.SetButtonInfo(2, IDC_BACK, TBSTYLE_BUTTON, 2);
	m_wndToolBar.SetButtonText(2, "关键字查询");

	m_wndToolBar.SetButtonInfo(3, IDC_HELPTEXT, TBSTYLE_BUTTON, 3);
	m_wndToolBar.SetButtonText(3, "姓名查询");	

	m_wndToolBar.SetButtonInfo(4, IDC_GAOTEXT, TBSTYLE_BUTTON, 3);
	m_wndToolBar.SetButtonText(4, "高级查询");	
	
	m_wndToolBar.SetButtonInfo(5, IDC_EMAIL, TBSTYLE_BUTTON, 4);
	m_wndToolBar.SetButtonText(5, "设置");
	
	m_wndToolBar.SetButtonInfo(6, IDC_EXIT, TBSTYLE_BUTTON, 5);
	m_wndToolBar.SetButtonText(6,"退出");
	
    CRect rectToolBar;
	//得到按钮的大小
	m_wndToolBar.GetItemRect(0, &rectToolBar);
	//设置按钮的大小
	m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(20,23));
	
	//在Rebar中加入ToolBar
	m_wndReBar.AddBar(&m_wndToolBar);
	
	//改变一些属性
	REBARBANDINFO rbbi;
	rbbi.cbSize = sizeof(rbbi);		//这个是必须填
	rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE|RBBIM_BACKGROUND;
	//工具条的宽度
	rbbi.cxMinChild = rectToolBar.Width();
	//高度
	rbbi.cyMinChild = rectToolBar.Height();
	//下面这行代码是为工具条加入背景位图,请注意上rbbi.fMask中RBBIM_BACKGROUND标志
	rbbi.hbmBack = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_TOOLBARBKGND));
	
	rbbi.cx = rbbi.cxIdeal = rectToolBar.Width() * 10;
	
	m_wndReBar.GetReBarCtrl().SetBandInfo(0, &rbbi);
	return TRUE;
}
void CMainFrame::OnAppWzd()
{
   showType = NONE;
   PlayResource(IDR_PRESSBTN);
   CShowDialog dlg;
   dlg.DoModal();
}
//STU_NAME=0,TCH_NAME,THESIS_NAME,KEY_WORD,ALL,NONE }
void CMainFrame::OnPre()
{
	PlayResource(IDR_PRESSBTN);
    CThesisSel thesisinfolookup;
 //   thesisinfolookup.DoModal();
	if( thesisinfolookup.DoModal() == IDCANCEL )
		return;
//	AfxMessageBox(nameinfolookup.strText);
    showType = THESIS_NAME;
    CShowDialog dlg(thesisinfolookup.strText);
    dlg.DoModal();
}

void CMainFrame::OnBack()
{

	PlayResource(IDR_PRESSBTN);
	CKeyWord keywordinfolookup;
 //   keywordinfolookup.DoModal();
	if( keywordinfolookup.DoModal() == IDCANCEL )
		return;
//	AfxMessageBox(nameinfolookup.strText);
	showType = KEY_WORD;
    CShowDialog dlg(keywordinfolookup.strText);
    dlg.DoModal();

}
void CMainFrame::OnHelp()
{

	PlayResource(IDR_PRESSBTN);
    CNameSel nameinfolookup;
   // nameinfolookup.DoModal();
	if( nameinfolookup.DoModal() == IDCANCEL )
		return;
//	AfxMessageBox(nameinfolookup.strText);
	if( nameinfolookup.m_name_radio == 0)
        showType = STU_NAME;
	else
		showType = TCH_NAME;
    CShowDialog dlg(nameinfolookup.strText);
    dlg.DoModal();

//	CAboutDlg aboutDlg;
//	aboutDlg.DoModal();
 
}
void CMainFrame::OnGao()
{

	PlayResource(IDR_PRESSBTN);
    CLookup infolookup;
	if( infolookup.DoModal() == IDCANCEL )
		return;
	showType = ALL;
    CShowDialog dlg(infolookup.strText);
    dlg.DoModal();
 
}
void CMainFrame::OnEmail()
{

	PlayResource(IDR_PRESSBTN);
	CDialogSetOther m_Dlg;
	m_Dlg.DoModal();
}
void CMainFrame::OnExit()
{
	PlayResource(IDR_PRESSBTN);
	CFrameWnd::OnClose();
}

BOOL CMainFrame::PlayResource(WORD wResourceID)
{	
	// Get the handle to the current instance of the application
	HINSTANCE hInstance = AfxGetInstanceHandle();
    ASSERT (hInstance != NULL);
	
	// Find the WAVE resource
	HRSRC hResInfo = 
		FindResource(hInstance, MAKEINTRESOURCE(wResourceID), _T("WAVE"));
	if(hResInfo == NULL)
		return FALSE;
	
	// Load the WAVE resource
    HANDLE hRes = LoadResource(hInstance, hResInfo);
	if (hRes == NULL)
		return FALSE;
    
	// Lock the WAVE resource and play it
    LPSTR lpRes = (LPSTR) LockResource(hRes);
	if(lpRes==NULL)
		return FALSE;
    
	if (sndPlaySound(lpRes, SND_MEMORY | SND_ASYNC) == NULL)
		return FALSE;	
	
    // Free the WAVE resource and return success or failure.
    FreeResource(hRes);
	
	return TRUE;
}

void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect) 
{//改变框架的大小处理消息
	CFrameWnd::OnSizing(fwSide, pRect);


	// TODO: Add your message handler code here
	CQQView* pView=CQQView::GetView();
    RestorViewBmp();//改变大小时,视图区重画,
	                //显示在视图区的图像也被擦除,应该恢复

}

void CMainFrame::RestorViewBmp()
{//因为如窗口大小改变等原因引起视图区重画,恢复视图区先前显示的图像
	CQQView* pView=CQQView::GetView();
	pView->UpdateData(TRUE);
	CDC* pDC=pView->GetDC();
    CRect rect;
	pView->GetClientRect(&rect);
//	pDC->FillSolidRect(rect,pDC->GetBkColor());
	CBitmap* m_bitmap=CBitmap::FromHandle(pView->m_CurScreenBitmap);
	CDC MemDC;
	MemDC.CreateCompatibleDC(pDC);
	MemDC.SelectObject(m_bitmap);
	pDC->BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);
}

void CMainFrame::DoDataExchange(CDataExchange* pDX) 
{
	// TODO: Add your specialized code here and/or call the base class
	DDX_Control(pDX, IDC_CLOCK, m_clock);
	CFrameWnd::DoDataExchange(pDX);
}

void CMainFrame::OnTchAsy() 
{
	// TODO: Add your command handler code here
	CAsy dlg(1);
	dlg.DoModal();
	
}

void CMainFrame::OnThesisType() 
{
	// TODO: Add your command handler code here
	CAsy dlg(2);
	dlg.DoModal();
	
}

void CMainFrame::OnAllAsy() 
{
	// TODO: Add your command handler code here
	CAsy dlg(0);
	dlg.DoModal();
	
}
/////////////////////////////////////////////////////////////////////////////
// CSetMaxNum dialog

/*
CSetMaxNum::CSetMaxNum(CWnd* pParent /=NULL/)
	: CDialog(CSetMaxNum::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetMaxNum)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CSetMaxNum::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetMaxNum)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetMaxNum, CDialog)
	//{{AFX_MSG_MAP(CSetMaxNum)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetMaxNum message handlers

void CSetMaxNum::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	
}
*/

⌨️ 快捷键说明

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