I found the following code which cancels the flickering in a WinForms application:
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H2000000
Return cp
End Get
End Property 'CreateParams
The issue comes when "minimizing and maximizing the form, all controls are invisible. Removing &H2000000 fix the problem, but the controls start to flicker" like it says in this comment on this question.
There's any update or way to solve this?
Related
The form shows many black boxes, I don't paint any graphics, I also removed the background image and it is still flickering.
I used double buffer and used this code below too
Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or 33554432
Return cp
End Get
End Property
all this reduced the flickering but it still happens and leaves these black boxes. and it happens when I scroll in a flowpanel too.
I also want to use a background image, so I need something that will work with it too.
I'm working on a project where I have an input with validation.
Next to it there are a set of buttons which you can press. When you focus the input the buttons will be shown. But when you click on 1 of the buttons the focus of the input is gone and the validation will start and the buttons will be hidden.
What I want is that the input focus is not lost, at any time.
Is it possible to not activate/focus the buttons when you click on them or is it possible to force focus on the input without losing it?
I have tried this on the Control, but seems to be only working on a form:
Const WS_EX_NOACTIVATE As Integer = &H8000000
Const WS_EX_TOOLWINDOW As Integer = &H80
Protected Overrides ReadOnly Property CreateParams As CreateParams
Get
Dim ret As CreateParams = MyBase.CreateParams
ret.ExStyle = ret.ExStyle Or WS_EX_NOACTIVATE Or WS_EX_TOOLWINDOW
Return ret
End Get
End Property
You can create your custom button and make it non-selectable:
Public Class MyButton
Inherits Button
Public Sub New()
SetStyle(ControlStyles.Selectable, False)
End Sub
End Class
If you don't want to create custom control, set CausesValidation = False for your normal button and it will get focus, but doesn't cause validation.
Set the TabStop property of the buttons to false.
By setting this to false you'll stop them receiving focus when the user tabs, but they'll still be clickable.
I have migrated a userControl from vb6 to vb.net, and i have problem with it's transparency.
in vb6, the property backstyle was used to make the control transparent, but in vb.net, i can't find it.
is there any equivalent for this property?
After some searches on the internet I found this pearl:
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
' Make background transparent
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H20
Return cp
End Get
End Property
Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
'' call MyBase.OnPaintBackground(e) only if the backColor is not Color.Transparent
If Me.BackColor <> Color.Transparent Then
MyBase.OnPaintBackground(e)
End If
End Sub
I've tested it and it seems to be working fine.
I want clean the PictureBox image, so I make this code: TransparentPictureBox.Image = Nothing, the image don't disappear and I obtain all new image overlapping to the previous. How can I fix this?
I stay using a custom control, this is the class:
Public Class TransparentPictureBox
Inherits PictureBox
Public Sub New()
Me.SetStyle(ControlStyles.Opaque, True)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, False)
End Sub
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H20 ' Turn on WS_EX_TRANSPARENT
Return cp
End Get
End Property
End Class
The control is working exactly as you designed it.
With the ControlStyles.Opaque option set to True, it does not draw its background:
If true, the control is drawn opaque and the background is not painted.
When you set the Image property to Nothing, you're expecting it to be emptied.
How does a PictureBox draw itself though? It first draws the background color, then it draws the image on top of that. Since you've disabled background painting, though, the background doesn't get drawn and the previous image doesn't get erased.
Why do you have that option set? Remove it if that is not the behavior you're looking for.
Just write this although this not optimal solution but it will work
picturebox1.imagelocation = ""
I have a form which is set to TopMost. It is basically a gaming tool which runs in-game and only accepts key bindings. Now, I need to disable all click events in the form and making "Click-through" so that the users will not be interrupted when they accidentally click or right-click the form. If I will not use a click-through form, clicking events will focus the form which shows the taskbar and makes the game slow. I'll just use a key binding to enable/disable that click-through feature. How do you set this in a Windows form using VB.Net?
Override CreateParams() in your Form and set the WS_EX_TRANSPARENT flag:
Public Class Form1
Private Const WS_EX_TRANSPARENT As Integer = &H20
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or WS_EX_TRANSPARENT
Return cp
End Get
End Property
End Class
This will give the "Click-through" functionality that you're looking for.