Visual Designer Demo Problems

Everything else that doesn't fall into one of the other PB categories.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Visual Designer Demo Problems

Post 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
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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 

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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.
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post 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 
Please correct my english
http://purebasic.developpez.com/
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Thanks Your a Lifesaver!
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: Visual Designer Demo Problems

Post 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
Post Reply