|
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End Sub
End Class
all the other keys are blocked , but if TAB or Enter key is pressed then MyBase.WNDProc(m) is executed.
|
|
|
|
|
This will capture all of the keys using the ProcessCmdKey override rather than WndProc
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
Const WM_KEYDOWN As Integer = &H100
If ((msg.Msg = WM_KEYDOWN)) Then
Select Case (keyData)
Case Keys.Tab
Me.Label1.Text = "Tab Key Captured"
Case Keys.Enter
Me.Label1.Text = "Enter Key Captured"
Case Keys.Return
Me.Label1.Text = "Return Key Captured"
Case Else
Me.Label1.Text = keyData.ToString
End Select
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function But I really don't understand your problem as this also works for me.
Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_CHAR = &H102
If m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End Sub
|
|
|
|
|
Thank you !
The problem with my code is that all other keys are blocked for the control , except the TAB key and Enter key.
If you have test my code , you should see that for the control , all the other keys are blocked inside the IF . But for Tab key and Enter key , the IF condition is always false , and the standart WNDProc is executed.
|
|
|
|
|
sorry but I can't use your function ProcessCMD.
The reason is that I'm usng NativeWindow , and when I try to use your function , I get an error
'ProcessCmdKey' is not a member of 'System.Windows.Forms.NativeWindow'.
What can I do ?
This is my whole class that actually I'm using :
Class NW
Inherits NativeWindow
Public Sub New(hwnd As IntPtr)
AssignHandle(hwnd)
End Sub
Const WM_NCHITTEST As Integer = &H84
Const WM_CHAR As Integer = &H102
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_NCHITTEST OrElse m.Msg = WM_CHAR Then
Return
End If
MyBase.WndProc(m)
End Sub
<pre>
End Class</pre>
|
|
|
|
|
Sorry - I'm about to head off to the airport and won't get a chance to look at this properly.
My advice is to post a question in Quick Answers forum - put in a link to this thread and include the code that you have posted here (you could also post the code I suggested and explain that it didn't work, so everything is in one place).
Hopefully someone else will be able to pick it up while I'm away.
P.S. - If anyone tells you off for cross-posting point them to this post and I'll take the flack
|
|
|
|
|
Hi there,
I'm trying to create a property in vb like FolderBrowserDialog.SelectedPath wich is a string but it has a button to open the FolderBrowserDialog to select the path. please help me.
thanks.
|
|
|
|
|
- Properties don't have buttons. Forms have buttons.
- What kind of help do you need?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I need to create a property just like the SelectedPath but for another control.
|
|
|
|
|
Why not just create a button that opens the FolderBrowserDialog when clicked?
|
|
|
|
|
Ok but how do I put that button in the PropertyGrid??
|
|
|
|
|
|
|
Hello !
When a condition is true I want to make all the controls inside a groupbox not usable by users but without disabling them.
This is the code I use :
Class NW
Inherits NativeWindow
Public Sub New(hwnd As IntPtr)
AssignHandle(hwnd)
End Sub
Const WM_NCHITTEST As Integer = &H84
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_NCHITTEST Then
Return
End If
MyBase.WndProc(m)
End Sub
End Class
Dim nwss As List(Of NW) = Nothing
Public Sub block_area(flag As Boolean)
If flag = True AndAlso IsNothing(nwss) Then
nwss = New List(Of NW)()
For Each c As Control In GroupBox1.Controls
nwss.Add(New NW(c.Handle))
Next
Else
If flag = False And (Not IsNothing(nwss)) Then
For Each nw As Object In nwss
nw.ReleaseHandle()
Next
nwss = Nothing
End If
End If
End Sub
The problem is that this code works for all controls , except the TextBox and DateTimePicker. These 2 controls remain always clickable and editable.
What's wrong ?
Thank you !
|
|
|
|
|
Try enable and / or readonly
|
|
|
|
|
Sorry , but I have posted a code. I have some reasons to not use disable / readonly.
Can you give me a solution for my code ?
Thank you !
|
|
|
|
|
login codes with reset password option using sql server 2008
|
|
|
|
|
If you're looking for someone to just give you code or a finished project you've come to the wrong place.
If you've got specific questions about code you are writing, ask away, but we're not going to do your work for you.
|
|
|
|
|
Hello !
Is there any way to detect if any of the controls inside a TableLaoutPanel is clicked ?
( I mean without using Click event for each control ).
I try using MouseClick's event of TableLayoutPanel , but this doesn't fire when a control is clicked.
Thank you !
modified 5-Apr-15 23:47pm.
|
|
|
|
|
You need to add an event handler which is connected to each control.
|
|
|
|
|
Ok , but what is going to handle this event ?
Because if he's going to handle the click action , this is the same as using all control's click event.
|
|
|
|
|
Yes. You have to wire up the Click event of each control to a central Click handler to do what you want.
It seems like your concern is based on the assumption that only one handler can be assigned to the Click event. That is NOT the case. Multiple handlers can be assigned to the same event and they will all get executed.
So, you CAN have your general Click event handler for every control that you want to be notified for and you can have individual Click handlers for each control for specific functionality for whatever a certain button, or whatever controls, is going to do when clicked.
|
|
|
|
|
sorry , but I have a central Click event.
The problem is that the code inside the click event is depending from the case where the click event is fired from user action ( so a user has clicked ) , or is fired from code.
I can't distinguish these 2 cases , then I ask if is possible to detect a click fro the TableLayoutPanel in general.
|
|
|
|
|
Again, the TableLayoutPanel is NOT a control you can click on. It is an extension to other controls where it adds properties to them to change the way they layout in their parent container, such as a Form or Panel.
There is no way to differentiate where a Click event came from. It's always going to be from the button itself.
If you're kicking off a Click event from code, you're doing it wrong. Move the code from inside the event handler into it's own method and call it from both your code and from the Click event handler.
|
|
|
|
|
What's the trouble with using all control's click event?
|
|
|
|
|
The problem is that the code inside the click event is depending from the case where the click event is fired from user action ( so a user has clicked ) , or is fired from code.
I can't distinguish these 2 cases , then I ask if is possible to detect a click fro the TableLayoutPanel in general.
|
|
|
|