Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Capture the image behinde my vcl

Posted on 2006-07-17
23
Medium Priority
?
206 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
[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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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 750 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

722 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