Fixed mouse wheel crashes.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1449 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
macpgmr
2011-01-15 20:59:53 +00:00
parent 897d9483ac
commit ed64ad4b80
2 changed files with 15 additions and 3 deletions

View File

@ -1844,6 +1844,11 @@ end;
procedure TO32CustomControl.DoOnMouseWheel(Shift : TShiftState; procedure TO32CustomControl.DoOnMouseWheel(Shift : TShiftState;
Delta, XPos, YPos : SmallInt); Delta, XPos, YPos : SmallInt);
// Another TurboPower bug? Their TMouseWheelEvent expects Word
// params, yet passing SmallInts here. Delta is negative when
// scroll down, which will raise exception if a descendent class
// with a TMouseWheelEvent handler has range checking turned on.
// Note that their TMouseWheelEvent redefines LCL's.
begin begin
if Assigned(FOnMouseWheel) then if Assigned(FOnMouseWheel) then
FOnMouseWheel(Self, Shift, Delta, XPos, YPos); FOnMouseWheel(Self, Shift, Delta, XPos, YPos);
@ -2026,10 +2031,15 @@ begin
end; end;
procedure TO32CustomControl.WMMouseWheel(var Msg : TMessage); procedure TO32CustomControl.WMMouseWheel(var Msg : TMessage);
// TurboPower bug: They should have used TWMMouseWheel instead of
// TMessage. Delta is negative on scroll down, but extracting it
// from wParam with HIWORD returns a Word, which causes an
// exception when passed as SmallInt to DoOnMouseWheel when
// range checking turned on. Fix is to cast delta as SmallInt.
begin begin
with Msg do with Msg do
DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys}, DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys},
HIWORD(wParam) {zDelta}, SmallInt(HIWORD(wParam)) {zDelta}, //bug fix
LOWORD(lParam) {xPos}, HIWORD(lParam) {yPos}); LOWORD(lParam) {xPos}, HIWORD(lParam) {yPos});
end; end;
@ -2265,10 +2275,11 @@ begin
end; end;
procedure TOvcCustomControl.WMMouseWheel(var Msg : TMessage); procedure TOvcCustomControl.WMMouseWheel(var Msg : TMessage);
// See TurboPower bug comments above.
begin begin
with Msg do with Msg do
DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys}, DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys},
HIWORD(wParam) {zDelta}, SmallInt(HIWORD(wParam)) {zDelta}, //bug fix
LOWORD(lParam) {xPos}, HIWORD(lParam) {yPos}); LOWORD(lParam) {xPos}, HIWORD(lParam) {yPos});
end; end;

View File

@ -1530,12 +1530,13 @@ begin
end; end;
procedure TOvcBaseComboBox.WMMouseWheel(var Msg : TMessage); procedure TOvcBaseComboBox.WMMouseWheel(var Msg : TMessage);
// See TurboPower bug comments in TO32CustomControl.WMMouseWheel.
begin begin
inherited; inherited;
with Msg do with Msg do
DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys}, DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys},
HIWORD(wParam) {zDelta}, SmallInt(HIWORD(wParam)) {zDelta}, //bug fix
LOWORD(lParam) {xPos}, HIWORD(lParam) {yPos}); LOWORD(lParam) {xPos}, HIWORD(lParam) {yPos});
end; end;