Capturing a Control

Capturing a Control

Post by Pin Ta » Sun, 25 Oct 1998 04:00:00



Is it possible to get a picture of a control and store it as a graphic?
 
 
 

Capturing a Control

Post by Team » Mon, 26 Oct 1998 03:00:00


Quote:>>Is it possible to get a picture of a control and store it as a graphic?

Sure. Just do a screen capture (Alt-Print Screen will work). Start a bitmap
editor and extract the button you want. Now save it to disk. Nothing to it.

--
Kent (TeamB and TurboPower Software)

 
 
 

Capturing a Control

Post by Pin Ta » Mon, 26 Oct 1998 03:00:00


Oops, i should of made my question clearer.  I meant to get a picture of a
specific control like a Button or something while inside the program and be
able to display it on a TImage or save it as a bitmap.

>>>Is it possible to get a picture of a control and store it as a graphic?

>Sure. Just do a screen capture (Alt-Print Screen will work). Start a bitmap
>editor and extract the button you want. Now save it to disk. Nothing to it.

>--
>Kent (TeamB and TurboPower Software)

 
 
 

Capturing a Control

Post by Team » Mon, 26 Oct 1998 03:00:00


Quote:>>I meant to get a picture of a specific control like a Button or something

while inside the program and be able to display it on a TImage or save it as
a bitmap.

Same answer.<g> Here's the quick version:

1. Create a memory bitmap (a TBitmap).

2. Copy the portion of the screen you are interested in to the memory
bitmap's canvas.

3. Copy the memory bitmap to the TImage or...

4. Call TBitmap::SaveToFile() to save the image to disk.

--
Kent (TeamB and TurboPower Software)

 
 
 

Capturing a Control

Post by Robert Dun » Mon, 26 Oct 1998 03:00:00



> >>I meant to get a picture of a specific control like a Button or something
> while inside the program and be able to display it on a TImage or save it as
> a bitmap.

> Same answer.<g> Here's the quick version:

> 1. Create a memory bitmap (a TBitmap).

> 2. Copy the portion of the screen you are interested in to the memory
> bitmap's canvas.

Kent, do you suppose that was the part he was having *trouble* with?

robert

 
 
 

Capturing a Control

Post by Pin Ta » Mon, 26 Oct 1998 03:00:00


Quote:>2. Copy the portion of the screen you are interested in to the memory
>bitmap's canvas.

How do I do this?
 
 
 

Capturing a Control

Post by Jeff Garret » Mon, 26 Oct 1998 03:00:00


If you can't wait for the pro's to answer, I'll go out on a limb...

I think you need to do something like get the device handle for
the screen, and do something with that... Using windows API stuff.

I've never done it, but I think that is where you'd start.

Have you tried looking at all of the web sites ? I'd expect one
of them does stuff directly with the screen. I don't know which
one to suggest. But if you want, you can look at :
http://www.*junkie.com/microsoftsucks  (it's just a temporary
test thing though, but the links at the bottom should help)...


> >2. Copy the portion of the screen you are interested in to the memory
> >bitmap's canvas.

> How do I do this?

 
 
 

Capturing a Control

Post by Team » Tue, 27 Oct 1998 04:00:00


Quote:>>Kent, do you suppose that was the part he was having *trouble* with?

I'm supposed to spoon feed every forum participant? Some people just want a
shove in the right direction. Others want you to write their apps for them.
I don't always have the time to dig up code examples for every question I
read. Do you have a problem with that?

--
Kent (TeamB and TurboPower Software)

 
 
 

Capturing a Control

Post by Team » Tue, 27 Oct 1998 04:00:00


The following is code from "Teach Yourself BCB 3 in 21 Days." It captures an
entire form to memory and saves it to disk. You can modify it to capture a
single control rather than an entire form.

--
Kent (TeamB and TurboPower Software)

void __fastcall TForm1::CaptureBtnClick(TObject *Sender)
{
  // Create a TCanvas object for the desktop DC.
  TCanvas* dtCanvas = new TCanvas;
  dtCanvas->Handle = GetDC(0);

  // Create a new TBitmap object and set its
  // size to the size of the form.
  Graphics::TBitmap*
    bitmap = new Graphics::TBitmap;
  bitmap->Width = Width;
  bitmap->Height = Height;

  // Create a palette from the form's Canvas
  // and assign that palette to the bitmap's
  // Palette property.
  int nColors =
    GetDeviceCaps(Canvas->Handle, SIZEPALETTE);
  LOGPALETTE* logPal = (LOGPALETTE*)new Byte[
     sizeof(LOGPALETTE) + (nColors - 1) *
     sizeof(PALET*TRY)];
  logPal->palVersion  = 0x300;
  logPal->palNumEntries = (Word)nColors;
  GetSystemPalet*tries(Canvas->Handle,
    0, nColors, logPal->palPalEntry);
  bitmap->Palette = CreatePalette(logPal);
  delete[] logPal;

  // Copy a section of the screen from the
  // desktop canvas to the bitmap.
  TRect src = BoundsRect;
  TRect dest = Rect(0, 0, Width, Height);
  bitmap->Canvas->CopyRect(dest, dtCanvas, src);

  // Save it to disk.
  bitmap->SaveToFile("form.bmp");

  // Clean up and go home.
  delete bitmap;
  delete dtCanvas;
  ResultsBtn->Enabled = true;

Quote:}

 
 
 

Capturing a Control

Post by Pin Ta » Tue, 27 Oct 1998 04:00:00


Thanks Kent.  You almost wrote my whole app. :-)
 
 
 

1. Command-line control of capture

Apologies if this is frequently-asked or a really dumb question...

Is there a way of controlling the IndyCam capture utility from a command
line or script?

To be more specific, I'd like to start it up, take a still shot and exit
(or start recording a movie, wait a given time then stop and exit). The
exiting I can do quite happily by killing it from another process but I
can't think of a way to get it to start recording automatically.

Alternatively, is there a replacement utility available that will let me
do this?

If it makes any difference I'm using basic-setup Indy workstations.

Thanks,

--
Andrew Clegg    0402 649008    http://www.warpfive.demon.co.uk/

"Satan! Satan! Satan! Satan! Satan! Satan! Satan! Satan!" - Orbital

2. 3dClipping

3. Looking for library in C\C++ for control video capture card

4. accessing 3ds from a remote access

5. Video Capture Control - Beta

6. None

7. API or ActiveX Control To Do Screen Capture

8. help: 3D facial model source code in C

9. Video capture ? (need sample code or control)

10. capturing picture box with controls

11. Device Control - Capture Plug in - Template manager

12. How to initiate control of dv camera at capture with MSP 6

13. Capture accelerators in control, how?