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))
Related
I set my NotifyIcon of the boot form as follows:
![
]1
thinking about getting something like:
But it doesn't show me anything when I hover over the icona in the systemtray. How come? what am I wrong
The balloon is only shown when you call NotifyIcon.ShowBalloonTip(timeout), not when you hover on the system tray icon, and it uses BalloonTipText and BalloonTipTile properties. You have to handle this method in some event or function.
For example, you could do this when you minimize the form:
NotifyIcon.Visible = True
NotifyIcon.ShowBalloonTip(2000, "MyApp", "The program is still running!", ToolTipIcon.Info)
When you hover on the icon and the icon is visible, instead, only a tooltip appears. The tooltip displays the string set in the Text property and doesn't use BalloonTipText and BalloonTipTile.
So you don't have to handle the hover, the ToolTip should automatically appear.
If the issue persists, try to set Visible = False in the designer in order to see whether setting Visible = True works and make sure that there isn't any instruction that throws exception before the ShowBalloonTip method.
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.
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
Like the title says, I've got a Child form being shown with it's TopLevel property set to False and I am unable to click a MaskedTextBox control that it contains (in order to bring focus to it). I can bring focus to it by using TAB on the keyboard though.
The child form contains other regular TextBox controls and these I can click to focus with no problems, although they also exhibit some odd behavior: for example if I've got a value in the Textbox and I try to drag-click from the end of the string to the beginning, nothing happens. In fact I can't use my mouse to move the cursor inside the TextBox's text at all (although they keyboard arrow keys work).
I'm not too worried about the odd TextBox behavior, but why can't I activate my MaskedTextBox by clicking on it?
Below is the code that shows the form:
Dim newReportForm As New Form
Dim formName As String
Dim FullTypeName As String
Dim FormInstanceType As Type
formName = TreeView1.SelectedNode.Name
FullTypeName = Application.ProductName & "." & formName
FormInstanceType = Type.GetType(FullTypeName, True, True)
newReportForm = CType(Activator.CreateInstance(FormInstanceType), Form)
Try
newReportForm.Top = CType(SplitContainer1.Panel2.Controls(0), Form).Top + 25
newReportForm.Left = CType(SplitContainer1.Panel2.Controls(0), Form).Left + 25
Catch
End Try
newReportForm.TopLevel = False
newReportForm.Parent = SplitContainer1.Panel2
newReportForm.BringToFront()
newReportForm.Show()
I tried your code and got a good repro this time. As I mentioned in my original post, this is indeed a window activation problem. You can see this in Spy++, note the WM_MOUSEACTIVATE messages.
This happens because you display the form with a caption bar. That convinces the Windows window manager that the window can be activated. That doesn't actually work, it is no longer a top-level window. Visible from the caption bar, it never gets drawn with the "window activated" colors.
You will have to remove the caption bar from the form. That's best done by adding this line to your code:
newReportForm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Which will turn the form into a control that's otherwise indistinguishable from a UserControl. You can still make it distinctive by using this code instead:
newReportForm.ControlBox = False
newReportForm.Text = ""
Either fix solves the mouse click problem.
This is a miserable bug and it took me a long time to find this question. We're doing exactly the same thing as the OP, displaying a Form inside a split container. My workaround was to add an event handler to the MaskedTextBox's Click event:
private void MaskedTextBoxSetFocus(object sender, EventArgs e)
{
var mtb = (MaskedTextBox)sender;
mtb.Focus();
}
This works for the MaskedTextBox but I'm concerned about other odd behavior due to this bug so I will probably set the border style as in the accepted answer.
The text box behavior is a symptom of the same problem. Something is swallowing mouse down notifications. It isn't explained by your code snippet. Forms indeed swallow the mouse click that activates them, but that is a one-time behavior and is turned off by setting its TopLevel property to False.
Not much left. One candidate is the Control.Capture property, turned on at the MouseDown event for a button so that the button can see the MouseUp event, no matter where the mouse moved. That's a one-time effect as well. Watch out for controls that set the Focus in a MouseDown event.
The other is some kind of IMessageFilter code in your form(s) that's eating WM_LBUTTONDOWN messages.
I'm trying to make a thumbnail toolbar button (TTB from now on)visible when the it is clicked. I know how to do stuff when it is clicked, AddHandler etc. But if I tell it TTB.visible=false then it doesn't become invisible. If I put TTB.enabled = False it will be disabled, so it's only the visible that isn't working.
Also I put a button on my form (not a TTB) and when that is click wrote, TTB.visible = false and that didn't work, so there is no way to make it invisible.
Try set TTB.visible=true after you Add it into toolbar button list.