With this test of EventMouseWheel , the behaviour changes before 1 click or 2 on the editor
or after the click : before we get the normal event EventMouseWheel but after ... nothing .
What happens ?
When you click in the RICHEDIT editor (editorgadget), it captures the focus, so the EventMouseWheel messages no longer come to the main window. TextGadget does not capture focus. Try changing the textgadget to buttongadget, click on the button and you will see that the button captures the focus and the EventMouseWheel message will be processed again.
After a click on the editor , turning on the mousewheel just a bit , one step , we get
20 or 30 events ... and this is a lot if the treatment we want to do is heavy ... for ex syntax highlighting ...
Yes, exactly, there is such a nuisance, but I can’t do anything, it’s a little implementation curve RICHEDIT from microsoft. Below in the example you will see that this happens regardless of window9:
Code: Select all
#INCLUDE "windows.bi"
LoadLibrary "RICHED20.DLL"
Dim msg As MSG
Dim As WNDCLASSEX wc
Dim As String NameClass="MyClass"
Dim As HINSTANCE Hinst=GetModuleHandle(0)
Dim Shared As Integer iCount
Function wndproc(hwnd As HWND, msg As Uinteger,_
wparam As WPARAM, lparam As LPARAM) As Integer
Select Case msg
Case WM_DESTROY
PostQuitMessage(0)
Case WM_CREATE
CreateWindowEx(WS_EX_CLIENTEDGE, "RICHEDIT20A", "RichEdit Control",_
WS_VISIBLE Or WS_CHILD Or WS_HSCROLL Or WS_VSCROLL Or ES_MULTILINE Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL,_
10,10,200,200, hwnd, Cast(HMENU,1), 0, 0)
Case WM_COMMAND
iCount+=1
? iCount
End Select
Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function
With wc
.cbSize=SizeOf(WNDCLASSEX)
.style=CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc=@wndproc
.hInstance=Hinst
.hIcon=LoadIcon(0,IDI_WINLOGO)
.hCursor=LoadCursor(0,IDC_ARROW)
.hbrBackground=Cast(HBRUSH,COLOR_WINDOWFRAME)
.lpszClassName=StrPtr(NameClass)
.hIconSm=.hIcon
End With
If RegisterClassEx(@wc)=0 Then
Print "Register error, press any key"
Sleep
End
Endif
CreateWindowEx(0,NameClass,"RichEdit",_
WS_VISIBLE Or WS_OVERLAPPEDWINDOW,100,100,240,260,0,0,Hinst,0)
While GetMessage(@msg,0,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Wend
And now we change the class of the editor with "RICHEDIT20A" on the "EDIT". As you can see, there is already no such problem, but "EDIT" does not have extended functionality like "RICHEDIT20A"
Code: Select all
#INCLUDE "windows.bi"
Dim msg As MSG
Dim As WNDCLASSEX wc
Dim As String NameClass="MyClass"
Dim As HINSTANCE Hinst=GetModuleHandle(0)
Dim Shared As Integer iCount
Function wndproc(hwnd As HWND, msg As Uinteger,_
wparam As WPARAM, lparam As LPARAM) As Integer
Select Case msg
Case WM_DESTROY
PostQuitMessage(0)
Case WM_CREATE
CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "Edit Control",_
WS_VISIBLE Or WS_CHILD Or WS_HSCROLL Or WS_VSCROLL Or ES_MULTILINE Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL,_
10,10,200,200, hwnd, Cast(HMENU,1), 0, 0)
Case WM_COMMAND
iCount+=1
? iCount
End Select
Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function
With wc
.cbSize=SizeOf(WNDCLASSEX)
.style=CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc=@wndproc
.hInstance=Hinst
.hIcon=LoadIcon(0,IDI_WINLOGO)
.hCursor=LoadCursor(0,IDC_ARROW)
.hbrBackground=Cast(HBRUSH,COLOR_WINDOWFRAME)
.lpszClassName=StrPtr(NameClass)
.hIconSm=.hIcon
End With
If RegisterClassEx(@wc)=0 Then
Print "Register error, press any key"
Sleep
End
Endif
CreateWindowEx(0,NameClass,"Edit",_
WS_VISIBLE Or WS_OVERLAPPEDWINDOW,100,100,240,260,0,0,Hinst,0)
While GetMessage(@msg,0,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Wend
P.S. It seems to me when RICHEDIT was created, the microsoft company was in a hurry somewhere, because this control was not thought out.