Page 1 of 1

[Windows Programming] Add Name to List button not works

Posted: Wed Jul 11, 2018 7:57 pm
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.

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

Posted: Wed Jul 11, 2018 8:15 pm
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()

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

Posted: Thu Jul 12, 2018 9:08 am
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.