Cinco Dicas de Delphi

Veja nesse artigo cinco dicas para a Linguagem de Programação Delphi.

Procedure TForm1.DBGrid1TitleClick(Column: TColumn); var I : integer; begin for i:=0 to DBGrid1.Columns.count-1 do begin DBGrid1.Columns[i].Title.Color := clBtnFace; DBGrid1.Columns[i].Title.Font.Color := clBlack; DBGrid1.Columns[i].Title.Font.Style := []; end; Column.Title.color := ClYellow; Column.Title.Font.Style := [ fsBold, fsItalic]; Column.Title.Font.Color := clRed; end;
Alterar as cores do título de um DBGrid em tempo execução
program wallpapr; uses Registry, WinProcs; procedure SetWallpaper(sWallpaperBMPPath : String; bTile : boolean ); var reg : TRegIniFile; begin // Mudando o Registro HKEY_CURRENT_USER // Control Panel\Desktop // TileWallpaper (REG_SZ) // Wallpaper (REG_SZ) reg := TRegIniFile.Create('Control Panel\Desktop' ); with reg do begin WriteString( '', 'Wallpaper',sWallpaperBMPPath ); if( bTile )then begin WriteString( '', 'TileWallpaper', '1' ); end else begin WriteString( '', 'TileWallpaper', '0' ); end; end; reg.Free; // Mostrar que o parametro do sistema foi alterado SystemParametersInfo( SPI_SETDESKWALLPAPER,0, Nil, SPIF_SENDWININICHANGE ); end; begin SetWallpaper( 'c:\winnt\winnt.bmp', False ); end.
Alterar o papel de parede - 1
procedure ChangeWallpaper(bitmap: string); var pBitmap : pchar; begin bitmap:=bitmap+#0; {bitmap contém um arquivo *.bmp} pBitmap:=@bitmap[1]; SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pBitmap, SPIF_UPDATEINIFILE); end;
Alterar papel de parede - 2
Para testar o exemplo abaixo inclua no seu form um componente Button e no evento OnClick o código abaixo: procedure TForm1.Button1Click(Sender: TObject); begin SystemParametersInfo(SPI_SETDESKWALLPAPER,0, PChar('C:\windows\Arenito.bmp'),SPIF_SENDWININICHANGE); end;
Alterar o papel de parede - 3
Variáveis globais do form: var Form1: TForm1; Iniciar : hWnd; OldBitmap : THandle; NewImage : TPicture; No Oncreate do Form: procedure TForm1.FormCreate(Sender: TObject); begin NewImage:=TPicture.create; NewImage.LoadFromFile('C:\Delphi3\Images\DEFAULT\OutOpen.BMP'); Iniciar := FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil); OldBitmap:=SendMessage(Iniciar,BM_SetImage,0,NewImage.Bitmap.Handle); end; No OnDestroy procedure TForm1.FormDestroy(Sender: TObject); begin SendMessage(Iniciar,BM_SetImage,0,OldBitmap); NewImage.Free; end;
Alterar o ícone do botão iniciar do Windows
Ebook exclusivo
Dê um upgrade no início da sua jornada. Crie sua conta grátis e baixe o e-book

Artigos relacionados