﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-南山狒狒-随笔分类-VC++</title><link>http://www.cppblog.com/Jrong/category/9939.html</link><description>我梦江南好</description><language>zh-cn</language><lastBuildDate>Mon, 30 Mar 2009 03:27:39 GMT</lastBuildDate><pubDate>Mon, 30 Mar 2009 03:27:39 GMT</pubDate><ttl>60</ttl><item><title>[转]evc vc字符串转换处理一：（绝对精华，收集所有的例子）</title><link>http://www.cppblog.com/Jrong/archive/2009/03/24/77703.html</link><dc:creator>iJrong</dc:creator><author>iJrong</author><pubDate>Tue, 24 Mar 2009 03:21:00 GMT</pubDate><guid>http://www.cppblog.com/Jrong/archive/2009/03/24/77703.html</guid><wfw:comment>http://www.cppblog.com/Jrong/comments/77703.html</wfw:comment><comments>http://www.cppblog.com/Jrong/archive/2009/03/24/77703.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Jrong/comments/commentRss/77703.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Jrong/services/trackbacks/77703.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 原文：http://blog.csdn.net/hnhyhongmingjiang/archive/2008/03/06/2154009.aspx1.头文件中要定义宏;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #define&nbsp;&nbsp; UNICODE&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbs...&nbsp;&nbsp;<a href='http://www.cppblog.com/Jrong/archive/2009/03/24/77703.html'>阅读全文</a><img src ="http://www.cppblog.com/Jrong/aggbug/77703.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Jrong/" target="_blank">iJrong</a> 2009-03-24 11:21 <a href="http://www.cppblog.com/Jrong/archive/2009/03/24/77703.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]关于VC++中，两种自定义消息的发送与接收的方法实现进行说明</title><link>http://www.cppblog.com/Jrong/archive/2009/03/23/77537.html</link><dc:creator>iJrong</dc:creator><author>iJrong</author><pubDate>Mon, 23 Mar 2009 01:08:00 GMT</pubDate><guid>http://www.cppblog.com/Jrong/archive/2009/03/23/77537.html</guid><wfw:comment>http://www.cppblog.com/Jrong/comments/77537.html</wfw:comment><comments>http://www.cppblog.com/Jrong/archive/2009/03/23/77537.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Jrong/comments/commentRss/77537.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Jrong/services/trackbacks/77537.html</trackback:ping><description><![CDATA[　　说明：<br highlighted="1">　　以下用一个自创的对话框类(MyMessageDlg)<zmkey class=zoomino-searchword style="FONT-WEIGHT: bold; FLOAT: none; CURSOR: pointer; MARGIN-RIGHT: 3px; BORDER-BOTTOM: #ff6c00 2px dotted; cssFloat: none" offset="28" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(0)" anchorType="previous" jQuery1237769822734="10">向视图<img class=zoominoBgImage style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: inline; BACKGROUND: none transparent scroll repeat 0% 0%; FLOAT: none; MARGIN: 0px; BORDER-LEFT: medium none; WIDTH: 12px; BORDER-BOTTOM: medium none; HEIGHT: 14px; cssFloat: none" height=14 src="http://www.zoomino.cn/static-ox/images/z-keyword.gif" width=12></zmkey>类(MessageTestView)<br>　　发送自定义消息为例，说明这两种不同方法的自定义消息的<br>　　总结：<br>　　消息传递的方法一：使用ON_MESSAGE<br>　　使用ON_MESSAGE响应消息，必须配合定义消息#define WM_MY_MESSAGE (WM_USER+100)<br>　　对于发送消息者-MyMessageDlg，<br>　　在其MyMessageDlg.h中，定义#define WM_MY_MESSAGE (WM_USER+100)<br>　　在其MyMessageDlg.cpp中要先添加：#include "MainFrm.h"<br>　　因为使用了CMainFrame*定义对象。<br highlighted="1">　　并且要有测试消息的<zmkey class=zoomino-searchword style="FONT-WEIGHT: bold; FLOAT: none; CURSOR: pointer; MARGIN-RIGHT: 3px; BORDER-BOTTOM: #ff6c00 2px dotted; cssFloat: none" offset="11" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(9)" anchorType="previous" jQuery1237769822734="8">函数<img class=zoominoBgImage style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: inline; BACKGROUND: none transparent scroll repeat 0% 0%; FLOAT: none; MARGIN: 0px; BORDER-LEFT: medium none; WIDTH: 12px; BORDER-BOTTOM: medium none; HEIGHT: 14px; cssFloat: none" height=14 src="http://www.zoomino.cn/static-ox/images/z-keyword.gif" width=12></zmkey>：<br>　　void MyMessageDlg::OnButtonMsg() <br>　　{<br>　　 // TODO: Add your control notification handler code here<br highlighted="2">　　 CMainFrame* pMF=(CMainFrame*)AfxGetApp()-&gt;m_pMainWnd; //先通过获取当前<zmkey class=zoomino-searchword style="FONT-WEIGHT: bold; FLOAT: none; CURSOR: pointer; MARGIN-RIGHT: 3px; BORDER-BOTTOM: #ff6c00 2px dotted; cssFloat: none" offset="66" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(13)" anchorType="previous" jQuery1237769822734="6">框架<img class=zoominoBgImage style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: inline; BACKGROUND: none transparent scroll repeat 0% 0%; FLOAT: none; MARGIN: 0px; BORDER-LEFT: medium none; WIDTH: 12px; BORDER-BOTTOM: medium none; HEIGHT: 14px; cssFloat: none" height=14 src="http://www.zoomino.cn/static-ox/images/z-keyword.gif" width=12></zmkey><zmkey class=zoomino-searchword style="FONT-WEIGHT: bold; FLOAT: none; CURSOR: pointer; MARGIN-RIGHT: 3px; BORDER-BOTTOM: #ff6c00 2px dotted; cssFloat: none" offset="0" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(13)" anchorType="previous" jQuery1237769822734="12">指针<img class=zoominoBgImage style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: inline; BACKGROUND: none transparent scroll repeat 0% 0%; FLOAT: none; MARGIN: 0px; BORDER-LEFT: medium none; WIDTH: 12px; BORDER-BOTTOM: medium none; HEIGHT: 14px; cssFloat: none" height=14 src="http://www.zoomino.cn/static-ox/images/z-keyword.gif" width=12></zmkey><br>　　 CView * active = pMF-&gt;GetActiveView();//才能获取当前视类指针<br>　　 if(active != NULL) //获取了当前视类指针才能发送消息<br>　　 active-&gt;PostMessage(WM_MY_MESSAGE,0,0); //使用PostMessage发送消息<br>　　}<br highlighted="1">　　对于消息的<zmkey class=zoomino-searchword style="FONT-WEIGHT: bold; FLOAT: none; CURSOR: pointer; MARGIN-RIGHT: 3px; BORDER-BOTTOM: #ff6c00 2px dotted; cssFloat: none" offset="7" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(18)" anchorType="previous" jQuery1237769822734="9">接受者<img class=zoominoBgImage style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: inline; BACKGROUND: none transparent scroll repeat 0% 0%; FLOAT: none; MARGIN: 0px; BORDER-LEFT: medium none; WIDTH: 12px; BORDER-BOTTOM: medium none; HEIGHT: 14px; cssFloat: none" height=14 src="http://www.zoomino.cn/static-ox/images/z-keyword.gif" width=12></zmkey>-MessageTestView，<br>　　在其MessageTestView.h中，也要定义#define WM_MY_MESSAGE (WM_USER+100)<br>　　并定义消息映射函数-OnMyMessage()<br>　　protected:<br>　　//{{AFX_MSG(CMessageTestView)<br>　　afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam); <br>　　//}}AFX_MSG<br>　　DECLARE_MESSAGE_MAP()<br>　　在其MessageTestView.cpp中，<br>　　先要声明响应消息：<br>　　BEGIN_MESSAGE_MAP(CMessageTestView, CEditView)<br>　　//{{AFX_MSG_MAP(CMessageTestView)<br>　　ON_MESSAGE(WM_MY_MESSAGE, OnMyMessage)<br>　　//}}AFX_MSG_MAP<br>　　再添加消息响应的函数实现：<br>　　LRESULT CMessageTestView::OnMyMessage(WPARAM wParam, LPARAM lParam)<br>　　{<br>　　MessageBox("OnMyMessage!");<br>　　return 0;<br>　　} <br>　　消息传递的方法二：使用ON_REGISTERED_MESSAGE<br>　　使用ON_REGISTERED_MESSAGE注册消息，必须配合<br>　　static UINT WM_MY_MESSAGE=RegisterWindowMessage("Message");<br highlighted="1">　　对于消息的<zmkey class=zoomino-searchword style="FONT-WEIGHT: bold; FLOAT: none; CURSOR: pointer; MARGIN-RIGHT: 3px; BORDER-BOTTOM: #ff6c00 2px dotted; cssFloat: none" offset="7" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(41)" anchorType="previous" jQuery1237769822734="11">发送者<img class=zoominoBgImage style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: inline; BACKGROUND: none transparent scroll repeat 0% 0%; FLOAT: none; MARGIN: 0px; BORDER-LEFT: medium none; WIDTH: 12px; BORDER-BOTTOM: medium none; HEIGHT: 14px; cssFloat: none" height=14 src="http://www.zoomino.cn/static-ox/images/z-keyword.gif" width=12></zmkey>-MyMessageDlg，<br>　　在其MyMessageDlg.h中，只要<br>　　定义static UINT WM_MY_MESSAGE=RegisterWindowMessage("Message");<br>　　就可以了。<br>　　在其MyMessageDlg.cpp中要先添加：#include "MainFrm.h"<br>　　因为使用了CMainFrame*定义对象。<br>　　并且要有测试消息的函数：<br>　　void MyMessageDlg::OnButtonMsg() <br>　　{<br>　　 // TODO: Add your control notification handler code here<br>　　 CMainFrame* pMF=(CMainFrame*)AfxGetApp()-&gt;m_pMainWnd; //先通过获取当前框架指针<br>　　 CView * active = pMF-&gt;GetActiveView();//才能获取当前视类指针<br>　　 if(active != NULL) //获取了当前视类指针才能发送消息<br>　　 active-&gt;PostMessage(WM_MY_MESSAGE,0,0); //使用PostMessage发送消息<br>　　}<br highlighted="1">　　对于消息的<zmkey class=zoomino-searchword style="FONT-WEIGHT: bold; FLOAT: none; CURSOR: pointer; MARGIN-RIGHT: 3px; BORDER-BOTTOM: #ff6c00 2px dotted; cssFloat: none" offset="7" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(56)" anchorType="previous" jQuery1237769822734="7">接收者<img class=zoominoBgImage style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: inline; BACKGROUND: none transparent scroll repeat 0% 0%; FLOAT: none; MARGIN: 0px; BORDER-LEFT: medium none; WIDTH: 12px; BORDER-BOTTOM: medium none; HEIGHT: 14px; cssFloat: none" height=14 src="http://www.zoomino.cn/static-ox/images/z-keyword.gif" width=12></zmkey>-MessageTestView，<br>　　在其MessageTestView.h中不要定义<br>　　static UINT WM_MY_MESSAGE=RegisterWindowMessage("Message");<br>　　应该把这个定义放到MessageTestView.cpp中，要不会出现: redefinition<br>　　在其MessageTestView.h中只要定义消息映射函数<br>　　protected:<br>　　//{{AFX_MSG(CMessageTestView)<br>　　afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam); <br>　　//}}AFX_MSG<br>　　DECLARE_MESSAGE_MAP()<br>　　在其MessageTestView.cpp中,先定义<br>　　static UINT WM_MY_MESSAGE=RegisterWindowMessage("Message");<br>　　接着注册消息：<br>　　BEGIN_MESSAGE_MAP(CMessageTestView, CEditView)<br>　　//{{AFX_MSG_MAP(CMessageTestView)<br>　　 ON_REGISTERED_MESSAGE(WM_MY_MESSAGE,OnMyMessage)<br>　　//}}AFX_MSG_MAP<br>　　最后添加消息响应的函数实现：<br>　　LRESULT CMessageTestView::OnMyMessage(WPARAM wParam, LPARAM lParam)<br>　　{<br>　　MessageBox("OnMyMessage!");<br>　　return 0;<br>　　}<br>　　----------------------------------------------------------------<br>　　比较两种方法，只是略有不同。但也要小心谨慎，以免出现接收不到消息的情况。 <br>　　-------------------------------------------------------------------<br>　　其他注意事项：<br>　　发送消息的-MyMessageDlg.cpp前也要定义<br>　　static UINT WM_MY_MESSAGE=RegisterWindowMessage("Message");<br>　　接受消息的-MessageTestView.cpp前也要定义<br>　　static UINT WM_MY_MESSAGE=RegisterWindowMessage("Message");<br>　　RegisterWindowMessage("Message")中""的内容是什么不重要，写什么都可以，单必须<br>　　发送者与接受者是一样的内容，例如："Message" 
<img src ="http://www.cppblog.com/Jrong/aggbug/77537.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Jrong/" target="_blank">iJrong</a> 2009-03-23 09:08 <a href="http://www.cppblog.com/Jrong/archive/2009/03/23/77537.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>