No announcement yet.

Using bold font to highlight frame controls

  • Filter
  • Time
  • Show
Clear All
new posts

  • Using bold font to highlight frame controls

    I've got a dialog with 3 frame controls on it. Each frame has a grid control located inside it's borders.

    I would like for the frame corresponding to the grid control that has focus to display it's label in bold font. I tried creating a bold font (createfontindirect from system menu font) and using selectobject on an hDC for the frame control, but it didn't appear to work.

    I'll be happy to use PB's FONT NEW, CONTROL SET FONT, FONT END statements, but I'm a little unclear on how to specify the correct font for FONT NEW. It's also not clear to me what happens with the fonts when using CONTROL SET FONT. Is there no need to retain a handle to the original font when selecting a new font into a control (like you need to do with SelectObject)?
    Bernard Ertl
    InterPlan Systems

  • #2
    The control itself handles the drawing of itself, including fonts, so there is no need to mess with DC's, selectobject and the like.

    Windows provides a message, WM_SETFONT, which when sent to many controls allows you to pass to the control a font handle. That handle can be shared among multiple controls, but it must always exist while any controls are using it (until the controls are destroyed).

    You can create a font using the CreateFont API function and then pass the returned handle to the control via the WM_SETFONT message.

    DDT provides its own commands for working with fonts which accomplishes basically the same thing.

    FONT NEW creates a font
    CONTROL SET FONT passes the font to a control, similiar to the WM_SETFONT message
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"


    • #3
      Thanks Chris. I got it sorted out now. I should have remembered that.
      Bernard Ertl
      InterPlan Systems


      • #4
        When I reset a frame from the bold font to the original font, the text in the label portion requires less space to display and the program does not clean up the difference (ie. the last few characters of the bold text don't get erased when the label is redrawn in the non-bold font).

        I am using CONTROL SEND hWnd, lFrameID, %WM_SETFONT, hOldFont, %True to reset the font.

        CONTROL REDRAW does not fix the problem.

        Last edited by Bern Ertl; 17 Feb 2009, 10:17 AM.
        Bernard Ertl
        InterPlan Systems


        • #5
          I found a solution, but it seems a bit of kludge to me.

          I had to use:

          CONTROL GET TEXT <frame> TO sText
          CONTROL SET TEXT <frame>, ""
          CONTROL SEND <frame>, %WM_SETFONT
          CONTROL SET TEXT <frame>, sText

          to erase all the bold text.
          Bernard Ertl
          InterPlan Systems