Okay... but all these crashes have started since I began using 6.10 recently. It was all fine with 6.04 before that. I haven't coded with the x86 version of PureBasic for a couple of years now. Only the 64-bit version.mk-soft wrote: Mon Mar 11, 2024 10:58 amThis is not a problem with pb v6.10.
It is a problem with old codes written for x86.
[Solved] Mouse wheel hook laggy in Windows
Re: [Solved] Mouse wheel hook laggy in Windows
Re: [Solved] Mouse wheel hook laggy in Windows
The confusing thing here is that wrong codes were 'correctly' working with previous version due to memory address fitting into long (.l) on x64. Again see this as an opportunity to finally have less hidden bugs in your apps.BarryG wrote: Mon Mar 11, 2024 10:51 am Changed to ".i" and all is working well again. Far out. Coding with 6.10 is so confusing now.![]()
Re: [Solved] Mouse wheel hook laggy in Windows
If I remember correctly ...
In the past, the virtual address range was limited to 2gb or 4gb for a window application and had to be explicitly allowed to get a larger memory.
This meant that the address could also fit into a long.
This restriction no longer exists.
In the past, the virtual address range was limited to 2gb or 4gb for a window application and had to be explicitly allowed to get a larger memory.
This meant that the address could also fit into a long.
This restriction no longer exists.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: [Solved] Mouse wheel hook laggy in Windows
Thank you very much for your quick answer.
GenMax has almost 24000 lines of code, so it is very heavy to share, even the supect portions.
I don't use pointers in the program. The counter variable that has issues (surely there are more over there) is a global integer variable.
I also checked the link you sent me and there are no long integer variables in my code. I only use integer anf float types (as well as strings). My compiler always was of 64b.
If it used to work ok in version 6.00, what could have changed in the following versions to make it incompatible now?
Thank you very much
Claudio Bollini
GenMax has almost 24000 lines of code, so it is very heavy to share, even the supect portions.
I don't use pointers in the program. The counter variable that has issues (surely there are more over there) is a global integer variable.
I also checked the link you sent me and there are no long integer variables in my code. I only use integer anf float types (as well as strings). My compiler always was of 64b.
If it used to work ok in version 6.00, what could have changed in the following versions to make it incompatible now?
Thank you very much
Claudio Bollini
Re: [Solved] Mouse wheel hook laggy in Windows
In this way I adjusted the sound on WindowsXP, regardless of what application you were in, even in games. Rotating the mouse wheel while pressing the Ctrl key showed an adjustment window.
Code: Select all
EnableExplicit
#Window = 0
#ImgGdg = 0
#Image = 0
#Menu = 0
Macro LOWORD(dwValue)
(dwValue & $FFFF)
EndMacro
Macro HIWORD(dwValue)
(dwValue >> 16)
EndMacro
Enumeration #WM_USER + 1
#WM_USER_MOUSEWHEEL
EndEnumeration
Structure MSLLHOOKSTRUCT
pt.point
mouseData.l
flags.l
time.l
*dwExtraInfo
EndStructure
Global MouseWheelHook, MouseWheelWindow, MouseWheelDir
Global dh, dw
Global pt.POINT
Global g_pos = 50
ExamineDesktops()
dw = DesktopWidth(0)
dh = DesktopHeight(0)
Procedure LowLevelMouseProc(nCode.i, wParam.i, lParam.i)
Protected *data.MSLLHOOKSTRUCT, wNewParam.l, lNewParam.l
If wParam = #WM_MOUSEWHEEL
*data = lParam
wNewParam = *data\mouseData & $FFFF0000
lNewParam = (*data\pt\y << 16) | (*data\pt\x & $FFFF)
PostMessage_(MouseWheelWindow, #WM_USER_MOUSEWHEEL, wNewParam, lNewParam)
EndIf
ProcedureReturn CallNextHookEx_(MouseWheelHook, nCode, wParam, lParam)
EndProcedure
Procedure AddMouseWheelHook(hWnd)
If MouseWheelHook = 0
MouseWheelHook = SetWindowsHookEx_(#WH_MOUSE_LL, @LowLevelMouseProc(), GetModuleHandle_(0), 0)
EndIf
MouseWheelWindow = hWnd
ProcedureReturn MouseWheelHook
EndProcedure
Procedure RemoveMouseWheelHook()
If MouseWheelHook
UnhookWindowsHookEx_(MouseWheelHook)
MouseWheelHook = 0
EndIf
EndProcedure
; без копирования
Procedure Limit(*Value.integer, Min, Max)
If *Value\i < Min
*Value\i = Min
ElseIf *Value\i > Max
*Value\i = Max
EndIf
EndProcedure
Procedure MyWindowCallback(WindowID, Message, wParam, lParam)
Protected Result = #PB_ProcessPureBasicEvents
Protected StepSize = 5
Static oldpos = 0
Select Message
Case #WM_USER_MOUSEWHEEL
; info = "User Message Delta = " + Str(HIWORD(dwValue) / #WHEEL_DELTA)
; info + " / X = " + Str(LOWORD(lParam)) + " / Y = " + Str(HIWORD(lParam))
; Debug info
; Debug LOWORD(wParam)
; If LOWORD(wParam) & #MK_CONTROL
If oldpos >= 20
StepSize = 5
ElseIf oldpos < 5
StepSize = 1
ElseIf oldpos < 20
StepSize = 3
EndIf
g_pos + HIWORD(wParam) / (#WHEEL_DELTA / StepSize)
Limit(@g_pos, 0, 100)
If oldpos <> g_pos
Debug g_pos
oldpos = g_pos
If StartDrawing(ImageOutput(#Image))
Box(0, 0, 54, 104, $99FF99)
Box(2, 102 - g_pos, 50, g_pos, $339933)
StopDrawing()
SetGadgetState(#ImgGdg, ImageID(#Image))
EndIf
EndIf
; EndIf
; Case #WM_MOUSEWHEEL
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(#Window, dw - 80, dh - 180, 54, 104, "Mouse Hook", #PB_Window_BorderLess)
StickyWindow(#Window, #True)
ImageGadget(#ImgGdg, 0, 0, 54, 104, 0)
If CreateImage(#Image, 54, 104, 32, $99FF99)
If StartDrawing(ImageOutput(#Image))
Box(2, 50, 50, 52, $339933)
StopDrawing()
EndIf
EndIf
If CreatePopupMenu(#Menu)
MenuItem(0, "Exit")
EndIf
SetGadgetState(#ImgGdg, ImageID(#Image))
AddMouseWheelHook(WindowID(0))
SetWindowCallback(@MyWindowCallback())
Repeat
Select WaitWindowEvent()
; Case #PB_Event_RightClick
; DisplayPopupMenu(#Menu, WindowID(#Window))
Case #PB_Event_Gadget
Select EventGadget()
Case #ImgGdg
Select EventType()
Case #PB_EventType_LeftClick
GetCursorPos_(@pt.POINT)
g_pos = pt\y - WindowY(#Window)
g_pos = 104 - g_pos
If StartDrawing(ImageOutput(#Image))
Box(0, 0, 54, 104, $99FF99)
Box(2, 102 - g_pos, 50, g_pos, $339933)
StopDrawing()
SetGadgetState(#ImgGdg, ImageID(#Image))
EndIf
Case #PB_EventType_RightClick
DisplayPopupMenu(#Menu, WindowID(#Window))
EndSelect
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case 0
Break
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
RemoveMouseWheelHook()
EndIf