Page 1 of 1

[SOLVED] Cannot get Button to appear on line 620 -- Thanks pjay!!

Posted: Wed Dec 31, 2025 7:57 am
by Randy Walker
trying to get my EDIT button to appear to the left of the textGadget that should appear just to the right. These two gadgets should appear side-by-side and there is no overlap so I have no idea why ButtonGadget line 620 will not appear:

Code: Select all

; adapted to work with PuTTY using 3-Way_CSM as template.
;  putty.exe -ssh 47.51.47.138 -P 4343 -l User -pw Secret!!
;- NOTE that -P MUST BE UPPERCASE for port number.

Global NewList sessions.s()
Global NewList TTLs.s()
Global rw.RECT
Global Dim m(10)
Global c, sessionsFolder$, ttl$, TeraTerm$, AppName.s, hWin.i, count, PuttyPath$, WinSCP$
Global WinSCPath$ = "C:\Accessories\3-Way_CSM"
Global PuttyPath$ = GetCurrentDirectory()+"putty.exe"
Global _mess, fontAria1.i, Specimen$, Kreturn.W
Global fontCuriorB.i = LoadFont(#PB_Default,"Curior",10,#PB_Font_Bold)
Global LastActionTime.q
If FileSize(PuttyPath$) = -1
  If FileSize("C:\Program Files\PuTTY\putty.exe") > 120
    PuttyPath$ = "C:\Program Files\PuTTY\putty.exe"
  ElseIf FileSize("C:\Program Files (x86)\PuTTY\putty.exe") > 120
    PuttyPath$ = "C:\Program Files (x86)\PuTTY\putty.exe"
  EndIf
EndIf
If FileSize(PuttyPath$) = -1
  PuttyPath$ = "C:\Accessories\3-Way_CSM\putty.exe"
EndIf
Debug PuttyPath$; If FileSize(PuttyPath$) = -1
;   PuttyPath$ = "C:\ONELOG\putty.exe"
; EndIf
;######################################################################################
;              DO NOT ALLOW MORE THAN ONE INSTANCE
;######################################################################################
Procedure.l EnumWindows(WindowHandle.l, Parameter.l)
  hWin.i = 0
  Title$ = Space(200)
  GetWindowText_(WindowHandle, @Title$, 200)
    If FindString(Title$, AppName, 1, #PB_String_NoCase ) <> 0
    HwndDebug = WindowHandle
    hWin.i = WindowHandle
    ;Debug title$, 2
    ;Debug AppName, 2
    ProcedureReturn #False
  Else
    ProcedureReturn #True
  EndIf
EndProcedure
AppName = "3-Way Client Session Manager"
EnumWindows_(@EnumWindows(), 0)
If hWin.i
  If IsIconic_(hWin.i)
    ShowWindow_(hWin.i, #SW_RESTORE)
    Delay(50) ; let Windows process the restore
  EndIf
  ShowWindow_(hWin.i, #SW_SHOW)
  BringWindowToTop_(hWin.i)
  ShowWindow_(hWin.i, #SW_RESTORE)
  FlashWindow_(hWin.i, #True)
  End
EndIf
#ALL = 3900
#DEBOUNCE_MS = 300
;{- Enumerations / DataSections
;{ Windows
Enumeration ; Windows
  #Window_0
  #Window_11
  #AboutWin
  #EDITWINDOW
EndEnumeration
#KeyDelete = 1
;#PB_Default,FontID(fontCuriorB.i))
Enumeration ; Gadgets
  #TTERM
  #PTTY
  #WinSCP
  #ListView_0
  #NAME
  #PSWD
  #SWOWP
  #IPAddress
  #PORT
  #PING
  #UserName
  #NoTTERM
  #User
  #SAVE
  #TITLE
  #ADDRESS
  #PORTno
  #USRPswdOK
  #SHOWpwd
  #PwdLBL
  #EDIT
  #SECRET
  #CONNECT
  #HELP
  #PickMacro
  #FOLDER
  #ABOUT
  #Text_1_11
  #Text_2_11
  #Text_3_11
  #Manual_11
  #More_11
  #AbtTXT
  #TTHome
  #PTYHome
  #WSCPHome
  #TTLIC
  #PTYLIC
  #WSCPLIC
  #OK
  #KEEP
  #RESTORE
  #EDITOR
EndEnumeration

Procedure CanActivate()
  Protected now.q = ElapsedMilliseconds()
  If now - LastActionTime < #DEBOUNCE_MS
    ProcedureReturn #False
  EndIf
  LastActionTime = now
  ProcedureReturn #True
EndProcedure

Procedure savenote()
  If CreateFile(4,Specimen$)
    s$ = Trim(GetGadgetText(#EDITOR))
    WriteString(4, s$)
    CloseFile(4)
  Else
    MessageRequester("Failed","Cannot open "+Specimen$)
  EndIf
EndProcedure  
Procedure LoadMacs()
    If FileSize(Specimen$) > 0
      Debug Specimen$
      If ReadFile(4,Specimen$)
        ;UseFile(4)
        Repeat
          s$ = ReadString(4,#PB_Ascii)
          AddGadgetItem(#EDITOR,-1,s$)
        Until Eof(4)
        CloseFile(4)
      Else
        MessageRequester("Failed","Cannot open "+Specimen$)
      EndIf 
    EndIf 
    If GetFocus_() <> GadgetID(#EDITOR)
      SetActiveGadget(#EDITOR)
    EndIf
EndProcedure
;- About window
OpenWindow(#AboutWin, 0, 0, 400, 175, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered |#PB_Window_Invisible)

; Define About text (valid PB syntax)
AboutText$ = "3-Way Client Session Manager v1.0  provided ''AS-IS''" + #CRLF$ + #CRLF$
AboutText$ + "Launches independent programs: Tera Term (TT), PuTTY & WinSCP." + #CRLF$
AboutText$ + "These Third-party programs are unmodified and remain property of their respective authors.  " ;+ #CRLF$
AboutText$ + "Not affiliated with or endorsed by them." + #CRLF$
AboutText$ + "Licenses and source links included in installation."
; Display About text (no invalid constants)
TextGadget(#AbtTXT, 20, 10, 380, 100, AboutText$)
; Hyperlink gadgets for each program
HyperLinkGadget(#TTHome, 20, 103, 100, 25, "Tera Term homepage", RGB(0,0,255), #PB_HyperLink_Underline)
HyperLinkGadget(#PTYHome, 20, 126, 100, 25, "PuTTY homepage", RGB(0,0,255), #PB_HyperLink_Underline)
HyperLinkGadget(#WSCPHome, 20, 149, 100, 25, "WinSCP homepage", RGB(0,0,255), #PB_HyperLink_Underline)
HyperLinkGadget(#TTLIC, 130, 103, 100, 25, "Tera Term license", RGB(0,0,255), #PB_HyperLink_Underline)
HyperLinkGadget(#PTYLIC, 130, 126, 100, 25, "PuTTY license", RGB(0,0,255), #PB_HyperLink_Underline)
HyperLinkGadget(#WSCPLIC, 130, 149, 100, 25, "WinSCP license", RGB(0,0,255), #PB_HyperLink_Underline)
; OK button
ButtonGadget(#OK, 260, 115, 80, 25, "OK")
Procedure ReallySetForegroundWindow(m_hWnd.I)
  ; http://www.drdobbs.com/184405755
  hOtherWnd.I = GetForegroundWindow_()
  ;
  ; get thread handles on our window and foreground window
  hMyThread.I = GetWindowThreadProcessId_(m_hWnd, 0)
  hOtherThread.I = GetWindowThreadProcessId_(hOtherWnd,0)
  ;
  ; attach our thread to foreground thread, take foreground, and detach threads
  AttachThreadInput_(hMyThread,hOtherThread, #True)
  SetForegroundWindow_(m_hWnd)
  AttachThreadInput_(hMyThread,hOtherThread, #False)
  ; AttachThreadInput_(hOtherThread,hMyThread, #True); backward set
  ; SetForegroundWindow_(m_hWnd)
  ; AttachThreadInput_(hOtherThread,hMyThread, #False)
  ;
  ; Now that our window "thread" has fisrt place in the queue...
  ; make sure our "window" is visible
  If IsIconic_(m_hWnd)
    ShowWindow_(m_hWnd,#SW_RESTORE)
  Else
    ShowWindow_(m_hWnd,#SW_SHOW)
  EndIf
  SetActiveWindow(GetDlgCtrlID_(m_hWnd))
  WaitWindowEvent()
  SetForegroundWindow_(m_hWnd)
EndProcedure 
Procedure Ping(IP$)
  url$="-n 1 "+IP$
  If InternetGetConnectedState_(0,0)=1 ; Only check further if modem is switched on.
    p=RunProgram("ping.exe",url$,"",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
    If p : While ProgramRunning(p) : o$+ReadProgramString(p) : Wend : CloseProgram(p) : EndIf
    If o$<>"" And FindString(o$,"(0% loss",1)>0 And FindString(o$,"Request timed out",1)=0 : Status=1 : EndIf
  EndIf
  ProcedureReturn Status
EndProcedure
Procedure ShowOrHidePass(StringGadget, activate = #True)
   Protected x,y,w,h,s.s
   x=GadgetX(StringGadget)
   y=GadgetY(StringGadget)
   w=GadgetWidth(StringGadget)
   h=GadgetHeight(StringGadget)
   s=GetGadgetText(StringGadget)
   FreeGadget(StringGadget)
   StringGadget(StringGadget,x,y,w,h,s,StringGadgetFlags)
   If activate: SetActiveGadget(StringGadget) :EndIf
   StringGadgetFlags ! #PB_String_Password
EndProcedure
Procedure TogglePassword(Gadget.i, State.i)
  
  If State
    SendMessage_(GadgetID(Gadget), #EM_SETPASSWORDCHAR, 0, 0)
    ResizeGadget(Gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore)
  Else
    SendMessage_(GadgetID(Gadget), #EM_SETPASSWORDCHAR, $2A, 0)
    ResizeGadget(Gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore)
  EndIf
  
EndProcedure
Procedure.s crypt(crypt$)   ; output job$
                            ;>>Protected crypt$
  job$ = ""
  If Len(crypt$)
    If Len(crypt$) & 1
      crypt$ = " " + crypt$
    EndIf
    Repeat
      byte1.B = Asc(Left(crypt$,1))
      byte2.B = Asc(Mid(crypt$,2,1))
      crypt$ = Mid(crypt$,3, #ALL)
      ;
      Repeat
        mask.B = (Random(30) + 31)   ; random seed For 3 byte packet
        c1.i = (byte1.B ! mask.B) + 14
        c2.i = (byte2.B ! (mask.B / 4)) - 4
      Until (c1.i > 32) And (c2.i > 32) And (c1.i < 127) And (c2.i < 127)
      ;
      byte1.B = c1.i
      byte2.B = c2.i
      ;
      ;mask.b = (mask.b) + (Random(1) * mask.b)
      If (mask.B & $FF) > 62
        mask.B = mask.B + (Random(1) )
      EndIf
      job$ = job$ + Chr(byte1.B) + Chr(mask.B) + Chr(byte2.B)
    Until crypt$ = ""
    ProcedureReturn job$
  EndIf
EndProcedure
Procedure.s DeCrypt(job$)
  Protected DeCrypt$
  Repeat
    byte1.B = Asc(Left(job$,1))
    mask.B = Asc(Mid(job$,2,1))
    byte2.B =  Asc(Mid(job$,3,1))
    ;
    If (mask.B > 63) Or (mask.B < 0)
      mask.B = (mask.B & 126) / 2
    EndIf
    byte1.B = (byte1.B - 14) ! mask.B       ;  "!" means XOR
    byte2.B = (byte2.B + 4) ! (mask.B >> 2)
    DeCrypt$ = DeCrypt$ + Chr(byte1.B) + Chr(byte2.B)
    job$ = Mid(job$,4,#ALL)
  Until job$ = ""
  DeCrypt$ = Trim(DeCrypt$)
  ProcedureReturn DeCrypt$
EndProcedure
Procedure MacroWindow()
  hWnd16 = OpenWindow(#EDITWINDOW, 100,100,500, 337, "Macro Editor", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_TitleBar |#PB_Window_Invisible)
  If hWnd16
    SetGadgetFont(#PB_Default,FontID(fontCuriorB.i))
    ButtonGadget(#KEEP,5,5,40,20,"Save")
    ButtonGadget(#RESTORE,60,5,50,20,"Reload")
    EditorGadget(#EDITOR, 5, 25, 490, 300) ; AddKeyboardShortcut(1,#PB_Shortcut_Return,2)
    SendMessage_(GadgetID(#EDITOR), #EM_SETTARGETDEVICE, #Null, 0)                 ; 0=wrap , 1up=linewidth , $FFFFFF(effectively)=wrapoff
                                                                                      ;AddKeyboardShortcut(1, #PB_Shortcut_Escape, #KB_Escape)
    AddKeyboardShortcut(#EDITWINDOW, #PB_Shortcut_Escape, 1)
    SendMessage_(GadgetID(#EDITOR), #EM_SETTARGETDEVICE, #Null, 0)                 ; 0=wrap , 1up=linewidth , $FFFFFF(effectively)=wrapoff
  EndIf
EndProcedure
MacroWindow()

;{- Enumerations / DataSections
;{ Windows
Enumeration
  #Window_0
  #Window_11
EndEnumeration
#KeyDelete = 1

;}
;{ Gadgets
Enumeration
  #TTERM
  #PTTY
  #WinSCP
  #ListView_0
  #NAME
  #PSWD
  #SWOWP
  #IPAddress
  #PORT
  #PING
  #UserName
  #NoTTERM
  #User
  #SAVE
  #TITLE
  #ADDRESS
  #PORTno
  #USRPswdOK
  #SHOWpwd
  #PwdLBL
  #MacroLabel
  #SECRET
  #CONNECT
  #HELP
  #PickMacro
  #FOLDER
  #ABOUT
  #Text_1_11
  #Text_2_11
  #Text_3_11
  #Manual_11
  #More_11
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
If FileSize("C:\Program Files (x86)\teraterm5\ttermpro.exe") > 1
  TeraTerm$ = "C:\Program Files (x86)\teraterm5\ttermpro.exe"
  Debug "Exe Path: "+TeraTerm$+CRLF$
Else
  If FileSize("C:\Program Files\teraterm5\ttermpro.exe") > 1
    TeraTerm$ = "C:\Program Files\teraterm5\ttermpro.exe"
    Debug "Exe Path: "+TeraTerm$+CRLF$
  Else
    MessageRequester("BIG PROBLEM", "Cannot find ttermPro.exe Client Application.", #MB_OK|#MB_ICONWARNING|#MB_SYSTEMMODAL)
  EndIf
EndIf

If FileSize(WinSCPath$+"\WinSCP.exe") > 1
  WinSCP$ = WinSCPath$+"\WinSCP.exe"
  Debug "Exe Path: "+WinSCP$+CRLF$
ElseIf FileSize("C:\Accessories\TT+P+WscpSM\winSCP.exe")
  WinSCP$ = "C:\Accessories\TT+P+WscpSM\winSCP.exe"
EndIf
buffer$=Space(512)
s$=""
;Home$ = "C:\ONELOG\"
sessionsFolder$ = GetEnvironmentVariable("AppData")+ "\teraterm5\"
n = FindString(buffer$,"Roaming",#PB_String_NoCase)-1
Debug "sessionsFolder ="+sessionsFolder$
Global Sessions$ = sessionsFolder$+"Sessions"
Global Sessions1$ = sessionsFolder$+"Sessions1"
Global Sessions2$ = sessionsFolder$+"Sessions2"
Procedure makebackups()
  Debug "Making BACKUPS"
  Debug "sessions$ = " + sessions$
  Debug "sessions2$ = " + sessions2$
  If FileSize(sessions2$) > 0
    DeleteFile(Sessions2$)
  EndIf
  RenameFile(Sessions1$,Sessions2$)
  Debug "sessions1$ = " + sessions1$
  If FileSize(sessions1$) > 0
    DeleteFile(Sessions1$)
  EndIf
  RenameFile(Sessions$,Sessions1$)
EndProcedure
Procedure Save()
  If CreateFile(0,Sessions$,#PB_Ascii)
    For n = 0 To count ; Loop thru entire list and save each kline in full.
      g$ = GetGadgetItemText(#ListView_0,n)
      ;                 If FindString(g$,Chr(9))
      ;                   g$ = StringField(g$,1,Chr(9))
      ;                 EndIf
      ;                 t$ = GetGadgetText(#NAME)
      ;                 If Left(g$,Len(t$)) = t$
      ;                   Debug "YEP WE SEE THIS ENTRY"
      ;                   g$ + Chr(9) + crypt(GetGadgetText(#SECRET))
      ;                 EndIf
      Debug g$
      WriteStringN(0,g$)
    Next n
    CloseFile(0)
  EndIf
EndProcedure
Procedure SortSessions()
  ;             For item = 0 To CountGadgetItems(#ListView_0)
  ;               SendMessage_(GadgetID(#ListView_0), #LB_ADDSTRING, 0, GetGadgetItemText(#ListView_0,0))
  ;               RemoveGadgetItem(#ListView_0,0)
  ;             Next
  count = CountGadgetItems(#ListView_0)
  If count
    Debug "we have items"
  Else
    Debug "No Items count"
  EndIf
  For n = 0 To count
    g$ = GetGadgetItemText(#ListView_0,n)
    If g$
      AddElement(sessions())
      sessions() = g$
    EndIf
  Next n
  SortList(Sessions(),#PB_Sort_Ascending)
  ClearGadgetItems(#ListView_0)
  ClearGadgetItems(#ListView_0)
  ClearGadgetItems(#ListView_0)
  If GetGadgetItemText(#ListView_0,0)+GetGadgetItemText(#ListView_0,1) = ""
    ForEach sessions()
      If Sessions()
        AddGadgetItem(#ListView_0,-1,sessions())
      EndIf
    Next
  Else
    Debug "Did not Clear List"
  EndIf
EndProcedure
Procedure Connect()
;                 param$ = "-ssh "+IP$+" -P "+PT$
;                 ;putty.exe -ssh 47.51.47.138 -p 4343 -l User -pw Secret!!
;                 RunProgram(PuttyPath$,param$,"") ;"/?")
;-Connect
  If GetGadgetState(#PTTY) = 1
    ;-------------------------
    ;  USE PUTTY MODE
    ;-------------------------
    ;n = ListSize(TTLs())
    n = 0
    IP$   = GetGadgetText(#IPAddress)
    Usr$  = GetGadgetText(#User)
    PW$   = GetGadgetText(#SECRET)
    Port$ = GetGadgetText(#PORT)
    Title$ = Chr(34)+Trim(GetGadgetText(#IPAddress))+" - "+Trim(GetGadgetText(#NAME))+Chr(34)
    If Port$ = ""
      Port$ = "22"
    EndIf
    ; Build PuTTY command line
    If GetGadgetState(#USRPswdOK) = 1 And PW$ <> ""
      ; Password available
      param$ = "-ssh " + IP$ + " -P " + Port$ + " -l " + Usr$ + " -pw " + Chr(34) + PW$ + Chr(34)+" -loghost "+Title$
    Else
      ; No password saved
      param$ = "-ssh " + IP$ + " -P " + Port$+" -loghost "+Title$
    EndIf
    Debug "PuTTY Params: " + param$
    RunProgram(PuttyPath$, param$, "")
  ElseIf GetGadgetState(#TTERM) = 1
    n = 0
    ForEach TTLs()  ; gad = 0 To n-1
      Debug m(n)
      Debug TTLs()
      ;For gad = 0 To n-1
      If GetGadgetState(m(n))
        ttl$ = TTLs()
        Debug ttl$+"<<<<<<<<"
        Break
      EndIf
      n +1
    Next
    Title$ = Chr(34)+Trim(GetGadgetText(#NAME))+" - TeraTerm"
    s$ = ""
    x$ = sessionsFolder$+ttl$
    Debug "This is the TTL File: "+x$
    If GetGadgetState(#USRPswdOK)
      s$ + GetGadgetText(#SECRET)
    EndIf
    If FileSize(x$) = 0
      x$ = ""
    EndIf
    Usr$ = GetGadgetText(#User)
    IP$ = GetGadgetText(#IPAddress)
    Debug IP$
    PT$ = GetGadgetText(#SECRET)
    If FT$ = ""
      ;                  IP$ = s$
      PT$ = "22"
    EndIf
    ;p$ =GetGadgetText(#IPAddress)+":"+GetGadgetText(#PORT)+" /ssh /2 /auth=password /user="+GetGadgetText(#User)+" /passwd="+Chr(34)+GetGadgetText(#SECRET)+Chr(34)
    p$ =GetGadgetText(#IPAddress)+":"+GetGadgetText(#PORT)+" /ssh /2 /auth=password /user="+GetGadgetText(#User)+" /passwd="+Chr(34)+GetGadgetText(#SECRET)+Chr(34)
    ;;ttermpro.exe 119.160.130.97:22 /ssh /2 /auth=password /user=myname /passwd="Srcamlbe"
    Debug x$
    ;title$ = Chr(34)+GetGadgetText(#NAME)+ " - TeraTerm"+Chr(34)
    If s$ ;Password?
      Debug "HAVE IT"
      param$ = " -ssh "+IP$+" -P "+PT$+" -l "+Usr$+" -pw "+s$
    Else
      Debug "DONT HAVE IT"
      param$ = "-ssh "+IP$+" -P "+PT$
    EndIf
    If x$
      p$ + " /m=" + x$
    EndIf
    Debug p$
    ;p$ = GetGadgetText(#IPAddress)+":"+GetGadgetText(#PORT) + " /F="+sessionsFolder$+"TERATERM.INI /m="+sessionsFolder$+"tterm.ttl /w="+GetGadgetText(#NAME)
    p$ + " /F="+sessionsFolder$+"TERATERM.INI /m=" +x$ + " /w="+title$
    Debug p$
    Exe = RunProgram(TeraTerm$,p$,"",#PB_Program_Open|#PB_Program_Read)
    ;Exe = RunProgram(PuttyPath$,param$,"") ;"/?")
  Else
    If CreateFile(9,WinSCPath$+"\winscp.ini")
      WriteStringN(9,"[Configuration]")
      WriteStringN(9,"DefaultProtocol=SFTP")
      WriteStringN(9,"DefaultPort=22")
      CloseFile(9)
    Else
      Debug "FUUUUUCK!!"
    EndIf
    s$ = ""
    x$ = sessionsFolder$+ttl$
    If GetGadgetState(#USRPswdOK)
      s$ + GetGadgetText(#SECRET)
    EndIf
    If FileSize(x$) = 0
      x$ = ""
    EndIf
    Usr$ = GetGadgetText(#User)
    IP$ = GetGadgetText(#IPAddress)
    Debug IP$
    PT$ = GetGadgetText(#SECRET)
    If FT$ = ""
      ;                  IP$ = s$
      PT$ = "22"
    EndIf
    ;p$ =GetGadgetText(#IPAddress)+":"+GetGadgetText(#PORT)+" /ssh /2 /auth=password /user="+GetGadgetText(#User)+" /passwd="+Chr(34)+GetGadgetText(#SECRET)+Chr(34)
    ;;ttermpro.exe 119.160.130.97:22 /ssh /2 /auth=password /user=myname /passwd="Srcamlbe"
    Debug x$
    ;title$ = Chr(34)+GetGadgetText(#NAME)+ " - TeraTerm"+Chr(34)
    If s$ ;Password?
      Debug "HAVE IT"
      param$ = " -ssh "+IP$+" -P "+PT$+" -l "+Usr$+" -pw "+s$
    Else
      Debug "DONT HAVE IT"
      param$ = "-ssh "+IP$+" -P "+PT$
    EndIf
    Debug Param$
    If x$
      p$ + " /m=" + x$
    EndIf ; sftp://username:password@ip_address:port
    ;p$ = GetGadgetText(#IPAddress)+":"+GetGadgetText(#PORT) + " /F="+sessionsFolder$+"TERATERM.INI /m="+sessionsFolder$+"tterm.ttl /w="+GetGadgetText(#NAME)
    ;p$ = " --username "+GetGadgetText(#User)+" --password "+ Chr(34)+s$+Chr(34) + "sftp://"+ IP$ +":"+PT$ +"/u"
    ;p$ = " sftp://"+GetGadgetText(#User)+":"+Chr(34)+s$+Chr(34)+"@"+IP$+":"+PT$
    p$ = " sftp://"+GetGadgetText(#User)+":"+s$+"@"+IP$+":"+PT$

    Debug WinSCP$+p$
    Exe = RunProgram(WinSCP$,p$,"",#PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
    ;Exe = RunProgram(PuttyPath$,param$,"") ;"/?")
    
  EndIf
EndProcedure
If ExamineDirectory(0, sessionsFolder$, "*.*")  
  While NextDirectoryEntry(0)
    If DirectoryEntryType(0) = #PB_DirectoryEntry_File
      file$ = DirectoryEntryName(0)
      If GetExtensionPart(file$) = "ttl"
        ttl+1
        AddElement(TTLs())
        TTLs() = DirectoryEntryName(0)
      EndIf
    EndIf
  Wend
  FinishDirectory(0)
  SortList(TTLs(),#PB_Sort_Ascending)
EndIf
fontAri8.i = LoadFont(#PB_Any,"Arial",8) 
fontAri12B.i = LoadFont(#PB_Any,"Arial",12,#PB_Font_Bold)
fontCur12B.i = LoadFont(#PB_Any,"Courier",12, #PB_Font_Bold)
fontAri8B.i = LoadFont(#PB_Any,"Arial",8,#PB_Font_Bold)
HWND11 = OpenWindow(#Window_11, 466, 203, 395, 284, "RightClick Help", #PB_Window_Invisible | #PB_Window_BorderLess) ; | $400000)
If HWND11
  SetGadgetFont(#PB_Default,FontID(fontAri8B.i))
  helpText11.W = EditorGadget(#Text_1_11, 0, 0, 94, 205,#PB_Editor_WordWrap)
  SetGadgetFont(#PB_Default,FontID(fontCur12B.i))
  SetGadgetFont(#PB_Default,FontID(fontAri8B.i))
  anyKey2xit11.W = TextGadget(#Text_3_11, -5,205, 403,23, "~  Press any key to close.  ~", #PB_Text_Center | #PB_Text_Border)
  SetGadgetFont(#PB_Default,FontID(fontAri8.i))
  manual11.W = ButtonGadget(#Manual_11, 15, 329, 55, 15, "Manual")
  more11.W = ButtonGadget(#More_11, 413, 329, 55, 15, "F1  More")
  SendMessage_(helpText11, #EM_SETTARGETDEVICE, #Null, 0) ; 0=wrap , 1up=linewidth , $FFFFFF(effectively)=wrapoff
  SendMessage_(helpText11, #EM_SETREADONLY, 1, 0) 
  SendMessage_(helpText11, #EM_SETBKGNDCOLOR, 0, RGB(250, 255, 175))
  HideGadget(#Manual_11, 1)
  HideGadget(#More_11, 1)
  SetWindowColor(#Window_11,0)
EndIf

;-READFILE Sessions

;-MAIN WINDOW
  If OpenWindow(#Window_0, 518, 325, 600, 337, "3-Way Client Session Manager - TT, PuTTY & WinSCP v1.0x64", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_Invisible)
    OptionGadget(#TTERM, 340, 15, 70, 20, "Tera Term")
    OptionGadget(#PTTY, 420, 15, 60, 20, "PuTTY")
    OptionGadget(#WinSCP, 485, 15, 95, 20, "WinSCP") ;<<wishful tghinking fo scp explorer solution
    ListIconGadget(#ListView_0, 10, 10, 285, 320,"Checkboxes provided below for use as check list.",400,#PB_ListIcon_CheckBoxes|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
    StringGadget(#NAME, 350, 40, 240, 32, "")
    IPAddressGadget(#IPAddress, 440, 70, 150, 28)
    StringGadget(#PORT, 515, 100, 70, 20, "22")
    StringGadget(#User, 385, 120, 200, 20, "hds", #PB_String_Password)
    StringGadget(#SECRET, 385, 140, 200, 20, "Secrets!!!", #PB_String_Password)
    ButtonGadget(#SAVE, 510, 190, 65, 25, "SAVE")
    TextGadget(#TITLE, 300, 48, 50, 20, "TITLE ", #PB_Text_Right)
    TextGadget(#ADDRESS, 355, 79, 80, 20, "ADDRESS ", #PB_Text_Right)
    TextGadget(#PORTno, 455, 100, 55, 20, "PORT# ", #PB_Text_Right)
    ButtonGadget(#CONNECT, 315, 310, 105, 25, "CONNECT")
    CheckBoxGadget(#USRPswdOK, 305, 160, 140, 20, "User/Pswd OK")
    CheckBoxGadget(#SHOWpwd, 465, 165, 140, 20, "Show Password")
    TextGadget(#PwdLBL, 310, 140, 75, 20, "Password")
    ButtonGadget(#EDIT,295,200,35,18,"EDIT>")
    TextGadget(#MacroLabel, 360, 200, 130, 20, "v Pick your TT Macro file. v");, #PB_Text_Border)
    ButtonGadget(#FOLDER, 450, 315, 140, 20, "Sessions Folder")
    ButtonGadget(#Help, 425, 310, 20, 20, " ? ")
    ButtonGadget(#PING, 300, 75, 35, 25, "ping")
    TextGadget(#UserName, 315, 120, 65, 20, "UserName")
    TextGadget(#NoTTERM, 330, 230, 200, 70, "Macro filees appear here if they exist AND you have installed Tera Term")
    ButtonGadget(#ABOUT, 540, 296, 50, 20, "About")
  SetGadgetState(#USRPswdOK,1)
  SetGadgetState(#PTTY,0)
  SetGadgetState(#TTERM,1)
  SendMessage_(GadgetID(#ListView_0), #LB_SETHORIZONTALEXTENT,1000, #Null)
  If FileSize(PuttyPath$) = -1
    DisableGadget(#PTTY,1)
    SetGadgetState(#TTERM,1)
  EndIf
  If FileSize(TeraTerm$) = -1
    DisableGadget(#TTERM,1)
    SetGadgetState(#PTTY,1)
  ElseIf TeraTerm$  ;  CREATE MACRO OPTION BUTTONS
    HideGadget(#NoTTERM,1)
    y = 200
    n = ListSize(TTLs())
    For m = 0 To 3
      Debug m
      SelectElement(TTLs(),m)
      y+20
      V = OptionGadget(#PB_Any,330,y,100,20,TTLs())
      Debug V
      m(m) = V
      If ttls() = "ttxterm.ttl"
        SetGadgetState(V,1)
      EndIf
    Next m
    Debug "--------------------"
    x = m
    y = 200
    For m = x To n-1
      Debug m
      If SelectElement(TTLs(),m)
        y+20
        If m > 3 And m < 8
          V = OptionGadget(#PB_Any,450,y,100,20,TTLs())
      Debug V
          m(m) = V
          n+1
          If ttls() = "ttxterm.ttl"
            SetGadgetState(V,1)
          EndIf
          Debug TTLs()
        Else
        EndIf
      EndIf
    Next m
  EndIf
EndIf
Debug "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
If FileSize(Sessions$) > 0
  If ReadFile(0,Sessions$,#PB_Ascii)
    Repeat
      Item$ = ReadString(0)
      c+1
      Debug item$
      If 1;item$
        AddGadgetItem(#ListView_0,-1,Item$)
      EndIf
    Until Eof(0)
    CloseFile(0)
  EndIf
EndIf
;-Call for SORT
HideWindow(#Window_0,0);-Call for SORT
SortSessions()
SetActiveWindow(0)
count = CountGadgetItems(#ListView_0)
;- MAIN loop
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
End
Written in PB 5.40 but also tested and failed in PB 6.21 on Windows 11 Pro.

Re: Cannot get Button to appear on line 620

Posted: Wed Dec 31, 2025 8:28 am
by Randy Walker
Totally Bizzare. If I replace line 620 with this the gadget appears as it should have anyway:
ButtonGadget(#PB_Any,305,200,35,18,"EDIT>")
Makes no sense that #PB_Any should have any affect.

Re: Cannot get Button to appear on line 620

Posted: Wed Dec 31, 2025 9:04 am
by pjay
You have conflicting gadget enumeration blocks - #EDIT = 20 in the first block & #MacroLabel = 20 in the second.

Re: Cannot get Button to appear on line 620

Posted: Wed Dec 31, 2025 9:24 am
by Randy Walker
pjay wrote: Wed Dec 31, 2025 9:04 am You have conflicting gadget enumeration blocks - #EDIT = 20 in the first block & #MacroLabel = 20 in the second.
You were so correct pjay. eliminating that conflict fixed the problem.
THANKS pjay!!!!!! ;!: ;!: ;!: ;!: