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

📄 button.h

📁 一个提示软件
💻 H
字号:
// Button.h: interface for the buttons and edit class.
//
//////////////////////////////////////////////////////////////////////

#ifndef __ATLBTN_H__
#define __ATLBTN_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CEditEx : public CWindowImpl<CEditEx, CEdit>
{
public:
	BEGIN_MSG_MAP(CEditEx)
		MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
		DEFAULT_REFLECTION_HANDLER()
	END_MSG_MAP()

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return FALSE;
	}

	LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		ATLTRACE(_T("CEditEx::OnKeyDown()\n"));

		// If an 'Enter' key was pressed
		if (wParam == VK_RETURN)		
		{
			// Do a search
			::SendMessage(GetParent(), WMU_FINDNOTE, 0, 0);	
			return 0;
		}

		// If any other key do not handle the message
		bHandled = FALSE;
		return 0;
	}
};

class CButtonExCancel : public CWindowImpl<CButtonExCancel, CButton>
{
public:
	BEGIN_MSG_MAP(CButtonExCancel)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
		DEFAULT_REFLECTION_HANDLER()
	END_MSG_MAP()

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return FALSE;
	}

	// Handles clicking on 'Cancel' button
	LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		ATLTRACE(_T("CButtonExCancel::OnLButtonDown()\n"));
	
		// Close the search dialog
		// Can't use SendMessage(), because by the time SendMessage() returns
		// object's gone
		::PostMessage(GetParent(), WM_CLOSE, 0, 0);
		return 0;
	}

	// Handles pressing the 'Enter' key when 'Cancel' button has a focus
	LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		ATLTRACE(_T("CButtonExCancel::OnKeyDown()\n"));

		// Close the search dialog
		// Can't use SendMessage(), because by the time SendMessage() returns
		// object's gone
		::PostMessage(GetParent(), WM_CLOSE, 0, 0);
		return 0;
	}
};

class CButtonExFind : public CWindowImpl<CButtonExFind, CButton>
{
public:
	BEGIN_MSG_MAP(CButtonExFind)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
		DEFAULT_REFLECTION_HANDLER()
	END_MSG_MAP()

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return FALSE;
	}

	// Handles clicking on 'Find' button
	LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		ATLTRACE(_T("CButtonExFind::OnLButtonDown()\n"));

		// Do a search
		::SendMessage(GetParent(), WMU_FINDNOTE, 0, 0);
		return 0;
	}

	// Handles pressing the 'Enter' key when 'Find' button has a focus
	LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		ATLTRACE(_T("CButtonExFind::OnKeyDown()\n"));

		// Do a search
		::SendMessage(GetParent(), WMU_FINDNOTE, 0, 0);
		return 0;
	}
};

class CButtonExNew : public CWindowImpl<CButtonExNew, CButton>
{
public:
	BEGIN_MSG_MAP(CButtonExNew)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
		MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
		DEFAULT_REFLECTION_HANDLER()
	END_MSG_MAP()

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return FALSE;
	}

	// Handles clicking on 'New note' button
	LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		ATLTRACE(_T("CButtonExNew::OnLButtonDown()\n"));

		// Send a message to create a new Note dialog
		::SendMessage(GetParent(), WMU_NEWNOTE, 0, 0);
		return 0;
	}

	// Handles pressing the 'Enter' key when 'New Note' button has a focus
	LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		ATLTRACE(_T("CButtonExNew::OnKeyDown()\n"));

		// Send a message to create a new Note dialog
		::SendMessage(GetParent(), WMU_NEWNOTE, 0, 0);
		return 0;
	}
};

/************************************************************************/
#endif // __ATLBTN_H__

⌨️ 快捷键说明

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