请问关于控件和VIEW传递参数,相互通信的问题
现在我有一个继承的mybutton,在formview初始化时已经放在了formview上,定义有OnLButtonUp消息,我希望当触发mybutton的OnLButtonUp消息时,在formview另外添加一个mybutton
请问如何实现?
小弟刚开始学vc还希望高人多多指点
问题点数:50、回复次数:8Top
1 楼flyelf(空谷清音)回复于 2005-04-02 17:17:54 得分 10
CreateWindow一个buttonTop
2 楼wangjianddy(~~~~>_<~~~~)回复于 2005-04-02 17:42:00 得分 10
同楼上,那就在OnLButtonUp的响应函数里动态创建一个按钮阿
动态创建按钮自己在CSDN搜把,一搜一大堆Top
3 楼oyljerry(【勇敢的心】→ ㊣提拉米苏√㊣)回复于 2005-04-02 18:05:23 得分 10
在OnLButtonUp消息函数中动态创建 CreateWindowTop
4 楼Scorpioxp1983()回复于 2005-04-02 18:54:51 得分 0
OnLButton是在Button的类中定义的
如果要在FormView上创建Button
parent指针怎么取得呢?
Top
5 楼wangjianddy(~~~~>_<~~~~)回复于 2005-04-02 19:16:17 得分 10
GetParent();Top
6 楼Scorpioxp1983()回复于 2005-04-02 20:26:41 得分 0
但是在Button类的OnLButton消息处理中调用create如下
// create shapes for button
// make sure that region is in button client coordinates
HRGN r;
// RECTANGULAR BUTTONS
r = CreateEllipticRgn(0, 0, 63, 63);
this->Create("Btn 1", WS_CHILD | WS_VISIBLE, CPoint(150, 150), r, this->GetParent, 1002,RGB(255, 255, 0));
DeleteObject(r);
这样总是运行会有错误Top
7 楼Mackz(在相互)回复于 2005-04-02 22:06:12 得分 10
r应该是LPRECT类型的,或者CRect。Top
8 楼Scorpioxp1983()回复于 2005-04-02 22:39:13 得分 0
// create shapes for button
// make sure that region is in button client coordinates
HRGN r;
// RECTANGULAR BUTTONS
r = CreateEllipticRgn(0, 0, 63, 63);
m_Btn1.Create("Btn 1", WS_CHILD | WS_VISIBLE, CPoint(150, 150), r, this, 1002,RGB(255, 255, 0));
DeleteObject(r);
在Formview的初始化函数里调用上述代码,得到的结果是正确的。
CreateEllipticRgn是因为我继承CButton 后,重载DrawItem绘制圆形的按钮,所以使用画圆的区域。
在OnLButton使用
// create shapes for button
// make sure that region is in button client coordinates
HRGN r;
// RECTANGULAR BUTTONS
r = CreateEllipticRgn(0, 0, 63, 63);
this->Create("Btn 1", WS_CHILD | WS_VISIBLE, CPoint(150, 150), r, this->GetParent, 1002,RGB(255, 255, 0));
DeleteObject(r);
这一代码时,程序可以运行,但触发OnLButton消息后,程序出错,显示debug assertion failed!Top




