Recent

Author Topic: [Solved]example/canvas_test/shapedwindow doesn't take effect  (Read 686 times)

PeterHu

  • Jr. Member
  • **
  • Posts: 60
[Solved]example/canvas_test/shapedwindow doesn't take effect
« on: August 12, 2025, 05:30:26 am »
lazarus/examples/canvas_test/canvastest.lpi,shapedwindowtest form:I guess from the source code this unit will generate a borderless,red circle window with a close button inside it.But--

a). Lazarus 4.0+fpc 3.2.2 Version May 5,2025 under my machine win10 64 bit,it doese not take effect.Just generate a borderless,red rectangle window with a close button inside.
b). But rather,the commented code will do take effect.

Any tips please?

Code: Pascal  [Select][+][-]
  1. unit shapedwindowtest;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  9.   StdCtrls, LCLIntf, LCLType;
  10.  
  11. type
  12.  
  13.   { TfrmShapedWindow }
  14.  
  15.   TfrmShapedWindow = class(TForm)
  16.     btnClose: TButton;
  17.     procedure btnCloseClick(Sender: TObject);
  18.        
  19.     procedure FormShow(Sender: TObject);
  20.   private
  21.  
  22.   public
  23.  
  24.   end;
  25.  
  26. var
  27.   frmShapedWindow: TfrmShapedWindow;
  28.  
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TfrmShapedWindow }
  34.  
  35. procedure TfrmShapedWindow.FormShow(Sender: TObject);
  36. {var
  37.   Rgn: HRGN;
  38. begin
  39.   Rgn := LCLIntf.CreateEllipticRgn(0, 0, 200, 200);
  40.   LCLIntf.SetWindowRgn(Handle, Rgn, False);
  41.   LCLIntf.DeleteObject(Rgn);}
  42. var
  43.   Shape: TBitmap;
  44. begin
  45.   Shape := TBitmap.Create;
  46.   try
  47.     Shape.Width := 200;
  48.     Shape.Height := 200;
  49.     Shape.Canvas.Ellipse(0, 0, 200, 200);
  50.     SetShape(Shape);
  51.   finally
  52.     Shape.Free;
  53.   end;
  54. end;
  55.  
  56. procedure TfrmShapedWindow.btnCloseClick(Sender: TObject);
  57. begin
  58.   Close;
  59. end;
  60.  
  61. end.
  62.  
  63.  
  64.  
  65.  
« Last Edit: August 12, 2025, 02:30:29 pm by PeterHu »

bytebites

  • Hero Member
  • *****
  • Posts: 756
Re: example/canvas_test/shapedwindow doesn't take effect
« Reply #1 on: August 12, 2025, 09:10:59 am »
Does it help if you add     Shape.Monochrome := True;

Code: Pascal  [Select][+][-]
  1.   try
  2.     {$IFDEF LCLGtk2}
  3.     Shape.Monochrome := True;
  4.     {$ENDIF}
  5.     Shape.Width := Width;
  6.     Shape.Height := Height;
  7.     Shape.Canvas.Ellipse(0, 0, Width, Height);
  8.     SetShape(Shape);
  9.   finally
  10.     Shape.Free;
  11.   end;  

wp

  • Hero Member
  • *****
  • Posts: 13219
Re: example/canvas_test/shapedwindow doesn't take effect
« Reply #2 on: August 12, 2025, 10:25:08 am »
Strange, cannot confirm using the same settings Laz 4.0/fpc 3.2.2 / 64bit, except for Windows which is Win-11 here: just seeing the red circular form with the Close button in it, no matter whether the regular or the HRGN code is active.

PeterHu

  • Jr. Member
  • **
  • Posts: 60
Re: example/canvas_test/shapedwindow doesn't take effect
« Reply #3 on: August 12, 2025, 02:30:06 pm »
Thanks for all the helps!

I upgrade Laz from 4.0 to 4.2 then the issue disappeared,together fixed a couple of other issues such as failed to install brookpascal/brookframework etc in 4.0.

 

TinyPortal © 2005-2018