I am writing a input program for work and want to be able to control the lenght of text on a line in a multiline Stringgadget - 12 characters ( This is so when it is printed out it should look the same as on the screen ) and make it insert a shifted return and to drop the cursor to the beginning of the next line for more text to be entered or stop and tell the user that there is no more space to enter data ( 60 characters max has been reached. )
This is what I have so far but I am now stuck. I have taken out the input part as the rest of it is far to long to put here and is not related to the stringgadget problem.
Code: Select all
Global Well.l
Global Sample.l
Global Dim Paste.s(96)
OpenWindow(0,0,0,1010,660,"Grid input",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
Well = 0    
For Column = 1 To 12
  For Row = 1 To 8
    Well = B + Row
    StringGadget(Well,(Column * 80)-50,(Row * 75)-55,80,75,"", #ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT) 
    SendMessage_(GadgetID(well),#EM_SETREADONLY,1,0)
  Next Row
  B = B + 8
Next Column
For t= 1 To 12
  TextGadget(100+t,(t*80)-15,5,40,15,Str(t))
Next t  
For t = 1 To 8
  TextGadget(112+t,10,(t*75)-25,15,75,Chr(64+t))
Next t
CreateMenu(0, WindowID(0))
  MenuTitle("Edit")
    MenuItem(1,"Copy")
    MenuItem(2,"Paste")
    MenuItem(3,"Clear Grid")
  MenuTitle("Print")
    MenuItem(4,"Print") 
  MenuTitle("Quit")
  MenuTitle("About")
   
Repeat
  Event = WaitWindowEvent()
  
  Select Event
    
    Case #PB_Event_Gadget
      
      Select EventGadget()
        
        Case 1 To 96
          sample = EventGadget()
          Quit = 0
          C = (Sample/8)+1
          R.f = ((sample/8)-Int(Sample/8))*8
          If R = 0
            R = 8
          EndIf  
          
          Select EventType()
            
            Case #PB_EventType_Focus
              SetGadgetColor(sample,#PB_Gadget_BackColor,RGB(251, 149, 4))
              OpenWindow(1,0,0,150,150,"",#PB_Window_ScreenCentered|#PB_Window_BorderLess )
                StickyWindow(1,1)
                SetWindowColor(1,RGB(234,56,34)) 
                CreateGadgetList(WindowID(1))
                  StringGadget(500, 35, 10, 80, 75,"",#ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT)
                  ButtonGadget(501, 80,120, 60, 20,"Enter")
                  ButtonGadget(502, 10,120, 60, 20,"Clear")
                  TextGadget  (503, 10, 95,135,20,"Use Shift Enter for new line.")
                  SetGadgetColor(503,#PB_Gadget_BackColor,RGB(234,56,34))
                  SetGadgetColor(503,#PB_Gadget_FrontColor,RGB(255, 255, 0))
                  
                  SetGadgetText(500,GetGadgetText(Sample))
                  SetActiveGadget(500)
              Repeat
                EventID = WaitWindowEvent()
                If EventID = #PB_Event_Gadget
                  
                  Select EventGadget()
                    
                    Case 501
                      If Len(GetGadgetText(500)) > 0 And Len(GetGadgetText(500)) < 61
                        SetGadgetText(Sample,GetGadgetText(500))
                        SetGadgetColor(sample,#PB_Gadget_BackColor,GetSysColor_(#COLOR_3DFACE))
                      Else
                        MessageRequester(" INPUT ERROR ! ","Incorrect Input. " + Chr(10) + Chr(10) + "Must be between 1 and 60 characters long.",0)
                        SetGadgetColor(sample,#PB_Gadget_BackColor,GetSysColor_(#COLOR_3DFACE))
                      EndIf     
                      Quit = 1
                   
                   Case 502
                     SetGadgetText(Sample,"")
                     SetGadgetColor(sample,#PB_Gadget_BackColor,GetSysColor_(#COLOR_3DFACE))
                     Quit = 1
                       
                  EndSelect
                  
                  EndIf
                  NR.s = Chr(10) + Chr(13) 
                  If EventID = 256
                    If GetActiveGadget() = 500
                      K = K + 1
                      If K > 11
                        T$ = GetGadgetText(500) 
                        t$ =  t$ + Chr(16) + Chr(13)+ Chr(10)
                        SetGadgetText(500,T$)
                        K=0
                      EndIf  
                    EndIf
                  EndIf
              Until quit = 1
              CloseWindow(1)
          EndSelect
          
      EndSelect
      
    Case #PB_Event_Menu
      Select EventMenu()
        
        Case 1
          SetClipboardText("")
          NR.s = Chr(13) + Chr(10)
          Copy.s = ""
          For t = 1 To 96
            Copy.s = Copy.s + GetGadgetText(t) + NR.s
          Next t
          SetClipboardText(Copy.s)
          
        Case 2
          NumberofSamples.l =1
          Text$ = GetClipboardText()
          ClipData$ = GetClipboardText()
          For t = 1 To Len(ClipData$)
            A$ = Mid(ClipData$, t, 1)
            If A$ = Chr(13) 
              A$ = ""
              NumberofSamples.l = NumberofSamples.l + 1
              B$ = ""
              DataColumn = 1
            EndIf
            If A$ = Chr(10) 
              A$ = ""
            EndIf
            B$ = B$ + A$
            Paste.s(NumberofSamples.l) = B$
          Next t
          For t= 1 To 96
          SetGadgetText(t,Paste.s(t))
          Next t
          
        Case 3
          For t= 1 To 96
            SetGadgetText(t,"")
          Next t
          
       Case 4
        ;Gosub PrintSheet   
              
      EndSelect
    
  EndSelect
  
Until Event = #PB_Event_CloseWindow
End
Hope someone can help me with this.
Regards
Leo

