🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Colour and Font from Handle

#8287
From: Chris
Date: Wed, 10 Nov 2004 08:39
62 lines
3180 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:419142a6$1@newsgroups.borland.com...
>
> For getting the colors, look at GetWindowDC(), GetTextColor(), 
> GetBkColor().
>
> For the font, that is a little more involved.  What kind of font data are
> you looking to retrieve exactly?
>
>

I cannot get this to work.  GetBkColor always returns 0x00ffffff (white) 
regardless of control back colour.  In fairness it does work if provided 
with Canvas->Handle but not if I get the DC via GetDC or GetWindowDC.

    For example:

    //This works
    Label1->Caption = IntToHex((int)GetBkColor(Canvas->Handle),8);

    //These don't
   HDC hDC = 0;
   hDC = GetDC(Handle);
   if (hDC)
      {Label2->Caption = IntToHex((int)GetBkColor(hDC),8);
      ReleaseDC(Handle, hDC);
      }

   hDC = 0;
   hDC = GetWindowDC(Handle);
   if (hDC)
      {Label3->Caption = IntToHex((int)GetBkColor(hDC),8);
      ReleaseDC(Handle, hDC);
      }

As I am working with Windows Edits which don't have a 'Canvas' I am stuck. 
Any ideas.

As regards the font, I would really prefer a LOGFONT as then I get almost 
all of the font's characteristics but I also need the font Colour 
(GetTextColor doesn't seem to work for me for the same reasons as above).  I 
will try Bob's suggestions re GetTextMetrics,GetTextFace and WM_GETFONT 
later today as these may go some way towards what I need.

Of course it may be that I'm going about this wrong, what I'm trying to do 
is add spell checking to an old app, however, I cannot set HideSelection to 
false for the application's textboxes which makes spell checking weird for 
the user (they cannot see the selected word), hence I create a form without 
a border with an edit box on it (again without a border), I size an position 
this exactly over the other app's textbox client area and then copy the text 
over, spell check it and then copy the text back, this works extremely well 
however, some of the other app's text boxes have background colours other 
that white and  different fonts, hence it starts to look a little bit less 
than professional.


Hope someone can help.

Cheers

Chris 
Technical Details
Message-ID: <4191d3da$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <41913a9c$1@newsgroups.borland.com> <419142a6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,329ec276f5c5c9bf
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Chris" <chris@REMOVETHISchrischfmousey.karoo.co.uk>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <41913a9c$1@newsgroups.borland.com> <419142a6$1@newsgroups.borland.com>
Subject: Re: Colour and Font from Handle
Date: Wed, 10 Nov 2004 08:39:52 -0000
Lines: 64
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 213.249.225.107
Message-ID: <4191d3da$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1100075994 213.249.225.107 (10 Nov 2004 00:39:54 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail