Results 1 to 24 of 24

Thread: Flexgrid: A long word is not wrapping in MSFlexgrid

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    130

    Flexgrid: A long word is not wrapping in MSFlexgrid

    Hello, unfortunately the MSFlexgrid control doesn't wrap long words, as the following
    code sample shows.
    Code:
    Code sample :
    
    Name:  cropped2.jpg
    Views: 1222
    Size:  4.2 KB
    Private Sub Form_Activate()
        DoEvents
        MSFlexGrid1.Height = 1600
        MSFlexGrid1.RowHeight(1) = 800
        MSFlexGrid1.WordWrap = True
        MSFlexGrid1.TextMatrix(1, 1) = "XaaaaaaaaaaaaaaaaaY"
    End Sub
    So I coded my own wordwrapper function. It needs a TextBox with the "multiline" property
    set to "True" and it is using "SendMessage". The wordwrapper is working fine :
    Code:
    Function wordwrapper(s As String) As String
      Const EM_GETLINECOUNT = &HBA
      Const EM_LINEINDEX = &HBB
      Dim NumOfLines As Long, y As Long, firstCharInThisLine As Long
      Dim firstCharInThisLineOld As Long
        Text1.Text = s
        'getting the number of lines in Text1 :
        NumOfLines = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0&, ByVal 0&)
        For y = 1 To NumOfLines - 1
            firstCharInThisLine = SendMessage(Text1.hwnd, EM_LINEINDEX, y, ByVal 0&)
            wordwrapper = wordwrapper & Mid(Text1, firstCharInThisLineOld _
            + 1, firstCharInThisLine - firstCharInThisLineOld) & vbCrLf
            firstCharInThisLineOld = firstCharInThisLine
        Next
        wordwrapper = wordwrapper & Mid(Text1, firstCharInThisLineOld + 1)
    End Function

    My problem:
    In the thread http://www.vbforums.com/showthread.p...le-long-words) I used the "DrawText"
    API to break a single long word like "XaaaaaaaaaaaaaaaaaY" (successfully!).
    -My question: How can I write the "DrawText" output to the Flexgrid Cell(1,1) ?
    -I want to do this with an API, and I don't want to use MSFlexGrid1.TextMatrix(1, 1) = "XaaaaaaaaaaaaaaaaaY".

    The API Viewer is showing eleven different "TextOut" functions.
    Name:  cropapiviewer.jpg
Views: 1302
Size:  14.2 KB
    Last edited by vb.elmar; Jun 26th, 2016 at 09:30 AM.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Short answer: you can't.

    I don't have a fix to offer but maybe somebody else will share one before you or I come up with one ourselves.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    The answer for this in the MSHFlexGrid seems to be a property called ColWordWrapOption that can be assigned a value such as flexWordBreakEllipsis:

    Code:
            .ColWidth(.Cols - 1) = 2400
            .ColWordWrapOption(.Cols - 1) = flexWordBreakEllipsis
    This doesn't do things the way you want of course and it relies on the user to resize the row to expose the wrapped data:

    Name:  sshot.png
Views: 1530
Size:  13.4 KB

    The MSDN web site has dropped the article describing this property and its values, so you'll have to look it up in your MSDN CD documentation.

  4. #4
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,452

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    This is a longshot because you'd probably be using this control over the MSFlexGrid if you had the choice, but do you have the ComponentOne VSFlexGrid in your components list? If so, you can set the OwnerDraw property to FlexODComplete, and then draw anything you like in any cell using API calls.

  5. #5
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by dilettante View Post
    The answer for this in the MSHFlexGrid seems to be a property called ColWordWrapOption that can be assigned a value such as flexWordBreakEllipsis:

    Code:
            .ColWidth(.Cols - 1) = 2400
            .ColWordWrapOption(.Cols - 1) = flexWordBreakEllipsis
    This doesn't do things the way you want of course and it relies on the user to resize the row to expose the wrapped data:

    Name:  sshot.png
