Announcement

Collapse
No announcement yet.

slight problem with display font

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

  • slight problem with display font

    I appreciate some input on display font command if user does not select font size, if there is a way to check if no font size has not been select. the font requester always return size 10 if no size has been selected, I assume it is the current font size the application is using.

    Thanks.

  • #2
    According to the dialog new help
    If the DIALOG FONT statement is not used, the default font (MS Sans Serif, 8 point) is used.
    Of course this is pertaining to a DDT dialog. Also, aren't you using a double negative ?
    Last edited by Fred Buffington; 10 Jul 2009, 08:37 AM.
    Client Writeup for the CPA

    buffs.proboards2.com

    Links Page

    Comment


    • #3
      PBWin901..
      Looks like you should have a defpoints& value other than 0.
      Then you will get that value returned when the user doesn't make a size selection (unless you use the %CF_NOSIZESEL flag).
      Code:
      #Dim All
      #Register NONE
      #INCLUDE "WIN32API.INC"
       
      Function PbMain()
       Dim fontname$, defpoints&, fpoints&, style&, color&, charset&
       
      'DISPLAY FONT [hParent], [xpos], [ypos], defname$, defpoints&, defstyle&, flags& _
      'TO fontname$, points&, style& [,color&, charset&]
       
       defpoints = 12 ' initial (default) point size.
       
       DISPLAY FONT 0, , , "Arial", defpoints, 0, %CF_TTONLY _ 'OR %CF_NOSIZESEL _
                    To fontname, fpoints, style ,color, charset 
       
       ' adding %CF_NOSIZESEL flag overrides default 'defpoints' size
       ' - point size 10 returned instead, if user makes no size selection..
       
        MsgBox str$(fpoints),,"PointSze"
       
      End Function
      '------------------/PBMain
      Rgds, Dave

      Comment


      • #4
        Thank you both for the input, Dave , I already tried this and faced with the following problem, there is one font I have with only one size , and it is different from the default. now I am storing the user selection, if user selected this font, assuming we have the same setup,it will store the default size which does not fit the selected font , on restart,font will not be displayed correctly.

        Regards.

        Comment


        • #5
          I assume you are using the DDT 'DISPLAY FONT' statement but code not shown.

          If you change to the ChooseFont() Windows API call, when the user clicks OK you can get a LOGFONT structure returned with the selection. If he picked this font which is not available in some size, you can stop him right there.

          However, if this font is not a trueType font, he should not even be able to select a font in a size which is not available. No, I have not tried DISPLAY FONT to see what that does.

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

          Comment


          • #6
            Thank you MCM for the valuable reply, that will do it, but I was hoping for the DDT Display Font command to do it , it is much shorter,However, your answer made the day, Thanks again.

            AA.

            Comment


            • #7
              For that matter, you can hook the ChooseFont() dialog and prevent him from selecting something you don't want him to select in the first place.

              (Set the lpfnHook member of CHOOSEFONT and set the CF_ENABLEHOOK flag)
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                >input on Display Font command ..

                Check the fontname$ and fpoints& returned by Display Font ,, and change them if neccessary ?
                Rgds, Dave

                Comment


                • #9
                  After getting MM suggestion, I thought this statement from Microsoft is accurate " When ChooseFont returns, this structure contains information about the user's font selection", it is not, the 10 size it returns is not user selection, if font has font's size 10 , there is no way to till, if it is the user or Microsoft who selected that.does it make a difference , yes, if font has only size 9 for example , the application will store the size 10 for this font.

                  @Dave,Thank you, I am trying to find a way to know if user did not select a size, because the default size returned is not always present in all fonts.

                  I think I have to enumerate font size for the selected font, and if it is within the range for the font , I will let it pass.This is the closest I can get at this moment.

                  Thank you all for trying to help, and it is appreciated..
                  Last edited by Abdulaziz ALsaud; 11 Jul 2009, 05:57 AM.

                  Comment


                  • #10
                    However, if this font is not a trueType font, he should not even be able to select a font in a size which is not available. No, I have not tried DISPLAY FONT to see what that does.
                    Actually the user can select a font size that is not in the Font Size Combobox with either Display Font (DDT) OR the ChooseFont() API TTF (Yes I tried).

                    Using CF_FORCEFONTEXIST will cause an error indication if the user attemps to select a font or style that doesn't exist. But there is no corresponding flag to prevent the user from using a font size that isn't listed (TTF or not) .
                    The closest flag seems to be CF_LIMITSIZE - but that requires a Min and a Max value be set when the Choosefont call is made - so won't fit all fonts..

                    If it is important to control / filter what the user selects, one method could be to use Choosefont() with flag CF_ENABLEHOOK. Then, in the HookProc, examine the listed font sizes compared to the user selection when [ OK ] is clicked - 'eating' the button press (or forcing a size) if there is a mismatch or 'out of range' issue..

                    Example of using a hook procedure here.. http://www.powerbasic.com/support/pb...ead.php?t=6498
                    Rgds, Dave

                    Comment

                    Working...
                    X