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

📄 machinedlg.cpp

📁 Winzip 7.0 8.0 的注册机的源代码。简单的算法研究。
💻 CPP
字号:
// MachineDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Machine.h"
#include "MachineDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMachineDlg dialog

CMachineDlg::CMachineDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMachineDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMachineDlg)
	m_sCode = _T("ADA500C7");
	m_sName = _T("SEA");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMachineDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMachineDlg)
	DDX_Text(pDX, IDC_EDIT_Code, m_sCode);
	DDX_Text(pDX, IDC_EDIT_Name, m_sName);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMachineDlg, CDialog)
	//{{AFX_MSG_MAP(CMachineDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_EN_CHANGE(IDC_EDIT_Name, OnChangeEDITName)
	ON_WM_SYSCOMMAND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMachineDlg message handlers

BOOL CMachineDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here

	CString sText;
	CMenu *pSysMenu=GetSystemMenu(FALSE);
	if(pSysMenu)
	{
		pSysMenu->EnableMenuItem(0, MF_BYPOSITION | MF_GRAYED);
		pSysMenu->DeleteMenu(2, MF_BYPOSITION);
		pSysMenu->DeleteMenu(3, MF_BYPOSITION);
		sText.LoadString(IDS_KeepTop);
		pSysMenu->AppendMenu(MF_STRING, WM_KEEPTOP, sText);
	}


	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMachineDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMachineDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CMachineDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{
	// TODO: Add your message handler code here and/or call default

	CMenu *pSysMenu=GetSystemMenu(FALSE);
	if (pSysMenu)
		switch (nID)// & 0xFFF0)
		{
			case SC_MINIMIZE:
			{
				pSysMenu->EnableMenuItem(SC_RESTORE, MF_BYCOMMAND | MF_ENABLED);
				pSysMenu->EnableMenuItem(SC_MINIMIZE, MF_BYCOMMAND | MF_GRAYED);
				break;
			}
			case SC_RESTORE:
			{
				pSysMenu->EnableMenuItem(SC_RESTORE, MF_BYCOMMAND | MF_GRAYED);
				pSysMenu->EnableMenuItem(SC_MINIMIZE, MF_BYCOMMAND | MF_ENABLED);
				break;
			}
			case WM_KEEPTOP:
			{
				if (GetExStyle() & WS_EX_TOPMOST)
				{
					SetWindowPos(&wndNoTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
					pSysMenu->CheckMenuItem(WM_KEEPTOP,MF_UNCHECKED);
				}
				else
				{
					SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
					pSysMenu->CheckMenuItem(WM_KEEPTOP,MF_CHECKED);
				}
				break;
			}
		}	
	CDialog::OnSysCommand(nID, lParam);	
}

void CMachineDlg::OnChangeEDITName() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

    int i,j,n;
	CString sName,sCode;
	unsigned long f0,f1,f2,f3,f4;

	n=m_sName.GetLength();
	sName=m_sName;

   	f1=0; f4=0;
    for (i=0;i<n;i++)
	    f1=f1+i*sName[i];
    f1=f1&0xffff;
    for (i=0;i<n;i++)
	{
	    f2=sName[i]<<8;
	    for (j=0;j<8;j++)
		{
		    f3=f2;
		    f3=f3^f4;
		    if ((f3&0x8000)!=0)
			{
			    f4=f4*2;
				f4=f4&0xffff;
			    f4=f4^0x1021;
			}
		    else
				f4=f4<<1;
		    f2=f2<<1;
		}
	}
    f4=f4+0x63;
    f4=f4&0xffff;
    f4=f4<<16;
    f0=f1^f4;

    sCode.Format("%x",f0);
	m_sCode=sCode;

	UpdateData(FALSE);
}

⌨️ 快捷键说明

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