Page 33 of 45

Re: Form Designer 5.00 beta 3

Posted: Mon Sep 24, 2012 5:37 pm
by Polo
And as I replied on the french forum, if you check "Caption is a variable" it'll be treated as a variable...
Again, if you want to use enumeration, just uncheck #PB_Any (gadget per gadget or in preferences)

Re: Form Designer 5.00 beta 3

Posted: Mon Sep 24, 2012 6:03 pm
by Polo
To make sure everyone is using the latest version I've quickly compiled a new one:

http://www.gdpcomputing.co.uk/formdesigner.html

Re: Form Designer 5.00 beta 3

Posted: Mon Sep 24, 2012 6:20 pm
by ts-soft
Polo wrote:To make sure everyone is using the latest version I've quickly compiled a new one:
But you should always use the same name :wink:
Windows: FormDesigner.exe, Form Designer.exe and Visuell Designer.exe :?:

Re: Form Designer 5.00 beta 3

Posted: Mon Sep 24, 2012 6:24 pm
by Polo
Oops. :oops:

Re: Form Designer 5.00 beta 3

Posted: Mon Sep 24, 2012 6:30 pm
by Golfy
Polo wrote:And as I replied on the french forum, if you check "Caption is a variable" it'll be treated as a variable...
Again, if you want to use enumeration, just uncheck #PB_Any (gadget per gadget or in preferences)
:oops:
I'm really a dumb : 3 options could sink me :lol:
Sorry about annoyance :|

By the way, how to use the EventProcedure field (the list is empty) ? I would to add some action like below...

Code: Select all

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
    Case #PB_Event_SizeWindow
    	ResizeGadgetsWindow_0()
  EndSelect
EndProcedure

InitWindow_0()
Repeat
	event = WaitWindowEvent(20)
	Window_0_Events(event)
Until event = #PB_Event_CloseWindow

Re: Form Designer 5.00 beta 3

Posted: Mon Sep 24, 2012 7:33 pm
by luciano
I downloaded the latest version. I believe there is a problem with gadget positions when there is the toolbar (at least in windows):

Code: Select all

Global Window_1

Global Panel_0

Global Img_0, Img_1

Enumeration #PB_Compiler_EnumerationValue
  #Toolbar_0
  #Toolbar_1
EndEnumeration

UsePNGImageDecoder()

