Solved

Toolbar Image swap on mouseover

Posted on 2000-05-16
4
325 Views
Last Modified: 2010-04-04
How do I swap an image when the mouse pointer is over a toolbar button?
0
Comment
Question by:fibdev
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
simonet earned 50 total points
ID: 2815369
You have to create 2 imagelists:

One that contais the images the user sees when the control is sitting still (the user is NOT hovering the mouse pointer over it) and another TImageList which contais the images the user sees when the mouse is over the buttons.

The assign these image lists to the Images HotImage properties (respectively) of a TToolBar control.

Note that the images in the first image list must correspond to the hot image, at the same index, on the hot images imagelist. Put in other words:

If the "cold" imagelist, contains, at index 6, the image for the Save button, the Hot imagelist must contain, at index 6, the hot image for the Save button.

Yours,

Alex
0
 
LVL 3

Expert Comment

by:shenqw
ID: 2815500
First.
  You install the component TSQWToolButton.

Second.
  When you new a Toolbutton then view the Form as Text , Change the ToolButton into TSQWToolButton. If you do that , then you can use the events OnMouseEnter and OnMouseLeave and you can change the Image of the ToolButton.

Good Luck!
shenqw


//TSQWToolButton Component

unit SQWToolButton;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls;

type
  TSQWToolButton = class(TToolButton)
  private
    { Private declarations }
    FOnMouseEnter,
    FOnMouseLeave:TNotifyEvent;
  protected
    { Protected declarations }
    procedure CMMouseEnter(var Message:TMessage);message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message:TMessage);message CM_MOUSELEAVE;
  public
    { Public declarations }
  published
    { Published declarations }
    property OnMouseEnter:TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave:TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TSQWToolButton]);
end;

{ TSQWToolButton }

procedure TSQWToolButton.CMMouseEnter(var Message: TMessage);
begin
  inherited;
  if Assigned(FOnMouseEnter) then FOnMouseEnter(Self);
end;

procedure TSQWToolButton.CMMouseLeave(var Message: TMessage);
begin
  inherited;
  if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);
end;

end.
0
 
LVL 3

Author Comment

by:fibdev
ID: 2815512
Thanks again Alex,

You the man
0
 
LVL 15

Expert Comment

by:simonet
ID: 2815519
Anytime, fibdev. ;)

Alex
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now