Caption is a variable Wishlist

You need some new stunning features ? Tell us here.
SniffTheGlove
Enthusiast
Enthusiast
Posts: 122
Joined: Sat Nov 19, 2011 6:51 pm

Caption is a variable Wishlist

Post 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.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Caption is a variable Wishlist

Post by Polo »

Sounds like a good idea, will try to had this!
SniffTheGlove
Enthusiast
Enthusiast
Posts: 122
Joined: Sat Nov 19, 2011 6:51 pm

Re: Caption is a variable Wishlist

Post by SniffTheGlove »

Thanks Polo :-)
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Caption is a variable Wishlist

Post 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.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Caption is a variable Wishlist

Post by Polo »

Yes that was what I intended to add :)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Caption is a variable Wishlist

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
SniffTheGlove
Enthusiast
Enthusiast
Posts: 122
Joined: Sat Nov 19, 2011 6:51 pm

Re: Caption is a variable Wishlist

Post by SniffTheGlove »

What ever works will make me happy. :D
Post Reply