Announcement

Collapse
No announcement yet.

Default Dialog Font

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Default Dialog Font

    I'm using variable size fonts linked to each control in my
    dialogs. I read in documentation that in the absence of a
    particular font for a control, the default dialog font is used.
    That is,

    CALL SendMessage(Control_ID_Font_Handle,%WM_SETFONT,0,0)

    would cause the font for that control to be set to the default
    DIALOG font. (assuming Control_ID_Font_Handle is properly set
    up using CONTROL HANDLE).

    I have one dialog with about 100 controls, each with one letter
    of text. Resizing the screen takes a while with a 200 MHz CPU.
    Rather than use the above SendMessage for each control, I'd
    like to do it once for the dialog and have all controls
    initialized with a 0 for the font_ID. Then change the
    DIALOG font size once at the start of the WM_SIZE logic,
    instead of once for each CONTROL.

    But how does one change the size of the default dialog font?
    ----------------------------------------------------------------

  • #2
    Joe;

    There is no thing as a Universal Font for controls in a Dialog. You can't just change a single font (like the Dialogs default font) and expect all the controls to change.

    When a Dialog is created (using the Windows Dialog engine or with DDT), the Dialog itself has a default font. Using the API Dialog functions, the default font is the System font. Using DDT, the default font is MS Sans Serif, 8 point.

    The Windows Dialog engine (and DDT I assume uses a similiar mechanism) will then send the WM_SETFONT message automatically to all the controls before the Dialog is displayed. It actually sends a WM_SETFONT message to each individual control.

    You can change the fonts for controls later, by using the WM_SETFONT message for each and every control.

    When you resize a Dialog and you want to change all the fonts, it is best to first turn off the "Redraw" state of the Dialog so none of the controls will repaint. Then change the fonts for each and every control and then turn the Redraw state back on and then "Invalidate" the entire Dialog so it repaints as a single unit (all the controls too).


    ------------------
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #3
      How does one "Invalidate" an entire Dialog Window? I played
      with a few API calls, but I suspect that to use the technique
      you are refering to, one has to put a total dialog structure
      together with a list of controls. Then give the entire
      structure to a REDRAW function. This does not look too easy
      to accomplish using DDT.

      Or perhaps there is a straightforward way to do this even in
      DDT?

      I had no problem with

      Code:
              CALL SendMessage(hDlg,%WM_SETREDRAW,0,0)
      
                . . . 
      
              CALL SendMessage(hDlg,%WM_SETREDRAW,1,0)
      I made lots of blank screens and could bring back some of
      the controls with random clicking on the screen). But couldn't
      make the screen repaint.

      ------------------

      Comment


      • #4
        To force a window/dialog update, invalidate the window contents and force a WM_PAINT event:
        Code:
        CALL InvalidateRect(hDlg, BYVAL %NULL, %TRUE)
        CALL UpdateWindow(hDlg)

        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment


        • #5
          Thanks fellows. Very impressive speed difference when you have
          100 controls in a single dialog.

          ------------------

          Comment

          Working...
          X