Announcement

Collapse
No announcement yet.

transparenter Hintergrund

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • transparenter Hintergrund

    kurze Frage, schnelle Antwort :-)

    Wie kann man den Hintergrund eines Hauptformulars transparent setzen/machen? Also ich will mit canvas in das Formular zeichnen und der Rest soll eben transparent sein. Ich weiss, dass es Anwendungen gibt, die sowas koennen.

  • #2
    SetWindowRgn()

    Comment


    • #3
      Hi<p>Sowas hab ich auch schon lange gesucht <p>Ich poste euch mal meinen bisherigen Quellcode:<pre>procedure TForm1.Button1Click(Sender: TObject);
      var
      MyRgn: HRGN ;
      begin
      MyRgn := CreateRectRgn(100,100,200,200);
      SelectClipRgn(Canvas.Handle,MyRgn);
      SetWindowRgn(Form1.Handle,MyRgn,True);
      DeleteObject(MyRgn);
      end;</pre>Es klappt soweit ja eigentlich ganz gut...das Rechteck 100,100,200,200 wird angezeigt und der Rest des Formulars ist transparent...was ich jetzt dazu wissen wollte, ist, wie ich es schaffe, unregelmäßige Flächen transparent zu setzen. So, dass das Formular dann beispielsweise als Kreis erscheint (oder eine beliebige andere Form hat). Ist das möglich?<p>cu, Sebastian Meßme

      Comment


      • #4
        Dies habe ich dazu gefunden:

        Q: custom shaped forms?

        1. Start a new application.
        2. Override the forms createparams method as shown.
        3. Place your bitmap on the form, and set the transparent property to true.
        4. Place a speed button on the form and write a method to close the application. (Making a round form will result in the little icons in the corner not being visible.
        5. Assign the method shown below to the form's oncreate event.
        Hope this helps.
        --------------------------------------------------------------------------------

        unit Unit1;
        interface
        uses
        Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
        ExtCtrls, Buttons;
        type
        TForm1 = class(TForm)
        Image1: TImage;
        SpeedButton1: TSpeedButton;
        procedure FormCreate(Sender: TObject);
        procedure SpeedButton1Click(Sender: TObject);
        private
        { Private declarations }
        procedure CreateParams(var Params: TCreateParams); override;
        public
        { Public declarations }
        end;
        var
        Form1: TForm1;
        implementation
        procedure TForm1.CreateParams(var Params: TCreateParams);
        begin
        inherited createparams(params);
        {This makes a borderless and captionless form}
        params.style:=params.style or ws_popup xor ws_dlgframe;
        end;
        {$R *.DFM}
        procedure TForm1.FormCreate(Sender: TObject);
        var
        formrgn:hrgn;
        begin
        {makes the form clear}
        form1.brush.style:=bsclear;
        {makes the form round}
        GetWindowRgn(form1.Handle, formRgn);
        DeleteObject(formRgn);
        formrgn:=
        CreateroundRectRgn(0,
        0,form1.width,form1.width,form1.width,form1.width) ;
        SetWindowRgn(form1.Handle, formrgn, TRUE);
        end;
        procedure TForm1.SpeedButton1Click(Sender: TObject);
        begin
        form1.close;
        end;
        end.

        Es geht aber auch noch anders, wenn dies hier oben nicht hilft, schreib noch mal, dann schaue ich auch noch mal nach

        Comment


        • #5
          hi<p>danke - es funktioniert <p>cu, Sebastia

          Comment

          Working...
          X