Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 4 Sep 2008 06:29:01 -0700 (PDT),    group: microsoft.public.win32.programmer.ui        back       


DrawTextW with DT_CALCRECT returning zero width   
I'm trying to use DrawTextW with the DT_CALCRECT flag to find the
width and height of a Unicode string.  Everything works correctly if
the string contains only 'latin' characters (MS byte = 0) but as soon
as I include one or more Arabic or Cyrillic characters DrawTextW is
returning a width of *zero* for the entire string (the height is
correct, however).  The font selected into the DC definitely has the
required characters; I've tried both Arial and Tahoma.

For example if the string is 0x0028 0x002A 0x0029 DrawTextW returns a
height of 58 and a width of 62.  If I change the string to 0x0028
0x062A 0x0029 (the second character being Arabic Teh) DrawTextW
returns a height of 58 but a width of zero.

If I remove the DT_CALCRECT flag the correct characters are drawn,
proving that the selected font has them.

Any idea why this is happening (with Windows XP SP2, if it matters) ?

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
date: Thu, 4 Sep 2008 06:29:01 -0700 (PDT)   author:   unknown

Re: DrawTextW with DT_CALCRECT returning zero width   
[XPPro SP2] Your example gives me rect of 22 width and 16 height. Cyrillic letters also works fine. Double-check your invocations...

 hath wrote: news:e117d366-b11a-4e60-9b15-014cca888552@q26g2000prq.googlegroups.com...
> I'm trying to use DrawTextW with the DT_CALCRECT flag to find the
> width and height of a Unicode string.  Everything works correctly if
> the string contains only 'latin' characters (MS byte = 0) but as soon
> as I include one or more Arabic or Cyrillic characters DrawTextW is
> returning a width of *zero* for the entire string (the height is
> correct, however).  The font selected into the DC definitely has the
> required characters; I've tried both Arial and Tahoma.
> 
> For example if the string is 0x0028 0x002A 0x0029 DrawTextW returns a
> height of 58 and a width of 62.  If I change the string to 0x0028
> 0x062A 0x0029 (the second character being Arabic Teh) DrawTextW
> returns a height of 58 but a width of zero.
> 
> If I remove the DT_CALCRECT flag the correct characters are drawn,
> proving that the selected font has them.
> 
> Any idea why this is happening (with Windows XP SP2, if it matters) ?
> 
> Richard.
> http://www.rtrussell.co.uk/
> To reply by email change 'news' to my forename.
date: Fri, 5 Sep 2008 02:24:33 +0700   author:   st ldomain

Re: DrawTextW with DT_CALCRECT returning zero width   
On Sep 4, 8:24 pm, "st" <s...@sandy.localdomain> wrote:
> [XPPro SP2] Your example gives me rect of 22 width and 16 height.
> Cyrillic letters also works fine. Double-check your invocations...

It's hard to understand what I could be doing wrong, given that I am
simply changing one character in a Unicode (wide) string and making no
other changes at all.  The language I am using - BBC BASIC - also
isolates me from some of the possible errors I might make in a lower-
level language like C.  It does mean I am making the DrawTextW call
from a thread without a message pump, but I'm not aware of that being
an issue, especially not one that could affect only certain Unicode
characters.

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
date: Thu, 4 Sep 2008 14:24:42 -0700 (PDT)   author:   unknown

Re: DrawTextW with DT_CALCRECT returning zero width   
Also note that DrawTextW returns only string *height*. Function adjusts width and height rectangle which you passed in it _by reference_. Also check your compiler documentation about formatting wide strings (if you specify it as literal) and data type if you use WCHAR array.

 hath written: news:e791e04f-9f80-4ef2-a168-f501f7d7d22b@a18g2000pra.googlegroups.com...
On Sep 4, 8:24 pm, "st" <s...@sandy.localdomain> wrote:
> [XPPro SP2] Your example gives me rect of 22 width and 16 height.
> Cyrillic letters also works fine. Double-check your invocations...

It's hard to understand what I could be doing wrong, given that I am
simply changing one character in a Unicode (wide) string and making no
other changes at all.  The language I am using - BBC BASIC - also
isolates me from some of the possible errors I might make in a lower-
level language like C.  It does mean I am making the DrawTextW call
from a thread without a message pump, but I'm not aware of that being
an issue, especially not one that could affect only certain Unicode
characters.

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
date: Fri, 5 Sep 2008 13:00:29 +0700   author:   st ldomain

Re: DrawTextW with DT_CALCRECT returning zero width   
On Sep 5, 7:00 am, "st" <s...@sandy.localdomain> wrote:
> Also note that DrawTextW returns only string *height*.
> Function adjusts width and height rectangle which you passed
> in it _by reference_.

Of course.  How else do you think I am getting the (correct) width
value when the second character is 0x002A?

In both cases (working, with the second character 0x002A, and non-
working, with the second character 0x062A) the height is returned
*both* in the appropriate field of the rectangle *and* as the value
returned from the function.

> Also check your compiler documentation about formatting wide strings
> (if you specify it as literal) and data type if you use WCHAR array.

I am explicitly loading the 16-bit values, since BBC BASIC doesn't
support that data type natively.  Remember, it is all working as
expected with the 'latin' characters (they are still 16-bit Unicode)
so such issues would have broken that case as well.

Whatever the problem is, it isn't that I'm doing something 'stupid' as
you seem to suggest.

Richard.
http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
date: Fri, 5 Sep 2008 01:37:43 -0700 (PDT)   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us