Views: 1530
Size:  13.4 KB

    The MSDN web site has dropped the article describing this property and its values, so you'll have to look it up in your MSDN CD documentation.
    hi bro.
    can you post a little project for tath?
    Tks.

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,177

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Why do you need an example project...dilettante gave you the necessary code to wrap long words....TRY IT!
    Sam I am (as well as Confused at times).

  7. #7
    Addicted Member ISAWHIM's Avatar
    Join Date
    Jan 2023
    Posts
    181

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Few programs, if any, will "break a whole word into multiple word-chunks"

    Pay
    the
    rap
    ist

    Is it "Pay therapist" or "Pay the rapist"?

    This is why they invented "auto-fit" to boxes and columns, and it's called "Word wrap", not "Letter wrap", it wraps whole words. You want it to wrap letters, from words.

    It will look horrible using it for anything that has actual volume to it. (Which is why programs don't do it.)
    I see y
    ou went
    to the s
    tore fo
    r groce
    ries.

  8. #8
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by SamOscarBrown View Post
    Why do you need an example project...dilettante gave you the necessary code to wrap long words....TRY IT!
    Have error in:

    ...
    .ColWidth(.Cols - 1) = 2400

    .ColWordWrapOption(.Cols - 1) = flexWordBreakEllipsis '<<<<<< here
    ...
    Attached Images Attached Images  

  9. #9
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,255

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by luca90 View Post
    Have error in:

    ...
    .ColWidth(.Cols - 1) = 2400

    .ColWordWrapOption(.Cols - 1) = flexWordBreakEllipsis '<<<<<< here
    ...
    Dilettante's code was for a MSHFlexGrid, not an MSFlexgrid. Which are you using?
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  10. #10
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by ColinE66 View Post
    Dilettante's code was for a MSHFlexGrid, not an MSFlexgrid. Which are you using?
    MSFlexGrid1...

  11. #11
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,910

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Then switch to MSHFlexGrid

  12. #12
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by Arnoutdv View Post
    Then switch to MSHFlexGrid
    OK TKS.

    but i dont love the the very bold line, to define the cells..
    i love the thiny line in msflexgrid...

  13. #13
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,177

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    What bold versus thin lines are you talking about?
    Last edited by SamOscarBrown; Mar 29th, 2023 at 06:56 AM.
    Sam I am (as well as Confused at times).

  14. #14
    Addicted Member ISAWHIM's Avatar
    Join Date
    Jan 2023
    Posts
    181

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Change the grid color to grey and be sure the grid style is flat.



    Or are you complaining about the "selection indicator outline"? (Or lack of, in the MSFlexGrid.)
    Please, chime-in on my latest WIP.
    I can use all the help I can get.
    [VB6 Game], (In Development), "Galactic-Bondsman"

  15. #15
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by SamOscarBrown View Post
    What bold versus thin lines are you talking about?

    Attachment 187279
    first image

  16. #16
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,910

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Which bold lines? All lines have a thickness of 1 pixel

  17. #17
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,177

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Yeah...I don't see any difference...Here, I put the BackColorBkg to white on both...see?

    Name:  grids.JPG
Views: 323
Size:  15.6 KB
    Last edited by SamOscarBrown; Mar 29th, 2023 at 06:54 AM.
    Sam I am (as well as Confused at times).

  18. #18
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,259

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    He probably means the "default-color of the inner GridLines"
    (visible in the ScreenShots only at the small vertical line between the "Me | You" cells).

    Olaf

  19. #19
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,177

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Ah, yes...probably. My old eyes didn't catch that. Yeah, MAN, that would bother the heck out of me too!!!!! :-)
    Sam I am (as well as Confused at times).

  20. #20
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,255

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by SamOscarBrown View Post
    Yeah, MAN, that would bother the heck out of me too!!!!! :-)
    So much so, that you didn't even notice it
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  21. #21
    Addicted Member ISAWHIM's Avatar
    Join Date
    Jan 2023
    Posts
    181

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by luca90 View Post
    first image
    Yes, it's not "bold" it's just "grey", not "black".

    Thus, change the color of the grid to grey, and it won't look "bold". (Illusion, it's just black, not bold. The other is just grey, not thinner. Both are, as it was said, only 1 pixel wide. "Bold" = "Thicker", not "Darker".)


    My other post shows the same exact results with the MSHFlexGrid control... I just changed the color to grey. (This is the MSH grid, in the picture.)


    Default color is Black... (The blue selected one, I changed to grey)
    Name:  Image1.jpg
Views: 302
Size:  38.5 KB
    Last edited by ISAWHIM; Mar 29th, 2023 at 08:41 AM.
    Please, chime-in on my latest WIP.
    I can use all the help I can get.
    [VB6 Game], (In Development), "Galactic-Bondsman"

  22. #22
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,177

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Yeah...THIS gray looks better: &H00808080&
    Attached Images Attached Images  
    Sam I am (as well as Confused at times).

  23. #23
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by ISAWHIM View Post
    Yes, it's not "bold" it's just "grey", not "black".

    Thus, change the color of the grid to grey, and it won't look "bold". (Illusion, it's just black, not bold. The other is just grey, not thinner. Both are, as it was said, only 1 pixel wide. "Bold" = "Thicker", not "Darker".)


    My other post shows the same exact results with the MSHFlexGrid control... I just changed the color to grey. (This is the MSH grid, in the picture.)


    Default color is Black... (The blue selected one, I changed to grey)
    Name:  Image1.jpg
Views: 302
Size:  38.5 KB
    YES!

  24. #24
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: Flexgrid: A long word is not wrapping in MSFlexgrid

    Quote Originally Posted by ISAWHIM View Post
    Few programs, if any, will "break a whole word into multiple word-chunks"

    Pay
    the
    rap
    ist

    Is it "Pay therapist" or "Pay the rapist"?

    This is why they invented "auto-fit" to boxes and columns, and it's called "Word wrap", not "Letter wrap", it wraps whole words. You want it to wrap letters, from words.

    It will look horrible using it for anything that has actual volume to it. (Which is why programs don't do it.)
    I see y
    ou went
    to the s
    tore fo
    r groce
    ries.
    Just wanted to point out that there are programs that WILL do this. Desktop publishing programs that are fitting text to column widths will do this. They prefer to fiddle with the spacing between words, but if a word must be split up then there is a way to do that in written English: The hyphen.

    Interestingly, this is akin to the line continuation character in VB, as it is a character that means 'this continues on the next line', though in VB, it is that the line of logic continues on the next line, while in written English it means that the word continues on the next line. Note that it solves the first example, because there is no ambiguity as to which parts of the word go together when you use a hyphen to connote word continuation.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width