Unit1.cpp
资源名称:XPbutton.rar [点击查看]
上传用户:jjjzlw
上传日期:2022-05-15
资源大小:695k
文件大小:13k
源码类别:
按钮控件
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- int w;
- void *OldProc; // 保存旧的消息处理函数地址入口
- int flag1=0;
- int flag2=0;
- int SetF =0;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- this->DoubleBuffered=true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- HRGN rgn;
- rgn=CreateRoundRectRgn(0,0,75,25,4,4);
- SetWindowRgn(Button5->Handle,rgn,TRUE);
- TCanvas *can = new TCanvas();
- HDC ae = GetDC(Button5->Handle);
- can->Handle = ae;
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,75,25,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- ReleaseDC(Button5->Handle,ae);
- delete can;
- Button5->WindowProc = NewProc3;
- }
- void __fastcall TForm1::NewProc3(TMessage &msg)
- {
- TCanvas *can = new TCanvas();
- TRect r;
- HDC ae = GetDC(Button5->Handle);
- switch (msg.Msg)
- {
- case WM_PAINT:
- Button5->Dispatch(&msg);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xEEF5FF);
- can->Pen->Color = TColor(0xEBCE87);
- can->RoundRect(1,1,73,23,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- break;
- case WM_SETFOCUS:
- Button5->Dispatch(&msg);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xEEF5FF);
- can->Pen->Color = TColor(0x25C1FF); //黄色
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- SetF=1;
- break;
- case WM_KILLFOCUS:
- SetF=0;
- Button5->Dispatch(&msg);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xEEF5FF);
- can->Pen->Color = TColor(0xEBCE87);
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- break;
- case WM_LBUTTONDOWN:
- if(SetF==0){
- Button5->Dispatch(&msg);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xEEF5FF);
- can->Pen->Color = TColor(0x25C1FF); //黄色
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- SetF=1;
- }
- break;
- default:
- Button5->Dispatch(&msg);
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5MouseMove(TObject *Sender,
- TShiftState Shift, int X, int Y)
- {
- if(Button5->Tag==0)
- {
- TCanvas *can = new TCanvas();
- HDC ae = GetDC(Button5->Handle);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xEEF5FF);
- can->Pen->Color = TColor(0x25C1FF);
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- Button5->Tag=1;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
- int X, int Y)
- {
- if(Button5->Tag==1)
- {
- TCanvas *can = new TCanvas();
- HDC ae = GetDC(Button5->Handle);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xEEF5FF);
- can->Pen->Color = TColor(0xEBCE87);
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- Button5->Tag=0;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5MouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- TCanvas *can = new TCanvas();
- HDC ae = GetDC(Button5->Handle);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xCDB5A2);
- can->Pen->Color = TColor(0x25C1FF);
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5Click(TObject *Sender)
- {
- TCanvas *can = new TCanvas();
- HDC ae = GetDC(Button5->Handle);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xCDB5A2); //
- can->Pen->Color = TColor(0x25C1FF); //黄色
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5MouseUp(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- TCanvas *can = new TCanvas();
- HDC ae = GetDC(Button5->Handle);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xCDB5A2); //
- can->Pen->Color = TColor(0x25C1FF); //黄色
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5KeyPress(TObject *Sender, char &Key)
- {
- if(SetF==1)
- {
- if(Key==13)
- {
- TCanvas *can = new TCanvas();
- HDC ae = GetDC(Button5->Handle);
- can->Handle = ae;
- /////////////////加底色,刷屏幕
- can->Brush->Style = bsClear;
- can->Brush->Color = clBackground;
- can->Pen->Color = clBackground;
- can->Pen->Width = 1;
- can->RoundRect(0,0,Button5->Width,Button5->Height,5,5);
- /////////////////重画新的边框,并重填按钮色彩
- can->Brush->Style = bsClear;
- can->Brush->Color = TColor(0xCDB5A2); //
- can->Pen->Color = TColor(0x25C1FF); //黄色
- can->RoundRect(1,1,Button5->Width-2,Button5->Height-2,5,5);
- can->Font->Color = clBlack;
- can->Brush->Style = bsClear;
- can->TextOut(18, 5, "下一条");
- ReleaseDC(Button5->Handle,ae);
- delete can;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormKeyUp(TObject *Sender, WORD &Key,
- TShiftState Shift)
- {
- if(Key==VK_RETURN)
- Button5Click(Sender);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5EndDock(TObject *Sender, TObject *Target,
- int X, int Y)
- {
- int t;
- t++;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5EndDrag(TObject *Sender, TObject *Target,
- int X, int Y)
- {
- int t;
- t++;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5DragOver(TObject *Sender, TObject *Source,
- int X, int Y, TDragState State, bool &Accept)
- {
- int t;
- t++;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5DragDrop(TObject *Sender, TObject *Source,
- int X, int Y)
- {
- int t;
- t++;
- }
- //---------------------------------------------------------------------------