Announcement

Collapse
No announcement yet.

Forms verformen?

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

  • Forms verformen?

    Wie kann ich Formulare beliebig verformen?(Beispiel Kreis ... oder wie bei ANNO 1602 das Anfangsbild!) Oder Wie kann ich mansche Bereiche mit Teils bild und Teils Durschsichtig gestallten?

  • #2
    Hi

    Schau mal hier bei "Bitmaps als Formular" :-)

    Gruß Hage

    Comment


    • #3
      Hääh ?
      Hagen, kannste das mal bitte genauer erklären !?!
      Danke )
      Grüße
      Zuletzt editiert von Gast_1; 31.03.2010, 13:29.

      Comment


      • #4
        Hi

        <pre>

        function PictureToRGN(Picture: TPicture): hRgn;
        var
        B: TBitmap;
        C: Byte;
        R: hRgn;
        P: PByte;
        S,E,Y: Integer;
        begin
        B := TBitmap.Create;
        try
        B.HandleType := bmDIB;
        B.PixelFormat := pf24Bit;
        B.Width := Picture.Width;
        B.Height := Picture.Height;
        B.Canvas.Draw(0, 0, Picture.Graphic);
        B.Mask(B.TransparentColor);
        B.PixelFormat := pf8Bit;
        C := PByte(B.Scanline[0])^;
        Result := CreateRectRgn(0, 0, B.Width, B.Height);
        for Y := B.Height-1 downto 0 do
        begin
        P := B.ScanLine[Y];
        S := 0;
        E := 0;
        repeat
        while (P^ = C) and (E < B.Width) do
        begin
        Inc(P);
        Inc(E);
        end;
        R := CreateRectRgn(S, Y, E, Y+1);
        try
        CombineRgn(Result, Result, R, RGN_DIFF);
        finally
        DeleteObject(R);
        end;
        while (P^ <> C) and (E < B.Width) do
        begin
        Inc(P);
        Inc(E);
        end;
        S := E;
        until E >= B.Width;
        if S <> E then
        begin
        R := CreateRectRgn(S, Y, E, Y+1);
        try
        CombineRgn(Result, Result, R, RGN_DIFF);
        finally
        DeleteObject(R);
        end;
        end;
        end;
        finally
        B.Free;
        end;
        end;

        procedure TForm1.FormCreate(Sender: TObject);
        begin
        SetWindowRgn(Handle, PictureToRGN(Image1.Picture), false);
        end;

        </pre>

        Erstelle ein neues Form, BorderStyle := bsSingle, BorderIcons := [];
        Füge eine TImage Komponente ein, "Image1", Image1.Align := alClient;
        Nun irgendeine Grafik in Image1.Picture, beachte das der linksunten liegende Pixel der Grafik als Hintergrundfarbe genommen wird. Die farbe dieses Pixels bestimmt also den durchsichtigen Bereich des Forms.

        Gruß Hage

        Comment

        Working...
        X