Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 661885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:19:04+00:00 2026-05-13T23:19:04+00:00

If a mouse has other buttons in addition to the standard left/right/middle (e.g. forward/back),

  • 0

If a mouse has other buttons in addition to the standard left/right/middle (e.g. forward/back), how can we detect those button clicks in Delphi?

An example of how this is used is the Internet Explorer, where the forward/back button on the side of a Logitech or MS mouse cycles forward and back between any loaded web pages. This seems to replicate the Backspace/CTRL+Backspace on the keyboard but I tried to detect that using KeyPreview and the KeyPress event but it does not pick it up.

Any idea how to detect clicks on these extended mouse buttons?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:19:04+00:00Added an answer on May 13, 2026 at 11:19 pm

    You need to capture the WM_APPCOMMAND message and then extract the specific command request using GET_APPCOMMAND_LPARAM. Basically, something like this:

    type
      TMyForm = class(TForm)
      private
        procedure WMAppCommand(var Msg: TMessage); message WM_APPCOMMAND;
      end;
    
    procedure TMyForm.WMAppCommand(var Msg: TMessage);
    begin
      case GET_APPCOMMAND_LPARAM(Msg.LParam) of
        APPCOMMAND_BROWSER_BACKWARD:
        begin
          // Do "go back" code
          Msg.Result := 1;
        end;
      end;
    end;
    

    Here’s the relevant header translation:

    unit AppCommand;
    
    {$RANGECHECKS OFF}
    
    interface
    
    uses
      Windows;
    
    const
      WM_APPCOMMAND = $0319;
    
    const
      // Windows 2000, ME, and above
      APPCOMMAND_BROWSER_BACKWARD                   = 1;
      APPCOMMAND_BROWSER_FORWARD                    = 2;
      APPCOMMAND_BROWSER_REFRESH                    = 3;
      APPCOMMAND_BROWSER_STOP                       = 4;
      APPCOMMAND_BROWSER_SEARCH                     = 5;
      APPCOMMAND_BROWSER_FAVORITES                  = 6;
      APPCOMMAND_BROWSER_HOME                       = 7;
      APPCOMMAND_VOLUME_MUTE                        = 8;
      APPCOMMAND_VOLUME_DOWN                        = 9;
      APPCOMMAND_VOLUME_UP                          = 10;
      APPCOMMAND_MEDIA_NEXTTRACK                    = 11;
      APPCOMMAND_MEDIA_PREVIOUSTRACK                = 12;
      APPCOMMAND_MEDIA_STOP                         = 13;
      APPCOMMAND_MEDIA_PLAY_PAUSE                   = 14;
      APPCOMMAND_LAUNCH_MAIL                        = 15;
      APPCOMMAND_LAUNCH_MEDIA_SELECT                = 16;
      APPCOMMAND_LAUNCH_APP1                        = 17;
      APPCOMMAND_LAUNCH_APP2                        = 18;
      APPCOMMAND_BASS_DOWN                          = 19;
      APPCOMMAND_BASS_BOOST                         = 20;
      APPCOMMAND_BASS_UP                            = 21;
      APPCOMMAND_TREBLE_DOWN                        = 22;
      APPCOMMAND_TREBLE_UP                          = 23;
      // Windows XP and above
      APPCOMMAND_MICROPHONE_VOLUME_MUTE             = 24;
      APPCOMMAND_MICROPHONE_VOLUME_DOWN             = 25;
      APPCOMMAND_MICROPHONE_VOLUME_UP               = 26;
      APPCOMMAND_HELP                               = 27;
      APPCOMMAND_FIND                               = 28;
      APPCOMMAND_NEW                                = 29;
      APPCOMMAND_OPEN                               = 30;
      APPCOMMAND_CLOSE                              = 31;
      APPCOMMAND_SAVE                               = 32;
      APPCOMMAND_PRINT                              = 33;
      APPCOMMAND_UNDO                               = 34;
      APPCOMMAND_REDO                               = 35;
      APPCOMMAND_COPY                               = 36;
      APPCOMMAND_CUT                                = 37;
      APPCOMMAND_PASTE                              = 38;
      APPCOMMAND_REPLY_TO_MAIL                      = 39;
      APPCOMMAND_FORWARD_MAIL                       = 40;
      APPCOMMAND_SEND_MAIL                          = 41;
      APPCOMMAND_SPELL_CHECK                        = 42;
      APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE  = 43;
      APPCOMMAND_MIC_ON_OFF_TOGGLE                  = 44;
      APPCOMMAND_CORRECTION_LIST                    = 45;
      // Windows XP SP1 and above
      APPCOMMAND_MEDIA_PLAY                         = 46;
      APPCOMMAND_MEDIA_PAUSE                        = 47;
      APPCOMMAND_MEDIA_RECORD                       = 48;
      APPCOMMAND_MEDIA_FAST_FORWARD                 = 49;
      APPCOMMAND_MEDIA_REWIND                       = 50;
      APPCOMMAND_MEDIA_CHANNEL_UP                   = 51;
      APPCOMMAND_MEDIA_CHANNEL_DOWN                 = 52;
    
      FAPPCOMMAND_MOUSE = $8000;
      FAPPCOMMAND_KEY   = 0;
      FAPPCOMMAND_OEM   = $1000;
      FAPPCOMMAND_MASK  = $F000;
    
      // Mouse buttons;  remaining ones are declared in Windows.pas
      MK_XBUTTON1 = $20;
      MK_XBUTTON2 = $40;
    
    function GET_APPCOMMAND_LPARAM(lParam: LPARAM): Short;
    function GET_DEVICE_LPARAM(lParam: LPARAM): Word;
    function GET_KEYSTATE_LPARAM(lParam: LPARAM): Word;
    
    
    implementation
    
    function GET_APPCOMMAND_LPARAM(lParam: LPARAM): Short;
    begin
      Result := HiWord(lParam) and not FAPPCOMMAND_MASK;
    end;
    
    function GET_DEVICE_LPARAM(lParam: LPARAM): Word;
    begin
      Result := HiWord(lParam) and FAPPCOMMAND_MASK;
    end;
    
    function GET_KEYSTATE_LPARAM(lParam: LPARAM): Word;
    begin
      Result := LoWord(lParam);
    end;
    
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Triple-clicking the mouse to select a paragraph sets document.getSelection().leftOffset to 0 (which seems right)
Struggling with styling the mouse over for a button ... I have managed to
What's the correct way to detect, from Flash, when someone has started a drag
We all know that you can simulate click or any other event on an
Is it possible to set the virtual key state / mouse button state for
I used MouseMove event to detect mouse movement, so I could change the visibility
The WPF Grid has an IsMouseOver property that you can use in the Grid's
This code disabled mouse scroll functionality, when i click on the document. $(document).on(click, function
How do you track mouse motion after mousedown until mouseup using JQuery? Tracking should
I'm moving the mouse over a div and I want to know the mouse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.