Improve company productivity with a Business Account.Sign Up

x
?
Solved

Get picture

Posted on 1998-11-03
9
Medium Priority
?
205 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 200 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Watch the software video of Kernel Import PST to Office 365 tools which can easily import PST and OST files to Office 365 for bulk mailboxes. The process of migration is simple and user can map source and destination mailboxes and easily import data…

607 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