Page 1 of 1

Visual Designer Demo Problems

Posted: Fri Jul 02, 2004 7:57 pm
by Dark Mars Software
I am using the demo version of PureBASIC with the Visual designer. The visual designer has generated the following code that works within Visual designer but if i use it outside of that like the main ide, the debug window appears then disappears and nothing happens. For some strange reason it works within VS but not in the main IDE. Can someone explain why? heres the generated code:

Code: Select all

; PureBasic Visual Designer v3.90 build 1360


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Text_0
  #Text_1
  #Button_0
  #Sales
  #Commission
EndEnumeration


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 322, 189, 227, 142,  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Commission Manager")
    If CreateGadgetList(WindowID())
      TextGadget(#Text_0, 10, 30, 40, 20, "Sales:$")
      TextGadget(#Text_1, 10, 60, 70, 20, "Commission:$")
      ButtonGadget(#Button_0, 100, 100, 50, 20, "Calculate")
      StringGadget(#Sales, 90, 30, 80, 20, "0", #PB_String_Numeric)
      GadgetToolTip(#Sales, "Enter Sales Amount Here")
      StringGadget(#Commission, 90, 60, 80, 20, "0", #PB_String_ReadOnly | #PB_String_Numeric)
      GadgetToolTip(#Commission, "Your Commission Appears Here")
      
    EndIf
  EndIf
EndProcedure

Posted: Fri Jul 02, 2004 8:34 pm
by localmotion34

Code: Select all

; PureBasic Visual Designer v3.90 build 1360 


;- Window Constants 
; 
Enumeration 
  #Window_0 
EndEnumeration 

;- Gadget Constants 
; 
Enumeration 
  #Text_0 
  #Text_1 
  #Button_0 
  #Sales 
  #Commission 
EndEnumeration 


Procedure Open_Window_0() 
  If OpenWindow(#Window_0, 322, 189, 227, 142,  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Commission Manager") 
    If CreateGadgetList(WindowID()) 
      TextGadget(#Text_0, 10, 30, 40, 20, "Sales:$") 
      TextGadget(#Text_1, 10, 60, 70, 20, "Commission:$") 
      ButtonGadget(#Button_0, 100, 100, 50, 20, "Calculate") 
      StringGadget(#Sales, 90, 30, 80, 20, "0", #PB_String_Numeric) 
      GadgetToolTip(#Sales, "Enter Sales Amount Here") 
      StringGadget(#Commission, 90, 60, 80, 20, "0", #PB_String_ReadOnly | #PB_String_Numeric) 
      GadgetToolTip(#Commission, "Your Commission Appears Here") 
      
    EndIf 
  EndIf 
EndProcedure 

;FORGOT TO CALL THE OPENWINDOW PROCEDURE Visual designer just generates procedures unless you specify
;in the preferences to include the EVENT LOOP

Open_Window_0() 

;FOR GOT THE EVENT LOOP
Repeat 
   
  Select WaitWindowEvent() 
    Case  #PB_Event_CloseWindow 
      End 
    Case  #PB_Event_Gadget 
      Select EventGadgetID() 
        
      EndSelect 
      
  EndSelect 
  
ForEver 

Posted: Fri Jul 02, 2004 9:04 pm
by Dark Mars Software
Thank You, now how do i make it so that when the user clicks on the Calculate button the commission field is 10% of the sales field? Sorry to ask so many questions but i'm a newbie to PureBASIC and it seems a little complicated.

Posted: Fri Jul 02, 2004 9:20 pm
by Comtois
add something like this

Code: Select all

Case  #PB_Event_Gadget 
      Select EventGadgetID() 
        Case #Button_0
          SetGadgetText(#Commission,StrF(Val(GetGadgetText(#Sales))*0.1,2))
        
EndSelect 

Posted: Fri Jul 02, 2004 9:23 pm
by Dark Mars Software
Thanks Your a Lifesaver!

Re: Visual Designer Demo Problems

Posted: Fri Jul 02, 2004 11:13 pm
by NoahPhense
..and just so you know, from inside the VD, click Project (dropdown)
then check the box, Include event loop. And it will creae your code like
such.. automatically: When you're done creating your GUI, just go
back to the Project menu, and click: PureBasic Editor

Code: Select all

; PureBasic Visual Designer v3.90 build 1361

IncludeFile "GeneratedIncludeFile.pb"

Open_Window_0()

Repeat
  
  Event = WaitWindowEvent()
  
  If Event = #PB_EventGadget
    
    ;Debug "WindowID: " + Str(EventWindowID())
    
    GadgetID = EventGadgetID()
    
    If GadgetID = #Button_0
      Debug "GadgetID: #Button_0"
      
    ElseIf GadgetID = #Button_1
      Debug "GadgetID: #Button_1"
      
    ElseIf GadgetID = #Button_2
      Debug "GadgetID: #Button_2"
      
    ElseIf GadgetID = #String_0
      Debug "GadgetID: #String_0"
      
    EndIf
    
  EndIf
  
Until Event = #PB_EventCloseWindow

End
;
...and the include file

Code: Select all

; PureBasic Visual Designer v3.90 build 1361


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Button_0
  #Button_1
  #Button_2
  #String_0
EndEnumeration


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 324, 293, 402, 107,  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "New window ( 0 )")
    If CreateGadgetList(WindowID())
      ButtonGadget(#Button_0, 5, 5, 105, 20, "")
      ButtonGadget(#Button_1, 5, 30, 105, 20, "")
      ButtonGadget(#Button_2, 5, 55, 105, 20, "")
      StringGadget(#String_0, 145, 30, 225, 25, "")
      
    EndIf
  EndIf
EndProcedure
- np