点击快了能闪烁,有解决方案吗
点击快了会闪烁,有解决方案吗?
.h文件
//---------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TButton *Button2;
private: // User declarations
TWndMethod OldProc;
void __fastcall NewProc(TMessage &Msg);
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------
#endif
//---------------------------------------
.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)
{
//SetWindowLong(Button1->Handle, GWL_STYLE, GetWindowLong(Button1->Handle,GWL_STYLE) | BS_OWNERDRAW );
OldProc = Button1->WindowProc;
Button1->WindowProc = NewProc;
DoubleBuffered = true;
//创建圆角矩形按钮,去掉这两句就是默认的矩形区域
HRGN hRgnR = CreateRoundRectRgn(0,0,Button1->Width,Button1->Height,45,45);
SetWindowRgn(Button1->Handle,hRgnR,TRUE);
}
//---------------------------------------
//用到三张图片,分别表示几种状态:正常(移出),移入(抬起),按下
void __fastcall TForm1::NewProc(TMessage &Msg)
{
TRect Rect;
Graphics::TBitmap* Bmp;
TControlCanvas* Canvas;