Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Capture the image behinde my vcl

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
ginsonic
Asked:
ginsonic
  • 9
  • 8
  • 6
1 Solution
 
kfoster11CEOCommented:
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
 
kfoster11CEOCommented:
sry,  so if you paint the parent then invalidate the controls they will each repaint themselves on the new background.  
0
 
ginsonicAuthor Commented:
????
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!

 
kfoster11CEOCommented:
???? - explain what you are trying to do.
0
 
kfoster11CEOCommented:
better yet, just set your controls visible to false, capture everything, then set it to visible
0
 
ginsonicAuthor Commented:
I just say in my question that I don't want to do this.
0
 
ginsonicAuthor Commented:
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
 
kfoster11CEOCommented:
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
 
ginsonicAuthor Commented:
My code can copy the region without my vcl, but unfortunatelly without any other controls. Snap just labels or images.
0
 
kfoster11CEOCommented:
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
 
kfoster11CEOCommented:
also, in order to get the screen coordinates of your control use the control.clienttoscreen function.

hope this helps
0
 
ginsonicAuthor Commented:
How to copy the controls under my vcl ?
0
 
Eddie ShipmanAll-around developerCommented:
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
 
kfoster11CEOCommented:
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
 
ginsonicAuthor Commented:
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
 
Eddie ShipmanAll-around developerCommented:
Is it kind of like a hotspot type control? Maybe you should inherit from tgaphiccontrol instead of tcontrol?
0
 
ginsonicAuthor Commented:
Nope. I need some properties and events from TControl.
0
 
ginsonicAuthor Commented:
Think at my vcl as a semi-transparent panel.
0
 
Eddie ShipmanAll-around developerCommented:
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
 
Eddie ShipmanAll-around developerCommented:
Panel1 is the base that includes a button and edit and panel2 covers the button and edit.
0
 
Eddie ShipmanAll-around developerCommented:
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
 
ginsonicAuthor Commented:
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
 
Eddie ShipmanAll-around developerCommented:
Did you try my simple example?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 9
  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now