Home computickets Make a transparent component TPANEL DELPHI

Make a transparent component TPANEL DELPHI

Author

Date

Category

Are there any properties, or everything needs to be prescribed by code?


Answer 1

The standard TPANEL does not have such a property, so – only with your hands.

or, you can take a ready-made component TJVPanel from the jvcl , which has such a property There is .


Answer 2

unit unit1;
Interface.
Uses.
 Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, Stdctrls, Extctrls, JPEG;
 // Hook for Standard Panel
Type
 TPanel = Class (extctrls.tpanel)
 Protected.
  Procedure Paint; Override;
  Procedure Createparams (Var Params: TCREATEPARAMS); Override;
 end;
Type
 TForm1 = Class (TForm)
  Image1: Timage;
  Panel1: TPanel;
  Button1: Tbutton;
 Private
  {Private Declarations}
 Public
  {Public Declarations}
 end;
var.
 Form1: TForm1;
Implementation
{$ R * .dfm}
 // write a procedure that is responsible for the transparency of the standard panel
Procedure TPANEL.CREATEPARAMS (Var Params: TCREATEPARAMS);
Begin.
 Inherited CreateParams (Params);
 IF NOT (CSDesigning in ComponentState) THEN
  Params.exstyle: = params.exstyle or ws_ex_transparent;
end;
 // Redraw a standard panel
procedure tpanel.paint;
var.
 Xbitmap: TBitmap;
 XOLDDC: HDC;
 XRect: Trect;
Begin.
 If (CSDesigning in ComponentState) THEN
  Inherited Paint
 ELSE.
 Begin.
  XRect: = ClientRect;
  XOLDDC: = canvas.Handle;
  Xbitmap: = tbitmap.create;
  Try.
   Xbitmap.Height: = Height;
   Xbitmap.width: = width;
   Canvas.Handle: = xbitmap.canvas.Handle;
   Inherited Paint;
   REDRAWWINDOW (Parent.Handle, @xRect, 0, RDW_ERASE O RDW_Invalidate or RDW_NOCHILDREN OR RDW_UPDATENOW);
  Finally
   Canvas.Handle: = XOLDDC;
   Canvas.brushcopy (XRect, Xbitmap, Xrect, Color);
   Xbitmap.free;
  end;
 end;
end;
end.

 Enter a description of the image

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions