Solved

Capture the image behinde my vcl

Posted on 2006-07-17
23
197 Views
Last Modified: 2010-04-04
I use next code to snap the form behind my vcl :

    i := SaveDC(DC);
    p := GetScreenClient( Self );
    p.x := -p.x;
    p.y := -p.y;
    MoveWindowOrg( DC, p.x, p.y );
    SendMessage( Parent.Handle, WM_ERASEBKGND, DC, 0 );
    SendMessage( Parent.Handle, WM_PAINT, DC, 0 );
   
    BitBlt( Temp.Canvas.Handle, 0, 0, Width, Height, DC, Left, Top, SRCCOPY );
    RestoreDC( DC, i );
    ReleaseDC( Handle, DC );

My problem is that I can snap just the form or images but no controls like grids, editboxes or buttons.

How can I get an image of all vcls behind my vcl ? I don't wish to move my vcl, snap the desktop and then put my vcl back.

I need a code that can render the background directly.

Thanks in advance!
0
Comment
Question by:ginsonic
  • 9
  • 8
  • 6
23 Comments
 
LVL 7

Expert Comment

by:kfoster11
ID: 17122954
are you setting the background for the parent of your control?  if so you should be able to tell your control to invalidate and it will repaint itself.
0
 
LVL 7

Expert Comment

by:kfoster11
ID: 17122959
sry,  so if you paint the parent then invalidate the controls they will each repaint themselves on the new background.  
0
 
LVL 9

Author Comment

by:ginsonic
ID: 17123027
????
0
 
LVL 7

Expert Comment

by:kfoster11
ID: 17123048
???? - explain what you are trying to do.
0
 
LVL 7

Expert Comment

by:kfoster11
ID: 17123060
better yet, just set your controls visible to false, capture everything, then set it to visible
0
 
LVL 9

Author Comment

by:ginsonic
ID: 17123164
I just say in my question that I don't want to do this.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 17123174
think that you have a panel and wish to see what is behind. I wish to snap the form area covered by my vcl.
0
 
LVL 7

Expert Comment

by:kfoster11
ID: 17123458
The problem is that you are copying a region.  If your control is visilbe in the region then you are going to get the control in the bitmap.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 17127670
My code can copy the region without my vcl, but unfortunatelly without any other controls. Snap just labels or images.
0
 
LVL 7

Expert Comment

by:kfoster11
ID: 17127719
so, if you can copy the region with no controls into bitmap1, then copy all controls into bitmap 2, then copy the region from 1 where your control is into bitmap2 to overlay where your control is.  I haven't done any bitmap work in awhile but that should be the gist of it.
0
 
LVL 7

Expert Comment

by:kfoster11
ID: 17127724
also, in order to get the screen coordinates of your control use the control.clienttoscreen function.

hope this helps
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Author Comment

by:ginsonic
ID: 17131376
How to copy the controls under my vcl ?
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17146063
If you want to capture the full window, usestill are not clear in what you want to capture.
First, you say that you want to capture the "image" UNDER your vcl, then you say you want
to capture  labels, buttons, etc.

Explain better what you want, maybe describe to us the form and what the result should look like.
0
 
LVL 7

Expert Comment

by:kfoster11
ID: 17146403
so you have a panel with a lot of controls on it.  maybe a background bitmap.  ???Your control is also on this panel???  You want to capture the entire contents of the panel except your control.  Is this correct?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 17154271
My VCL can be a simple TCustomControl. Can have 300 pixels width and 300 pixels height. Behind this vcl I can have an image, two buttons, two labels and a part from a DBGrid. All are for example. I need a code that will snap the form area under my vcl (as will look if my vcl will not be there). I intend to use this image and to blend with my vcl image to simulate as my vcl is semi-transparent.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17155254
Is it kind of like a hotspot type control? Maybe you should inherit from tgaphiccontrol instead of tcontrol?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 17155875
Nope. I need some properties and events from TControl.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 17155883
Think at my vcl as a semi-transparent panel.
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 250 total points
ID: 17156690
Well, you are not going to be able to get what's BEHIND your panel unless you hide it first.
Windows does not paint in "Layers" and windows that cover another window occupy the
combined space in the graphic area.

Saying that, did you try the PaintTo function of the control that hosts your panel?
You may have to hide it before the call.

  LockWindowUpdate(Panel1.Handle);
  Panel2.Hide;
  Panel1.PaintTo(Image1.Canvas, 0, 0);
  Panel2.Show;
  LockWindowUpdate(0);
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17156695
Panel1 is the base that includes a button and edit and panel2 covers the button and edit.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17156696
here's the DFM:

object Form1: TForm1
  Left = 282
  Top = 62
  Width = 696
  Height = 582
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Image1: TImage
    Left = 301
    Top = 309
    Width = 305
    Height = 212
  end
  object Panel1: TPanel
    Left = 8
    Top = 15
    Width = 305
    Height = 212
    Caption = 'Panel1'
    TabOrder = 0
    object Button1: TButton
      Left = 87
      Top = 74
      Width = 75
      Height = 25
      Caption = 'Button1'
      TabOrder = 0
    end
    object Edit1: TEdit
      Left = 138
      Top = 111
      Width = 121
      Height = 21
      TabOrder = 1
      Text = 'Edit1'
    end
    object Panel2: TPanel
      Left = 38
      Top = 46
      Width = 230
      Height = 104
      Caption = 'Panel2'
      TabOrder = 2
    end
  end
  object Button2: TButton
    Left = 402
    Top = 59
    Width = 75
    Height = 25
    Caption = 'Button2'
    TabOrder = 1
    OnClick = Button2Click
  end
end
0
 
LVL 9

Author Comment

by:ginsonic
ID: 17159200
I found a better way. Snap the background image without TWinControls, then detect all controls from my area and then paint each one in my snaped image.

But have a problem when my vcl have parent another control and not my form.

The code work perfect except this part :(
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 17160643
Did you try my simple example?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

14 Experts available now in Live!

Get 1:1 Help Now