?
Solved

Creating a button like IE's Go

Posted on 2003-02-25
3
Medium Priority
?
197 Views
Last Modified: 2010-04-04
Hi,

I'm using Delphi 4 Pro.  I would like to create a button similar to the Go button in IE (the button that appears to the right of the address combo box).  The button needs to have these properties:

* Consist of both a glyph and text.
* There should be no border shown, except for when the mouse pointer is moved over the button.
* When the mouse pointer is moved over the button, the glyph should change from grey (default state) to colour (hot state).
* The button must *not* be part of a TToolbar.  I intend to place the button either directly on a form or on a TCoolBar.

I've tried using TButton, TBitBtn and TSpeedButton, however none seem to be able to do all of the above.

Can a button with the above properties be created in Delphi 4 Pro?  Do later versions of Delphi (such as Delphi 7 Pro) have any enhanced button components for doing the above?

Thanks in Advance,

Richard
0
Comment
Question by:Richard2000
[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
3 Comments
 
LVL 3

Expert Comment

by:ILE
ID: 8020582
i dont know for the button but u cen easily do that with other component
like the panel

put one panel on the form in this example panel2

set the bevelinear and bevelouter to false;

and put  this code in the  mosemove,mousedovn and  event



procedure TForm1.Panel2MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  panel2.bevelinner:=bvraised;
end;

procedure TForm1.Panel2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  panel2.bevelinner:=bvlowered;
end;


{after that in the form mouse move do}
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
panel2.bevelinner:=bvnone;
end;


and you do what u wont arent you jut add code for one picture on the panel2 what u mey show hide or what u wont

and yes procedure TForm1.Panel2MouseDown
is the supstitution for buttonclick

you see just 3 easy commands :))

0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 8039943
just from scratch

unit HotSpeedButton;

interface

uses
  SysUtils, Classes, Controls, Buttons, graphics, messages;

type
  THotSpeedButton = class(TSpeedButton)
  private
    FHotBitmap : TBitMap;
    FOnMouseEnter : TNotifyEvent;
    FOnMouseLeave : TNotifyEvent;
    FNormalBitMap : TBitMap;
  protected
    Procedure CMMouseEnter(var Message : TMessage); Message CM_MouseEnter;
    Procedure CMMouseLeave(var Message : TMessage); Message CM_MouseLeave;
    Procedure SetHotBitMap(AValue : TBitMap);
    Procedure SetNormalBitMap(AValue : TBitMap);
  public
    Constructor Create(AOwner : TComponent); OverRide;
    Destructor Destroy; OverRide;
    { Public declarations }
  published
    property HotBitMap : TBitMap read FHotBitMap write SetHotBitMap;
    property NormalBitMap : TBitMap read FNormalBitMap write SetNormalBitMap;
    property onMouseEnter : TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property onMouseLeave : TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
    { Published declarations }
  end;

procedure Register;

implementation

Constructor THotSpeedButton.Create(AOwner : TComponent);
begin
  inherited Create(AOwner);
  FHotBitmap := TBitMap.Create;
  FNormalBitMap := TBitMap.Create;
  Flat := True;
end;

Destructor THotSpeedButton.Destroy;
begin
  if assigned(FHotBitMap) then
    FHotBitMap.Free;
  if assigned(FNormalBitMap) then
    FNormalBitMap.Free;
  inherited Destroy;
end;

Procedure THotSpeedButton.CMMouseEnter(var Message : TMessage);
begin
  inherited;
  If Not (csDesigning in ComponentState) then
  begin
    If assigned(FHotBitmap) then
      Glyph.Assign(FHotBitMap);
    If assigned(FOnMouseEnter) then
      FOnMouseEnter(Self);
  end;
end;


Procedure THotSpeedButton.CMMouseLeave(var Message : TMessage);
begin
  inherited;
  If Not (csDesigning in ComponentState) then
  begin
    If assigned(FNormalBitMap) then
      Glyph.Assign(FNormalBitMap);
    If assigned(FOnMouseLeave) then
      FOnMouseLeave(Self);
  end;
end;

Procedure THotSpeedButton.SetHotBitMap(AValue : TBitMap);
begin
  FreeAndNil(FHotBitMap);
  if Assigned(AValue) then
  begin
    FHotBitMap := TBitMap.Create;
    FHotBitMap.Assign(AValue);
  end;
end;

Procedure THotSpeedButton.SetNormalBitMap(AValue : TBitMap);
begin
  FreeAndNil(FNormalBitMap);
  if Assigned(AValue) then
  begin
    FNormalBitMap := TBitMap.Create;
    FNormalBitMap.Assign(AValue);
  end;
  Glyph.Assign(AValue);
end;


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

end.

meikl ;-)
0
 

Author Comment

by:Richard2000
ID: 8051352
Hi,

Thanks for the code.  I was just wondering if there was any way of creating such a button using the standard buttons components in the VCL that come with Delphi?

It is possible to create such a button as a button on a TToolBar in Delphi 4 Pro.  However, the TToolBar is intended for creating groups of buttons and I just need one button on its own that isn't part of a TToolBar.

Thanks in Advance,

Richard
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

777 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