Code Faster in Delphi Book

This book will make you a faster Delphi developer, it doesn't matter if you are just starting out, or have been using Delphi since version 1, you will find all sorts of tips, tricks and hacks to boost your productivity.

Slide
Mega Pack Video Bundle
Get The Complete Video Series

Buy big and save bigger, Megapack is the complete premium video content (over 34 hours) at one low price.

Code Better in Delphi Book

Make your Delphi code better by reading this book! You will find numerous tips, tricks, techniques and tools to enhance and improve code. How does your code stack up? Are you writing code that will be usable for years, or are you heading towards a dystopian maintenance apocalypse?

previous arrow
next arrow

Movie #6 - Hiding the form Caption

Here we have a look at one technique for hiding the caption for a form.  I've fixed the sound quality for this one and have some branding - one day I may even look professional.

Click Here to watch on YouTube.

Here is the code that I'm using to show and hide the caption

procedure TForm1.HideCaption;
var
OldStyle : integer;
begin
OldStyle := GetWindowLong(Handle, GWL_STYLE);
if (OldStyle and WS_CAPTION) = WS_CAPTION then
begin
LockWindowUpdate(handle);
SetWindowLong(Handle, GWL_STYLE, OldStyle and not WS_CAPTION);
Height := Height - getSystemMetrics(SM_CYCAPTION) - 2 * getSystemMetrics(SM_CYBORDER);
Width := Width - 2 * getSystemMetrics(SM_CXBORDER);
Top := Top + getSystemMetrics(SM_CYCAPTION) + getSystemMetrics(SM_CYBORDER);
Left := Left + getSystemMetrics(SM_CXBORDER);
LockWindowUpdate(0);
end;
end;

procedure TForm1.ShowCaption;
var
OldStyle : integer;
begin
OldStyle := GetWindowLong(Handle, GWL_STYLE);
if (OldStyle and WS_CAPTION) <> WS_CAPTION then
begin
LockWindowUpdate(Handle);
SetWindowLong(Handle, GWL_STYLE, OldStyle or WS_CAPTION);
Height := Height + GetSystemMetrics(SM_CYCAPTION) + 2 * GetSystemMetrics(SM_CYBORDER);
Width := Width + 2 * GetSystemMetrics(SM_CXBORDER);
Top := Top - getSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYBORDER);
Left := Left - getSystemMetrics(SM_CXBORDER);
LockWindowUpdate(0);
end;
end;