//************************************** ************************************** // 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 (partition _) # Define _ # 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 // // @ 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 (partition _) ///////////////////////////// // 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; } |