Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
#Include "Win32API.inc"
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
Local temp$
temp$ = "Now is the time for all good men to come to the aid of the party!"
? "xxx" + WordWrap(temp$,40)
End If
End Function
Function WordWrap(ByVal temp$, MaxChar As Long) As String
Local result$,tmp$
Do
Split Word temp$, MaxChar To tmp$, temp$ 'tmp$ has <= MaxChar, temp$ has all else
If Len(tmp$) = 0 Then Function = temp$ : Exit Loop 'needed in case no word break found by MaxChar in string
result$ = result$ + $CrLf + LTrim$(tmp$) 'accumulate tmp$ until there's no more temp$
Loop While Len(temp$)
Function = LTrim$(result$,$CrLf) + IIf$(Len(temp$),$CrLf + LTrim$(temp$),"")
End Function
'gbs_01366
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm