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

📄 theprogdlg.cpp

📁 该系统为一个完整的全球云预报系统,编得非常友好,功能强大
💻 CPP
字号:
// TheProgDlg.cpp : implementation file
//

#include "stdafx.h"
#include "TheProg.h"
#include "TheProgDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTheProgDlg dialog

CTheProgDlg::CTheProgDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTheProgDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTheProgDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	m_nMsgs = 0;
}

void CTheProgDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTheProgDlg)
	DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
	DDX_Control(pDX, IDC_EDIT3, m_Edit3);
	DDX_Control(pDX, IDC_EDIT2, m_Edit2);
	DDX_Control(pDX, IDC_EDIT1, m_Edit1);
	DDX_Control(pDX, IDC_COMBO2, m_Combo2);
	DDX_Control(pDX, IDC_COMBO1, m_Combo1);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTheProgDlg, CDialog)
	//{{AFX_MSG_MAP(CTheProgDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP

	ON_UPDATE_COMMAND_UI(IDC_COMBO2, OnUpdateCombo2)
	ON_UPDATE_COMMAND_UI(IDC_EDIT2, OnUpdateEdit2)
	ON_UPDATE_COMMAND_UI(IDC_EDIT3, OnUpdateEdit3)
	ON_UPDATE_COMMAND_UI(IDC_PROGRESS, OnUpdateProgress)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTheProgDlg message handlers

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

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// 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
	

	int nIndex = m_Combo1.AddString(CString((LPCTSTR) IDS_COLOURS));
	m_Combo1.SetItemData(nIndex, IDS_COLOURS);

	nIndex = m_Combo1.AddString(CString((LPCTSTR) IDS_NUMBERS));
	m_Combo1.SetItemData(nIndex, IDS_NUMBERS);

	m_Combo1.SetCurSel(0);
	m_uLastSel = IDS_NUMBERS;

	m_Progress.SetRange(0, 100);

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

void CTheProgDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// 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 CTheProgDlg::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 CTheProgDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}


//////////////////////////////////////////////////////////////////////////////////////////////
// The main stuff

BOOL CTheProgDlg::PreTranslateMessage(MSG* pMsg) 
{
	m_nMsgs++;
	UpdateDialogControls(this, false);

	return CDialog::PreTranslateMessage(pMsg);
}


// Does the current window have the focus
bool CTheProgDlg::HasFocus(const CWnd* pWndCtrl) const
{
	ASSERT(::IsWindow(pWndCtrl->m_hWnd));
	// if (pWndCtrl->m_hWnd == GetFocus()->m_hWnd) is insufficient, so...

	// Get window with focus
	CWnd* pFocusWnd = GetFocus();

	// Ensure its not null and is a window. Can occur if application loses and regains focus
	if (pFocusWnd == NULL || !::IsWindow(pFocusWnd->m_hWnd))
		return true;

	// Don't update if the control has the focus
	if (pFocusWnd->GetDlgCtrlID() == pWndCtrl->GetDlgCtrlID())
		return true;

	return false;
}


void CTheProgDlg::OnUpdateCombo2(CCmdUI* pCmdUI)
{
	if (HasFocus(&m_Combo2))
		return;

	int nIndex = m_Combo1.GetCurSel();
	UINT uData = m_Combo1.GetItemData(nIndex);

	if (uData == m_uLastSel)
		return;

	m_Combo2.ResetContent();

	switch (uData)
	{
		case IDS_NUMBERS:
			m_Combo2.AddString(CString((LPCTSTR) IDS_1));
			m_Combo2.AddString(CString((LPCTSTR) IDS_2));
			m_Combo2.AddString(CString((LPCTSTR) IDS_3));
			m_Combo2.AddString(CString((LPCTSTR) IDS_4));
			m_Combo2.AddString(CString((LPCTSTR) IDS_5));
			break;		

		case IDS_COLOURS:
			m_Combo2.AddString(CString((LPCTSTR) IDS_RED));
			m_Combo2.AddString(CString((LPCTSTR) IDS_ORANGE));
			m_Combo2.AddString(CString((LPCTSTR) IDS_YELLOW));
			m_Combo2.AddString(CString((LPCTSTR) IDS_GREEN));
			m_Combo2.AddString(CString((LPCTSTR) IDS_BLUE));
			break;
	}

	m_Combo2.SetCurSel(0);

	m_uLastSel = uData;
}


void CTheProgDlg::OnUpdateEdit3(CCmdUI* pCmdUI)
{
	UNREFERENCED_PARAMETER(pCmdUI);

	SetDlgItemInt(IDC_EDIT3, m_nMsgs, false);
}


void CTheProgDlg::OnUpdateEdit2(CCmdUI* pCmdUI)
{
	UNREFERENCED_PARAMETER(pCmdUI);

	CString strEdit1;
	GetDlgItemText(IDC_EDIT1, strEdit1);

	CString strEdit2;
	GetDlgItemText(IDC_EDIT2, strEdit2);

	if (strEdit1.Compare(strEdit2) == 0)
		return;

	SetDlgItemText(IDC_EDIT2, strEdit1);
}


void CTheProgDlg::OnUpdateProgress(CCmdUI* pCmdUI)
{
	UNREFERENCED_PARAMETER(pCmdUI);

	if (m_Progress.GetPos() == 100)
		m_Progress.SetStep(-1);
	else 
		if (m_Progress.GetPos() == 0)
			m_Progress.SetStep(1);

	m_Progress.StepIt();
}







⌨️ 快捷键说明

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