Announcement

Collapse
No announcement yet.

Greek characters

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

  • Greek characters

    In a new application, using DDT, I'm trying to display some greek characters on labels inside a dialog, like pi, phi, beta, etc, in some maths explanations. I tried with two standard fonts "Arial Greek" and "Courier New Greek" without success, with sentences DIALOG FONT and FONT NEW.

    At this moment I'm not able to found were is my mistake or if exist some limitations for this fonts. Or, even, if I need to translate text to a Unicode string before display.

    Someone who has experience in this kind of problem using DDT dialogs? (PbWin 9.01 under Vista SP2)

    Jordi
    Last edited by Jordi Vallès; 2 Sep 2009, 01:04 PM.

  • #2
    I always use the "Terminal" font.
    Regards,
    Bob

    Comment


    • #3
      The characters that you need are also in the Symbol font which is distributed with all versions of Windows. (No need for unicode fonts).

      You could use a richedit control as a label.. ( http://www.powerbasic.com/support/pb...d.php?p=165217 )

      A graphic control might be a better option though..
      Code:
      #Dim All
      #Compile Exe
      #Include "WIN32API.INC"
      '------------------/
      CallBack Function DlgProc() As Long
       Local hFontArial, hFontSymbol As Dword
        Select Case CbMsg
          Case %WM_InitDialog
            Font New "Times New Roman", 11, 1, 0, 0, 0 To hFontArial
            Font New "Symbol", 11, 1, 0, 0, 0 To hFontSymbol
       
            Control Set Text CbHndl, 100, "3.141592653589793"
            Graphic Attach CbHndl, 101
            Graphic Clear
       
            Graphic Color %Red, -2
            Graphic Set Font hFontSymbol            ' Use CharMap to get character codes
            Graphic Print Chr$(" ", &h70);          ' (XP - Start/Run/CharMap, same in Vista?)
                                        '^ suppress new line
            Graphic Color %Blue, -2
            Graphic Set Font hFontArial
            Graphic Print " (Value of Pi)"
        End Select
      End Function
      '------------------/DlgProc
      Function PBMain() As Long
       Local hDlg As Dword
        Dialog Font "Arial", 11, 0, 0
        Dialog New Pixels, 0, "Graphic Label Test",,, 300, 160, %WS_Caption Or %WS_SysMenu, 0 To hDlg
          Control Add TextBox, hDlg, 100, "TextBox ID 100", 20, 70, 145, 15, %ES_Right
          Control Add Graphic, hDlg, 101, "Graphic ID 101", 170, 70, 115, 17
       
        Dialog Show Modal hDlg, Call DlgProc
      End Function
      '------------------/PBMain
      Rgds, Dave

      Comment


      • #4
        Thanks Dave

        Your suggestion using graphic environments is a good solution for a few greek characters, perhaps in my case the best choice is to use a Richedit control as you suggested. I've tried it in an small DDT dialog an seems the appropriate solution.

        Many thanks for both samples.

        The "Symbol" font it's really what I need.

        Jordi

        P.S. My original question about how to use FONT NEW and DIALOG FONT statements with some specific fonts remains unanswered.

        Comment


        • #5
          Jordi, if you look at the code that Dave supplied in Post #3 you'll see that he has used both the DIALOG FONT in the function PBMain and in the CALLBACK he used two FONT NEW statements to prepare for the program output.
          This line then uses the Font set with DIALOG FONT, which he set as the font for the little program
          Code:
          Control Set Text CbHndl, 100, "3.141592653589793"
          After the GRAPHIC ATTACH statement he then sets the active font with
          Code:
          Graphic Set Font hFontSymbol
          hFontSymbol is the handle to the FONT established with the second FONT NEW statement.
          He then uses the other FONT created with the first FONT NEW statement.
          In order to use the symbol font again you would have to use the GRAPHIC SET FONT hFontSymbol statement.
          These fonts stay active until you use another GRAPHIC SET FONT statement.
          There are lots of other examples here in the fora if you search for "FONT NEW"
          Rod
          In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

          Comment


          • #6
            > My original question about how to use FONT NEW and DIALOG FONT statements with some specific fonts remains..

            When you execute the DIALOG FONT statement it defines the font that will be used as the default font by any DIALOGS (and child controls) that are subsequently created.
            It can be overridden by FONT NEW / CONTROL SET FONT statements in individual controls. Graphic controls can 'do their own thing' too .

            However PB's native strings (and controls) are ANSI and as such are limited to displaying the first 255 character codes of any font.
            Even though, using CharMap, you can see that 'Pi' does exist in the Arial font with a Character Code &h03C0, we normally have to use the Symbol font as it has that character at Character Code &h70 (Decimal 112) i.e. within the scope of ANSI controls.

            If you want to display the higher (Unicode) Characters Codes you can use a Unicode RichEdit control as in this example..
            Code:
            #Dim All
            #Include "WIN32API.INC"
            #Include "RICHEDIT.INC"
            %RE_Label   = 101
            %IDC_Label  = 102
            Declare Function SetDlgItemTextU Lib "USER32.DLL" Alias "SetDlgItemTextW" (ByVal hDlg As Dword, _
                      ByVal nIDDlgItem As Long, ByVal suString As String) As Long
            '------------------/
            CallBack Function DlgProc()
             Local sTemp As String
             Local cf As CHARFORMAT   ' can be used to set RichEdit character atributes for font, color etc
              Select Case As Long CbMsg
                Case %WM_INITDIALOG
                  cf.cbSize      = LEN(cf)
                  cf.dwMask      = %CFM_COLOR       ' set mask to indicate which attributes are being set
                  cf.crTextColor = %Black
                  SendMessage GetDlgItem(CbHndl, %RE_Label), %EM_SETCHARFORMAT, %SCF_ALL, Varptr(cf)
             
                  sTemp = CHR$(&hC0, &h03) + UCODE$(" (Pi) = 3.141592653589793 (Arial)")  ' codes LSB first
                  Call SetDlgItemTextU(CbHndl, %RE_LABEL, sTemp)      
              End Select
            End Function
            '------------------/DlgProc
            Function PBMain()
             Local hDlg, hFontCourier12 As Dword 
             Dialog Font "Arial", 12, 0, 0
             Font New    "Courier", 12, 0, 0, 0, 0 To hFontCourier12
             
              Dialog New Pixels, 0, "RE_Label Test",,, 300, 160, %WS_CAPTION Or %WS_SYSMENU, To hDlg
               LoadLibrary "Riched20.dll"           ' could use Msftedit.dll and RichEdit50W'
               Control Add "RichEdit20W", hDlg, %RE_LABEL, "RELabel", 20, 40, 280, 25, %WS_CHILD Or _
                            %WS_VISIBLE Or %WS_DISABLED 
               Control Add Label, hDlg, %IDC_Label, "Plain label (Courier)", 20, 70, 280, 20
               Control Set Font hDlg, %IDC_Label, hFontCourier12
             
              Dialog Show Modal hDlg, Call DlgProc
            End Function
            '------------------/PbMain
            Rgds, Dave

            Comment


            • #7
              Dave and Rod, thanks for your kindly explanations.

              Your comments and examples how font and chars substitution works and the differents methods to reach that. For a large text with several strange (greek) characters the RichEdit control method referenced on Post #3 is the best solution, I think.

              Jordi

              Comment

              Working...
              X