Delphi - Change Start button bitmap

Delphi - Change Start button bitmap

Postby Dieliric » 18 Jan 2010, 21:42

Am gasit un programel interesant intr-o carte recent achizitionata si m-am gandit ca poate va fi folositor cuiva.
Let's begin the party code ;)).

In primul rand trebuie sa definim cateva variabile globale.
  1. var StartButton : hWnd;
  2.     OldBitmap : THandle;
  3.     NewImage : TPicture;

Apoi cream un event in form-ul principal numit "OnCreate"
  1. procedure TForm1.FormCreate(Sender: TObject) ;
  2. begin
  3.   NewImage:=TPicture.Create;
  4.   NewImage.LoadFromFile('C:\Windows\fotografie.BMP') ;  {dam calea de acces catre fotografie + extensia}
  5.   StartButton := FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'Button', nil) ;
  6.   OldBitmap:=SendMessage(StartButton, BM_SetImage, 0, NewImage.Bitmap.Handle) ;
  7. end;

Al doilea event care trebuie creat este "OnDestroy", caruia ii atribuim urmatorul cod.
  1. procedure TForm1.FormDestroy(Sender: TObject) ;
  2. begin
  3.    SendMessage(StartButton, BM_SetImage, 0, OldBitmap) ;
  4.    NewImage.Free;
  5. end;

Sper ca am tradus bine si nu am greseli in cod, nu l-am testat inca, dar o sa o fac dupa sesiune.

P.S. Sper sa nu iau bataie pentru cod de la cei doi Delphi Masters :">.
1p / 1 votes
"Nu spun ca nu stiu ci nu stiu inca"
User avatar
Dieliric
Bit
 
Joined: 08 Jan 2010
Location: Roman
Status: 7

Re: [Delphi]Change Start button bitmap

Postby DarkByte » 18 Jan 2010, 21:44

Buna initiativa, dar nu uita sa pui [code=delphi] data viitoare. Am pus eu si am mai corectat niste greseli.
0,0p / 0 votes
User avatar
DarkByte
11011011
 
Joined: 29 Dec 2009
Status: 136

Re: [Delphi]Change Start button bitmap

Postby v0id » 19 Jan 2010, 10:43

Bataie o sa iei numai daca nu merge :)
0,0p / 0 votes
A good coder is never on holiday - he may be working on a different machine, that's about as far as it gets.
User avatar
v0id
Word
 
Joined: 05 Jan 2010
Location: 127.0.0.1
Status: 39.5


Return to Snippets

Who is online

Users browsing this forum: No registered users and 0 guests