import form designed by VD

Just starting out? Need help? Post your questions and find answers here.
didier69
User
User
Posts: 15
Joined: Wed Apr 30, 2008 11:24 am
Location: Lyon (France)

import form designed by VD

Post by didier69 »

Hi,

I make a try with purebasic, and I would like to try to generate a little form and then assign command to a button.

Is there an example somewhere where I can see how I can mix a form generated by visual designer tool and the editor with a callback function for the button ?

Thanks.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: import form designed by VD

Post by gnozal »

didier69 wrote:Hi,

I make a try with purebasic, and I would like to try to generate a little form and then assign command to a button.

Is there an example somewhere where I can see how I can mix a form generated by visual designer tool and the editor with a callback function for the button ?

Thanks.
The visual designer generates ready to use code : Project -> Generate source (check 'include event loop').

Source (GeneratedIncludeFile.pb+GeneratedMainFile.pb merged) :

Code: Select all

;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Button_0
EndEnumeration


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 223, 216, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_0))
      ButtonGadget(#Button_0, 20, 30, 90, 30, "")
      
    EndIf
  EndIf
EndProcedure

Open_Window_0()

Repeat ; Start of the event loop
  
  Event = WaitWindowEvent() ; This line waits until an event is received from Windows
  
  WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
  
  GadgetID = EventGadget() ; Is it a gadget event?
  
  EventType = EventType() ; The event type
  
  ;You can place code here, and use the result as parameters for the procedures
  
  If Event = #PB_Event_Gadget
    
    If GadgetID = #Button_0
      ;
      ; ********************************************
      ;
      ; -------------------> Event for your button
      ;
      ; Write your code for the button here :
      ;
      MessageRequester("Event", "You clicked the button !")
      ;
      ;
      ; ********************************************
      ;
    EndIf
    
  EndIf
  
Until Event = #PB_Event_CloseWindow ; End of the event loop

End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
didier69
User
User
Posts: 15
Joined: Wed Apr 30, 2008 11:24 am
Location: Lyon (France)

Post by didier69 »

Thanks for the tips. It works :). I continue my tests.
Post Reply