Announcement

Collapse
No announcement yet.

Width of a scroll bar

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

  • Width of a scroll bar

    Guys,

    When designing dialogs I'm using GetTextExtentPoint32, in order to retrieve correct values for cx and cy.
    For listboxes and edit controls there is one minor unsolved matter: when those controls have a vertical scroll bar, text sometimes disappears behind that bar. What is the number of du's to take in account for the expected width of a scroll bar?


    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    Get the width of a vertical scroll bar by using GetSystemMetrics( %SM_CXVSCROLL ) - this will give you the width in pixels. Then you can use GetDialogBaseUnits to convert it to DUs.

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




    [This message has been edited by Aldo Cavini (edited April 02, 2001).]
    Rgds, Aldo

    Comment


    • #3
      Thanks Aldo,

      I have to know such standard API things, but sometimes I'm worse than my laptop: 'out of memory'. Let's assume it is my age.


      ------------------
      mailto:[email protected][email protected]</A>
      www.basicguru.com/zijlema/

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment


      • #4
        From MSDN:
        The GetDialogBaseUnits function retrieves the system's dialog base units, which are the average width and height of characters in the system font.
        For dialog boxes that do not use the system font (DDT), the conversion from dialog template units to pixels depends on the font used by the dialog box.

        This means that it's necessary ro use MapDialogRect. Almost sure that PB Dialog Pixels to Units uses exactly this function.


        ------------------
        E-MAIL: [email protected]

        Comment


        • #5
          GetClientRect returns size minus scrollbars, if such exist. See:
          Code:
          '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
          ' Template
          '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
          #COMPILE EXE
          #INCLUDE "WIN32API.INC"
           
          '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
          ' Create dialog and controls, etc
          '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
          FUNCTION PBMAIN () AS LONG
            LOCAL hDlg AS LONG, rc AS RECT, rc2 AS RECT
           
            DIALOG NEW 0, "Test",,, 180, 115, %DS_MODALFRAME OR %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
            CONTROL ADD TEXTBOX, hDlg, 10, "", 4,  4, 172, 50, %WS_CHILD OR _
                                       %ES_MULTILINE OR %WS_VSCROLL, %WS_EX_CLIENTEDGE
            CONTROL ADD TEXTBOX, hDlg, 11, "", 4,  60, 172, 50, %WS_CHILD OR _
                                       %ES_MULTILINE, %WS_EX_CLIENTEDGE
           
            GetClientRect GetDlgItem(hDlg, 10), rc
            GetClientRect GetDlgItem(hDlg, 11), rc2
            CONTROL SET TEXT hDlg, 10, "ClientWidth:" & STR$(rc.nRight)
            CONTROL SET TEXT hDlg, 11, "ClientWidth:" & STR$(rc2.nRight)
           
            DIALOG SHOW MODAL hDlg
          END FUNCTION

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

          Comment


          • #6
            %LB_GETITEMRECT


            ------------------
            hellobasic

            Comment


            • #7
              Guys,

              Thanks for all your help, but.....
              I don't need the client width of a created listbox, edit control or whatsoever.
              What I am after is the expected width of a scroll bar, in order to create a control with sufficient space for both, text and the scrollbar..
              In that respect Aldo already gave me the answer I need.

              ------------------
              mailto:[email protected][email protected]</A>
              www.basicguru.com/zijlema/

              Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
              http://zijlema.basicguru.eu
              *** Opinions expressed here are not necessarily untrue ***

              Comment

              Working...
              X