Solved

Get picture

Posted on 1998-11-03
9
203 Views
Last Modified: 2010-04-06
I put TImage (alClient) in form and I put TPanel in front of TImage.
How to get picture the behind of TPanel and next painted in TPanel.
(I don't want using TLabel !)

Regards,
Joely
0
Comment
Question by:joely
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1345521
YOu mean you want to paint the same picture that is in TImage and pasted(paint) it onto TPanel?? If that's what you want I think I got an idea, but I'm not exactly sure if it works...

Cheers,
Viktor
0
 

Author Comment

by:joely
ID: 1345522
Yes, I want to paint the same picture.
Just picture behind of TPanel.
(Align of TPanel not alClient like TImage !!!).
0
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1345523
Well, here is what I had in mind...

procedure TForm1.Button1Click(Sender: TObject);
var
  DC : hDC;
begin
  DC := GetDC(Panel1.Handle);
  BitBlt(DC, 2, 2, Panel1.Width-4, Panel1.Height-4, Image1.Canvas.Handle, 0, 0, SRCCOPY);
  ReleaseDC(Panel1.Handle, DC);
end;

Hope this helps...

Cheers,
Viktor
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:joely
ID: 1345524
Hello Vik

If I put TLabel in TPanel so this component not visible. Why ?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345525
Because what happens in the procedure above is that I get the DC(Device Context) of the TImage and copy that to the DC of the TPanel. What happens is that if you have any graphical controls like TLabel(It's a graphical control) it will not bee seen since the DC is the painting that you see on the Control...

You can try MyLabel.Refresh; or MyLabel.Update; after you do the procedure I gave you above, so you can allow the Label to be painted again... try it out and tell me what happens...

Cheers,
Viktor
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345526
You could even try MyLabel.Invalidate; and see if it works...
0
 

Author Comment

by:joely
ID: 1345527
Hello Vik

I found another problem.

This is Semi Transparent Label component.
Put this component in front of TImage and you'll know what I meant about Semi Tranparent Label.

Try to put this component in TPanel and use procedure that you gave me.
You'll find out that this component isn't working as it should be.

Please install this component.

unit STLabel;

interface

uses
  Windows, Classes, StdCtrls, Controls, Graphics;

type
  TEffect = (teBlackness,teDSTInvert,teMergeCopy,teMergePaint,teNotSRCCopy,
            teNotSRCErase,tePATCopy,tePATInvert,tePATPaint,teSRCAnd,teSRCCopy,
            teSRCErase,teSRCInvert,teSRCPaint,teWhiteness);

  TSemiTransparentLabel = class(TGraphicControl)
  private
    FEffect: TEffect;

    procedure SetEffect(Value:TEffect);
  protected
    procedure Paint; Override;
  public
    constructor Create(AOwner:TComponent); override;
  published
    property Color;
    property Effect:TEffect read FEffect write SetEffect;
  end;

procedure Register;

implementation

const
  Effects : array[TEffect] of Integer = (BLACKNESS,DSTINVERT,MERGECOPY,
            MERGEPAINT,NOTSRCCOPY,NOTSRCERASE,PATCOPY,PATINVERT,PATPAINT,SRCAND,
            SRCCOPY,SRCERASE,SRCINVERT,SRCPAINT,WHITENESS);

constructor TSemiTransparentLabel.Create(AOwner:TComponent);
begin
  inherited Create(AOwner);
  SetBounds(0,0,100,25);
  Color := clRed;
  FEffect := teSRCAnd;
end;

procedure TSemiTransparentLabel.Paint;
var Bmp1:TBitmap;
begin
  Bmp1:=TBitmap.Create;
  Bmp1.Width:=Width;
  Bmp1.Height:=Height;
  Bmp1.Canvas.Brush.Style:=bsSolid;
  Bmp1.Canvas.Brush.Color:=Color;
  Bmp1.Canvas.FillRect(Rect(0,0,Width,Height));
  BitBLT(Bmp1.Canvas.Handle,0,0,Width,Height,Canvas.Handle,0,0,Effects[FEffect]);
  Canvas.Draw(0,0,Bmp1);
  Bmp1.Free;
//  inherited;
end;

procedure TSemiTransparentLabel.SetEffect(Value:TEffect);
begin
  if FEffect<>Value then
  begin
    FEffect := Value;
    Invalidate;
  end;
end;

procedure Register;
begin
  RegisterComponents('Samples', [TSemiTransparentLabel]);
end;

end.
0
 

Author Comment

by:joely
ID: 1345528
Hello Vik

I have the answer.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345529
Hello Joely!

Sorry I didn't reply, but I've been very busy with school lately and I really don't have time for working with Delphi that much.. Also I've been studying C/C++ and some Assembler so that eats uo all of my spare time...

Regards,
Viktor Ivanov
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question