Measuring a String

Discussion in 'C++' started by John Fullman, Sep 23, 2005.

  1. John  Fullman

    John Fullman Guest

    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.
     
    John Fullman, Sep 23, 2005
    #1
    1. Advertising

  2. John  Fullman

    Jim Langston Guest

    "John Fullman" <> wrote in message
    news:...
    > 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.
     
    Jim Langston, Sep 23, 2005
    #2
    1. Advertising

  3. John  Fullman

    Zara Guest

    John Fullman wrote:
    > 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>
     
    Zara, Sep 23, 2005
    #3
  4. John  Fullman

    John Fullman Guest

    Zara wrote:
    > GetTextExtentPoint32


    Hmmm... I think microsoft should name their functions better.
     
    John Fullman, Sep 23, 2005
    #4
  5. John  Fullman

    Tim Love Guest

    "John Fullman" <> writes:

    >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++.
     
    Tim Love, Sep 23, 2005
    #5
  6. John  Fullman

    benben Guest

    > 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
     
    benben, Sep 23, 2005
    #6
  7. John  Fullman

    John Fullman Guest

    benben wrote:
    > 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.
     
    John Fullman, Sep 24, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlo Filippini

    Measuring performance of Net::FTP

    Carlo Filippini, Sep 9, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,181
    Philip
    Sep 9, 2003
  2. Guadala Harry

    Measuring Memory Useage

    Guadala Harry, Oct 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    451
    bruce barker
    Oct 25, 2004
  3. Bill Cohagan

    Measuring serialized session "size"

    Bill Cohagan, Nov 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    642
    bruce barker
    Nov 25, 2004
  4. John Raggio
    Replies:
    10
    Views:
    806
    rpadev
    Mar 7, 2004
  5. Katerina MacLean

    Measuring Memory Usgae

    Katerina MacLean, Aug 29, 2004, in forum: Java
    Replies:
    0
    Views:
    428
    Katerina MacLean
    Aug 29, 2004
Loading...

Share This Page