This question might seems stupid, but it really annoys me. :p
I use TabPages, where I activated AutoScroll, so when the content doesn't fit a TabPage, a scrollbar appears.
But I would like to scroll when I use my mouse wheel, which is far easiest than clicking on the scrollbar.
Does I have to write something in the form Loader?
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Do you have any ideas?
Thanks !
Well, I found what I was searching for, I post it in case somebody encounter the same problem as me.
So in fact, you need to make the tabs "active" to scroll. I personnally use this code hich is a bit tricky but works well :
Private Sub TAB_MouseClick(sender As Object, e As MouseEventArgs) Handles TAB.MouseClick
Me.ActiveControl = Me.TAB.SelectedTab
End Sub
Where TAB is my TabControl
Thanks for your help guys
Related
I am trying to use the circular progress bar solution that was provided at
Visual basic circular progress bar
However I am getting a lot of error messages when I try to incorporate it within a Windows Form that has textbox entries (have to do with System.EventArgs versus PaintEventArgs and MyBase.Load versus Me.Paint).
I tried "mixing" both handles like this:
Private Sub LoginForm1_Load(ByVal sender As System.Object, e As System.EventArgs, g as PaintEventArgs) Handles MyBase.Load, Me.Paint
but of course that bombed out. Can someone please advise what are my alternatives here?
Thanks
You're taking something very easy and making it hard. ALL drawing gets done in the Paint event handler or a method called from the Paint event handler. That's it, that's all when it comes to drawing. You already know how to do that because you already have the code to do it from another question. Use that code.
If the code that does the drawing needs to get data from elsewhere to know what to draw then do that. There's nothing magical about a method using the value of one or more fields to do its work. The data in that field(s) can be put there by any other method, e.g. the Load event handler of the form, the TextChanged event handler of a TextBox or the Click event handler of Button.
Here's a simple example that will draw whatever is in a TextBox as the user types:
Private textToDraw As String
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.Text
textToDraw = TextBox1.Text
'Force a Paint event to be raised.
Invalidate()
End Sub
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
e.Graphics.DrawString(textToDraw, Font, Brushes.Black, PointF.Empty)
End Sub
Put the data where it can be accessed, raise a Paint event, do the drawing. Simple!
The main point to note there is that calling Invalidate with no arguments will cause the entire control it's called on (the form, in this case) to be repainted and that should be avoided if possible. You should calculate and specify the smallest area possible that has or could have changed and pass that when calling Invalidate. That way, parts of the control that definitely haven't changed will not be repainted, speeding up the process. You draw everything every time but the actual repainting of pixels on the screen is the slow part of the operation and so should be minimised. You might read this for more information.
I'm writing an examination piece of software for my workplace and would like to know how I can trap and cancel key-presses such as:
ALT+F4
WIN+TAB
ALT+TAB
WIN
CTRL+ALT+DEL
I'm aware CTRL+ALT+DEL may not be possible, but if any of this is it'll be a step in the right direction!
Ideally I want to prevent the action, and then open a new form I've created saying 'Unauthorised keypress'
as #SQLHound link relates... us the FormClosing event to handle what happens when a user attempts to close. But if you want to block a boot attempt, then #Plutonix suggestion may help. Something along these lines...
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dim splashScreen as New Form
splashScreen.OpenDialog
e.Cancel=True
End Sub
I am having a bit problems trying this. I must admit that I am still novice programming. Well, I managed for do this in this way (VB.NET):
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
If My.Computer.Keyboard.CtrlKeyDown Then
MORE IRRELEVANT CODE HERE
End If
End Sub
But with this way, even if it work, it dont let me customice the key shortcut (only Control, shift and others).
I did this too for try differents things:
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = GlobalVariables.own_key Then
MORE IRRELEVANT CODE HERE
End If
End Sub
I give value to GlobalVariables.own_key from other button. This work perfectly, but only if program have the focus.
So... With the first code program work even if it haven't the focus but only with few keys... And with the second it let me use any key, but don't work if it haven't the focus.
I tryed understand the "keyboard hook" but I must admit that I didn't understad it and couldn't manage for work any of them.
Using VB.net 2012.
Really thanks so much for your help
It may not be an answer you like but it is the answer. In .NET, you cannot get notification of keys when your application does not have focus and you cannot get mouse events outside your applications windows. If you looked into the "Keyboard Hook", you should have read that little important fact regarding VB.
Global hooks are not supported in the .NET Framework
I am creating a Win32-application in Visual Basic 2008. I would like to have a button in the form, with custom color (BackColor), on MouseEnter event. This works fine, but as you can see below, this custom color doesn't cover the whole area of the button. The button border remains as standard (Windows 7). Can I somehow have this color for the whole button? I don't want to use Flat button style, I prefer this Standard style, which has the normal Windows look.
What I typically do is this I first gather two buttons that look similar, such as this Pic A and B.
Then I will put in those two picture into my Resources.
After I begin coding the function such as the Example I have made down below.
Now their are two ways of going about this. There is a hover option as seen below:
Private Sub PictureBox1_MouseHover(sender As Object, e As EventArgs) Handles PictureBox1.MouseHover
PictureBox1.Image = My.Resources.Button1
End Sub
or there is this option which has way better response times when moving your mouse:
Private Sub PictureBox1_MouseEnter(sender As Object, e As EventArgs) Handles PictureBox1.MouseEnter
PictureBox1.Image = My.Resources.Button1
End Sub
Then you need this to set things back to normal:
Private Sub PictureBox1_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox1.MouseLeave
PictureBox1.Image = My.Resources.Button
End Sub
Real simple code but in a realistics thats all you need! I typically hate the buttons! I find myself messing with the button look more then I actually code, really simple to just go to Photoshop and make a easy button that looks good!
I read your Question don't worry but to be honest that style button looks old fashion the buttons I made are more up to date and Modern!
Ok, I'm aware there's a lots of topis about this, but I haven't found anything that works for me.
My program generates a small picture that i would like to keep in a WinForm that's always at the bottom, "with the desktop". Something like the gadgets in windows 7.
How do i tell my form to always stay here, and just can't be visible over any other form/window?
Should'nt this be doable like in the form_load function for this window?
Like this
Private Sub Sticky_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeepMeAtTheBottomUntillIAmClosed
End Sub
If you create a form that has no border and no controlbox, the user will not be able to resize or move it. Then add your own button to allow it to close, tell it where you want it to be and tada!
You can even add some mouse over functionality to make the tools appear when you are over the form.