User Tools

Site Tools


selecting_20and_20copying_20using_20the_20mouse

Differences

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

Link to this comparison view

selecting_20and_20copying_20using_20the_20mouse [2018/03/31 13:19]
127.0.0.1 external edit
selecting_20and_20copying_20using_20the_20mouse [2018/04/16 14:33] (current)
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Selecting and copying using the mouse===== =====Selecting and copying using the mouse=====
  
-//by Richard Russell, May 2006, amended October 2009//\\ \\ +//by Richard Russell, May 2006, amended October 2009// 
 ===== Selecting and copying text ===== ===== Selecting and copying text =====
-\\  ​Many Windows programs allow you to select a block of text by //​dragging//​ the mouse. Typically you can then copy the selected text to the clipboard by right-clicking and selecting **Copy** from a popup menu.\\ \\  You get this functionality for free if you use an **edit box** for text input or output (either on your main window or in a dialogue box), but otherwise it's not straightforward to achieve in BASIC.\\ \\  The code below allows you to incorporate this facility very easily. It will work with almost any program that outputs (monospaced) text to the main window at ordinary text coordinates. Since it's implemented as an **ON MOUSE** routine you can often add it to a program without modifying the existing code at all.\\ \\  To use this code first add the following line near the beginning of your program:\\ \\ + 
 +Many Windows programs allow you to select a block of text by //​dragging//​ the mouse. Typically you can then copy the selected text to the clipboard by right-clicking and selecting **Copy** from a popup menu.\\ \\  You get this functionality for free if you use an **edit box** for text input or output (either on your main window or in a dialogue box), but otherwise it's not straightforward to achieve in BASIC.\\ \\  The code below allows you to incorporate this facility very easily. It will work with almost any program that outputs (monospaced) text to the main window at ordinary text coordinates. Since it's implemented as an **ON MOUSE** routine you can often add it to a program without modifying the existing code at all.\\ \\  To use this code first add the following line near the beginning of your program: 
 + 
 +<code bb4w>
         ON MOUSE PROCmouse:​RETURN         ON MOUSE PROCmouse:​RETURN
-Then copy the code below into your program where it will not get in the way (for example at the very end):\\ \\ +</​code>​ 
 + 
 +Then copy the code below into your program where it will not get in the way (for example at the very end): 
 + 
 +<code bb4w>
         DEF PROCmouse         DEF PROCmouse
         LOCAL H%,​M%,​O%,​P%,​A$,​@vdu%!24,​@vdu%!32         LOCAL H%,​M%,​O%,​P%,​A$,​@vdu%!24,​@vdu%!32
Line 91: Line 99:
         SYS "​SendMessage",​ @hwnd%, 0, 0, 0         SYS "​SendMessage",​ @hwnd%, 0, 0, 0
         = T%         = T%
-Once this code has been added to your program you can highlight a rectangular block of text by //​dragging//​ the mouse over it. A right mouse-click will display a popup menu containing the **Copy** item. Clicking on that will copy the selected text to the clipboard.\\ \\ +</​code>​ 
 + 
 +Once this code has been added to your program you can highlight a rectangular block of text by //​dragging//​ the mouse over it. A right mouse-click will display a popup menu containing the **Copy** item. Clicking on that will copy the selected text to the clipboard. 
 ===== Selecting and copying graphics ===== ===== Selecting and copying graphics =====
-\\  ​The code below implements a similar facility to the above, but allows you to select and copy graphics rather than text.\\ \\  To use this code first add the following line near the beginning of your program:\\ \\ + 
 +The code below implements a similar facility to the above, but allows you to select and copy graphics rather than text.\\ \\  To use this code first add the following line near the beginning of your program: 
 + 
 +<code bb4w>
         ON MOUSE PROCmouse:​RETURN         ON MOUSE PROCmouse:​RETURN
-Then copy the code below into your program where it will not get in the way (for example at the very end):\\ \\ +</​code>​ 
 + 
 +Then copy the code below into your program where it will not get in the way (for example at the very end): 
 + 
 +<code bb4w>
         DEF PROCmouse         DEF PROCmouse
         LOCAL D%,​H%,​M%,​O%,​P%         LOCAL D%,​H%,​M%,​O%,​P%
Line 176: Line 194:
         SYS "​SendMessage",​ @hwnd%, 0, 0, 0         SYS "​SendMessage",​ @hwnd%, 0, 0, 0
         = T%         = T%
 +</​code>​
 +
 Once this code has been added to your program you can select a rectangular region by //​dragging//​ the mouse over it. A right mouse-click will display a popup menu containing the **Copy** item. Clicking on that will copy the graphics in the selected region to the clipboard. Once this code has been added to your program you can select a rectangular region by //​dragging//​ the mouse over it. A right mouse-click will display a popup menu containing the **Copy** item. Clicking on that will copy the graphics in the selected region to the clipboard.
selecting_20and_20copying_20using_20the_20mouse.txt · Last modified: 2018/04/16 14:33 by richardrussell