Announcement

Collapse
No announcement yet.

Chr$(9) Probs.

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

    Chr$(9) Probs.

    Hullo!, Matt here.. again Much appreciated thanks pertaining to my last question, and thanks in advance for the following:

    I'm working with a standard DDT listbox control, and no matter what font I set to it, when I add a string followed by Chr(9), and another string (or no string at all) Chr(9) does not act as a tab, it is shows as a [] (a blank square, not brackets). Does anyone know how to resolve this. Note: I've tried with and without tabstops.

    Help!

    Regards,
    Matt

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

    #2
    matt, it's been discussed about 184 times before, a quick search gives us
    lots, but here are two you should read. the search engine is a great tool,
    and for very fast results you should try out borje's poffs.exe!!!!

    http://www.powerbasic.com/support/pb...ead.php?t=1569

    http://www.powerbasic.com/support/pb...ead.php?t=2352

    hth
    regards,
    jules


    Comment


      #3
      Thanks, but this doesn't change the fact of my problem, there is still a blank box where the tab (chr(9)) should be, with or without tab stops, on various fonts.

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

      Comment


        #4
        Matt;

        Please post some relevant code so the mechanics can see what's under the hood!

        Regards,
        Jules

        Comment


          #5
          Matt --
          Like Jules mentioned this thread discussed a lot of times.
          All is enough simple, except one - to understand, which size to set for columns, because 1/4 of character "average" width is enough interesting measurement.

          That's why below I used fixed width font (Courier) to avoid troubles.
          %nx - maximum size of column in chars
          dx - space between columns in 1/4 of char
          The third column is right alighned. That's why - and total width of all columns.

          Code:
             #Compile Exe
             #Register None
             #Dim All
             #Include "win32api.inc"
             %ID_Listbox = 101
          
             %n1 = 3
             %n2 = 10
             %n3 = 4
             %dx = 2
             
             Function PbMain
               Dim TabArray(1 To 3) As Dword, hDlg As Long
          
               Dialog New 0, "Select Test", , , 140, 100, %WS_CAPTION Or %WS_SYSMENU Or %WS_MAXIMIZEBOX To hDlg
               Control Add ListBox, hDlg, %ID_ListBox, , 10, 10,  120,  90, _
                  %WS_TABSTOP Or %LBS_USETABSTOPS Or %LBS_DISABLENOSCROLL Or %WS_VSCROLL, %WS_EX_CLIENTEDGE
          
               Local lf As LOGFONT, hFont As Long, lResult As Long, rc As RECT
               GetClientRect GetDlgItem(hDlg, %ID_ListBox), rc
               lResult = GetStockObject(%ANSI_VAR_FONT)
               GetObject lResult, SizeOf(lf), ByVal VarPtr(lf)
               lf.lfFaceName = "Courier New"
               lf.lfWeight = 0
               lf.lfHeight = 0
               lf.lfWidth = rc.nRight / 20
               hFont = CreateFontIndirect(lf)
               Control Send hDlg, %ID_LISTBOX, %WM_SETFONT, hFont, 0
          
               TabArray(1) = %n1 * 4 + %dx
               TabArray(2) = -((%n1 + %n2 + %n3) * 4 + %dx * 3)
               Dim i As Long, j As Long
               For i = 1 To 20
                  j = (i Mod 10)
                  If j = 0 Then j = 10
                  ListBox Add hDlg, %ID_LISTBOX, Format$(i) + "." + $TAB + _
                     Left$("Abcdefghijk", j) + $TAB + Format$(i * 50)
               Next
               Control Send hdlg, %ID_ListBox, %LB_SETTABSTOPS, 2, VarPtr(TabArray(1))
               Control Set Focus hDlg,%ID_ListBox
               Dialog Show Modal hDlg
               DeleteObject hFont
             End Function
          ------------------
          E-MAIL: [email protected]

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