Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Toolbar Image swap on mouseover

Posted on 2000-05-16
4
Medium Priority
?
357 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

718 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