Announcement

Collapse
No announcement yet.

Dialog fonts

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

  • Dialog fonts

    Is it possible to change the font in a dialog box?

    I want to insert a capital delta sign in the middle of some text,
    along the lines of the code below:-


    SlopeSVP= (4098*(0.6108*EXP((17.27*airtemp)/(airtemp+237.3))))/((airtemp+237.3)^2)
    textstring="Slope of Vapour pressure curve ("
    'change font to "Symbol", 8
    textstring=textstring+CHR$(068)
    'change font back to "MS Sans Serif", 8
    textstring=textstring+") at"+STR$(airtemp)+CHR$(0186)+"C = "+FORMAT$(SlopeSVP,"0.000")
    CONTROL SET TEXT hDlg, %IDC_LABEL15, textstring

    I have this feeling that I am going to fail on this one.

    Any ideas??

    Iain Johnstone

    ------------------
    “None but those who have experienced them can conceive of the enticements of science” - Mary Shelley

  • #2
    You're right in your feelings. You'll need a rich edit or you
    could get away with it in a grahic control.



    ------------------
    --
    C'ya
    Don
    don at DASoftVSS dot com
    http://www.DASoftVSS.com
    I program better than
    those who program faster
    and faster than those who program better.
    C'ya
    Don

    http://www.ImagesBy.me

    Comment


    • #3
      Or use TWO controls, one next to the other ... one for the plain text using the default font, and one in which you use the other font.

      See WM_SETFONT message (unless maybe DDT has a CONTROL SET FONT option?) to set the font for a control.

      To mix fonts on one control, you will have to draw the text yourself.. see SS_OWNERDRAW style for static controls, and DrawText and/or TextOut WinAPI GDI functions.

      MCM

      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Thanks Don - I thought as much!

        The graphic control would mean a fair bit of rewriting, but this
        may make it easier to display the formulae.

        Iain Johnstone

        ------------------
        “None but those who have experienced them can conceive of the enticements of science” - Mary Shelley

        Comment


        • #5
          MM - sorry, we must have posted at the same time. I shall leave this
          one at present, and replace the symbols by words. At least this is possible
          when using XPRINT for the calculation printouts.

          Many thanks

          Iain Johnstone

          ------------------
          “None but those who have experienced them can conceive of the enticements of science” - Mary Shelley

          Comment


          • #6
            Iain,

            Using a Richedit label may not require too much of a rewrite.
            Once the header is set up, the addition of a few 'markup' characters to your text is all you need.
            Here's an example -
            Code:
            #Dim All
            #Include "WIN32API.INC"
            #Include "RICHEDIT.INC"
            '------------------
            %LBL_LABEL1  = 100
            %RE_LABEL    = 101 
            %BTN_Test    = 102
            '------------------
             
            CallBack Function DlgProc()
              Static RE_Header As String
              Select Case As Long CbMsg
                Case %WM_INITDIALOG
                  RE_Header = _                                                         ' RTF header
                  "{"+ _                                                                ' Opening brace
                  "\rtf1\ansi\ansicpg1252\deff0\deflang1033"+ _                         ' Version and Char set
                  "{\fonttbl"+ _                                                        ' Font table
                  "{\f0\fswiss\fprq2\fcharset0 Microsoft Sans Serif;}"+ _               ' \f0 = default/initial font
                  "{\f1\froman\fprq2\fcharset2 Symbol;}"+ _
                  "{\f2\fnil\fprq2\fcharset2 Wingdings;}}
             
                Case %WM_COMMAND
                  Select Case As Long CbCtl
                    Case %BTN_Test
                      If CbCtlMsg = %BN_CLICKED Then 
                       Local SlopeSVP As Single, airtemp As Single, textstring As String 
                        airtemp = 10
                        SlopeSVP= (4098*(0.6108*EXP((17.27*airtemp)/(airtemp+237.3))))/((airtemp+237.3)^2)
                        textstring =  "\fs16 "+ _       ' fs16 = use 8 point text
                                      "Slope of Vapour pressure curve ("+ _
                                      "\f1 "+ _         ' \f1 change font to "Symbol"
                                      CHR$(068)+ _  
                                      "\f0 "+ _         ' \f0 change font back to default "MS Sans Serif"
                                      ") at"+STR$(airtemp)+CHR$(0186)+"C = "+FORMAT$(SlopeSVP,"0.000")+ _
                                      "\fs24 \f2  J"+ _ ' \fs24 = 12 point, \f2 change font to "Wingdings"  [img]http://www.powerbasic.com/support/forums/smile.gif[/img]
                                      "}"                                               ' Closing brace
                        textstring = RE_Header + textstring
                        Control Set Text CbHndl, %RE_Label, textstring
                      End If
                  End Select
             
              End Select
            End Function
            '------------------/DlgProc
             
            Function PBMain()
             Local hDlg  As Dword 
             LoadLibrary "RICHED32.DLL"
             
              Dialog New 0, "Test", 100, 100, 300, 120, %WS_CAPTION Or %WS_SYSMENU, To hDlg
              Control Add Label,  hDlg, %LBL_LABEL1,   "RichEdit labels - can do!", 10, 20, 100, 10
              Control Add "RichEdit", hDlg, %RE_LABEL, "RELabel", 10, 40, 280, 15, %WS_CHILD Or _
                            %WS_VISIBLE Or %WS_DISABLED 
              SendMessage GetDlgItem(hDlg, %RE_LABEL), %EM_SETBKGNDCOLOR, 0, GetSysColor(%COLOR_BTNFACE)
              Control Add Button, hDlg, %BTN_Test, "Test", 75, 70, 50, 15
             
              Dialog Show Modal hDlg, Call DlgProc
            End Function
            '------------------/PbMain
            Rgds Dave

            ------------------
            Rgds, Dave

            Comment


            • #7
              Thanks Dave - this looks interesting, and will be tomorrow's job.
              It is 21:30 here, and I have been at this non-stop today, so it
              is time to leave it for now!
              (Actually, this would be an early night in the programming stakes).

              Regards

              Iain Johnstone

              ------------------
              “None but those who have experienced them can conceive of the enticements of science” - Mary Shelley

              Comment

              Working...
              X