Font size of an ownerdrawn foreign listbox


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Font size of an ownerdrawn foreign listbox

Hybrid View

  1. #1
    Juergen Thuemmler Guest

    Font size of an ownerdrawn foreign listbox

    Hi *.*,

    I have to determine al least the size, better name and size
    of the currently selected font of an ownerdrawn listbox in a
    foreign application, e.g. User Manager in WinNT4. How can
    this be done?

    Juergen.



  2. #2
    Mark Alexander Bertenshaw Guest

    Re: Font size of an ownerdrawn foreign listbox

    "Juergen Thuemmler" <thue@gmx.de> wrote in message
    news:3d73aa3d@10.1.10.29...
    > Hi *.*,
    >
    > I have to determine al least the size, better name and size
    > of the currently selected font of an ownerdrawn listbox in a
    > foreign application, e.g. User Manager in WinNT4. How can
    > this be done?
    >
    > Juergen.


    Juergen -

    At a guess, you could use GetDC(hWnd) to get the Device Context handle, and
    then GetCurrentObject(hDC, OBJ_FONT) to get the current hFont. However,
    this might not necessarily get you the true Font, if the owner-draw code
    uses SelectObject() to change the font when responding to the WM_PAINT
    message. Also, I am not sure how to get back from a physical font
    (represented by hFont), and a logical font (represented by a LOGFONT
    structure). You could try GetOutlineTextMetrics(), which returns an
    OUTLINETEXTMETRIC structure, of which the otmpFaceName member may be what
    you want.

    --
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Chordiant Software, Inc.
    Brentford
    UK



  3. #3
    Juergen Thuemmler Guest

    Re: Font size of an ownerdrawn foreign listbox

    Mark,

    > At a guess, you could use GetDC(hWnd) to get the Device Context handle,

    and
    > then GetCurrentObject(hDC, OBJ_FONT) to get the current hFont. However,
    > this might not necessarily get you the true Font, if the owner-draw code
    > uses SelectObject() to change the font when responding to the WM_PAINT
    > message. Also, I am not sure how to get back from a physical font
    > (represented by hFont), and a logical font (represented by a LOGFONT
    > structure). You could try GetOutlineTextMetrics(), which returns an
    > OUTLINETEXTMETRIC structure, of which the otmpFaceName member may be what
    > you want.


    thanks for reply. Until now, I tried to avoid to use these functions ;-)
    I'm not sure about using functions which use pointers to structures in a
    foreign
    process. Sometimes it works, sometimes it crashes ...
    Well, there would be the possibility to hook into the foreign process using
    a Dll,
    but this seems to be overdone for this purpose ...
    Anyway, I'll check your proposal.

    Thanks!
    Juergen.



  4. #4
    Matthew Curland Guest

    Re: Font size of an ownerdrawn foreign listbox

    WM_GETFONT may work better than GetDC/GetCurrentObject, depending on how the
    ownerdraw was implemented. It doesn't help with the hFont->LOGFONT
    derivation, however. -Matt

    "Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote in message
    news:3d74700f$1@10.1.10.29...
    > "Juergen Thuemmler" <thue@gmx.de> wrote in message
    > news:3d73aa3d@10.1.10.29...
    > > Hi *.*,
    > >
    > > I have to determine al least the size, better name and size
    > > of the currently selected font of an ownerdrawn listbox in a
    > > foreign application, e.g. User Manager in WinNT4. How can
    > > this be done?
    > >
    > > Juergen.

    >
    > Juergen -
    >
    > At a guess, you could use GetDC(hWnd) to get the Device Context handle,

    and
    > then GetCurrentObject(hDC, OBJ_FONT) to get the current hFont. However,
    > this might not necessarily get you the true Font, if the owner-draw code
    > uses SelectObject() to change the font when responding to the WM_PAINT
    > message. Also, I am not sure how to get back from a physical font
    > (represented by hFont), and a logical font (represented by a LOGFONT
    > structure). You could try GetOutlineTextMetrics(), which returns an
    > OUTLINETEXTMETRIC structure, of which the otmpFaceName member may be what
    > you want.
    >
    > --
    > Mark Alexander Bertenshaw
    > Programmer/Analyst
    > Chordiant Software, Inc.
    > Brentford
    > UK
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center