It is currently Sun May 26, 2013 10:43 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: How Do you Remove Buttons?
PostPosted: Tue Oct 25, 2011 10:00 pm 
Offline
User
User

Joined: Sat Nov 08, 2008 8:19 pm
Posts: 94
I have made GUI window with 4 Buttons.

IF I click on new Game then I would like have new Screen which mean I need to remove the buttons but the questions I would like to ask is How?


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Tue Oct 25, 2011 10:10 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jan 21, 2011 8:25 am
Posts: 549
Use FreeGadget().

_________________
Image
ImageImageImage
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Tue Oct 25, 2011 10:35 pm 
Offline
User
User

Joined: Sat Nov 08, 2008 8:19 pm
Posts: 94
Thanks Shied

I got another questions...

What code should I do if I click on Button then new Screen come on...

for example

IF ButtonGadget()=true
FREEGADGET()
Make Tab Screen
Endif


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Tue Oct 25, 2011 11:28 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 4715
Location: Berlin - Germany
Use Container for your Screens:
Code:
Enumeration ; gadgets
  #con_SF
  #btn_SF_1
  #btn_SF_2
  #btn_SF_3
  #con_SS
  #btn_SS_1
EndEnumeration

OpenWindow(0, #PB_Ignore, #PB_Ignore, 340, 100, "")

ContainerGadget(#con_SF, 0, 0, WindowWidth(0), WindowHeight(0))
ButtonGadget(#btn_SF_1, 10, 10, 150, 30, "First on Screen First")
ButtonGadget(#btn_SF_2, 170, 10, 150, 30, "Secont on Screen First")
ButtonGadget(#btn_SF_3, 100, 60, 150,30, "Next Screen")
CloseGadgetList()
ContainerGadget(#con_SS, 0, 0, WindowWidth(0), WindowHeight(0))
ButtonGadget(#btn_SS_1, 60, 30, 200, 30, "Go Back to Screen First")
CloseGadgetList()
HideGadget(#con_SS, #True)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #btn_SF_1 : Debug "First on Screen First"
        Case #btn_SF_2 : Debug "Second on Screen First"
        Case #btn_SF_3 : HideGadget(#con_SF, #True) : HideGadget(#con_SS, #False)
        Case #btn_SS_1 : HideGadget(#con_SS, #True) : HideGadget(#con_SF, #False)
      EndSelect
  EndSelect
ForEver

_________________
PureBasic 5.11 | Windows 7 SP1 (x64) | Mageia 3 (x64) | RealSource

The use of EnableExplicit is free of charge and avoids errors.


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Wed Oct 26, 2011 12:00 am 
Offline
User
User

Joined: Sat Nov 08, 2008 8:19 pm
Posts: 94
Thanks ts-soft

That good to learn from and I do love Select case as it is so simple :)


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Wed Oct 26, 2011 12:12 am 
Offline
User
User

Joined: Sat Nov 08, 2008 8:19 pm
Posts: 94
This is what I have done so far

Code:
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Button_0
  #Button_1
  #Button_2
  #Button_3
  #Text_0
EndEnumeration

;- Fonts
Global FontID1
FontID1 = LoadFont(1, "@Meiryo UI", 28)

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 627, 148, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_TitleBar )
    If createGadgetlist(WindowID(#Window_0))
      ButtonGadget(#Button_0, 190, 70, 190, 40, "NEW GAME")
      ButtonGadget(#Button_1, 190, 120, 190, 40, "LOAD GAME")
      ButtonGadget(#Button_2, 190, 170, 190, 40, "OPTIONS")
      ButtonGadget(#Button_3, 190, 220, 190, 40, "EXIT")
 
      SetGadgetFont(#Text_0, FontID1)
     
    EndIf
  EndIf
EndProcedure

Repeat
  Select WaitWindowEvent()   ; << WHY Error?
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Button_0: HideGadget(#Button_1, #True) : HideGadget(#Button_2, #False): HideGadget(#Button_3, #True)
      EndSelect
  EndSelect
ForEver


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Wed Oct 26, 2011 8:06 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 684
Location: Cologne / Germany
Swos2009 wrote:
Code:
  Select WaitWindowEvent()   ; << WHY Error?

Without calling Open_Window_0() you have no window.
Without having a window, WaitWindowEvent() will
throw an error.

Greetings ... Kiffi

_________________
Sorry for my weird english


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Wed Oct 26, 2011 6:59 pm 
Offline
User
User

Joined: Sat Nov 08, 2008 8:19 pm
Posts: 94
Should I do this?

Code:
Repeat
  Select #Window_0
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Button_0: HideGadget(#Button_1, #True) : HideGadget(#Button_2, #False): HideGadget(#Button_3, #True)
      EndSelect
  EndSelect
ForEver


:?:


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Wed Oct 26, 2011 7:02 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 684
Location: Cologne / Germany
Code:
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Button_0
  #Button_1
  #Button_2
  #Button_3
  #Text_0
EndEnumeration

;- Fonts
Global FontID1
FontID1 = LoadFont(1, "@Meiryo UI", 28)

Procedure Open_Window_0()
 
  If OpenWindow(#Window_0, 627, 148, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_TitleBar )
   
    ButtonGadget(#Button_0, 190, 70, 190, 40, "NEW GAME")
    ButtonGadget(#Button_1, 190, 120, 190, 40, "LOAD GAME")
    ButtonGadget(#Button_2, 190, 170, 190, 40, "OPTIONS")
    ButtonGadget(#Button_3, 190, 220, 190, 40, "EXIT")
   
    SetGadgetFont(#Text_0, FontID1)
   
  EndIf
 
EndProcedure

Open_Window_0() ; <<< paste this

Repeat
  Select WaitWindowEvent()   ; << no error anymore
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Button_0: HideGadget(#Button_1, #True) : HideGadget(#Button_2, #False): HideGadget(#Button_3, #True)
      EndSelect
  EndSelect
ForEver


Greetings ... Kiffi

_________________
Sorry for my weird english


Top
 Profile  
 
 Post subject: Re: How Do you Remove Buttons?
PostPosted: Wed Oct 26, 2011 8:40 pm 
Offline
User
User

Joined: Sat Nov 08, 2008 8:19 pm
Posts: 94
Thanks Kiffi and now I understand how it work :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye