Announcement

Collapse
No announcement yet.

fonts

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

  • fonts

    I am posting this message as a request for
    PBDLL to support other fonts for startup
    coordinates of dialog boxes and ability to
    set/change fonts for dialogs and individual
    controls. The Windows API calls make it a
    hairy ordeal.
    (but I'm not complaining too much; v6.0 is good)
    - Jim

    Jim Seekamp

  • #2
    Yes Yes Yes !!!
    But for now can someone show me how to do this using the API (or at least a hint)?
    I am spoiled with the ease of VB

    Thanks
    Steve

    Comment


    • #3
      Hi again.
      Here is what I'm currently using (in a dll):


      function centerframe(byval hwnd&) export as long

      static wndrect as rect
      static hfont&

      xsize%=getsystemmetrics(%sm_cxscreen)
      ysize%=getsystemmetrics(%sm_cyscreen)

      getwindowrect hwnd&,wndrect

      if xsize%>640 then
      xdlg%=(wndrect.nright-wndrect.nleft)
      ydlg%=(wndrect.nbottom-wndrect.ntop)
      wndrect.nleft=0
      wndrect.nright=ceil((xdlg%*xsize%)/640)
      wndrect.ntop=0
      wndrect.nbottom=ceil((ydlg%*ysize%)/480)
      end if

      ''center the dialog

      x1&=(xsize%-(wndrect.nright-wndrect.nleft))\2
      x2&=wndrect.nright-wndrect.nleft
      y1&=(ysize%-(wndrect.nbottom-wndrect.ntop+getsystemmetrics(%sm_cycaption)))\2
      y2&=wndrect.nbottom-wndrect.ntop
      style&=%swp_nozorder
      setwindowpos hwnd&,%null,x1&,y1&,x2&,y2&,style&

      ''set the font

      y1&=int((ysize%*16)/480) ''height
      x1&=int((xsize%*8)/640) ''width
      hfont&=fontmaker("MS Sans Serif",byval y1&,byval x1&,0)
      sendmessage hwnd&,%wm_setfont,hfont&,1

      if xsize%>640 then

      ''set dialog controls to right position and size

      hwndnext&=getwindow(hwnd&,%gw_child)

      while hwndnext&<>%null
      ctrlid&=getdlgctrlid(hwndnext&)

      control get loc hwnd&,ctrlid& to x1&,y1&
      control get size hwnd&,ctrlid& to x2&,y2&

      x1&=(x1&*xsize%)/640
      y1&=(y1&*ysize%)/480
      control set loc hwnd&,ctrlid&,x1&,y1&

      x2&=(x2&*xsize%)/640
      y2&=(y2&*ysize%)/480
      control set size hwnd&,ctrlid&,x2&,y2&

      sendmessage hwndnext&,%wm_setfont,hfont&,1

      hwndnext&=getwindow(hwndnext&,%gw_hwndnext)
      wend

      end if

      end function

      Jim Seekamp

      Comment


      • #4
        It works!! Thanks.

        Steve

        Comment


        • #5
          The automatically make a DDT dialog centered at creation time, add %DS_CENTER to the style flags for the dialog.

          Lance
          PowerBASIC Support
          Lance
          mailto:[email protected]

          Comment


          • #6
            Jim:
            I'm trying to increase the size of the print in the various dialogs I have created with DDT with the code you posted here. I do not want to use a DLL, so I tried to convert the code to a function. I simply cut out the export keyword on the
            FUNCTION centerframe(BYVAL hWin&) AS LONG
            Line. Because I use hWin& for my dialog handles, I changed hWnd to hWin in the code as well. I then placed
            Call CenterFrame(hWin&)
            before the Dialog show statement.
            When compiling, PBDLL 6.0 gave error 516, stating that FontMaker was not defined, so I remmed out the
            hfont&=fontmaker("MS Sans Serif",BYVAL y1&,BYVAL x1&,0)
            line. The program compiled after that, but my dialog did not change in any way. What am I doing wrong?
            Thanks for your help!

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

            Comment


            • #7
              Fontmaker can be replaced by your own fontmaker routine if you want;
              but here is mine:

              function fontmaker(byval f$,byval fh&,byval fw&,byval uflag&) export as long

              dim lgfnt as logfont

              lgfnt.lffacename=f$
              lgfnt.lfheight=fh&
              lgfnt.lfwidth=fw&
              lgfnt.lfitalic=uflag&

              lgfnt.lfweight=x&
              'lgfnt.lfescapement=0
              'lgfnt.lforientation=%dmorient_portrait
              'lgfnt.lfunderline=0
              'lgfnt.lfstrikeout=0
              lgfnt.lfcharset=%default_charset ''%oem_charset
              lgfnt.lfoutprecision=%out_default_precis
              lgfnt.lfclipprecision=%clip_default_precis
              lgfnt.lfquality=%proof_quality
              lgfnt.lfpitchandfamily=%default_pitch

              function=createfontindirect(lgfnt)
              end function

              Best Regards

              Jim



              ------------------
              Jim Seekamp
              Jim Seekamp

              Comment


              • #8
                Jim:
                I checked the forum this morning and got a great surprise. I implemented the fontmaker function you gave me, changed my dialog handles back to hWnd and compiled the program. And there, much to my total delight, appeared a dialog with print twice its usual size!

                I, as I have mentioned before, cannot make any sense out of low-level API calls, and I thank you so much for making this huge development in my program a reality!

                Take care.
                Danny.

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

                Comment


                • #9
                  My pleasure

                  Best Regards

                  Jim


                  ------------------
                  Jim Seekamp
                  Jim Seekamp

                  Comment

                  Working...
                  X