1. Computing

TMouse - Delphi Usage Examples, Tips and Tricks

The TMouse Delphi object surfaces information about the mouse and specifies how the application responds to mouse messages. Using the global Mouse variable, which is a TMouse object, you can get information about the mouse.

Monitoring Mouse Activity
Is the mouse over a component? Was a mouse button pressed? Which button was it? Did the user release a button, which one? Exactly where inside the form is the mouse? Did the user move the mouse out of the form and into another?

Advanced Mouse Processing
Is Present, Enter, Move, Exit, Stop, Set, Move, Enter, Over, Leave, Restrict...

Capturing screen shots including the mouse cursor
Here's how to take a screen shot of the Desktop window including the mouse cursor, using Delphi code.

How to Hook the Mouse to Catch Events Outside of your application
Learn how to track the mouse activity even when your application is not active, sits in the Tray or does not have any UI at all.

Get the Control Under the Mouse in a Delphi application
How to know what Control is Under the Mouse in a Delphi application.

Moving the contest of a ScrollBox with mouse (like drag - drop)
How to move a TImage object in a ScrollBox with the mouse, like a drag and drop operation - without the scroll bars.

Highlighting Delphi's DBGrid Row On Mouse Hover
What most are not aware of, is that you can even implement the OnMouseHover (hot tracking) behavior to change the display (color, font, etc.) of the DBGRid's (data) row underneath the mouse - *not* the currently selected row - thus making it look like today's web driven interfaces.

Mouse Eyes
Mouse Eyes is another mouse cursor follower. Mouse eyes idea is indicating which direction to look in to find your mouse cursor.

How to set the progress bar position using mouse
By default, the TProgressBar control is used to provide visual feedback about the progress of a procedure within an application. If you want to enable the users of you application to set the position of the progress bar visually, using mouse, you can use the next trick...

Move ListBox Items with the Mouse (Drag and Drop)
Here's how to allow a user to rearrange (change item's position) the items of a ListBox using drag and drop...

Disable Mouse from Delphi Code
The BlockInput API function blocks keyboard and mouse input events from reaching applications.

Play a Sound When the Mouse Enters a Component
All descendants of TComponent send a CM_MOUSEENTER and CM_MOUSELEAVE messages when the mouse enters and leaves the bounds of the component. You will need to write a message handler for the respective messages if you wish to respond to them - and play a sound, for example, when the mouse "enters" the component.

Move the Mouse to the Focused Control when the Form is Displayed
The ActiveControl property of a Delphi Form object specifies what control has the input focus. You can use this property to set what control is (initially) focused when the form is created and displayed to the user.

Is Mouse over Form?
To tell if the mouse is over Delphi Form, we can use the GetCapture() windows API function to capture the mouse.

Get the Url of a Hyperlink when the Mouse moves Over a TWebBrowser
A very nice feature of a Browser is to display link information, for example, in the status bar, when the mouse hovers over a link in a document.

Drag a Delphi Form Without the Caption Bar
The article lets you provide dragging capabilities for Delphi forms without a title bar, so the user can move a form by clicking anywhere on the client area.

Select ListBox items as Mouse Hovers over them
Here's how to set the selected item in a ListBox as mouse moves over the list box.

What's the word under the mouse cursor in a TRichEdit?
Here's a code to find the word under the mouse cursor in a RichEdit..

Move and Resize Controls at Run Time
While in most situations you will arrange all the controls on a Delphi form in a "fixed" position, there are situations when you need to allow a user to change the placement and dimension of controls at run-time.

Implementing OnMouseOver for Items in a TComboBox, with custom hints
Here's how to get the caption of an item in a TComboBox as mouse hovers over an item when the ComboBox is in drop down state. Use this "trick" to get the object associated with the "pre-selected" item in a combo box, or to display a custom hint for each item, for example.

©2013 About.com. All rights reserved.