本文主要是介绍BCB中如何实时显示鼠标的坐标?---利用定时器,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
当鼠标在窗体上滑动时, 可以触发窗体的FormMouseMove方法, 代码如下:
//---------------------------------------------------------------------------#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::FormMouseMove(TObject *Sender, TShiftState Shift,int X, int Y)
{Label1->Caption = X;Label2->Caption = Y;
}
//---------------------------------------------------------------------------
但是, 上述方法是有缺陷的, 因为, Label1和Label2在窗体上, 当鼠标滑过他们时候, 窗体被挡住,
这篇关于BCB中如何实时显示鼠标的坐标?---利用定时器的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!