Solved

Get picture

Posted on 1998-11-03
9
201 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now