Examples Delphi

This canvas gives you access to a form's none-client (NC) area
and can be used to create a window with a personal frame style:

TNCCanvas = class(TCanvas)
private
FDeviceContext: HDC;
FWindowHandle : HWnd;
function GetWindowRect: TRect;
protected
procedure CreateHandle; override;
procedure FreeHandle;
public
constructor Create(aWindow: hWnd);
destructor Destroy; override;
property WindowRect: TRect read GetWindowRect;
end;
{ TNCCanvas - Object }
constructor TNCCanvas.Create(aWindow: hWnd);
begin
inherited Create;
FWindowHandle:=aWindow;
end;
destructor TNCCanvas.Destroy;
begin
FreeHandle;
inherited Destroy;
end;
procedure TNCCanvas.CreateHandle;
begin
if FWindowHandle=0 then inherited CreateHandle else
begin
if FDeviceContext = 0 then
FDeviceContext := GetWindowDC(FWindowHandle);
Handle := FDeviceContext;
end;
end;
procedure TNCCanvas.FreeHandle;
begin
Handle := 0;
if FDeviceContext <> 0 then
begin
ReleaseDC(FWindowHandle, FDeviceContext);
FDeviceContext:=0;
end;
end;
function TNCCanvas.GetWindowRect:TRect;
begin
winProcs.GetWindowRect(FWindowHandle,Result);
With Result do
begin
Right:=Pred(Right-Left);
Bottom:=Pred(Bottom-Top);
Left:=0; Top:=0;
end;
end;