|
-
Apr 17th, 2011, 12:51 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] RichTextBox - disable mouse scaling
Hello everyone.
Finishing off my control, but I now found a nasty problem. When the user holds the 'Ctrl' key and scrolls the mouse scrollwheel, the control is scaled. I do not want that, since it would make the Font size fail.
I previously made it reset the scale on Control up, but that is just not a very elegant way:
I do not want the text scaled at any time, not even while the user is scrolling and it resets afterwards.
I got to overriding the 'ProcessCmdKey' but no idea how to catch a scroll or zoom event.
Any way of disabling the RichTextBox scaling (or zooming) so it does not even occur? I have a control that inherits from the RichTextBox.
Last edited by bergerkiller; Apr 17th, 2011 at 12:57 PM.
-
Apr 17th, 2011, 03:14 PM
#2
Re: RichTextBox - disable mouse scaling
Here's how:
Code:
Public Class RTBnoZoom
Inherits RichTextBox
Private ctrlPressed As Boolean
Private Const WM_MOUSEWHEEL As Integer = &H20A
Public Sub New()
Me.SetStyle(ControlStyles.EnableNotifyMessage, True)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If Not (m.Msg = WM_MOUSEWHEEL AndAlso ctrlPressed) Then MyBase.WndProc(m)
End Sub
Protected Overrides Sub OnKeyDown(e As System.Windows.Forms.KeyEventArgs)
If e.Modifiers = Keys.Control Then ctrlPressed = True
MyBase.OnKeyDown(e)
End Sub
Protected Overrides Sub OnKeyUp(e As System.Windows.Forms.KeyEventArgs)
ctrlPressed = False
MyBase.OnKeyUp(e)
End Sub
End Class
BB
-
Apr 17th, 2011, 03:32 PM
#3
Thread Starter
Fanatic Member
Re: RichTextBox - disable mouse scaling
Thanks it works, although I changed it a bit around. 
Code:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_MOUSEWHEEL Then
Dim low As Short = m.WParam.ToInt32 - (m.WParam.ToInt32 >> 16) * 2 ^ 16
If (low And &H8) = &H8 Then Return
End If
MyBase.WndProc(m)
End Sub
Last edited by bergerkiller; Apr 17th, 2011 at 03:37 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|