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

📄 cdialogbox.cpp

📁 bt848,bt878 a采集卡的探测
💻 CPP
字号:
#include "CDialogBox.hpp"

// List of associations
CPtrArray<CDialogBox::Association,true> CDialogBox::List;
CDialogBox* CDialogBox::Current = NULL;

//
//  FUNCTION: Proc(HWND, UINT, UINT, LONG)
//
//  PURPOSE:  Processes messages for the dialog box 
//
//  MESSAGES:
//	
//	WM_INITDIALOG - initalizes the dialog box
//	WM_COMMAND - processes the input
//	
BOOL APIENTRY CDialogBox::Proc(
	HWND hDlg,
	UINT message,
	UINT wParam,
	LONG lParam)
{
	// Find out the association we want
	CDialogBox* Ptr = NULL;
	UINT Idx;
	for (Idx = 0; Idx < List.Count(); Idx++) {
		if (List[Idx]->GetHWND() == hDlg) {
			Ptr = List[Idx]->GetPtr();
			break;
		}
	}

	// If not found, create a new one!
	if (!Ptr && Current && message == WM_INITDIALOG) {
		List.Add(new Association(hDlg,Current));
		Current->SetHWND(hDlg);
		Ptr = Current;
		Current = NULL;

	}

	switch (message) {
		case WM_INITDIALOG:
			return Ptr->OnInitDialog();
		case WM_COMMAND:
			return Ptr->OnCommand(LOWORD(wParam) /* Id*/ , HIWORD(wParam) /*action*/);
		case WM_NOTIFY:
			return Ptr->OnNotify(lParam);
		case WM_TIMER:
			return Ptr->OnTimer(wParam);
		default:
			return FALSE;
	}
	return TRUE;
}

CDialogBox::~CDialogBox()
{
	// Find out the association we want
	UINT Idx;
	for (Idx = 0; Idx < List.Count(); Idx++) {
		if (List[Idx]->GetHWND() == GetHWND()) {
			List.Delete(Idx);
			break;
		}
	}
}

INT CDialogBox::OnInitDialog()
{
	return TRUE;
}

INT CDialogBox::OnCommand(WORD ControlID, WORD NotifyCode)
{
	if (ControlID == IDOK) {
		End();
	}
	return TRUE;
}

INT CDialogBox::OnNotify(DWORD lParam)
{
	return TRUE;
}

INT CDialogBox::OnTimer(DWORD wParam)
{
	return TRUE;
}

bool CDialogBox::Execute(
		HINSTANCE Instance,
		const CWnd& parent)
{
	Current = this;
	DialogBox(Instance,resource, parent.GetHWND(), (DLGPROC)Proc);
	return true;
}

bool CDialogBox::AmodalExecute(
		HINSTANCE Instance,
		const CWnd& parent)
{
	Current = this;
	CreateDialog(Instance,resource, parent.GetHWND(), (DLGPROC)Proc);
	return true;
}

⌨️ 快捷键说明

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