读书人

CBC对鼠标操作,该如何解决

发布时间: 2013-12-10 15:05:55 作者: rapoo

CBC对鼠标操作
程序中想实现鼠标左键按下时可追踪鼠标的位置,编程如下:
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
static int b;
down=1;
flag=1;
previous.x=X;
if(b==0)……
运行时提示FormMouseDown()不是TForm1的成员,该成员名有误还是必须得自己对该成员进行定义?或者说对鼠标的操作类包含在某个组件中而未安装该组件?

双击该事件属性,就会自动到下面.cpp文件中


#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
// 在这里写你的代码
}




你再回头看.hpp头文件中,IDE已经自动为你声明了该函数的原型

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:// IDE-managed Components
void __fastcall FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
private:// User declarations
public:// User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

读书人网 >C++ Builder

热点推荐