System

Clear "Documents" menu

Posted in System

Use SHAddToRecentDocs function with nil as second parameter. Don't forget to add SHlObj in uses chapter.

uses
  Shlobj;
...
procedure TForm1.Button1Click(Sender: TObject);
begin
  SHAddToRecentDocs(SHARD_PATH, nil);
end;

Change the wallpaper in Delphi

Posted in System

Use SystemParametersInfo procedure with SPI_SETDESCKWALLPAPER value.

procedure TForm1.Button1Click(Sender: TObject);
var
  St: array[0..100] of Char;
begin
  St:='C:\Windows\MyWallPaper.bmp';
  SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, @St, SPIF_SENDCHANGE);
end;

Change caption font

Posted in System

Change caption font - System - Tips & Tricks - Greatis Delphi Pages Use SystemParametersInfo function with SPI_SETNONCLIENTMETRICS parameter. All information, what you may set, are in NONCLIENTMETRICS structure.

procedure TForm1.Button1Click(Sender: TObject);
var
  MyStruct: TNonClientMetrics;
begin
  MyStruct.cbSize:=SizeOf(TNonClientMetrics);
  SystemParametersInfo(
    SPI_GETNONCLIENTMETRICS, 
    SizeOf(TNonClientMetrics), 
    @MyStruct, 
    0);
  MyStruct.lfCaptionFont.lfHeight:=8;
  MyStruct.lfCaptionFont.lfFaceName:='Arial';
  SystemParametersInfo(
    SPI_SETNONCLIENTMETRICS, 
    SizeOf(TNonClientMetrics), 
    @MyStruct, 
    0);
end;

Change bitmap of the start button

Posted in System

Use FindWindowEx funtion for getting handle of the Start-button and after that, you may use SendMessage function with BM_SETIMAGE parameter.

var
  MyBitmap: TBitmap;
  StartBtn: THandle;
  Old: Integer;

...

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyBitmap:=TBitmap.Create;
  MyBitmap.LoadFromFile('bmp1.bmp');
  StartBtn:=FindWindowEx(
    FindWindow('Shell_TrayWnd',nil),
    0,
    'Button',
    nil);
  Old:=SendMessage(
    StartBtn,
    BM_SETIMAGE,
    0,
    MyBitmap.Handle);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  SendMessage(
    StartBtn,
    BM_SETIMAGE,
    0,
    Old);
    MyBitmap.Free;
end;

Call Browse for Folder dialog

Posted in System

Following procedure can call the Browse for Folder dialog.

uses FileCtrl;
...

procedure TMainfrm.Button1Click(Sender: TObject);
var
  St: string;
begin
  St:='c:\';
  if SelectDirectory(St,[],0) then Label1.Caption:=St;
end;