=====Responding to mouse double-clicks===== //by Richard Russell, October 2015//\\ \\ By default the [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin6.html#onmouse|ON MOUSE]] event interrupt is activated by clicking one of the mouse buttons, but a **double-click** is not distinguishable from a single click. If you specifically want to respond to mouse double-clicks two steps are necessary; firstly you must enable them as follows: SYS "GetClassLong", @hwnd%, GCL_STYLE TO wc% SYS "SetClassLong", @hwnd%, GCL_STYLE, wc% OR CS_DBLCLKS This code should be executed just once during the initialisation phase of your program (use the **Windows Constants utility** to add declarations for the GCL_STYLE and CS_DBLCLKS constants in the usual way).\\ \\ Secondly, you need to modify your ON MOUSE event handler to examine the **@msg%** system variable in order to discover whether the interrupt was caused by a single or double click. @msg% will have one of the following values: | WM_LBUTTONDOWN\\ | Left button click\\ | | WM_MBUTTONDOWN\\ | Middle button click\\ | | WM_RBUTTONDOWN\\ | Right button click\\ | | WM_LBUTTONDBLCLK\\ | Left button double-click\\ | | WM_MBUTTONDBLCLK\\ | Middle button double-click\\ | | WM_RBUTTONDBLCLK\\ | Right button double-click\\ | There are various different approaches that may be adopted, but a simple asynchronous (polling) method is as follows: REM. During initialisation: DIM Mouse%(2), mous%(2) ON MOUSE Mouse%() = @msg%, @wparam%, @lparam% : RETURN REM. In your main 'polling loop': mous%() = 0 SWAP mous%(), Mouse%() On receiving a mouse click **mous%(0)** will contain the **@msg%** value, **mous%(1)** will contain the **@wparam%** value (which contains information on whether the Shift and/or Control keys were pressed) and **mous%(2)** will contain the **@lparam%** value (which contains information on the position of the mouse when it was clicked). See the description of [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin6.html#onmouse|ON MOUSE]] in the main Help documentation for more details.\\ \\ If you prefer to use a synchronous method you can call a procedure when the interrupt occurs, as follows: ON MOUSE PROCmouse(@msg%, @wparam%, @lparam%) : RETURN Note that when the user double-clicks the mouse you may well receive a 'single click' interrupt as well, and your program will need to cope with that.