用过CDialogBar的朋友请进(我创建了一个dialogbar,怎么样传递信息给视图框)

wolfasp 2003-08-19 02:34:58
同题
...全文
102 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
xghost 2003-08-20
  • 打赏
  • 举报
回复
从CDialogBar类派生一个CMyDlgBar类,

在类中添加那三个消息映射宏,让这个类有处理消息的能力:

//{{AFX_MSG(CMyDlgBar)
afx_msg void 你的消息(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

BEGIN_MESSAGE_MAP(CMyDlgBar, CDialogBar)
//{{AFX_MSG_MAP(CMyDlgBar)
你的消息处理函数
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

最后,用CDialogBar::Create 生成与资源相关联的对象
wolfasp 2003-08-20
  • 打赏
  • 举报
回复
谢谢各位的参与,问题基本上解决,但CDialogBar不能像Dialog那样使用,用起来有很多不便
wolfasp 2003-08-19
  • 打赏
  • 举报
回复
我也是这样做的啊,但不行。
RocWay007 2003-08-19
  • 打赏
  • 举报
回复
gz
ammycute 2003-08-19
  • 打赏
  • 举报
回复
可以用SendMessage(...)
消息: WM_COPYDATA
在View 中处理此消息


Karvey 2003-08-19
  • 打赏
  • 举报
回复
First, You can shadow the msg to the frame,
then copy the msg and the method to the view,
that is OK.
jennifergiant 2003-08-19
  • 打赏
  • 举报
回复
UP
wolfasp 2003-08-19
  • 打赏
  • 举报
回复
原来我的信息传递是没问题,原因国获取不到DialogBar的内容.
不知道怎么样来获取这些内容
wolfasp 2003-08-19
  • 打赏
  • 举报
回复
这样也太过麻烦了,应该有比较好的办法的
cuterain 2003-08-19
  • 打赏
  • 举报
回复
可以派生你自己的类CMyDialogBar
然后.h中
afx_msg void YourMessageProc();
.cpp中

BEGIN_MESSAGE_MAP(CTestApp, CWinApp)
//{{AFX_MSG_MAP(CTestApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_YOURBUTTON, YourMessageProc)
END_MESSAGE_MAP()

然后
Void CDialogBar::YourMessageProc()
{
//处理你的消息即可
}
wolfasp 2003-08-19
  • 打赏
  • 举报
回复
能帮我解决问题者,将给一百分酬谢
wolfasp 2003-08-19
  • 打赏
  • 举报
回复
现在主要是在CDialogBar中连添加事件函数时都没有反应
wolfasp 2003-08-19
  • 打赏
  • 举报
回复
对啊
其它可以这样做,便CDialogBar却做不到,是不是CDialogBar不能像CDialog那样使用
你可否share一些代码给我?
shangxiaodong 2003-08-19
  • 打赏
  • 举报
回复
要是你CDialogBar的基类室frame,那么你在CDialogBar中广播发送消息,在frame中再调用GetActiveView即可操作你所需的view!如果基类是view,那就更好办了;总之一句话,只要确定勒父子关系就好说!
xghost 2003-08-19
  • 打赏
  • 举报
回复
为什么不行???
要传递的变量要设成公有成员变量才行
wolfasp 2003-08-19
  • 打赏
  • 举报
回复
没错啊,我原就是这样做的,但不行
xghost 2003-08-19
  • 打赏
  • 举报
回复
第一、若你的CDialogBar是CMyView类的成员变量就好处理了,
第二、然后,在CDialogBar中定义构造函数时加入一个this参数(this代表CMyView *指针),
在CDialogBar类中定义一个CMyView指针用来接受参数传来的this指针,

这样就可以传递信息给视图框了。

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