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

📄 searchlist.cpp

📁 一个提示软件
💻 CPP
字号:
// SearchList.cpp: implementation of the CSearchList class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"
#include "SearchList.h"
#include "HiddenWnd.h"

CSearchList::CSearchList()
{
	ATLTRACE(_T("CSearchList::CSearchList()\n"));
}

CSearchList::~CSearchList()
{
	ATLTRACE(_T("CSearchList::~CSearchList()\n"));
}

// This function is used to receive a pointer to the hidden window
void CSearchList::SetPointerToHiddenWindow(CHiddenWindow * pwndHidden)
{
	ATLTRACE(_T("CSearchList::SetPointerToHiddenWindow()\n"));
	ATLASSERT(pwndHidden);

	m_pwndHidden = pwndHidden;
}

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

	bHandled = TRUE;
	DisplayNote();

	return 0;
}

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

	bHandled = FALSE;

	switch (wParam) 
	{
	case VK_RETURN:		// 'Enter' key pressed 
		DisplayNote();
		bHandled = TRUE;
		break;
	default: 
		break;
	}

	return 0;
}

// Tells the hidden window to display a note
void CSearchList::DisplayNote()
{
	ATLTRACE(_T("CSearchList::DisplayNote()\n"));

	// Retrieve the index of the currently selected item
	int nIndex = GetSelectedIndex();

	if (nIndex != LB_ERR)
	{
		// Retrieve the 32-bit value associated with the item, in our case it's the note's id
		DWORD dwID = GetItemData(nIndex);
		if (dwID != LB_ERR && dwID != 0)
		{
			// Post a message to the hidden window to display a note
			::PostMessage(m_pwndHidden->m_hWnd, WMU_DISPLAYNOTE, (WPARAM)dwID, 0);
		}
		else
			ATLTRACE(_T("Getting the 32-bit value of the list box item failed\n"));
	}
	else
		ATLTRACE(_T("No item is currently selected in the list box\n"));
}

⌨️ 快捷键说明

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