Autor Beitrag
Hagbard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP Home / Pro
D7.1 Architekt
BeitragVerfasst: Mo 03.05.04 14:37 
CLX Projekt unter Delphi 7 Architekt:


Hallo,
Ich setzte verschiedene Panel auf einer Form ein. Diese möchte Ich nun Halb-Transparent machen.
Bis jetzt habe Ich dazu folgenden Code:


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
procedure TTiCidItem.SetTransparency();
  var
    canSShot : TCanvas;
    rectShot : TRect;
    bmpTmpPic: TBitMap;

  begin
    // Transparenz
    canSShot := TCanvas.Create;
    canSShot.Handle := ParCtrl.Canvas.Handle;
    try
      rectShot.Left := iPanelYPos;
      rectShot.Top := iPanelXPos;
      rectShot.Right := iPanelYPos + iPanelWidth;
      rectShot.Bottom := iPanelYPos + iPanelHeight;

      bmpTmpPic := TBitmap.Create;
      bmpTmpPic.Width := iPanelWidth;
      bmpTmpPic.Height := iPanelHeight;

      bmpTmpPic.Canvas.CopyMode := cmSrcCopy;

      bmpTmpPic.Canvas.CopyRect(rectShot, canSShot, rectShot);

    finally
    end;

  end;



Doch bei
ausblenden Delphi-Quelltext
1:
bmpTmpPic.Canvas.CopyRect(rectShot, canSShot, rectShot);					


steigt er aus und sagt mir: Leinwand/Bild erlaubt kein Zeichnen.

Hat jemand vieleicht eine Idee, woran das liegen könnte? Ich bin noch Delphi Anfänger und kann mir da noch nicht so recht helfen :-(

Viele Grüße,
Christian

Moderiert von user profile iconMotzi: Code- durch Delphi-Tags ersetzt.
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: Mo 03.05.04 15:05 
Auf die Schnelle sehe ich kein Grund wieso es nicht gehen sollte. Nur mit den Try Finally gehst du ein wenig sograsam um. Das TBitmap.Create würde ich vor Try setzen, wie die anderen. Dann zwischen Finally und End solltest du die Bitmap und Canvas Objekte wieder freigeben (Free). CopyMode brauchst du in diesem Fall erst mal nicht.

_________________
VORSICHT: Ich behersche seit heute die Fünf-Finger-Handflächen-Herz-Explodier-Schlag-Kampf-Technik >:(