Plex 2E

  • 1.  Edit multiline - set size, line break after x characters and typing line

    Posted Nov 28, 2011 09:05 AM
    Dear all,

    I need (in a perfect scenario) to have a multiline text box to write, copy, paste and so on (therefore, several independent lines do not help), in which I can control the number of character written in each line, breaking to the next when the limit is reached. The text on this text box will later be copied into several records, with a maximum of x amount of characters per line.

    I have tried to control this with an multiline edit, where the text wraps automatically by setting horizontal scrolling to "no", which works fine if I ignore the fact that it wraps when the horizontal limit of the box is reached and not when the maximum allowed characters are reached (later I manually control the text break into lines of x character). I can resize the text box, but this will be static, every time a different size is needed, panel editing will be needed. Would be much better to have a parameter configuring the size and when opening the panel, the text box be resized to the configured width. Is it possible to set the width of a field at runtime? If yes, is it possible to do so in centimeters? Can't find anything in help...

    If not possible to set the size, is it possible to know the line where text is being typed on the multiline edit field? It is possible getting the current text, comparing to the old one, finding a different char and calculating the line, but this would probably take far to long processing and would not allow a fast typing with no pauses. Is there a fast way?

    If anyone has any idea or some advice on how to achieve the "perfect scenario", please advise. If not possible would be good to know as well. :)

    Thank you.

    Best regards,
    Nuno Dias


  • 2.  RE: Edit multiline - set size, line break after x characters and typing lin

    Posted Nov 28, 2011 10:08 AM
    oh my type of problem.

    Why do you need to control the number of characters per line? Could you control the number of characters in total added to the multiline by the user, then chop up the text into your required fixed length, being carefully to replace any hard returns, spaces etc with reserved characters. When you display from the DB you concat the fields together and finally subsitute out the reserved characters with your desired formating?

    RichTextBox activex might offer you greater control than the multiline

    I also go straight to WinWidgets Help to see what the controls are cable of using a little bit of source, ususally the MFC version supports what
    i have found and more

    Also there is a downloadable notes pattern provided by Roger Griffithwhich you should have a look at for some ideas.

    Great previous posting on Edge mentioning OBASE patterns with Text and PatternFactory free Note pattern


    Some pointers but i am hoping you got too close to the problem and concentrated to much on restricitng the size of each line. The total length of what is entered could be saved as a system value.


  • 3.  RE: Edit multiline - set size, line break after x characters and typing lin

    Posted Nov 29, 2011 05:39 AM
    First of all, thank you very much for your time and response.

    I need to have a place to edit text, where ideally the lines would have no more than a defined size (characters or centimeters) because the text will later be printed on a report with limited horizontal size. The text is stored in several record lines of a business entity and this is what causes the issue. Editing these lines in a grid is very limited, therefore we are creating a panel to do this, which later copies the lines of text to the records.
    This text is very important on the referred report and users would like to see it exactly as it will be printed. At the moment I have everything I need to achieve this, except the fact that the text box horizontal size is not flexible. I can build the panel with the correct size, but if for another situation the panel should have a different size it is not configurable. Is not a big deal, I was just looking for a way to do this better, with a configuration value. If I can set the panel horizontal size at runtime, after reading a parameter, would be great.
    I am a little short on time, will try to investigate the references you provided, but really the length change at runtime would be great and fast.

    Thank you again.

    Best regards,
    Nuno Dias


  • 4.  RE: Edit multiline - set size, line break after x characters and typing lin

    Posted Nov 29, 2011 04:22 AM
    I am now able to set the size of the panel using setwindowposition, and with the fix property of left and right on the text box, I can get somehow what I want. I now have another issue: the number of characters allowed in the size specified is different depending of what characters are typed, of the upper or lower case and so on. Is it possible to get the lines of the text box, without using code which needs to be built with the /clr option?

    Thanks in advance.

    Best regards,
    Nuno Dias


  • 5.  RE: Edit multiline - set size, line break after x characters and typing lin
    Best Answer

    Posted Nov 29, 2011 10:52 PM
    I have overcome this by using a monospaced font, I set the size of the text box with the size corresponding to the number of characters allowed to be written to each line.

    Best regards,
    Nuno Dias