Mega Code Archive

 
Categories / Delphi / System
 

Make your app to fill entire screen excluding taskbar

Title: Make your app to fill entire screen excluding taskbar Question: Did you ever tried to make your app window to cover everything except taskbar? The following solution does just that. Answer: To make your app window to cover all available work area you need to process WM_SETTINGCHANGE message and use SystemParametersInfo(...) WinAPI function. Using this technique you will be able to cover all available screen area excluding taskbar, MS Office toolbar and similarly behaving 'bars'. TfmMyForm=class(TForm) procedure FormCreate(Sender: TObject); ............. private ...... procedure WMSettingChange( var Msg: TMessage); message WM_SETTINGCHANGE; ........... protected ........ end; implementation // returns available work area function GetWindowsWorkArea: TRect; begin SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0); end; .......... //respond to any change of work area dimensions during runtime... procedure TfmMyForm.WMSettingChange( var Msg: TMessage); var R: TRect; begin if (Msg.WParam=SPI_SETWORKAREA) then begin R:=GetWindowsWorkArea; SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top); end; Msg.Result:=0; end; //in an OnFormCreate event get available work area, //because your form won't get WM_SETTINGCHANGE at startup... procedure TfmMyForm.FormCreate(Sender: TObject); var R: TRect; begin R:=GetWindowsWorkArea; SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top); end;