查看單個文章
舊 2005-08-24, 09:56 PM   #1
魔術王子
版區管理員
 
魔術王子 的頭像
榮譽勳章
UID - 115097
在線等級: 級別:42 | 在線時長:2001小時 | 升級還需:20小時級別:42 | 在線時長:2001小時 | 升級還需:20小時
註冊日期: 2004-01-13
住址: 魔術學園
文章: 3017
精華: 0
現金: 15080 金幣
資產: 2678710 金幣
預設 [C++ Builder]小時鐘

這程式原本是設計成螢幕保護程式的
現在改成一般程式,大家若有興趣可自行修改(原來部分小王子只是remake而已)
語法:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "math.h"
#include "stdlib.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int GX=0,GY=0;
int hr,min,sec;
int hr1,min1,sec1;
int x=Screen->Width/2;
int y=Screen->Height/2+10;
int r=Screen->Height/2-30;
float j;
/*
Graphics::TBitmap* Bmp0=new Graphics::TBitmap;
Graphics::TBitmap* Bmp1=new Graphics::TBitmap;
Graphics::TBitmap* Bmp2=new Graphics::TBitmap;
Graphics::TBitmap* Bmp3=new Graphics::TBitmap;
Graphics::TBitmap* Bmp4=new Graphics::TBitmap;
Graphics::TBitmap* Bmp5=new Graphics::TBitmap;
Graphics::TBitmap* Bmp6=new Graphics::TBitmap;
Graphics::TBitmap* Bmp7=new Graphics::TBitmap;
Graphics::TBitmap* Bmp8=new Graphics::TBitmap;
Graphics::TBitmap* Bmp9=new Graphics::TBitmap;
Graphics::TBitmap* Bmpc=new Graphics::TBitmap;   */
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
/*    if((GX==0)&&(GY==0))
     {GX=X;GY=Y;}
    if((GX!=X)||(GY!=Y))
        Close();        */
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    Close();    
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
    Close();    
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
/*
    Bmp0->Handle=LoadBitmap(HInstance,"bmp0");
    Bmp1->Handle=LoadBitmap(HInstance,"bmp1");
    Bmp2->Handle=LoadBitmap(HInstance,"bmp2");
    Bmp3->Handle=LoadBitmap(HInstance,"bmp3");
    Bmp4->Handle=LoadBitmap(HInstance,"bmp4");
    Bmp5->Handle=LoadBitmap(HInstance,"bmp5");
    Bmp6->Handle=LoadBitmap(HInstance,"bmp6");
    Bmp7->Handle=LoadBitmap(HInstance,"bmp7");
    Bmp8->Handle=LoadBitmap(HInstance,"bmp8");
    Bmp9->Handle=LoadBitmap(HInstance,"bmp9");
    Bmpc->Handle=LoadBitmap(HInstance,"bmpc");  */
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
/*    ShowCursor(true);
    delete Bmp0;
    delete Bmp1;
    delete Bmp2;
    delete Bmp3;
    delete Bmp4;
    delete Bmp5;
    delete Bmp6;
    delete Bmp7;
    delete Bmp8;
    delete Bmp9;
    delete Bmpc;
 */
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
{
/*    String d=DateToStr(Date());
    int y1=d.SubString(1,4).ToInt()-1911;
    Canvas->Draw(x-150,3,Day);
    DrawBmp(x-27,8,IntToStr(y1).SubString(1,1).ToInt());
    DrawBmp(x-10,8,IntToStr(y1).SubString(2,1).ToInt());
    if(d.SubString(7,1)!="\/"){
        DrawBmp(x+33,8,1);
        DrawBmp(x+50,8,d.SubString(7,1).ToInt());
    } else {
        DrawBmp(x+33,8,0);
        DrawBmp(x+50,8,d.SubString(6,1).ToInt());
    }
    if(d.SubString(d.Length()-1,1)!="\/"){
        DrawBmp(x+90,8,d.SubString(d.Length()-1,1).ToInt());
        DrawBmp(x+107,8,d.SubString(d.Length(),1).ToInt());
    } else {
        DrawBmp(x+90,8,0);
        DrawBmp(x+107,8,d.SubString(d.Length(),1).ToInt());
    }       */
    Canvas->Pen->Color=clWhite;
    Canvas->Pen->Width=1;
    Canvas->Ellipse(x-r,y-r,x+r,y+r);
    j=-1.57+3.14*0/30;
    Canvas->Pen->Width=2;
    Canvas->MoveTo(x+cos(j)*(r-50),y+sin(j)*(r-50));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*5/30;
    Canvas->Pen->Width=1;
    Canvas->MoveTo(x+cos(j)*(r-30),y+sin(j)*(r-30));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*10/30;
    Canvas->Pen->Width=1;
    Canvas->MoveTo(x+cos(j)*(r-30),y+sin(j)*(r-30));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*15/30;
    Canvas->Pen->Width=2;
    Canvas->MoveTo(x+cos(j)*(r-50),y+sin(j)*(r-50));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*20/30;
    Canvas->Pen->Width=1;
    Canvas->MoveTo(x+cos(j)*(r-30),y+sin(j)*(r-30));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*25/30;
    Canvas->Pen->Width=1;
    Canvas->MoveTo(x+cos(j)*(r-30),y+sin(j)*(r-30));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*30/30;
    Canvas->Pen->Width=2;
    Canvas->MoveTo(x+cos(j)*(r-50),y+sin(j)*(r-50));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*35/30;
    Canvas->Pen->Width=1;
    Canvas->MoveTo(x+cos(j)*(r-30),y+sin(j)*(r-30));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*40/30;
    Canvas->Pen->Width=1;
    Canvas->MoveTo(x+cos(j)*(r-30),y+sin(j)*(r-30));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*45/30;
    Canvas->Pen->Width=2;
    Canvas->MoveTo(x+cos(j)*(r-50),y+sin(j)*(r-50));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*50/30;
    Canvas->Pen->Width=1;
    Canvas->MoveTo(x+cos(j)*(r-30),y+sin(j)*(r-30));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
    j=-1.57+3.14*55/30;
    Canvas->Pen->Width=1;
    Canvas->MoveTo(x+cos(j)*(r-30),y+sin(j)*(r-30));
    Canvas->LineTo(x+cos(j)*(r-10),y+sin(j)*(r-10));
}
//---------------------------------------------------------------------------
void TForm1::DrawBmp(int x,int y,int n)
{
/*    switch(n)
    {
        case 0:
            Canvas->Draw(x,y,Bmp0);
            break;
        case 1:
            Canvas->Draw(x,y,Bmp1);
            break;
        case 2:
            Canvas->Draw(x,y,Bmp2);
            break;
        case 3:
            Canvas->Draw(x,y,Bmp3);
            break;
        case 4:
            Canvas->Draw(x,y,Bmp4);
            break;
        case 5:
            Canvas->Draw(x,y,Bmp5);
            break;
        case 6:
            Canvas->Draw(x,y,Bmp6);
            break;
        case 7:
            Canvas->Draw(x,y,Bmp7);
            break;
        case 8:
            Canvas->Draw(x,y,Bmp8);
            break;
        case 9:
            Canvas->Draw(x,y,Bmp9);
            break;
        case 10:
            Canvas->Draw(x,y,Bmpc);
            break;
    }    */
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
//    ShowCursor(false);
}
//---------------------------------------------------------------------------
魔術王子 目前離線  
送花文章: 1536, 收花文章: 1560 篇, 收花: 3905 次
回覆時引用此帖