Solved

Toolbar Image swap on mouseover

Posted on 2000-05-16
4
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 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