Solved

Toolbar Image swap on mouseover

Posted on 2000-05-16
4
321 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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