扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
//**************************************************************************** // D L G C S O F T W A R E C O. //**************************************************************************** // Filename: FepMergeMessage.h // Project: FEP V4 6.0 // Module: // Programmer: Ma Nan // Version: Version 1.00 // Revision Date: 2006/12/04 //**************************************************************************** // Description: Declaration of class CFepMergeMessage //**************************************************************************** // Revision history: // 2006/12/04 - First implementation //**************************************************************************** // Bugs: ........ //**************************************************************************** // @doc //**************************************************************************** // FepMergeMessage.h: interface for the CFepMergeMessage class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_FEPMERGEMESSAGE_H__D60309AA_9DA0_4474_9DC0_EDFF72E7165C__INCLUDED_) #define AFX_FEPMERGEMESSAGE_H__D60309AA_9DA0_4474_9DC0_EDFF72E7165C__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class MERGE_MES_HEADER; typedef void (*MergeMesCallBack)(const MERGE_MES_HEADER* lpMergMes); class MERGE_MES_HEADER : public CObject { DECLARE_DYNAMIC(MERGE_MES_HEADER); MergeMesCallBack pfnCallBack; virtual MERGE_MES_HEADER* Clone() const = 0; virtual BOOL IsSameMes(const MERGE_MES_HEADER* pMes) const = 0; }; //**************************************************************************** // @class CFepMergeMessage | // CFepMergeMessage is used to // // @base CDialog //**************************************************************************** // @ex // This shows how to call CFepMergeMessage : | // // // //**************************************************************************** // @prog // Ma Nan // @revs // 2006/12/04 - First implementation //**************************************************************************** // @todo //**************************************************************************** class CFepMergeMessage : public CDialog { public: CFepMergeMessage(); virtual ~CFepMergeMessage(); static BOOL Excute(const MERGE_MES_HEADER* pParam); protected: //create the dialog to deal the message BOOL Create(); protected: afx_msg LRESULT OnMergeMessage(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnProcessMessage(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP() protected: CArray<MERGE_MES_HEADER*, MERGE_MES_HEADER*> m_rgMessage; BOOL m_bMessagePosted; }; #endif // !defined(AFX_FEPMERGEMESSAGE_H__D60309AA_9DA0_4474_9DC0_EDFF72E7165C__INCLUDED_) ///////////////////////////// //FepMergeMessage.cpp //////////////////////////// #include "StdAfx.h" #include "FepMergeMessage.h" #include "../Include/FepPtr.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif #define WM_MERGE_MESSAGE WM_USER + 100 #define WM_PROCESS_MESSAGE WM_USER + 200 ////////////////////////////////////////////////////////////////////////// //struct MERGE_MES_HEADER ////////////////////////////////////////////////////////////////////////// IMPLEMENT_DYNAMIC(MERGE_MES_HEADER, CObject) ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// static CFepPtr<CFepMergeMessage> pDlgMergeMessage(NULL); CFepMergeMessage::CFepMergeMessage() { m_bMessagePosted = FALSE; Create(); } CFepMergeMessage::~CFepMergeMessage() { for(int i=0; i<m_rgMessage.GetSize(); ++i) { delete m_rgMessage.GetAt(i); } m_rgMessage.RemoveAll(); } BEGIN_MESSAGE_MAP(CFepMergeMessage, CDialog) ON_MESSAGE(WM_MERGE_MESSAGE, OnMergeMessage) ON_MESSAGE(WM_PROCESS_MESSAGE, OnProcessMessage) END_MESSAGE_MAP() //**************************************************************************** // Function CFepMergeMessage::Create // @mfunc // @rdesc TRUE if the function succeeds; otherwise, FALSE.(BOOL) // @xref <c CFepMergeMessage > //**************************************************************************** // @prog // Ma Nan // @revs // 2006/12/04 First implementation //**************************************************************************** // @todo // //**************************************************************************** BOOL CFepMergeMessage::Create() { if(GetSafeHwnd() != NULL) { return TRUE; } DWORD dwDlgTempl[100]; ZeroMemory(dwDlgTempl, sizeof(DWORD)*100); DLGTEMPLATE* pDlgTmp = (DLGTEMPLATE*)dwDlgTempl; pDlgTmp->style = WS_POPUP | DS_CONTROL; pDlgTmp->cx = 1; pDlgTmp->cy = 1; return CDialog::CreateIndirect(pDlgTmp); } //**************************************************************************** // Function CFepMergeMessage::Excute // @mfunc // @rdesc TRUE if the function succeeds; otherwise, FALSE.(BOOL) // @parm const MERGE_MES_HEADER* | pParam | a pointer to const MERGE_MES_HEADER // @xref <c CFepMergeMessage > //**************************************************************************** // @prog // Ma Nan // @revs // 2006/12/04 First implementation //**************************************************************************** // @todo // //**************************************************************************** BOOL CFepMergeMessage::Excute(const MERGE_MES_HEADER* pParam) { // dlgMergeMes.SendMessage(WM_MERGE_MESSAGE, (WPARAM)pParam, 0); if(pDlgMergeMessage.m_pPtr == NULL) { pDlgMergeMessage.m_pPtr = new CFepMergeMessage; } if(pDlgMergeMessage->GetSafeHwnd() == NULL) { return FALSE; } pDlgMergeMessage->SendMessage(WM_MERGE_MESSAGE, (WPARAM)pParam, 0); return TRUE; } //**************************************************************************** // Function CFepMergeMessage::OnMergeMessage // @mfunc // @rdesc (LRESULT) // @parm WPARAM | wParam | // @parm | LPARAM | // @xref <c CFepMergeMessage > //**************************************************************************** // @prog // Ma Nan // @revs // 2006/12/04 First implementation //**************************************************************************** // @todo // //**************************************************************************** LRESULT CFepMergeMessage::OnMergeMessage(WPARAM wParam, LPARAM) { const MERGE_MES_HEADER* pNewMes = (const MERGE_MES_HEADER*)wParam; for(int i=0; i<m_rgMessage.GetSize(); ++i) { MERGE_MES_HEADER* pMes = m_rgMessage.GetAt(i); if(pNewMes->IsKindOf(pMes->GetRuntimeClass()) && pNewMes->IsSameMes(pMes)) { delete pMes; m_rgMessage.RemoveAt(i); --i; } } m_rgMessage.Add(pNewMes->Clone()); if(!m_bMessagePosted) { PostMessage(WM_PROCESS_MESSAGE, 0, 0); m_bMessagePosted = TRUE; } return 0L; } //**************************************************************************** // Function CFepMergeMessage::OnProcessMessage // @mfunc // @rdesc (LRESULT) // @parm | WPARAM | // @parm | LPARAM | // @xref <c CFepMergeMessage > //**************************************************************************** // @prog // Ma Nan // @revs // 2006/12/04 First implementation //**************************************************************************** // @todo // //**************************************************************************** LRESULT CFepMergeMessage::OnProcessMessage(WPARAM, LPARAM) { while(m_rgMessage.GetSize() > 0) { MERGE_MES_HEADER* pHeader = m_rgMessage.GetAt(0); pHeader->pfnCallBack(pHeader); delete pHeader; m_rgMessage.RemoveAt(0); } m_bMessagePosted = FALSE; return 0L; } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者