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?
You need to capture the WM_APPCOMMAND message and then extract the specific command request using GET_APPCOMMAND_LPARAM. Basically, something like this:
Here’s the relevant header translation: