Label

Started by SeaVipe, March 07, 2020, 05:55:28 PM

Previous topic - Next topic

SeaVipe

Hi Paul, is there a limit to the number of characters that can be displayed in a label control? To clarify, I appear to have hit a limit of approximately 300 characters.
Clive Richey

Paul Squires

Hi Clive, I don't see anything in the code that would limit a Label to the amount of characters that you are seeing. I use CWSTR to hold the text data and that is a dynamic unicode string type. Maybe the display area of your label is not large enough and the text is getting clipped?
Paul Squires
PlanetSquires Software

Pierre Bellisle

You might also try to increase the height. You may be a victim of a word-wrap...

SeaVipe

#3
Thanks, Paul and Pierre, Here is the code:

Sub Show_Help()
    'Dim s as String * 500 = " Priority:" + Chr(13,10)
    'Dim s as String = " Priority:" + Chr(13,10)
    'Dim s as WString * 500 = " Priority:" + Chr(13,10)
    Dim s as CWSTR = " Priority:" + Chr(13,10)
    s += Chr(13,10)
    s += " A - Imminent Tasks. Must be completed by Due Date." + Chr(13,10)
    s += " B - Tasks that are weather dependent." + Chr(13,10)
    s += " C - Tasks that must be done but with a changeable Due Date." + Chr(13,10)
    s += " D - Tasks with long-term but still limited time constraints." + Chr(13,10)
    s += " E - Tasks that have no time constraints." + Chr(13,10)
    s += " F - Finished. Completed Tasks."
    frmMain.Label1.Text = s

    Dim as String x = Trim(frmMain.Label1.Text)
    ? Len(Trim(s)), Len(Trim(x))    End Sub
'' ______________________________________________________________________________________
''
Function frmMain_Button1_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
    Show_Help()
    Function = 0
End Function

The attached image is the result after Button1.Click. (The console displays the numbers 305 and 305) As you can see, 1/2 of line 'E' and all of line 'F' are missing. This is a new 2.0.7 project with just a Label and a Button.
Clive Richey

Paul Squires

Sorry Clive - this is my oversight. The Label is Owner Draw. Prior to outputting the text to the drawing rectangle I was assigning it to a WSTRING * MAX_PATH variable. Obviously using MAX_PATH is not large enough and you see that in your example. I have changed the code to the following and it is now working perfectly.

                     dim as CWSTR wszCaption = AfxGetWindowText( lpdis->hwndItem )
                     DrawText( memDC, wszCaption.sptr, -1, Cast(lpRect, @rcText), lFormat )

I hope to upload a new package tomorrow. I have some help files to write and finish a visual designer sample project.
Paul Squires
PlanetSquires Software

SeaVipe

Clive Richey