🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Getting text from an external Grid

#2417
From: Dan
Date: Thu, 01 Mar 2007 20:42
33 lines
2716 bytes
> Which HWND are you passing to GetWindowDC()?  The main window or the
> grid's window?  Since you are only intereste in the grid, you should
> be using its HWND for everything.
> 

I'm using the HWND for the grid.
In my 'CopyObject' routine that graphically copies the HWND I want (or 
the grid), I am doing the following:

   HANDLE HandleToTheGrid = HANDLE(HexIdOfGrid);
   if (HandleToTheGrid==NULL) return;
   HDC DCToTheGrid= GetWindowDC(HandleToTheGrid);

   //this displays the app that has the Grid
   ShowWindow(TheHandleToTheApp,SW_SHOWNORMAL);

   int w = GetDeviceCaps(DCToTheGrid, HORZRES);
   int h = GetDeviceCaps(DCToTheGrid, VERTRES);

   //then, basically I can fill a TImage, pixel by pixel.. (whoohoo)
   Unfortunetly, w and h are always the same, and equal to the 
application.  However, interestingly, the image of the grid, does start 
at pixel 0,0 and correctly corresponds to the grid I want and doesn't 
include any other GUI items.  So rather than calling GetDeviceCaps, 
right now, I am simply hardcoding worst cases; which results in 
extraordinarily slow code obviously.

To get pixels, I am looping from 0 to height within a 0 to width loop 
where I get the color of the pixel with GetPixel(DCToTheGrid,x,y); and 
then paint it to a TImage using ImageClassPointer->Canvas->Pixels[x][y] 
= c;

Better ways are welcome.
Technical Details
Message-ID: <45e73ae4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!208.48.142.85!newsfeed.news2me.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <45e59a3a$1@newsgroups.borland.com> <45e5bb7e$1@newsgroups.borland.com> <45e5cfa5$1@newsgroups.borland.com> <45e5f6d3@newsgroups.borland.com> <45e5fd07$1@newsgroups.borland.com> <45e60f88$1@newsgroups.borland.com> <45e6f2f0$1@newsgroups.borland.com> <lnvdu29ua6a88fpbfof4eu9pb4d7t42pm4@4ax.com> <45e72444$1@newsgroups.borland.com> <45e733b3$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,3d58209a1f02789a
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 01 Mar 2007 14:42:09 -0600
From: Dan <Dan@do.not.spam>
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Getting text from an external Grid
References: <45e59a3a$1@newsgroups.borland.com> <45e5bb7e$1@newsgroups.borland.com> <45e5cfa5$1@newsgroups.borland.com> <45e5f6d3@newsgroups.borland.com> <45e5fd07$1@newsgroups.borland.com> <45e60f88$1@newsgroups.borland.com> <45e6f2f0$1@newsgroups.borland.com> <lnvdu29ua6a88fpbfof4eu9pb4d7t42pm4@4ax.com> <45e72444$1@newsgroups.borland.com> <45e733b3$1@newsgroups.borland.com>
In-Reply-To: <45e733b3$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 216.174.165.174
Message-ID: <45e73ae4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1172781796 216.174.165.174 (1 Mar 2007 12:43:16 -0800)
Lines: 37
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!208.48.142.85!newsfeed.news2me.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail