Page 1 of 1

import form designed by VD

Posted: Wed Apr 30, 2008 11:28 am
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.

Re: import form designed by VD

Posted: Wed Apr 30, 2008 12:25 pm
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

Posted: Wed Apr 30, 2008 12:38 pm
by didier69
Thanks for the tips. It works :). I continue my tests.