Announcement

Collapse
No announcement yet.

GETTEXTEXTENTPOINT32 with TABS

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

  • GETTEXTEXTENTPOINT32 with TABS

    I have bee using this just fine:

    Untill I was sent a TAB delimited file. I display the first 8 lines of the file in a window. The window is sized using:

    LINE INPUT #425, InputStr
    GETTEXTEXTENTPOINT32 hDc, BYVAL STRPTR(InputStr), LEN(InputStr), lpSize ' Max width of first line
    WdPix = lpSize.cx
    DisplayStr = ""
    FOR i = 1 TO 8
    LINE INPUT #425, InputStr
    GETTEXTEXTENTPOINT32 hDc, BYVAL STRPTR(InputStr), LEN(InputStr), lpSize ' does not work for Tabs
    IF lpSize.cx > WdPix THEN WdPix = lpSize.cx
    DisplayStr = DisplayStr+InputStr+$CRLF
    NEXT
    CLOSE #425 ' Close Input file
    WdPix = WdPix + 18 ' to take account for LH margin in this Window type
    HtPix = lpSize.cy ' the Height of any line
    DIALOG PIXELS CBHNDL, WdPix, HtPix TO UNITS Wd, Ht ' Convert to Dialog units
    Ht = (TALLY(DisplayStr, $CRLF)+2)*Ht ' Multiply by the number of lines

    DIALOG SET SIZE CBHNDL, Wd, Ht ' Set the Window Size

    What do I need to include to adjust for the width of a TAB?


    ------------------
    Kind Regards
    Mike

  • #2
    If space works, replace tabs with spaces first?

    ------------------
    Best Regards
    Peter Scheutz
    Best Regards
    Peter Scheutz

    Comment


    • #3
      What sort of control are you using here (or are you drawing directly onto the dialog client area)?

      If you want to maintain "columns", then you should be able to work out the size of each "column element" and add these together to determine the width of the control/dialog. Of course, you'll have to draw the individual column items; or maybe use a listbox with tabstops.

      While I understand what your original code does (although it does not give the whole picture of how the text is displayed), there seems to be a lack of control over the maximum or minimum width of the dialog... your existing code looks like it could resize a dialog to be much wider than the work area of the desktop.

      Personally, I would not create a dialog that is sized according to the string data displayed inside the dialog (aside from the simplistic MSGBOX/MessageBox dialogs), as you would be presented with a constantly changing dialog each time the dialog is presented, and this may be disconcerting to the user who is (IMHO) more likely to expect consistantly sized dialogs.

      Rather, I would set the initial dialog size (say, 75% of the workarea) and make the dialog resizable; plus I would add a horizontal scrollbar to allow the text to be scrolled (for when the text was longer than the current viewable width). A listbox can make this easier to handle, since you can let the listbox deal with the scrolling issues just by setting it's style appropriately, along with the tab stop settings. This would produce a consistent appearance, and conform to "normal" GUI standards.

      My $0.02.



      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Peter,
        Why didnt I think of that! thank you. Whats the Chr$(??) for a tab?

        Lance,
        That makes alot of sense. I like the ideas. I have not done a resizable window yet. I guess thats next on mylist.

        ------------------
        Kind Regards
        Mike

        Comment


        • #5
          Originally posted by Mike Trader:
          Peter,
          Whats the Chr$(??) for a tab?
          I use the PB6 buildin $TAB constant.

          ------------------
          Best Regards
          Peter Scheutz
          Best Regards
          Peter Scheutz

          Comment


          • #6
            $TAB is equivalent to CHR$(9) (a standard ASCII code).

            For more information on the built-in string equates, please see the Errata postings in the FAQ forum.


            ------------------
            Lance
            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            Lance
            mailto:[email protected]

            Comment


            • #7
              Regarding resizable dialogs/windows... I have a small Custom Control (RESIZE32) that can automatically resize controls on a window or dialog (including DDT dialogs) using elastic and/or anchored resizing techniques - you can adjust the resize "rules" for each control if you so wish.

              To utilize elastic auto-resizing, you can either make just one call to my DLL in the %WM_INITDIALOG handler, or include the (invisible) control itself in your dialog/window.

              Specifying resize methods is done through a very simple function call.

              Please email me privately at mailto:[email protected][email protected]</A> and I'll be glad to send you a fully-functional demo (with examples) you can play with.

              It may even give you a few hints to help you learn how to make your dialogs resizable and look good at the same time!

              (I must find time to get this control up on a web site!)

              Regards,
              Lance
              Lance
              mailto:[email protected]

              Comment


              • #8
                What do I need to include to adjust for the width of a TAB?
                Build an array of the desired tab stop positions, then use the GetTabbedTextExtent function to compute the text length.
                If you try to make something idiot-proof, someone will invent a better idiot.

                Comment


                • #9
                  I mostly use DrawText with %DT_CALCRECT


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

                  Comment

                  Working...
                  X