Link to home
Start Free TrialLog in
Avatar of wolsen
wolsen

asked on

Screen Capture Interface

I would like to build a screen capture interface that will allow the user to select an area of the screen.  I already have the code I need to get the selected area as a bitmap.  I am only asking about how to do an interface for selecting an area of the screen.

My first attempt was to create an always on top form, that had the middle portion transparent.  The user could move the form, and resize it.  The transparent portions of the form showed the part that was to be captured.  This worked, until I minimized the other forms in my program.  This form was also minimized.

I would like the capture interface to be available, even if the main form of the application is minimized.  I would also like to capture interface to appear on top of anything else that may be on the screen.

I would like the interface to be "live", so that the user can capture things on the screen, as they are changing.  capturing a static image of the whole screen, and then selecting a portion of that, is not a viable solution.

I have seen other capture programs that allow you to use the mouse to draw a box on the screen, on top of all windows, by selecting two corners.  Any ideas how this is done? or, do you have any other ideas that may work?
Avatar of Ivanov_G
Ivanov_G
Flag of Bulgaria image

>> "This form was also minimized"
Take a look at my answer here
https://www.experts-exchange.com/questions/21186961/fsstayontop-form-disappears-when-i-click-show-desktop-in-winxp.html

Otherwise, you can use CopyRect method of the Canvas to copy spcific area of the desktop.
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TiborKi
TiborKi

Simple:

procedure GetScreen(var bmp: TBitmap);
var
   dc : integer;
   c  : TCanvas;
   R  : TRect;
begin
   bmp := TBitmap.Create;

   dc := GetWindowDC(Form1.Handle);
   try
      c := TCanvas.Create;
      c.Handle := dc;
      R := Rect(0, 0, Screen.Width, Screen.Height);
      bmp.Width := R.Right;
      bmp.Height := R.Bottom;
      bmp.Canvas.CopyRect(R, c, R);
      c.Handle := 0;
      c.Free;
   finally
      ReleaseDC(Form1.Handle, dc);
   end;


end;

In BMP variable you have image of form1!