[Windows Programming] Add Name to List button not works

Just starting out? Need help? Post your questions and find answers here.
User avatar
JamieVanCadsand
User
User
Posts: 34
Joined: Sun Jun 24, 2018 12:28 pm
Location: Holland

[Windows Programming] Add Name to List button not works

Post by JamieVanCadsand »

Hey Windows Programmers...,

I try to create an script, the user can typ an name via an input_requester...
So this is my script, written in PB5.6.2:

Code: Select all

Procedure Window()
  
  If OpenWindow(0, 0, 0, 128, 128, "List View", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    
    If CreateToolBar(0, WindowID(0))
      
      ToolBarStandardButton(0, #PB_ToolBarIcon_New)
      
      ListViewGadget(0, 0, 0, 128, 64)
      
    EndIf
    
  EndIf
  
EndProcedure


Procedure HandleEvents()
  
  Repeat
    
    Select WaitWindowEvent()
        
      Case #PB_Event_Menu
        
        Select EventMenu()
            
          Case 0
            
            Input$ = InputRequester("Add", "Name to List", "Name")
            
            If Input$
              
              AddGadgetItem(0, 1, Input$)
              
            EndIf
            
        EndSelect
        
      Case #PB_Event_CloseWindow
        
        Quit = 1
        
    EndSelect
    
  Until Quit = 1
  
EndProcedure

Window()
HandleEvents()

Just if you run this script, via the new file icon (or new name to list called) button, you can typ an name to the list.
But if you activate your name input via the 'InputRequester', the names had not be to the list...

So run this script and you should see thad it isn't works...So if you can find the problen, pleace
correct my code and post it here...

So can you correct my code pleace, thanks for help...
Jamie.
Jagermeister
Enthusiast
Enthusiast
Posts: 136
Joined: Thu Nov 15, 2012 11:38 pm
Location: Los Angeles

Re: [Windows Programming] Add Name to List button not works

Post by Jagermeister »

Code: Select all

Procedure Window()
 
  If OpenWindow(0, 0, 0, 128, 128, "List View", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   
    If CreateToolBar(0, WindowID(0))
     
      ToolBarStandardButton(0, #PB_ToolBarIcon_New)
     
      ListViewGadget(0, 0, 24, 128, 64) ; had to move it down Y a bit
     
    EndIf
   
  EndIf
 
EndProcedure


Procedure HandleEvents()
 
  Repeat
   
    Select WaitWindowEvent()
       
      Case #PB_Event_Menu
       
        Select EventMenu()
           
          Case 0
           
            Input$ = InputRequester("Add", "Name to List", "Name")
           
            If Input$
             
              AddGadgetItem(0, -1, Input$) ; -1 to add items to the end of the list
             
            EndIf
           
        EndSelect
       
      Case #PB_Event_CloseWindow
       
        Quit = 1
       
    EndSelect
   
  Until Quit = 1
 
EndProcedure

Window()
HandleEvents()
User avatar
JamieVanCadsand
User
User
Posts: 34
Joined: Sun Jun 24, 2018 12:28 pm
Location: Holland

Re: [Windows Programming] Add Name to List button not works

Post by JamieVanCadsand »

Jagermeister wrote:

Code: Select all

Procedure Window()
 
  If OpenWindow(0, 0, 0, 128, 128, "List View", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   
    If CreateToolBar(0, WindowID(0))
     
      ToolBarStandardButton(0, #PB_ToolBarIcon_New)
     
      ListViewGadget(0, 0, 24, 128, 64) ; had to move it down Y a bit
     
    EndIf
   
  EndIf
 
EndProcedure


Procedure HandleEvents()
 
  Repeat
   
    Select WaitWindowEvent()
       
      Case #PB_Event_Menu
       
        Select EventMenu()
           
          Case 0
           
            Input$ = InputRequester("Add", "Name to List", "Name")
           
            If Input$
             
              AddGadgetItem(0, -1, Input$) ; -1 to add items to the end of the list
             
            EndIf
           
        EndSelect
       
      Case #PB_Event_CloseWindow
       
        Quit = 1
       
    EndSelect
   
  Until Quit = 1
 
EndProcedure

Window()
HandleEvents()
Thanks... i think it help!.
Jamie.
Post Reply