#39 Oodialog tree view font

Windows
closed
Mark Miesfeld
5
2012-08-14
2010-08-10
hex
No

Is it possible to define a separate font to be used when filling up a tree view control with data, as for now the whole dialog (buttons, text, tree view), except menu items which seems to use the system default font, use the same font( via setDefaultFont or setDlgFont if one needs to use a monospaced font in a tree view control. My need is to use the default dialog font for the dialog items but in the tree view control I need a monospaced font that will line upp better when displaying data. Is this possible to achieve ?

Discussion

  • Mark Miesfeld
    Mark Miesfeld
    2010-08-10

    Yes you can assign a different font to either the dialog as a whole, or to individual controls.

    Use the createFontEx() method to create a new font and then use the setFont() method to assign it to a control.

    For example, edit the oodtree.rex sample program in the samples\oodialog directory. Go to the InitDialog() method:

    / Initialization Code, fill tree with initialization data /
    ::method InitDialog
    expose bmpFile treeFile itemFile

    InitDlgRet = self~InitDialog:super

    curTree = self~GetTreeControl("IDC_TREE")
    if curTree \= .Nil then
    do
    bmpFile = "bmp\oodtree.bmp" / file which contains the icons for selected/not-selected items /
    treeFile = "oodtree.inp" / input file which contains the items to build the tree /

    Right after the do statement, insert these lines:

    newFont = self~createFontEx("Courier New", 12)
    curTree~setFont(newFont)
    

    so you will have something this:

    if curTree \= .Nil then
    do
    newFont = self~createFontEx("Courier New", 12)
    curTree~setFont(newFont)

    bmpFile  = "bmp\oodtree.bmp"  /* file which contains the icons for selected/not-selected items */
    treeFile = "oodtree.inp"  /* input file which contains the items to build the tree         */
    

    Run the program and you will see the different font for th tree control.

    To set a new font, you need to do it after the underlying Windows dialog is created. Which is basically in initDialog() or later.

    ooDialog has another method, createFont(), that is very broken. You should use createFontEx() for all new code.

     
  • hex
    hex
    2010-08-11

    Thanks, worked like a charm.

     


Anonymous


Cancel   Add attachments