transparency - Delphi + Transparent forms with parent -
I want to create a form, but use it to keep an image (like a splash form)
I use these lines to create a form like this:
SetWindowLong (handle, GWL_EXSTYLE, LexStyle or WS_EX_LAYERED); UpdateLand window (handle, 0, zero, @litmap size, LBITMAP, sheeting handles, 0, @lb.l.andf Function, ULWALAPAAA);
This image is a PNG image with a transparent layer.
The form should be in the form of a parent or should be treated as a form.
The problem is, if I add some component to this form, it does not show only the component. And if I make a parent for it, its transparency is lost.
But I need to add components to this and I need to set up parents in the form
Do some people know in other ways to do this?
You can try not to set parent property directly, but using subclass ...
Assume that TParentForm is the parent form and is form with TAlphaForm image.
When creating a TAlphaForm example, pass the example of TParentForm as the owner parameter and make changes in the manufacturer as a WndProc master.
The next example is code for TAlphaForm:
type TAlphaForm = class (TForm) Private FParentWndProc: TWndMethod; FParentForm: TCustomForm; Process hookwindow (Y Message: TMessage); Build a Public Builder (AOwner: TComponent); Override; Destruction of Destruction; Override; End;
Implementation:
Constructor TAlphaForm.Create (AOwner: TComponent); inherited from; If (Assigned) and (Owner is TCustomForm) then start FParentForm: = TCustomForm (Owner); // subclass owner window FParentWndProc: = FParentForm.WindowProc; FParentForm.WindowProc: = HookWindowProc; // want to re-color to show the initial picture, if (phaphorform.handleallocated) then Fetchform.avendet; Finally start FParentForm: = Zero; FParentWndProc: = Zero; End; End; Destructor TALF. Destor; If (the platform format) starts / restore the original WndProc and republish to restore the original form if available FParentForm.WindowProc: = FParentWindProc; If (FParentForm.HandleAllocated) then FParentForm.Invalidate; FParentForm: = Zero; FParentWndProc: = Zero; End; inherited from; End; Process TAlphaForm.HookWindowProc (var Message: TMessage); Start (No (assigned formforms) and assigned (FPRNPDC))) then exit; FParentWndProc (message); If resume (Message.Msg = WM_PAINT) // Paint Alpha image is // sample painting on Canvas as owner here FParentForm.Canvas.Pen.Width: = 3; FParentForm.Canvas.Pen.Color: = clRed; FParentForm.Canvas.Ellipse (FParentForm.ClientRect); Finish the second (Message.Msg = WM_SIZE) then start / must be repainted because the whole form FParentForm.Invalidate; End; End;
The solution for me works with this basic form code:
type TForm1 = class (TForm) Button2: TButton; Button 3: Teaboton; Process Button2Click (Sender: Tubect); Process button 3 click (sender: twitch); Private {Private Announcements} FAlpha: TForm; Create Public {Public Announcement} Constructor (AOwner: TComponent); Override; End;
Implementation:
Process TForm1.Button2lick (Sender: Tubect); So start (not assigned (FAlpha)) then FAlpha: = TAlphaForm.Create (Self); End; Process TForm1.Button3Click (Sender: Toबेस); Free and Neal (FAlpha); End; Manufacturer TForm1.Create (AOwner: TComponent); inherited from; FAlpha: = Zero; End;
Comments
Post a Comment