Exit confirmation popup -how can I add this?

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.
This topic is 1 year and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
FBGITGROUP
Posts: 3
Last visit: Fri Nov 03, 2023 11:45 am

Exit confirmation popup -how can I add this?

Post by FBGITGROUP »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: Powershell Studio 2022 5.8.213
Operating system: Windows 11 Pro
PowerShell version(s): 5.1.22621.963

*** Please add details and screenshots as needed below. ***
I have a form which works exactly as I need, the only thing I want to add to it, at least right now, is a confirmation on exit popupbox.
I have an exit button in the bottom right corner of the form, it is isolated from all other buttons and controls but I have had people complain they have accidentally clicked it and would like a confimation box to prevent accidental closure.
I don't seem to be able to work out how to do this, I don't have any visible output, there is no box showing any text when users have the form run so I would need to have this confirmation appear as a popup. I tried adding
  1. $confirmation = Read-Host "Are you Sure You Want To Exit?"
  2. if ($confirmation -eq 'y')
before the
  1. $Form.Close()
line but all this does is halt the form opening, if I run it in ISE I get it asking this question and waiting for a response before opening, then closing, the form.
So is it possible to make a click on the exit button trigger a popup confirmation box?

DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Exit confirmation popup -how can I add this?

Post by Alexander Riedel »

[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 1 year and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked