SQLServer skill sets

  The following dialog with a self-type (MyMessageDlg) to view class (MessageTestView) 
  Send custom news as an example to illustrate these two different methods of self-definition of news 

  Summary: 
  One way messaging: the use of ON_MESSAGE 
  ON_MESSAGE response to the use of news, information must be consistent with the definition # define WM_MY_MESSAGE (WM_USER +100) 

  To send a message to – MyMessageDlg, 
  In its MyMessageDlg.h, definition # define WM_MY_MESSAGE (WM_USER +100) 
  In its MyMessageDlg.cpp in the first add: # include "MainFrm.h" 
  Because of the use of the CMainFrame * definition of objects. 
  And a test message function: 
  void MyMessageDlg:: OnButtonMsg () 
  ( 
  / / TODO: Add your control notification handler code here 
  CMainFrame * pMF = (CMainFrame *) AfxGetApp () -> m_pMainWnd; / / through the first access to the current framework of indicators 
  CView * active = pMF-> GetActiveView ();// to obtain the current class as indicators 
  if (active! = NULL) / / access to the current category indicators as to send a message 
  active-> PostMessage (WM_MY_MESSAGE, 0,0); / / send a message to use PostMessage 
  ) 

  For information on the recipient – MessageTestView, 
  In its MessageTestView.h, to the definition # define WM_MY_MESSAGE (WM_USER +100) 
  And definition of news mapping function – OnMyMessage () 
protected:
  / / ((AFX_MSG (CMessageTestView) 
  afx_msg LRESULT OnMyMessage (WPARAM wParam, LPARAM lParam); 
  / /)) AFX_MSG 
  DECLARE_MESSAGE_MAP () 
  In its MessageTestView.cpp, 
  First response to the statement: 
  BEGIN_MESSAGE_MAP (CMessageTestView, CEditView) 
  / / ((AFX_MSG_MAP (CMessageTestView) 
  ON_MESSAGE (WM_MY_MESSAGE, OnMyMessage) 
  / /)) AFX_MSG_MAP 
  To add information to achieve a function of response: 
  LRESULT CMessageTestView:: OnMyMessage (WPARAM wParam, LPARAM lParam) 
  ( 
  MessageBox ( "OnMyMessage!"); 
  return 0; 
  ) 

  The messaging approach: the use of ON_REGISTERED_MESSAGE 
  ON_REGISTERED_MESSAGE use of registration information must be compatible 
  static UINT WM_MY_MESSAGE = RegisterWindowMessage ( "Message"); 

  For information on the sender – MyMessageDlg, 
  In its MyMessageDlg.h, as long as the definition of static UINT WM_MY_MESSAGE = RegisterWindowMessage ( "Message"); 
  It. 
  In its MyMessageDlg.cpp in the first add: # include "MainFrm.h" 
  Because of the use of the CMainFrame * definition of objects. 
  And a test message function: 
  void MyMessageDlg:: OnButtonMsg () 
  ( 
  / / TODO: Add your control notification handler code here 
  CMainFrame * pMF = (CMainFrame *) AfxGetApp () -> m_pMainWnd; / / through the first access to the current framework of indicators 
  CView * active = pMF-> GetActiveView ();// to obtain the current class as indicators 
  if (active! = NULL) / / access to the current category indicators as to send a message 
  active-> PostMessage (WM_MY_MESSAGE, 0,0); / / send a message to use PostMessage 
  ) 

  For information on the recipient – MessageTestView, 
  Do not, in its definition of MessageTestView.h 
  static UINT WM_MY_MESSAGE = RegisterWindowMessage ( "Message"); 
  This definition should be put MessageTestView.cpp, we must not appear: redefinition 
  In its MessageTestView.h in the definition of news as long as the mapping function 
protected:
  / / ((AFX_MSG (CMessageTestView) 
  afx_msg LRESULT OnMyMessage (WPARAM wParam, LPARAM lParam); 
  / /)) AFX_MSG 
  DECLARE_MESSAGE_MAP () 
  In its MessageTestView.cpp, the first definition 
  static UINT WM_MY_MESSAGE = RegisterWindowMessage ( "Message"); 
  Then registration information: 
  BEGIN_MESSAGE_MAP (CMessageTestView, CEditView) 
  / / ((AFX_MSG_MAP (CMessageTestView) 
  ON_REGISTERED_MESSAGE (WM_MY_MESSAGE, OnMyMessage) 
  / /)) AFX_MSG_MAP 
  Add a final response to the news function to achieve: 
  LRESULT CMessageTestView:: OnMyMessage (WPARAM wParam, LPARAM lParam) 
  ( 
  MessageBox ( "OnMyMessage!"); 
  return 0; 
  ) 
  ————————————————– ————– 
  Comparing the two methods, only slightly different.    However, we should be careful to avoid receiving no news of the situation. 

  ————————————————– —————– 

  Other notes: 

  Send news – MyMessageDlg.cpp be defined before 
  static UINT WM_MY_MESSAGE = RegisterWindowMessage ( "Message"); 

  Accept the news – MessageTestView.cpp be defined before 
  static UINT WM_MY_MESSAGE = RegisterWindowMessage ( "Message"); 

  RegisterWindowMessage ( "Message") in the text "" What is not important, what can be written, single-sender and recipient must be the same content, such as: "Message" 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • DZone
  • Netvouz
  • NewsVine
  • Technorati

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Tags: