Measuring a String

J

John Fullman

Let's say I wanted the exact width of a string (in pixels) based on a
certain font or device context.
Anotherwords, how do I implement a funciton prototyped...

int MeasureStringInPixels(HDC dc, HFONT font, const char* text);

I've been pouring through windows api documentation to find the answer,
but it is very unclear (at least to me.) I'm sure this is easy. Just
not sure how it's done.
 
J

Jim Langston

John Fullman said:
Let's say I wanted the exact width of a string (in pixels) based on a
certain font or device context.
Anotherwords, how do I implement a funciton prototyped...

int MeasureStringInPixels(HDC dc, HFONT font, const char* text);

I've been pouring through windows api documentation to find the answer,
but it is very unclear (at least to me.) I'm sure this is easy. Just
not sure how it's done.

Try microsoft.public.vc.language maybe. Or microsoft.public.vc. Or maybe
some other m$ group.
 
Z

Zara

John said:
Let's say I wanted the exact width of a string (in pixels) based on a
certain font or device context.
Anotherwords, how do I implement a funciton prototyped...

int MeasureStringInPixels(HDC dc, HFONT font, const char* text);

I've been pouring through windows api documentation to find the answer,
but it is very unclear (at least to me.) I'm sure this is easy. Just
not sure how it's done.
<OT>
GetTextExtentPoint32
</OT>
 
T

Tim Love

John Fullman said:
I've been pouring through windows api documentation to find the answer,
but it is very unclear (at least to me.)
I suggest that you find a newsgroup that deals with windows api rather
than with C++.
 
B

benben

Hmmm... I think microsoft should name their functions better.
If that scares you, I'll let you know it is not even a function name. It is
a MACRO which resolves to either GetTextExtentPoint32A or
GetTextExtentPoint32W.

And I must tell ye I can't forget the last time I used a similar name in my
own namespace only to find out after hours of examination that the windows
header rudely renames my function name.

I HATE MACROS FULL STOP.

Ben
 
J

John Fullman

benben said:
If that scares you, I'll let you know it is not even a function name. It is
a MACRO which resolves to either GetTextExtentPoint32A or
GetTextExtentPoint32W.

And I must tell ye I can't forget the last time I used a similar name in my
own namespace only to find out after hours of examination that the windows
header rudely renames my function name.

I HATE MACROS FULL STOP.

This I know... and I hate it with an equal amount of passion. The
windows macros have caused me pain as well. Grrr....

I'm with ya.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top