GUI Forms MessageBox How to insert html

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 5 years and 7 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
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: GUI Forms MessageBox How to insert html

Post by hrlarsen »

Thanks jvierra.
That was a big help.

I have some problems now.
1. How do I change the background color off $webbrowser1?

2. How do I insert 1 button center screen in the box when clicked open in normal PC browser.

3. How do I Insert 1 text link open in normal PC browser.
<a href="https://www.google.com">test google</a>
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI Forms MessageBox How to insert html

Post by jvierra »

1. You have to do it in HTML.
2. http://www.w3schools.com
3. What? That is how.
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: GUI Forms MessageBox How to insert html

Post by hrlarsen »

Okay thanks
I have found a solution for color part a test:
<body style="background-color:red;">
I do have a 1-2 second delay, for some strange reason.
Where the box is
"white"
before it takes the red color.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI Forms MessageBox How to insert html

Post by jvierra »

A CSS style sheet would allow the body to be rendered in the target color.
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: GUI Forms MessageBox How to insert html

Post by hrlarsen »

Great that help whit css now.

Then I have the issue whit Links.

My Default browser is Chrome in Windows 10.

Will unly open in Internet Explorer
<a href="https://www.Google.com" target="_blank" title="message">Visit Google.com</a>

----------------------------------------------------------------------------------------------
Pop-up message in Internet Explorer, that ask me if I will open and APP: Microsoft Edge.
<a href="microsoft-edge:https://www.Google.com" target="_blank" title="message">Visit Google.com</a>

If I click Allow button in Internet Explorer Window, Chrome browser open whit the link.
But now I have 2 browsers open Internet EI and Chrome.

Is there a solution for that?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI Forms MessageBox How to insert html

Post by jvierra »

You question has nothing to do with scripting. You have allowed Chrome to alter the system settings. Post in Chrome forums to find out how to fix this.

Uninstalling Chrome will likely also fix this.

Try setting the default browser to IE.
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: GUI Forms MessageBox How to insert html

Post by hrlarsen »

Okay I have found a Way in Powershell.
But I have at problem getting Button in front off $webbrowser1
----------------------------------------------------------------
#webbrowser1
$webbrowser1.Location = '30, 13'
$webbrowser1.Margin = '4, 4, 4, 4'
$webbrowser1.MinimumSize = '20, 20'
$webbrowser1.Name = 'webbrowser1'
$webbrowser1.ScrollBarsEnabled = $False
$webbrowser1.Size = '317, 279'
$webbrowser1.TabIndex = 2
$webbrowser1.BackColor = 'blue'
----------------------------------------------------------------
# button
$button01 = New-Object 'System.Windows.Forms.Button'
$button01.text = "test button"
$button01.Location = New-Object Drawing.Point 100, 90
$button01.ForeColor = 'Red'
$form1.Controls.Add($button01)

$html += @'
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
'@
Here it needs to be placed the button inside the webbrowser1 form

$html += @'
<hr>
<br>
</body>
</html>
'@
Attachments
button.jpg
button.jpg (8.27 KiB) Viewed 2270 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI Forms MessageBox How to insert html

Post by jvierra »

$webbrowser1.SendToBack()
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: GUI Forms MessageBox How to insert html

Post by hrlarsen »

Thank you so much now, I can get the button in front now. ;)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI Forms MessageBox How to insert html

Post by jvierra »

Here are some examples of how to call the form from the HTML code and how to call the HTML code from the forms.

PSF and PS1 files.
Attachments
Demo-WBCallsForm.Export.ps1
(6.26 KiB) Downloaded 100 times
Demo-WBCallsForm.psf
(26.59 KiB) Downloaded 92 times
This topic is 5 years and 7 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