DelphiFAQ Home Search:
General :: Windows :: Programming :: Windows with Delphi :: Windows Graphics
Graphics programming under Windows with Delphi.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

TNCCanvas - write on a form's non-client area

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;
 

Generated 16:02:39 on Dec 14, 2017