| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 466 人关注过本帖
标题:急求:如何在自定义消息里传递数据,并在处理函数中接收处理
只看楼主 加入收藏
daver_yu
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-3-29
收藏
 问题点数:0 回复次数:0 
急求:如何在自定义消息里传递数据,并在处理函数中接收处理

如何在自定义消息里传递数据,并在处理函数中接收处理

我代码定义如下:

在 tyView.cpp中


static UINT WM_MY=RegisterWindowMessage("MY_PAINT");

IMPLEMENT_DYNCREATE(CTyphoonView, CView)

BEGIN_MESSAGE_MAP(CTyphoonView, CView)
//{{AFX_MSG_MAP(CTyphoonView)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
// Standard printing commands
ON_REGISTERED_MESSAGE(WM_MY,MyPaint)
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

在 tyView.h:

// Generated message map functions
protected:
//{{AFX_MSG(CTyphoonView)
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
afx_msg void MyPaint(WPARAM wParam, LPARAM lParam);
//afx_msg void MyPaint(CString wParam, CString lParam);
DECLARE_MESSAGE_MAP()


我从一个模式对话框控件发消息给tyView.cpp中的MyPaint(.......),可是我接受参数是老是出错(参数),
不知怎样接收处理?


发送消息函数:

void simalardalg::OnFound1()
{
// TODO: Add your control notification handler code here
UpdateData();//获取用户输入
CString m_typhoonname;
m_typhoonname=m_cstext;
//调用第一种查找方案
AfxMessageBox(m_cstext);

CFile mFile;
mFile.Open("typhoonname.txt",CFile::modeCreate|CFile::modeWrite,NULL);
mFile.Write(m_typhoonname,m_typhoonname.GetLength());
mFile.Close();
//调用第一种查询方案


CStdioFile mF;
mF.Open("typhoonname.txt",CFile::modeRead,NULL);
mF.ReadString(m_typhoonname);
mF.Close();
if( m_CwndA != NULL )
{
m_CwndA->PostMessage(WM_MY_MESSAGE,0,(LPARAM)&m_typhoonname);
}
CMainFrame *fm;
fm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CView *cv;
cv=fm->GetActiveView();
if( cv != NULL )
cv->PostMessage(WM_MY,(WPARAM)0, (LPARAM)&m_typhoonname);

CDialog::OnCancel();
}

接受消息函数:

void CTyphoonView::MyPaint(WPARAM wParam, LPARAM lParam)
{
//CDC *pDC;
CString *Para;
CString str;
CString *str1;
char com[100];
char year[5];
char month[3];
char day[4];
char hour[3];
CStdioFile mF;
char *name;
int i=0;
int j=0;
int number=0;
Para=(CString *)wParam;
//i=wParam;
str1=(CString *)lParam;
int length=str1->GetLength();
char *tserial=new char(length);
tserial=str1->GetBuffer(length);

CWnd cw;
CRect rgn;
cw.GetActiveWindow()->GetClientRect(&rgn);
cw.GetActiveWindow()->UpdateWindow();
cw.GetActiveWindow()->Invalidate(FALSE);
cw.GetActiveWindow()->RedrawWindow(NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE);

}

求助!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

搜索更多相关主题的帖子: 函数 定义 数据 
2006-05-14 14:57
快速回复:急求:如何在自定义消息里传递数据,并在处理函数中接收处理
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011470 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved