mainfrm.cpp

来自「序列号生成工具,使用MD5加密算法,生成程序的序列号,帮助程序员保护自己的产权.」· C++ 代码 · 共 163 行

CPP
163
字号
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "UserRegister.h"
#include "ChildFrm.h"
#include "MainFrm.h"
#include "FrmCreatePrmNum.h"
#include "FrmViewCreateRegCode.h"
#include "FrmViewCreateSerialNum.h"
#include "FrmViewMD5Encode.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_COMMAND(ID_MENUITEMMakeSerial, OnMENUITEMMakeSerial)
	ON_COMMAND(ID_MENUITEMMakeRegCode, OnMENUITEMMakeRegCode)
	ON_COMMAND(ID_MENUITEMCreatePrmNum, OnMENUITEMCreatePrmNum)
	ON_COMMAND(ID_MENUITEMMD5Encode, OnMENUITEMMD5Encode)
	//}}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 (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);

	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=800;
	cs.cy=550;
	int screenwidth= GetSystemMetrics(SM_CXSCREEN);
	int screenheight= GetSystemMetrics(SM_CYSCREEN);
	cs.x= (screenwidth-cs.cx)/2;
	cs.y= (screenheight-cs.cy)/2;
	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::OnMENUITEMMakeSerial() //生成序列号
{
	// TODO: Add your command handler code here
	CCreateContext context;
	CChildFrame *pFrame = new CChildFrame();
	context.m_pNewViewClass = RUNTIME_CLASS(CFrmViewCreateSerialNum);
	//context.m_pCurrentDoc->SetTitle("ppp");

	//show
	pFrame ->LoadFrame(IDR_CREATETYPE, WS_OVERLAPPEDWINDOW, this, &context);
	pFrame ->InitialUpdateFrame(NULL, TRUE);
	//pFrame->ShowWindow(SW_NORMAL);
}

void CMainFrame::OnMENUITEMMakeRegCode() //生成注册码
{
	// TODO: Add your command handler code here
	CCreateContext context;
	CChildFrame * pframe= new CChildFrame();
	context.m_pNewViewClass= RUNTIME_CLASS(CFrmViewCreateRegCode);
	pframe->LoadFrame(IDR_CREATETYPE,WS_OVERLAPPEDWINDOW/*|FWS_ADDTOTITLE*/,this,&context);
	pframe->InitialUpdateFrame(NULL,TRUE);
}

void CMainFrame::OnMENUITEMCreatePrmNum() //生成质数
{
	// TODO: Add your command handler code here
	CCreateContext context;
	context.m_pNewViewClass= RUNTIME_CLASS(CFrmCreatePrmNum);
	CChildFrame * pframe= new CChildFrame();
	pframe->LoadFrame(IDR_CREATETYPE,WS_OVERLAPPEDWINDOW/*|FWS_ADDTOTITLE*/,this,&context);
	pframe->InitialUpdateFrame(NULL,TRUE);
}

void CMainFrame::OnMENUITEMMD5Encode() //生成MD5编码
{
	// TODO: Add your command handler code here
	CCreateContext context;
	context.m_pNewViewClass= RUNTIME_CLASS(CFrmViewMD5Encode);
	CChildFrame * pframe= new CChildFrame();
	pframe->LoadFrame(IDR_CREATETYPE,WS_OVERLAPPEDWINDOW/*|FWS_ADDTOTITLE*/,this,&context);
	pframe->InitialUpdateFrame(NULL,TRUE);
}

⌨️ 快捷键说明

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