|
Post by grovesy on Aug 31, 2004 12:12:02 GMT
Hi Guys, yes its me again!
Is it possible to have one window (thats hidden to start with) then if the user presses a button (keyhit(30) for example) it shows the window with a list. But if the user presses a different button (keyhit(31) for example) the same window opens but displays a different list!
I'm doing this to save the number of different windows I have to create.
So effectively what im asking is, is it possible to have one window but change the list box contents?
Cheers
|
|
|
Post by WendellM on Sept 2, 2004 4:51:11 GMT
I'm no expert, but here's a quick example (adapted from Example_AddItems.bb) of how something like that could work:
Include "XSTART.BB"
Graphics 800,600,16,2
GUI_GFXSETUP()
;Make a window, but don't open it, so it starts hidden MyWIN=GUI_WINDOW(-1,-1,300,300,"My Window")
;Make a list MyList=GUI_List()
;Add a tree list gadget TreeLst=GUI_TreeList(MyWin,10,50,200,150,MyList)
GUI_DEBUG=True
While Not FINISH SetBuffer BackBuffer():Cls GUI() Color 255,255,255:Text 0,0,EV_LIST_SELECT(MYLIST) If KeyHit(30) Then; "A" hit If GUI_WinStatus(MyWin) = 0 Then GUI_OPENWIN(MyWin);open window if not already open GUI_List_Clear(MYLIST);start with an empty list GUI_LIST_ADDITM(MYLIST,"Keyhit 30 ('A') Item 1") GUI_LIST_ADDITM(MYLIST,"Keyhit 30 ('A') Item 2") GUI_LIST_ADDITM(MYLIST,"Keyhit 30 ('A') Item 3") EndIf If KeyHit(31) Then; "S" hit If GUI_WinStatus(MyWin) = 0 Then GUI_OPENWIN(MyWin);open window if not already open GUI_List_Clear(MYLIST);start with an empty list GUI_LIST_ADDITM(MYLIST,"Keyhit 31 ('S') Item 1") GUI_LIST_ADDITM(MYLIST,"Keyhit 31 ('S') Item 2") GUI_LIST_ADDITM(MYLIST,"Keyhit 31 ('S') Item 3") EndIf
If EV_WIN_CLOSE(MYWIN) Or KeyDown(1) FINISH=True EndIf Text 0,30,EVENT\GAD_LMBHIT Flip Wend
End
|
|
|
Post by grovesy on Sept 2, 2004 12:05:53 GMT
Thanks Wendellm, I actually ended up working out my own way of doing it, and i think it is more effeciant than your code (no dissrespect meant)
Your code clears and re-writes the lists every time there called. My code sets up the different lists during setup and then just calls the relavent list.
Include "XSTART.BB"
Graphics 800,600,16,2
GUI_GFXSETUP()
;Make a window, but don't open it, so it starts hidden MyWIN=GUI_WINDOW(-1,-1,300,300,"My Window")
;List for A keyhit AList=GUI_List() GUI_LIST_ADDITM(AList,"Keyhit 30 ('A') Item 1") GUI_LIST_ADDITM(AList,"Keyhit 30 ('A') Item 2") GUI_LIST_ADDITM(AList,"Keyhit 30 ('A') Item 3")
;List for S keyhit SList=GUI_List() GUI_LIST_ADDITM(SList,"Keyhit 31 ('S') Item 1") GUI_LIST_ADDITM(SList,"Keyhit 31 ('S') Item 2") GUI_LIST_ADDITM(SList,"Keyhit 31 ('S') Item 3")
GUI_OPENWIN(MyWin) ;Create the window GUI_WINHIDE(MyWin) ;Then hide it
GUI_DEBUG=True
While Not FINISH SetBuffer BackBuffer():Cls
GUI()
Color 255,255,255:Text 0,0,EV_LIST_SELECT(MYLIST)
If KeyHit(30) Then; "A" hit ;Add AList gadget to the window GUI_SetList(ListBox,AList) GUI_WINSHOW(MyWin);open window if not already open EndIf
If KeyHit(31) Then; "S" hit ;Add SList gadget to the window GUI_SetList(ListBox,SList) GUI_WINSHOW(MyWin);open window if not already open End If
If EV_WIN_CLOSE(MYWIN) Or KeyDown(1) FINISH=True EndIf
Text 0,30,EVENT\GAD_LMBHIT
Flip
Wend
Hope someone finds this useful
Chris
I have edited this post with a new improved version! By the way, what does new and improved mean??? Surely you can't improve something thats new, and something can't be new if its improved!!! Just something for you to think about!
|
|