Keep Popup Window in WebBrowser control instead of a new window - vb.net

When using the WebBrowser control, is it possible to cause popup windows to
appear within the WebBrowser control itself instead of a new window?
I can't figure out how to get the popup to appear in the same browser window. please help me :)
PS : The language I use is VB

If you have multiple tabs with WebBrowsers, use this under the "New Window" Event:
((WebBrowser)TabControl1.SelectedTab.Controls[0]).Navigate(((WebBrowser)
TabControl1.SelectedTab.Controls[0]).StatusText)
'next input <cancel[IE]>
e.Cancel = True
If just a plain browser put this under the New Window Event:
webBrowser1.Navigate(webBrowser1.StatusText)
e.Cancel = True

Related

How to disable clicking Webbrowser, but still able to scroll WebBroswer

I have a WebBrowser in my VB.net form. I want to disable from users clicking links in the Webbrowser, but still able to scroll the Webbrowser.
I found this code but it locks up the whole WebBroswers so I can't click links or scroll, but I need to be able to scroll.
DirectCast(WebBrowser1, Control).Enabled = False
Just set the following property:
WebBrowser1.AllowNavigation = False
A hacky work-around to change the address from code would be to turn AllowNavigation on again, but it requires a BeginInvoke to allow the navigation to take place before turning it off again:
WebBrowser1.AllowNavigation = True
WebBrowser1.Navigate("new web address...")
Me.BeginInvoke(New Action(Sub() WebBrowser1.AllowNavigation = False))

vb.net maximize program from notification area

I have a program which contains few project and get reference to them. When I start program the Main Form is open. Now, I can click button and start form one of my project. I set Main Form to minimize to Notify Icon. Now when I finish with Form (from project) I want to maximize Main Form from Notify Icon.
How can I do this?
This is how I start Form and minimize Main Form to Notify Icon:
Dim instance As New Machines.FormMain
instance.Show()
NotifyIcon1.BalloonTipTitle = "TF Tools"
NotifyIcon1.BalloonTipText = "Machines Readings"
NotifyIcon1.ShowBalloonTip(5)
Me.WindowState = FormWindowState.Minimized
ShowInTaskbar = False
I have Solution with 3 projects. Main project is TF Tools when I stat TF_Tools.Form1 start. I click button which start project Machines.Form1. TF_Tools.Form1 is minimized to Notify Icon. I want TF_Tools.Form1 maximized when Machines.Form1 is closing. I was try to do this like that:
ShowInTaskbar = True
Me.WindowState = FormWindowState.Maximized
NotifyIcon1.Visible = True
This is work when I double click on icon in Notify Icon. But when I put this in Machines.Form1 closing event it’s not work. I was try to change Me. WindowState for TF_Tools.Form1.WindowState but it’s not work. I was think to add TF_Tools as a reference to Machines but I can’t do this.

Unable to operate the prompts of spot fire using selenium webdriver

If anybody has tested spot fire web applications using selenium webdriver please help me. Spot fire uses prompts as popups. And am unable to locate the prompts buttons to click.
Steps i followed:
Save the current window handle.
Get the next prompt window
handle by traversing through iterator(While Loop).
Find the element on new window and click it. But when i printed current
window handle and new window handle are same.
Below is my code
String parentWindowHandler = driver.getWindowHandle();//Stored parent window
String subWindowHandler = null;
Set<String> handles = driver.getWindowHandles();
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler);
(....My click functions)
I have pasted the fire bug element track below for "OK" Button on prompts.
Next
I have tried to take control using "class" but its throwing exception saying it cant take common/general class.
Please suggest me how to proceed to click a OK button on spot fire prompts.
I forgot to inform.My Prompt contains a "scroll bar" and "Next" button and "Cancel" Button. I need to choose items from scroll bar and press next or cancel button.

Why is return from MessageBox.Show not "DialogResult.Cancel" when the close button is pressed?

I'm using the following code:
Dim Reply As DialogResult = MessageBox.Show("GOT IT!")
If Reply = DialogResult.OK Then '...`
When I click the Close button (red "X" in corner) the condition looking for DialogResult.OK still evaluates to true and when I check the Reply variable's value at runtime after clicking the close button it is 1 {OK}.
From the documentation on MessageBox Class it says:
Displays a message window, also known as a dialog box, which
presents a message to the user. It is a modal window, blocking other
actions in the application until the user closes it. A MessageBox can
contain text, buttons, and symbols that inform and instruct the user.
While I find the documentation on DialogBoxes a little convoluted and confusing, it appears to me (and i could be bery wrong) that the Close button should by default set the return to IDCancel which, I must assume is somehow parsed by the MessageBox class into DialogReturn.Cancel.
So why does MessageBox not show the return form the close button as DialogResult.Cancel??
This is all very confusing to me because it seems the MessageBox class is not consistent with other forms from within the same Systems.Windows.Forms namespace.
For instance, if we look at the documentation from the Form Class's .DialogResult method, it specifically tells us the return from the close button is DialogResult.Cancel:
When a form is displayed as a modal dialog box, clicking the Close
button (the button with an X in the top-right corner of the form)
causes the form to be hidden and the DialogResult property to be set
to DialogResult.Cancel.
As already stated in the comments above, you could get IDCancel result when clicking the Close Red Button, only if you add a MessageBoxButtons enum that include the Cancel option For example MessageBoxButtons.OKCancel and others.
The MessageBox.Show method is indeed a wrapper around the WinApi MessageBox function. You could see this wrapping looking at the reference sources
The behavior of MessageBox.Show is different from the link that you have pointed. That one is relative to the WinForm engine and of course the behavior of the WinForm Form class is totally managed by the library to handle the scenarios presumed for a WinForm class.
In the WinApi documentation you could find a subtle reference in the section about the Return value where they talks about the behavior when the cancel button is present. Then trial and error confirms this assumption.
You need to pass in MessageBoxButtons as an override that includes a cancel button so like MessageBoxButtons.OKCancel.
Dim message As String = "GOT IT!"
Dim caption As String = "Fancy Caption"
Dim Reply As DialogResult = MessageBox.Show(message, caption, MessageBoxButtons.OKCancel)
If Reply = DialogResult.OK Then '...`
If you dont want the caption than skip it but you'll still need a comma, like:
MessageBox.Show("GOT IT!",,MessageBoxButtons.OKCancel)
See here for full enumeration of options for MessageBoxButtons.

Get tab and enter event in form in panel

In Visual Studio 2012 I have a panel in FormA which loads FormB.
FormB = New FormB
FormB.TopLevel = False
FormB.WindowState = FormWindowState.Maximized
FormB.FormBorderStyle = Windows.Forms.FormBorderStyle.None
FormB.Visible = True
Panel1.Controls.Add(FormB)
FormB contains some TextBoxes and a Button. When I try to tab through the TextBoxes in FormB the focus jumps to controls in FormA. I'm not able to get the keyboard enter event in FormB neither. I started with a bunch of independent forms but I am now trying use Tabs and Panels to navigate through the app. It would be great if I could use my existing form in panels to achieve this.
do you know "KeyPreview"? If you activate this, it may help you to catch the events directly on your active form. By default this is disabled and you can find it in your form-properties.