Article View: borland.public.cppbuilder.nativeapi
Article #9877GetTextExtentPoint32
From: JD
Date: Fri, 11 Jun 2004 22:05
Date: Fri, 11 Jun 2004 22:05
40 lines
2419 bytes
2419 bytes
I'm trying to use GetTextExtentPoint32 to determine if I want to
manipulate a string before putting it to the window. The problem
is that it's giving me an incorrect result.
I have the hWnd to the BrowseForFolder dialog and using either
GetWindowDC or GetDC I get the same result. I've been able to
determine that GetTextExtentPoint32 is giving me the width if
it were the dialog caption - not text in the client area.
To prevent another icon in the task bar, I've assigned the
calling form as the owner so since the form was available, I
tried using GetTextExtentPoint32 with it's canvas and received
the correct result!!
Is there something additional that I need to include to get to
the client area of the dialog?
if( uMsg == BFFM_SELCHANGED )
{
TSize S;
char Path[ MAX_PATH + 1 ] = { 0 };
if( ::SHGetPathFromIDList((LPITEMIDLIST)lParam, Path) )
{
if( ::GetTextExtentPoint32( pForm->Canvas->Handle, PChar(Path), strlen(Path), &S) )
ShowMessage("Using the Form's Canvas handle - width is : " + IntToStr(S.cx) );
HDC hDC = ::GetWindowDC( hWnd );
if( ::GetTextExtentPoint32( hDC, PChar(Path), strlen(Path), &S) )
ShowMessage("Using the dialog WindowDC the width is : " + IntToStr(S.cx) );
::ReleaseDC( hWnd, hDC );
hDC = ::GetDC( hWnd );
if( ::GetTextExtentPoint32( hDC, PChar(Path), strlen(Path), &S) )
ShowMessage("Using the dialog hDC the width is : " + IntToStr(S.cx) );
::ReleaseDC( hWnd, hDC );
}
}
~ JD
Technical Details
Message-ID:
<40ca2cbe$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,e169022c7b789c9d,start X-Google-Attributes: gid10cc67,public From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: GetTextExtentPoint32 Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 172.137.19.47 NNTP-Posting-Host: 207.105.83.66 Message-ID: <40ca2cbe$1@newsgroups.borland.com> Date: 11 Jun 2004 15:05:50 -0700 X-Trace: newsgroups.borland.com 1086991550 207.105.83.66 (11 Jun 2004 15:05:50 -0700) Lines: 41 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail