用C++Builder开发Windows下的屏保.zip

  • PUDN用户
    了解作者
  • C++ Builder
    开发工具
  • 127KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 595
    下载次数
  • 2005-01-31 18:05
    上传日期
用C++Builder开发Windows下的屏保
用C++Builder开发Windows下的屏保.zip
  • 新建文件夹
  • bitmap.rc
    112B
  • Unit1.h
    1022B
  • lucyAnny.bpr
    2.8KB
  • Unitcontrol.h
    2KB
  • lucyAnny.cpp
    2.7KB
  • Unitmain.h
    1.8KB
  • Unitmain.cpp
    2.9KB
  • Unitcontrol.dfm
    1014B
  • Unit1.dfm
    982B
  • Unitview.h
    997B
  • Unitmain.dfm
    12.5KB
  • Unitview.cpp
    1.4KB
  • Unit1.cpp
    2.3KB
  • Unitcontrol.cpp
    11.4KB
  • Unitview.dfm
    216.4KB
  • www.pudn.com.txt
    218B
内容介绍
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include <stdlib.h> #include <Registry.hpp> #include <jpeg.hpp> #include "Unitcontrol.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TMainForm *MainForm; //--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { bussy=false; stoploop=false; stopcls=false; } //--------------------------------------------------------------------------- void __fastcall TMainForm::Fade(Graphics::TBitmap *Pic,TCanvas *dest) { int style,x,y,devide; int picwidth=Pic->Width ; int picheight=Pic->Height ; TRect rect1,rect2; const block=10; devide=picheight/block; randomize(); style=random(5); x=random(this->ClientWidth-Pic->Width); y=random(this->ClientHeight-Pic->Height); Timer1->Enabled=false; switch (style) { case 0: for(int i=0;i<devide;i++) {if(!stoploop){ rect1=Rect(0,i*block,picwidth,block*(i+1)); rect2=Rect(x,y+block*i,picwidth+x,y+block*(i+1)); dest->CopyRect(rect2,Pic->Canvas,rect1); Application->ProcessMessages(); Sleep(100);} else break; } break; case 1: for(int i=devide;i>=0;i--) { if(!stoploop){ rect1=Rect(0,i*block,picwidth,block*(i+1)); rect2=Rect(x,y+block*i,picwidth+x,y+block*(i+1)); dest->CopyRect(rect2,Pic->Canvas,rect1); Application->ProcessMessages(); Sleep(100); } else break; } break; case 2: for(int i=x;i>=0;i--) {if(!stoploop){ dest->Draw(i,y,Pic); y--; Application->ProcessMessages(); Sleep(10);} else break; } break; case 3: for(int i=picwidth/block-1;i>=0;i--) {if(!stoploop){ rect1=Rect(i*block,0,(i+1)*block,picheight); rect2=Rect(x+i*block,y,x+(i+1)*block,picheight); dest->CopyRect(rect2,Pic->Canvas,rect1); Application->ProcessMessages(); Sleep(100);} else break; } break; default: {dest->Draw(x,y,Pic) ; Sleep(100);} } Timer1->Enabled=true; } void __fastcall TMainForm::Timer1Timer(TObject *Sender) { stoploop=false; if(picdir=="no"){ Graphics::TBitmap *srcimg; srcimg=new Graphics::TBitmap(); randomize(); try { srcimg->LoadFromResourceID((int)HInstance,random(7)); this->Fade(srcimg,this->Canvas); this->clsscreen(Image1); } catch(...) { srcimg->Free(); Timer1->Enabled=true; } this->Canvas->FillRect(Rect(0,0,this->ClientWidth,this->ClientHeight)); } else {int s=0; s=random(File1->Items->Count); try { if(this->Height>Image1->Height&&this->Width>Image1->Width) {Image1->Top=rand()%(this->Height-Image1->Height); Image1->Left=rand()%(this->Width-Image1->Width);} else { Image1->Top =0; Image1->Left=0; } Image1->Picture->LoadFromFile(File1->Items->Strings[s]); this->clsscreen(Image1); /* Image1->Canvas->Brush->Color=clBlack; for(int i=0;i<100;i++){ if(!stoploop){ Image1->Canvas->Ellipse(random(Image1->ClientWidth),random(Image1->ClientHeight) , random(Image1->Width/10), random(Image1->ClientHeight/10)); Application->ProcessMessages(); Sleep(100); }*/ } catch(...) { } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormCreate(TObject *Sender) { SetWindowPos(this->Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); //Make the form exactly cover the screen this->Width=Screen->Width; this->Height=Screen->Height; this->Top=0; this->Left=0; this->Canvas->Brush->Color=clBlack; stoploop=false; Version=GetVersion(); TRegistry *Registry = new TRegistry; try { if(Version>0x80000000){ Registry->RootKey =HKEY_CURRENT_USER; Registry->OpenKey("\\Control Panel\\Desktop",false); PWProtect=Registry->ReadInteger("ScreenSaveUsePassword"); Registry->CloseKey();} Registry->RootKey =HKEY_CURRENT_USER; if(Registry->OpenKey("\\Software\\CODEHUNTER", false)){ picdir=Registry->ReadString("PicDir"); frequence=Registry->ReadInteger("frequence");} else { Registry->CreateKey("\\Software\\CODEHUNTER"); Registry->WriteString("PicDir","no"); Registry->WriteInteger("frequence",3); picdir="no"; } if(frequence<=0||frequence>6) frequence=3; if(picdir!="no"){File1->Directory=picdir; Timer1->Interval=800*frequence;} else Timer1->Interval=200*frequence; } __finally { delete Registry; } //Find out if we are running under NT if(Version!=0) //Disable Ctrl-Alt-Del if appropriate. NT handles password-protected //screen savers at the system level, so this is only needed for non-NT //situations with password protection enabled. if(PWProtect&&Version>0x80000000) SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, 0, 0); //Copy a clone of the desktop onto the form, to //serve as a background for the circle painting //CopyScreen Me //Make the cursor disappear while (!ShowCursor(false)< -5); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { Close(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { Close(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose) { stoploop=true; stopcls=true; Timer1->Enabled =false; if (PWProtect && Version>0x80000000) { bool PassChck; //We need a cursor so that the user can move around //the password form while(!ShowCursor(True) > 5); typedef UINT(CALLBACK *FUN)(HWND); HINSTANCE hDll=LoadLibrary("password.cpl"); FUN myfun; if(hDll!=NULL) { myfun=(FUN)GetProcAddress(hDll,"VerifyScreenSavePwd"); if(!myfun)FreeLibrary(hDll); else PassChck=myfun(this->Handle); } if(PassChck == false) { Timer1->Enabled =true; //Make the cursor disappear again while(!ShowCursor(False) < -5); CanClose = false; //stoploop=false; } } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action) { while(!ShowCursor(True) > 5); //re-enable Ctrl-Alt-Del if disabled if(PWProtect&&Version>0x80000000) SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, 0, 0); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { static int MouseMoves=0; MouseMoves = MouseMoves + 1; if(MouseMoves >4) { this->Close(); MouseMoves = 0 ; } } //--------------------------------------------------------------------------- void TMainForm::clsscreen(TImage * image) { int style; randomize(); style=random(5); TColor color; Timer1->Enabled=false; if(bussy==false) { stopcls=false; switch (style) { case 1: bussy=true; color=(TColor)RGB(rand()%256,rand()%256,rand()%256); image->Canvas->Pen->Color=
评论
    相关推荐