User Tools

Site Tools


using_20non-standard_20mouse_20pointers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

using_20non-standard_20mouse_20pointers [2018/03/31 13:19]
127.0.0.1 external edit
using_20non-standard_20mouse_20pointers [2018/04/16 14:38] (current)
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Using non-standard mouse pointers===== =====Using non-standard mouse pointers=====
  
-// by Richard Russell, October 2007//\\ \\  You can select the mouse pointer (cursor) from any of the standard shapes using the [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwin6.html#​mouseon|MOUSE ON]] statement. However there may be occasions when you want to use a pointer that is not one of the standard shapes. This is most straightforwardly achieved by loading the pointer shape from a cursor (.CUR) file.\\ \\  For example suppose you want to use the '​closed hand' shape in the file **HMOVE.CUR**. Firstly you must load the file and obtain a //handle// to the cursor:\\ \\ +// by Richard Russell, October 2007//\\ \\  You can select the mouse pointer (cursor) from any of the standard shapes using the [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwin6.html#​mouseon|MOUSE ON]] statement. However there may be occasions when you want to use a pointer that is not one of the standard shapes. This is most straightforwardly achieved by loading the pointer shape from a cursor (.CUR) file.\\ \\  For example suppose you want to use the '​closed hand' shape in the file **HMOVE.CUR**. Firstly you must load the file and obtain a //handle// to the cursor: 
 + 
 +<code bb4w>
         IMAGE_CURSOR = 2         IMAGE_CURSOR = 2
         LR_LOADFROMFILE = 16         LR_LOADFROMFILE = 16
         cursor$ = "​C:​\Windows\Cursors\HMOVE.CUR"​         cursor$ = "​C:​\Windows\Cursors\HMOVE.CUR"​
         SYS "​LoadImage",​ 0, cursor$, IMAGE_CURSOR,​ 0, 0, LR_LOADFROMFILE TO hHand%         SYS "​LoadImage",​ 0, cursor$, IMAGE_CURSOR,​ 0, 0, LR_LOADFROMFILE TO hHand%
-Note that the **2** signifies that the file contains a cursor image.\\ \\  Having obtained the handle (in this case **hHand%**) you can use it to set the mouse pointer to this shape as follows:\\ \\ +</​code>​ 
 + 
 +Note that the **2** signifies that the file contains a cursor image.\\ \\  Having obtained the handle (in this case **hHand%**) you can use it to set the mouse pointer to this shape as follows: 
 + 
 +<code bb4w>
         WM_MOUSEMOVE = 512         WM_MOUSEMOVE = 512
         @hcsr% = hHand%         @hcsr% = hHand%
         SYS "​SendMessage",​ @hwnd%, WM_MOUSEMOVE,​ 0, 0         SYS "​SendMessage",​ @hwnd%, WM_MOUSEMOVE,​ 0, 0
 +</​code>​
 +
 The **SendMessage** is simply to force the cursor to change immediately,​ rather than when the mouse is next moved. Depending on how your program works, it may not be essential.\\ \\  You must be careful to load the file only once, to avoid a //resource leak//. Once you have obtained a handle to the cursor you can use it to change the pointer shape whenever you like in your program, without needing to load the file again. The **SendMessage** is simply to force the cursor to change immediately,​ rather than when the mouse is next moved. Depending on how your program works, it may not be essential.\\ \\  You must be careful to load the file only once, to avoid a //resource leak//. Once you have obtained a handle to the cursor you can use it to change the pointer shape whenever you like in your program, without needing to load the file again.
using_20non-standard_20mouse_20pointers.txt · Last modified: 2018/04/16 14:38 by richardrussell