消息映射的问题
自定义类
希望截获WM_MOUSELEAVE消息
.h文件
#include <Mask.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <stdio.h>
#include "CGAUGES.H"
//---------------------------------------------------------------------------
class PACKAGE TCellPanel : public TPanel
{
private:
TControlCanvas *ACanvas;
protected:
void __fastcall Drawframe(); //给控件增加外框
void __fastcall DrawNoframe(); //给控件取消外框
void __fastcall WndProc(Messages::TMessage &Message);
void __fastcall DrawPoint(); //画连接点
void __fastcall DrawNoPoint(); //取消连接点
DYNAMIC void __fastcall MouseMove(TShiftState Shift,int X,int Y);
void __fastcall MouseLeave(TMessage &Message);
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_MOUSELEAVE,TMessage,MouseLeave);
END_MESSAGE_MAP(TComponent)
private:
public:
__fastcall TCellPanel(TComponent* Owner);
int ShapType; //控件外形 1 Start 2 Send 3 receive
bool bClick_Select; //是否被单击选中
bool bPoint; //是否出现连接点
__published:
__property Align;
__property BorderStyle;
__property Color;
__property Canvas;
__property BevelInner;
__property BevelOuter;
__property BorderWidth;
__property Parent;
};
//---------------------------------------------------------------------------
#endif
在.cpp文件中定义MouseLeave如下:
void __fastcall TCellPanel::MouseLeave(TMessage &Message)
{
DrawPoint();
}
编译通过了,但是调试时当鼠标移出控件时并没有调用MouseLeave函数,为何?请各位大侠指点!!
问题点数:20、回复次数:6Top
1 楼Libran()回复于 2005-12-22 18:55:58 得分 10
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSELEAVE,TMessage,MouseLeave);
END_MESSAGE_MAP(TPanel)Top
2 楼gaosifu(博博)回复于 2005-12-23 13:06:10 得分 0
Libran()你好, Windows也有WM_MOUSELEAV消息,请问什么时候用WM_MOUSELEAV,什么时候用
CM_MOUSELEAV?
还有下面一个问题:
对于MOUSEMOVE消息可以这样用:
在.h文件中加上:
DYNAMIC void __fastcall MouseMove(TShiftState Shift,int X,int Y);
在.cpp文件加上:
void __fastcall TCellPanel::MouseMove(TShiftState Shift,int X,int Y)
{
TPanel::MouseMove(Shift,X,Y);
DrawPoint();
}
但类似的方法用在MOUSELEAVE消息上就不行,问什么呢?
Top
3 楼ccrun(老妖)(www.ccrun.com)回复于 2005-12-23 13:15:48 得分 10
因为VCL中的TControl只有MouseMove事件,没有MouseLeave事件。
BTW: CLX中有。Top
4 楼gaosifu(博博)回复于 2005-12-23 13:38:18 得分 0
ccrun(老妖)大哥,给推荐些学习VCL的资料吧,谢了!Top
5 楼gaosifu(博博)回复于 2005-12-23 13:39:07 得分 0
另,BTW: CLX是什么?Top
6 楼ccrun(老妖)(www.ccrun.com)回复于 2005-12-23 13:44:02 得分 0
In computing, Component Library for Cross Platform (CLX), is a cross-platform visual component-based framework for developing Microsoft Windows and Linux applications. It is developed by Borland for use in its Kylix, Delphi, and C++ Builder software development environment. There is a Microsoft Windows-only equivalent of CLX called VCL (Visual Component Library).
简单来说就是跨平台组件库,传说中的Linux中用的VCL,我不曾用过。Top




