Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QB64 Phoenix Edition v3.4.0 Released!
#33
Write a function that does word-wrap, set a limit of number of characters, use CHR$(13) + CHR$(10) as the soft breaker, and use that as return value to the "message". This is something that could affect the "_MESSAGEBOX" also. What I used to prefer instead of "_MESSAGEBOX" was a contribution from somebody in the Purebasic forums writing such a dialog from scratch, but using the text-entry "gadget" with scrollbars to place the "message". The advantage of it was being able to select all of it quickly and copy it to the clipboard. The problem was, when the user didn't like all the text selected...

EDIT: This is what I did in Purebasic. Should work in v6 and on Linux as well.
Code: (Select All)
Procedure MessageWindow(Titel.s, Text.s)
    xwidth = 320
    xheight = 160
    ewindow = OpenWindow(#PB_Any, 0, 0, xwidth, xheight, Titel, #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If ewindow
        pip = 0
        Repeat
            pip = FindString(Text, "|", pip + 1)
            If pip
                If Mid(Text, pip + 1, 1) = "0"
                    ch = Val(Mid(Text, pip + 2, 3))
                    If ch = 124: ch = 1: EndIf
                    If ch
                        Text = Left(Text, pip - 1) + Chr(ch) + Mid(Text, pip + 5)
                    EndIf
                EndIf
            EndIf
        Until pip = 0
        Text = ReplaceString(Text, "|", Chr(13) + Chr(10))
        Text = ReplaceString(Text, #SOH$, "|")
        ewindowcontent = StringGadget(#PB_Any, 0, 0, xwidth, xheight - 32, Text, #PB_String_ReadOnly | #ES_MULTILINE | #PB_String_BorderLess | #WS_VSCROLL | #WS_HSCROLL)
        okbut = ButtonGadget(#PB_Any, xwidth / 2 - 60, xheight - 28, 120, 28, "OK")
        Repeat
            ev = WaitWindowEvent()
            If (ev = #PB_Event_Gadget) And (EventGadget() = okbut)
                Break
            EndIf
        Until ev = #PB_Event_CloseWindow
        CloseWindow(ewindow)
    EndIf
EndProcedure

This one allows the user to use "|" pipe symbol to indicate the soft-returns. I did this years ago so I'm not sure how to put a pipe as part of the message...
Reply


Messages In This Thread
RE: QB64 Phoenix Edition v3.4.0 Released! - by mnrvovrfc - 11-05-2022, 08:54 PM



Users browsing this thread: 10 Guest(s)