当前位置: 首页>>代码示例>>C++>>正文


C++ CDialog::MsgHandled方法代码示例

本文整理汇总了C++中CDialog::MsgHandled方法的典型用法代码示例。如果您正苦于以下问题:C++ CDialog::MsgHandled方法的具体用法?C++ CDialog::MsgHandled怎么用?C++ CDialog::MsgHandled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDialog的用法示例。


在下文中一共展示了CDialog::MsgHandled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DlgProc

WCL::DlgResult DIALOGPROC CDialog::DlgProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
	// Store the return values for this message.
	BOOL     bMsgHandled = false;
	LRESULT  lMsgResult  = 0;

	try
	{
		CDialog* pDialog;

		// Get the window object.
		pDialog = static_cast<CDialog*>(CWnd::s_WndMap.Find(hWnd));

		// Do we have a mapping?
		if (pDialog == nullptr)
		{
			// Time to initialise?
			// NB: We will receive other messages first.
			if (iMsg == WM_INITDIALOG)
			{
				// Get object from LPARAM.
				pDialog = reinterpret_cast<CDialog*>(lParam);

				//
				// This function can be called recursively so we need to use
				// the program stack to hold the return values for each
				// message whilst it is being precessed.
				//

				// Push the existing messages' return values onto the stack.
				BOOL*	 pbMsgHandled = pDialog->MsgHandledBuffer(&bMsgHandled);
				LRESULT* plMsgResult  = pDialog->MsgResultBuffer (&lMsgResult);

				// Save handle/result.
				pDialog->m_hWnd = hWnd;
				pDialog->MsgHandled(true);
				pDialog->MsgResult (0);

				// Setup Window mapping.
				CWnd::s_WndMap.Add(*pDialog);

				// Centre only if modal.
				if (pDialog->m_bModal)
					pDialog->Centre();

				// Initialise child controls.
				pDialog->InitControls();
				pDialog->InitGravityTable();

				// Now call initialise method.
				pDialog->OnCreate(pDialog->ClientRect());

				// Pop the old messages' return values back off the stack.
				pDialog->MsgHandledBuffer(pbMsgHandled);
				pDialog->MsgResultBuffer (plMsgResult);
			}
		}
		else
		{
			//
			// This function can be called recursively so we need to use
			// the program stack to hold the return values for each
			// message whilst it is being precessed.
			//

			// Push the existing messages' return values onto the stack.
			BOOL*	 pbMsgHandled = pDialog->MsgHandledBuffer(&bMsgHandled);
			LRESULT* plMsgResult  = pDialog->MsgResultBuffer (&lMsgResult);

			// Call real message handler.
			pDialog->WndProc(hWnd, iMsg, wParam, lParam);

			// Pop the old messages' return values back off the stack.
			pDialog->MsgHandledBuffer(pbMsgHandled);
			pDialog->MsgResultBuffer (plMsgResult);
		}
	}
	catch (const Core::Exception& e)
	{
		WCL::ReportUnhandledException(	TXT("Unexpected exception caught in DlgProc()\n\n")
										TXT("Message: H=0x%p M=0x%08X W=0x%08X L=0x%08X\n\n%s"),
										hWnd, iMsg, wParam, lParam, e.twhat());
	}
	catch (const std::exception& e)
	{
		WCL::ReportUnhandledException(	TXT("Unexpected exception caught in DlgProc()\n\n")
										TXT("Message: H=0x%p M=0x%08X W=0x%08X L=0x%08X\n\n%hs"),
										hWnd, iMsg, wParam, lParam, e.what());
	}
	catch (...)
	{
		WCL::ReportUnhandledException(	TXT("Unexpected unknown exception caught in DlgProc()\n\n")
										TXT("Message: H=0x%p M=0x%08X W=0x%08X L=0x%08X"),
										hWnd, iMsg, wParam, lParam);
	}

	// Set the return value.
	::SetWindowLongPtr(hWnd, DWLP_MSGRESULT, lMsgResult);

	// Return if msg was handled.
//.........这里部分代码省略.........
开发者ID:chrisoldwood,项目名称:WCL,代码行数:101,代码来源:Dialog.cpp


注:本文中的CDialog::MsgHandled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。