🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14927

GetDC Function

#14927
From: Dennis
Date: Sun, 27 Jul 2003 23:35
34 lines
1865 bytes
Hello,

I am trying to execute the following code to get an image of my current
desktop, actually it compiles ok, but no image is being displayed, and the
result file is 0 bytes and it contains Nothing....
I need help to know what I am doing wrong here...thanks

 try
 {
  if(SaveDialog1->Execute()==true)
 {
   HDC dc = GetDC(0);
   Graphics::TCanvas *ScreenCanvas = new Graphics::TCanvas;
   ScreenCanvas->Handle = dc;

   TJPEGImage *JP1 = new TJPEGImage();
   Graphics::TBitmap *BTMAP1 = new Graphics::TBitmap;

   TRect rect = Rect(0,0,Screen->Width, Screen->Height);
   BTMAP1->Canvas->CopyRect(rect, ScreenCanvas, rect);
   Image1->Picture->Bitmap->Canvas->CopyRect(rect, ScreenCanvas, rect);
   JP1->Assign(BTMAP1);
   JP1->SaveToFile(SaveDialog1->FileName);

   // cleanup
   delete ScreenCanvas;
   delete JP1;
   delete BTMAP1;
   ReleaseDC(NULL,dc);
  }
 }
 catch(...)
 {
 }
Technical Details
Message-ID: <3f2461b8@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,da7ae4b16663c3b1,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-27 16:39:21 PST
From: "Dennis" <mikedennis@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: GetDC Function
Date: Sun, 27 Jul 2003 15:35:20 -0800
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 212.103.167.4
Message-ID: <3f2461b8@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059348920 212.103.167.4 (27 Jul 2003 16:35:20 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail