DelphiFAQ Home Search:

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

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

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;

Comments:

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: