Did Call-Form get deprecated?

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Post Reply
JOCerner
Posts: 3
Joined: Mon Nov 12, 2018 3:35 pm

Did Call-Form get deprecated?

Post by JOCerner » Fri Sep 13, 2019 10:33 am

I'm watching the mutli-form GUI demonstration here: https://www.youtube.com/watch?v=SdaLaGReNk0

My projects do not include a "Call-Childform_psf" function. I only have "Show-ChildForm_psf". If Call-Form has been removed, how do I get values from my child form to my main form?

User avatar
jvierra
Posts: 13717
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Did Call-Form get deprecated?

Post by jvierra » Fri Sep 13, 2019 10:38 am

That was changed years ago and you are apparently watching a very old video.
Only the name has changed. Everything else is the same Just use "Show" instead of "Call".

JOCerner
Posts: 3
Joined: Mon Nov 12, 2018 3:35 pm

Re: Did Call-Form get deprecated?

Post by JOCerner » Fri Sep 13, 2019 10:49 am

Hey jvierra,

How do I get return values from my child form then? Main form has:

Code: Select all

$menuOptionLogin_Click = {
	#TODO: Place custom script here
	if ((Show-LoginForm_psf) -eq 'OK')
	{
		$usernameFromForm = $LoginForm_UserNameTextBox
		$PasswordFromForm = $LoginForm_passwordTextBox
		$TicketTextBox.Text = "$usernameFromForm,$PasswordFromForm"
	}
}
Childform just has two textboxes and an "Ok" button. Clicking "ok" doesn't seem to do anything.

Also is there any newer documentation? I've been reading: http://info.sapien.com/index.php/guis/g ... ects-work/

User avatar
jvierra
Posts: 13717
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Did Call-Form get deprecated?

Post by jvierra » Fri Sep 13, 2019 11:14 am

To get return values just pass an object reference that can be assigned with the values.

Returns from a form have nothing to do with the name of the function. Call or Show versions cannot return any value and the form object will not exist after the form is closed. Sapien assigns variables based on the name of the control.

If you build a new childform project then all will work. Start there because it is clear that you have done something in your code that has damaged the way the project works.

Create a new multiform project and add a textbox to the childform. After the button add the following:

[System.Windows.Forms.MessageBox]::Show($ChildForm_textbox1)

So it looks like this:

Code: Select all

$buttonCallChildForm_Click={
	#TODO: Place custom script here
	if((Show-ChildForm_psf) -eq 'OK'){
		[System.Windows.Forms.MessageBox]::Show($ChildForm_textbox1)
	}
}

User avatar
jvierra
Posts: 13717
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Did Call-Form get deprecated?

Post by jvierra » Fri Sep 13, 2019 11:15 am


JOCerner
Posts: 3
Joined: Mon Nov 12, 2018 3:35 pm

Re: Did Call-Form get deprecated?

Post by JOCerner » Fri Sep 13, 2019 12:05 pm

I created a new project. When I rename "ChildForm", the on-click function breaks. I named it back and it works again. Trying this in my main project it broken even after renaming it. I'm going to open up the code and see where it snapped.

User avatar
jvierra
Posts: 13717
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Did Call-Form get deprecated?

Post by jvierra » Fri Sep 13, 2019 12:16 pm

How did you rename the form? If you use the "rename" menu item then it will work.

User avatar
jvierra
Posts: 13717
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Did Call-Form get deprecated?

Post by jvierra » Fri Sep 13, 2019 12:35 pm

TO e more explicit. To rename any control or form correctly right-click on the form or control and select "rename" from the menu. This will rename the object and all references to the object in the whole project.

When learning forms be slow and careful. Forms are complex collections of objects and the rules are not obvious. PSS makes working with these much easier but can be a challenge to anyone without previous experience working with an IDE tool.

I suggest opening the PSS documentation (Help tool tab - left side - Product Manual) and reading it from the beginning. Don't read like it is a training manual. Read it to get the structure and capabilities of the product. In the end you will be able to reference it to get the details of things you want to do. Once you are familiar with the product and its usage/feature then all will become much easier. PSS is a very rich, deep and sophisticated IDE along the lines of Visual Studio. It is built using the Visual Studio development and customization SDK. The techniques and methods are based on Windows standards for a GUI tool and on the basic operations used in Visual Studio to optimize the development process. Without any IDE experience you must use the product manual to become familiar with how to use the product.

Yes - dump the PS1 file and review it carefully. I recommend printing the PS1 the first time and sitting somewhere quiet with a glass of wine or your favorite beverage and looking over the code very carefully. It will become an invaluable exercise as you proceed with the product. Trying to understand this on a video screen will not work as well.

In the end the product generates very predictable code and files. Everything in the IDE adjusts the parameters of this code generation. Actions either navigate the code or change the code. Some actions override things displayed in the "properties" editor. Some properties, when directly edited, do not update the overall code (form and control rename is one).

Understanding much of the PSS product also depends on your programming experience, PowerShell experience and your knowledge of Windows Forms (WinForms).

Here is a good place to learn about Winforms - https://docs.microsoft.com/en-us/dotnet ... dows-forms

Post Reply