Page 1 of 1

Caption is a variable Wishlist

Posted: Fri Sep 19, 2014 11:01 pm
by SniffTheGlove
Hello Polo et al,

Is it possible to modify the Open Window Procedure that the Form Designer auto generates. I ask if it's possible to add an extra parameter into the procedure call

Current output from Form Designger. I have "Caption as a variable" selected with the variable WindowTitle.s

Code: Select all

Procedure OpenAboutWindow(x = 0, y = 0, width = 180, height = 90)
  AboutWindow = OpenWindow(#PB_Any, x, y, width, height, WindowTitle.s, #PB_Window_SystemMenu)
  OKButton = ButtonGadget(#PB_Any, 40, 50, 100, 25, "OKButtony")
EndProcedure
Now with EnableExplicit I have to create a Global declaration for WindowTitle.s so that the procedure can access the variable. I don't like Globals much so if I can call the openwindow procedure and specify the string that would be great from my main.pb file.
main.pb

Code: Select all

OpenAboutWindow(x = 45, y = 60, width = 180, height = 90, "My About Page")
aboutwindow.pbf

Code: Select all

Procedure OpenAboutWindow(x = 0, y = 0, width = 180, height = 90,WindowTitle.s)
  AboutWindow = OpenWindow(#PB_Any, x, y, width, height, WindowTitle.s, #PB_Window_SystemMenu)
  OKButton = ButtonGadget(#PB_Any, 40, 50, 100, 25, "OKButtony")
EndProcedure
So the Form Designer takes your variable that you supply to "Caption as a variable" and puts it into the OpenWindow call and puts the variable into the Procedure call.

I hope you understand what I mean.

Re: Caption is a variable Wishlist

Posted: Sat Sep 20, 2014 8:42 am
by Polo
Sounds like a good idea, will try to had this!

Re: Caption is a variable Wishlist

Posted: Sat Sep 20, 2014 4:38 pm
by SniffTheGlove
Thanks Polo :-)

Re: Caption is a variable Wishlist

Posted: Tue Sep 23, 2014 9:54 am
by Fred
IMHO, you don't need another flag, we could just add the title as parameter with the default value as set in the IDE:

Code: Select all

Procedure OpenAboutWindow(x = 0, y = 0, width = 180, height = 90, WindowTitle$ = "Your title")
  AboutWindow = OpenWindow(#PB_Any, x, y, width, height, WindowTitle$, #PB_Window_SystemMenu)
  OKButton = ButtonGadget(#PB_Any, 40, 50, 100, 25, "OKButtony")
EndProcedure
You can also use SetWindowTitle() to change the title right after the window creation.

Re: Caption is a variable Wishlist

Posted: Tue Sep 23, 2014 4:28 pm
by Polo
Yes that was what I intended to add :)

Re: Caption is a variable Wishlist

Posted: Tue Sep 23, 2014 10:10 pm
by IdeasVacuum
I think it best to keep the generated code as simple as possible and not try to be the answer to the meaning of life. I'm sure I am not the only one who uses the Designer to design the form layout, then modify the code to my style.

Re: Caption is a variable Wishlist

Posted: Wed Sep 24, 2014 8:04 am
by SniffTheGlove
What ever works will make me happy. :D