AddGadgetItem() Problem

Windows specific forum
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

AddGadgetItem() Problem

Post by RichardL »

Hi,
I've just started using PureBasic and am having a problem with adding strings to a ListViewGadget.

.
. other gadgets made here
.
ListViewGadget(08,100, PanelH.w+50, 250, 050) creates the gadget.
AddGadgetItem(8,0,"fred")

The gadget appears on my display and the following line adds "fred" to it.

The same line will not work when called from with a procedure.
The debugger reports "#Gdget object not initialised"

Have I overlooked something obvious?

RichardL
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

Its probably some fault in your code somewhere as it seems to work for me. Try this code

Code: Select all

Procedure Proc()
  AddGadgetItem(8,-1,"Dum de dum dum")
EndProcedure

OpenWindow(0,0,0,400,400,#PB_Window_SystemMenu | #PB_Window_ScreenCentered,"test")
CreateGadgetList(WindowID(0))
ListViewGadget(8,10,10,380,350)
ButtonGadget(0,10,370,380,20,"Press this")

Repeat
ev=WaitWindowEvent()
If ev=#PB_Event_Gadget
  If EventGadgetID()=0
    Proc()
  EndIf
EndIf
Until ev=#PB_Event_CloseWindow
Thats working for me, so I'd guess you've made a mistake in yours. If you post the code people will try to help spot the problem for you.
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post by RichardL »

It was obvious after all...

I had a call that wrote to the ListViewGadget inside my initialising code and that ran before the gadgets were created. Sorry to waste your time!

Lack of coffer error in this morning.

However, it does throw up another problem:

How do I assign a non-proportional font to the gadget without using an API call... I'm specifically tryng to acheive a finished program without API calls and have almost finished. I want my nicely formatted data to appear in columns.


RicahrdL
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

How do I assign a non-proportional font to the gadget without using an API call

Code: Select all

Procedure Proc()
  AddGadgetItem(8,-1,"Dum de dum dum")
EndProcedure
OpenWindow(0,0,0,400,400,#PB_Window_SystemMenu | #PB_Window_ScreenCentered,"test")
CreateGadgetList(WindowID(0))
ListViewGadget(8,10,10,380,350)
SetGadgetFont(8, LoadFont(1, "Courier", 10))
ButtonGadget(0,10,370,380,20,"Press this")
Repeat
ev=WaitWindowEvent()
If ev=#PB_Event_Gadget
  If EventGadgetID()=0
    Proc()
  EndIf
EndIf
Until ev=#PB_Event_CloseWindow
:)
--Kale

Image
Post Reply