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

📄 hotsnapdlg.cpp

📁 MFC下对窗口属性的操作控制的例子
💻 CPP
字号:
// HotSnapDlg.cpp : implementation file
//

#include "stdafx.h"
#include "WndControl.h"
#include "HotSnapDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CHotSnapDlg dialog


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


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


BEGIN_MESSAGE_MAP(CHotSnapDlg, CDialog)
	//{{AFX_MSG_MAP(CHotSnapDlg)
	ON_WM_SETCURSOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHotSnapDlg message handlers

BOOL CHotSnapDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
	switch(pWnd->GetDlgCtrlID()) // 得到鼠标所在位置的控件的ID号
	{
		case IDC_PICTURE:		 // 鼠标位于"热点"1(图像框)区域内
		{
			// 设置鼠标指针为"手"形指针
			SetCursor(AfxGetApp()->LoadCursor(IDC_HAND)); 
			// 将提示文字可见
			GetDlgItem(IDC_TEXT)->ShowWindow(SW_SHOW);
			// 显示"This is a picture!"一行字
			GetDlgItem(IDC_TEXT)->SetWindowText("This is a picture!");
			return TRUE;
		}
		break;
		case IDC_BUTTON1:    //鼠标位于按钮区域内
		{
			SetCursor(AfxGetApp()->LoadCursor(IDC_HAND));
			GetDlgItem(IDC_TEXT)->ShowWindow(SW_SHOW);
			// 显示"This is a button!"一行字
			GetDlgItem(IDC_TEXT)->SetWindowText("This is a button!");
			return TRUE;
		}
		break;
		default:    // 鼠标离开了"热点"
		{
			// 将提示性文字隐藏
			GetDlgItem(IDC_TEXT)->ShowWindow(SW_HIDE);
			// 将鼠标指针设置为标准的鼠标指针
			SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); 
			return TRUE;
		}
    }
	
	return CDialog::OnSetCursor(pWnd, nHitTest, message);
}

⌨️ 快捷键说明

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