Recent

Author Topic: TImage - MOUSE SCROLL WHEEL  (Read 4955 times)

Boshu

  • Guest
TImage - MOUSE SCROLL WHEEL
« on: April 06, 2006, 11:06:25 am »
Hi!

...
  protected
  PROCEDURE MOUSEMOVE(SHIFT:TSHIFTSTATE;X,Y:LONGINT);OVERRIDE;
  PROCEDURE MOUSEDOWN(BUTTON:TMOUSEBUTTON;SHIFT:TSHIFTSTATE;X,Y:LONGINT);OVERRIDE;
  PROCEDURE MOUSEUP(BUTTON:TMOUSEBUTTON;SHIFT:TSHIFTSTATE;X,Y:LONGINT);OVERRIDE;
  public
....

These are the procedures i use to intercept mouse events in a custom TImage.
I can't find the procedure triggered by mouse wheel events. Is it implemented? If it's not then please reply this message in order to add it to Mantis.

Bye!

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
RE: TImage - MOUSE SCROLL WHEEL
« Reply #1 on: May 24, 2006, 03:30:18 pm »
You can handle those messages yourself. First you need to rebuild lazarus putting this as commandline option:

-dPassWin32MessagesToLCL

Now you can modify and use this sample code:

{*******************************************************************
*  TMainWindow.WndProc ()
*
*  DESCRIPTION:    Window function of the main window.
*                  Only handles manually the messages for the taskbar icon.
*                  Other messages are forwarded to the Component Library
*
*  PARAMETERS:     Standard window function parameters
*
*  RETURNS:        Nothing
*
*******************************************************************}
{$IFDEF Win32}
procedure TMainWindow.WndProc(var Message : TMessage);
var
  pt: TPoint;
  i: Integer;
  delta: ShortInt;
  wheel_delta: Word;
  rotation: Double;
begin
  case Message.msg of
    WM_HOTKEY: ExecuteLens(Self);

    WM_MOUSEWHEEL:
    begin
      wheel_delta := HiWord(Message.WParam);
      Move(wheel_delta, delta, SizeOf(Word));
      rotation := delta / WHEEL_DELTA;

      if (rotation > 0.0) then delta := Round(rotation + 0.5)
      else delta := Round(rotation - 0.5);

      for i := 1 to abs(delta) do
      begin
        // Call same code as from VK_ADD, VK_SUBTRACT handlers
        if (delta > 0.0) then
         vConfigurations.iMagnification := vConfigurations.iMagnification + 0.5
        else vConfigurations.iMagnification := vConfigurations.iMagnification - 0.5;
      end;

      // Hard limits for the magnification
      if vConfigurations.iMagnification < 1.0 then vConfigurations.iMagnification := 1.0
      else if vConfigurations.iMagnification > 16 then vConfigurations.iMagnification := 16;

      vGlass.Repaint;
    end;
  else
    {*******************************************************************
    *  All other messages from the Window are handled by the Component Library
    *******************************************************************}
    inherited WndProc(Message);
  end;
end;
{$ENDIF}

 

TinyPortal © 2005-2018