MasterCluster.software Contact   About
Apps for Windows Source Code SQL Server Extensions  

HintBox component

Hint Box mcHintBox component overview

The Task…

When write code that handles user inputs, it is a common practice to use WinAPI function MessageBox() to display just an information text, such as «Numeric value is too large», or «Password is incorrect», etc.

When the message box appears, then the user needs to spend time to:

  • Realize where he goes wrong (search the screen for the problematic control), then he needs to…
  • Discard the message box by pressing «OK» button using the mouse or keyboard, and, finally…
  • Move the input focus to the required control.

Too much for such an easy thing, isn't it? SO LET SIMPLIFY THIS!

…And The Solution

HintBox Demo Application

The mcHintBox component is a combination of Windows popup tooltips, «What's this?» context popup help, and ability to show and automatically hide the diagnostic messages.

MCHintBox simplifies the user's life:

  • User has no need to search the screen for the problematic control — the component will set focus to it, graphically point to it and display a message near to it.

  • User has no need to perform any special actions to discard this message from the screen. When he understand the message then he just continue with his task — and message will disappear.

  • Programmers may use only a single function call, HintBox, to display the message (see the «Simple Example» below).

Feature notes

  • Suitable for any version of Windows: 9x/Me/NT/2K/XP;

  • Invoked by a single function call, HintBox;

  • Appears on the screen as a modeless window (not modal or dialog) and can be discarded by any user acivity (by clicking mouse buttons or pressing keyboard) except the mouse movements;

  • Only one MCHintBox window can be visible at the same moment;

  • Under WindowsXP, it drops shadow from the right and bottom edges of the hint window.

  • This component has not to be installed into the Delphi Component Palette. It can be simple copied to any appropriate project's directory.

Example Simple Example

  • Run Delphi and start a new project.

  • Include mcHintBox into the uses clause of the Unit1. Now you've got access to HintBoxControl global variable.

  • Drop TEdit onto the Form1.

  • For the Edit1.OnChange, write the following code:

    if Length(Edit1.Text) > 5 then
       HintBox(Edit1, 'The desired maximum text length is only 5 chars', 'Did you know…');
  • Run the project. Type more than 5 characters into Edit1. You should see the hint near to Edit1. Try to press any key, or click the mouse, or switch to another application. Any user activity (except the mouse movements) causes hint window to be discarded.

mcHintBox.pas reference

The HintBox procedure

Use this procedure to activate mcHintBox message window. Its syntax is quite similar to standard MessageBox function.

HintBox

Displays the hint window near to given target control, using given message text, caption, and optional icon. It can be also positioned absolutely on screen or relatively to target control using optional coordinates.

procedure HintBox(ATarget: TWinControl; const AText, ACaption: String; AIconType: Integer = MB_ICONINFORMATION; X: Integer = -1; Y: Integer = -1); overload;

or

procedure HintBox(ATarget: TWinControl; const AText, ACaption: String; AIcon: TGraphic = nil; X: Integer = -1; Y: Integer = -1); overload;

ATarget
[in] A control to be focused.
AText
[in] Message text to be displayed. Can be empty if ACaption is not empty.
ACaption
[in] Message caption to be displayed (bold highlited). Can be empty if AText is not empty.
AIconType
[in] One of standard MB_ICONxxxx constants. It is MB_ICONINFORMATION by default. To display no icon, pass zero as an AIconType value.

or overloaded

AIcon
[in] A custom icon or bitmap. Either instances of TIcon, TBitmap, or TImage.Picture.Graphic can be passed there.
X
[in] An optional X-coordinate of HintBox window.
Y
[in] An optional Y-coordinate of HintBox window.
Remarks

Cases of Target and Coordinates

  • ATarget is NOT nil, X and Y params are both missed or equal to -1 (e.g. NOT specified):
    - The HintBox window will appear near to ATarget control and will point on it.

  • ATarget is NOT nil, the coordinates are specifed:
    - They define an offset of the HintBox window from its position near to the target control.

  • ATarget is nil, the coordinates are NOT specifed:
    - The pointing arrow will NOT be drawn and the window will be centered on screen.

  • ATarget is nil, the coordinates are specifed:
    - The HintBox window will appear at this position on screen.

Get It From Here!

  1. Try the demo including the project source code and executable (220K download size).
  2. Read our Privacy Policy and Order Processing information.
  3. Buy the HintBox component source code using a safe payment processing service from Share*it!.


Buy Now: Get HintBox component source code

Copyright © 2003-2015 MasterCluster.com
Share |