Gadget Not Initialized. Don't understand why..

Just starting out? Need help? Post your questions and find answers here.
MPrimal
User
User
Posts: 15
Joined: Fri Nov 11, 2005 4:54 pm
Location: England

Gadget Not Initialized. Don't understand why..

Post by MPrimal »

This sort of follows on from my previous question about Windows not opening. I managed to solve that and can now get all the windows to open without any problems.

On one of the windows there is a ListIconGadget which is set up when the window is created. Whenever I try to add information to that Listicongadget using the AddGadgetItem command I get the following error reported:

[ERROR] #Gadget not Initialized

The window setup was created using PurevisionXP (latest version). The window in defined in the file "DB_Windows.pb", the labels are Globallised in the file "DB_Constants.pb" - both created by Purevision.

Here are clips of the code.

"DB_Contants.pb"

Code: Select all

;Window_NewEntry1
 Global Gadget_TFDB_Main_But_PrevEnt
  Global Gadget_TFDB_Main_But_NewEnt
  Global Gadget_TFDB_Main_But_EditEnt
  Global Gadget_TFDB_Main_But_DelEnt
  Global Gadget_TFDB_Main_But_NextEnt
  Global Gadget_TFDB_Main_But_LastEnt
  Global Gadget_TFDB_Main_But_FrstEnt

  Global Gadget_NewEntry1_Text_SelChar
  Global Gadget_NewEntry1_Char_Select
  Global Gadget_NewEntry1_ANE1_Confirm
  Global Gadget_NewEntry1_ANE1_Cancel
  Global Gadget_NewEntry1_Image_TFDB1
  Global Gadget_NewEntry1_Image_TFDB2
"DB_Windows.pb"

Code: Select all

Procedure.l Window_NewEntry1()
  Window_NewEntry1=OpenWindow(#PB_Any,101,63,743,656,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible,"Add New Entry - Character Selection")
  If Window_NewEntry1
    If CreateGadgetList(WindowID(Window_NewEntry1))
      Gadget_NewEntry1_Text_SelChar=TextGadget(#PB_Any,280,15,180,30,"Select Character",#PB_Text_Center|#PB_Text_Border)
        PVDynamic_AddColorGadget(Gadget_NewEntry1_Text_SelChar,8388863,0)
        SetGadgetFont(Gadget_NewEntry1_Text_SelChar,UseFont(LoadFont(#PB_Any,"Arial",14,260)))
      Gadget_NewEntry1_Char_Select=ListIconGadget(#PB_Any,210,50,310,595,"Character",200,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        AddGadgetColumn(Gadget_NewEntry1_Char_Select,1,"Series",100)
      Gadget_NewEntry1_ANE1_Confirm=ButtonGadget(#PB_Any,625,615,85,25,"Confirm")
      Gadget_NewEntry1_ANE1_Cancel=ButtonGadget(#PB_Any,25,615,85,25,"Cancel Entry")
      Gadget_NewEntry1_Image_TFDB1=ImageGadget(#PB_Any,575,125,128,96,UseImage(Image_NewEntry1_Image_TFDB1))
      Gadget_NewEntry1_Image_TFDB2=ImageGadget(#PB_Any,25,125,128,96,UseImage(Image_NewEntry1_Image_TFDB2))
      HideWindow(Window_NewEntry1,0)
      ProcedureReturn WindowID()
    EndIf
  EndIf
EndProcedure
Finally this is how I try to set the ListIconGadget up:

"DB.pb"

Code: Select all

Case Gadget_DB_Main_But_NewEnt
          If NE_Window_Open=0
            NewEntry1(1)
              For Count =1 To 28
                Text$= Character (Count,1)+Chr(10)+Character (Count,2)
                AddGadgetItem(Gadget_NewEntry1_Char_Select, -1, Text$)
              Next Count
            Window_NewEntry1()
            NE_Window_Open=1
           EndIf
The button responds fine but as soon as it hits the AddGadgetItem command it throws up the error.

Any help would be greatly received.

Andy
Real Power Comes From Sharing It With Those Who Think They Have It All.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Code: Select all

Case Gadget_DB_Main_But_NewEnt
          If NE_Window_Open=0
            NewEntry1(1)
              For Count =1 To 28
                Text$= Character (Count,1)+Chr(10)+Character (Count,2)
                AddGadgetItem(Gadget_NewEntry1_Char_Select, -1, Text$)
              Next Count
            Window_NewEntry1()  ;<--  Window Opened after accessing Gadget
            NE_Window_Open=1
           EndIf

Your code above shows you are trying to access the ListIconGadget before the Window is actually created.
Gadgets do not exist until the Window Procedure is called and everything is created.
Image Image
Post Reply