Img_0 = LoadImage(#PB_Any,"C:\ZZZZ_Ardi_Go\Explorer\16x16-free-toolbar-icons\png\73.png")
Img_1 = LoadImage(#PB_Any,"C:\ZZZZ_Ardi_Go\Explorer\16x16-free-toolbar-icons\png\25.png")

Procedure InitWindow_1()
  Window_1 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
  CreateToolbar(0, WindowID(Window_1))
  ToolBarImageButton(#Toolbar_0,ImageID(Img_0))
  ToolBarImageButton(#Toolbar_1,ImageID(Img_1))
  Panel_0 = PanelGadget(#PB_Any, 10, 0, 580, 370)
  AddGadgetItem(Panel_0, -1, "Tab 1")
  CloseGadgetList()
EndProcedure

Procedure Window_1_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
EndProcedure

InitWindow_1()

Repeat
  event = WaitWindowEvent()
  Window_1_Events(event)
ForEver
[img]
http://s10.postimage.org/41m595qax/test.jpg
[/img]

Re: Form Designer 5.00 beta 3

Posted: Mon Sep 24, 2012 7:40 pm
by Polo
Fixed, thanks.

Re: Form Designer 5.00 beta 3

Posted: Mon Sep 24, 2012 11:35 pm
by Warmonger
Probably would be beneficial to add the #PB_Event_CloseWindow event to your event loop. Plus the "generate event loop" option should remove this procedure when its not checked. As it is part of the event loop. This way if people only decide to design the form in the designer they don't end up with a piece of the event loop.

Code: Select all

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
    Case #PB_Event_CloseWindow
      End
  EndSelect
EndProcedure

Re: Form Designer 5.00 beta 3

Posted: Tue Sep 25, 2012 5:10 am
by wilbert
Another option would be to let the event procedure return true / false.

Code: Select all

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
    Case #PB_Event_CloseWindow
      ProcedureReturn #True
  EndSelect
  ProcedureReturn #False
EndProcedure
That way you can repeat until Window_0_Events(event) = #True and still do some cleanup or closing of files afterwards.

Re: Form Designer 5.00 beta 3

Posted: Tue Sep 25, 2012 5:51 am
by Warmonger
wilbert wrote:Another option would be to let the event procedure return true / false.

Code: Select all

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
    Case #PB_Event_CloseWindow
      ProcedureReturn #True
  EndSelect
  ProcedureReturn #False
EndProcedure
That way you can repeat until Window_0_Events(event) = #True and still do some cleanup or closing of files afterwards.
That would not work, as the #PB_Event_CloseWindow is to represent the close program event. It should be a simple End, what you are referring to is a custom event that only pertains to your use. Usually when everyone uses the #PB_Event_CloseWindow flag its usually followed by a End. Especially for GUI applications, the only way it would return a value is if Polo added in code prediction for applications that don't even exist yet, for example a application that I will code tomorrow, or maybe next week. He will need to know the exact structure of your code with all data types etc. Its impossible for him to know code that doesn't exist, let alone write this tool to predict future code its 100% impossible to do. So it would end up staying the way it is before it would ever return a value. Tho if he adds the proper End to it, all you would have to do is change it out with a procedurereturn. Instead of having to type the case flag, and then what to do. The idea is to structure the event loop properly, not structure it to one persons needs.

Re: Form Designer 5.00 beta 3

Posted: Tue Sep 25, 2012 5:56 am
by KJ67
Wilberts version works well indeed, that is a template that I've been using for years.
Just doing 'End' with no cleaning up, flushing data to disks from arrays and lists etc. could be bad.

In general: I would recommend a single shutdown code instead of having uncontrolled End's all over.

Re: Form Designer 5.00 beta 3

Posted: Tue Sep 25, 2012 5:57 am
by Warmonger
KJ67 wrote:Wilberts version works well indeed, that is a template that I've been using for years.
Just doing 'End' with no cleaning up, flushing data to disks from arrays and lists etc. could be bad.

In general: I would recommend a single shutdown code instead of having uncontrolled End's all over.
Like stated above it would be a up-most terrible idea to have it return a value not everyone is going to use. Take a look at this code and tell me how it would not work for you.

Code: Select all

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
    Case #PB_Event_CloseWindow
      CleanUp() ;Add Your Cleanup
      End
  EndSelect
EndProceduree
Keep in mind 90% of the people when debugging and using the generated code for the first time are going to want that control to do what its made for. And that purpose is exiting the program, having to go into the process manager every time just to debug a form would be just too much. Also remember that your cleanup function isn't going to look nothing like mine, let alone look anything like anybody else's. Tho one thing is for sure once you click the exit control, you intend for the program to eventually end.

Re: Form Designer 5.00 beta 3

Posted: Tue Sep 25, 2012 6:08 am
by KJ67
For me the loop before the GUI would look something like;

Code: Select all

InitCode()
InitWindow_0()
Repeat:Until Window_0_Events(WaitWindowEvent()) = #True
;CloseWindow(XYZ)
ShutDownGracefully()
The use of End would risk causing lost data. Any application that handles more complicated data will have to consider the use of a shutdown & save function - not just pull the plug.

Re: Form Designer 5.00 beta 3

Posted: Tue Sep 25, 2012 6:36 am
by wilbert
Warmonger wrote:Tho one thing is for sure once you click the exit control, you intend for the program to eventually end.
True, but almost never immediately.
Both the PureBasic IDE and the Form Designer are coded using PureBasic itself. Assume you did a lot of hard work on the project you are working on, forget to save the changes and hit the close button. Most people would be very unhappy if it just exists without asking if the modified files need to be saved.
As for your other comment, what's wrong with returning a value if not everybody is using it. A procedure like ButtonGadget returns a value but most users just ignore it.

Re: Form Designer 5.00 beta 3

Posted: Tue Sep 25, 2012 6:43 am
by Warmonger
wilbert wrote:
Warmonger wrote:Tho one thing is for sure once you click the exit control, you intend for the program to eventually end.
True, but almost never immediately.
Both the PureBasic IDE and the Form Designer are coded using PureBasic itself. Assume you did a lot of hard work on the project you are working on, forget to save the changes and hit the close button. Most people would be very unhappy if it just exists without asking if the modified files need to be saved.
As for your other comment, what's wrong with returning a value if not everybody is using it. A procedure like ButtonGadget returns a value but most users just ignore it.
So your suggesting he code in support for everyone's own cleanup functions? You do understand they are different with every single program that was ever written. Like posted before you just call your cleanup before the end. The end is universal among every single application, as it will look exactly the same in every program any of you will write. An example how is this...

Code: Select all

Procedure CleanUp()
  ;Do Some Stuff
  End
EndProcedure

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
    Case #PB_Event_CloseWindow
      CleanUp() ;Add Your Cleanup
  EndSelect
EndProcedure
...different from this.

Code: Select all

Procedure CleanUp()
  ;Do Some Stuff
EndProcedure

Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
    Case #PB_Event_CloseWindow
      CleanUp() ;Add Your Cleanup
      End
  EndSelect
EndProcedure
Why is this exactly hard for you guys to understand. :shock: