Link to home
Start Free TrialLog in
Avatar of kretzschmar
kretzschmarFlag for Germany

asked on

qow 20: Make a "Hoover"-Button Component

hi experts,

each week i will introduce a new simple? question.

now qow 20

sorry, top 15 experts, you are not allowed to solve this
q, only other can solve this question, :-(
but you can place your suggestions (for free) after
closing this q

well the question is:

How to make Hoover-Button Component?

Scenario Description:
What i want is a button, which changes its Font, if i enter/move my mouse over the button, and set it back if i leave the button. Additional i will be able to adjust the Font-properties for both possibilities in the object-inspector at designtime.

i, myself,
can only validate sources until delphi version 5.

Validations may faster, if you can, additional to the source-posting here, send me your compiled project to
info@meikl.de

each different solution may get 50 pts (a-graded)

end of this question is next monday

have fun and let see

meikl ;-)
Avatar of DragonSlayer
DragonSlayer
Flag of Malaysia image

create a new button type :)

type
  THoverButton = class(TButton)
  private
    FHoverFont: TFont;
    FOldFont: TFont;
  protected
    procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    HoverFont: TFont read FHoverFont write FHoverFont;
  end;

implementation

{ THoverButton }

constructor THoverButton.Create(AOwner: TComponent);
begin
  inherited;
  FHoverFont := TFont.Create;
  FOldFont := TFont.Create;
end;

destructor THoverButton.Destroy;
begin
  FHoverFont.Free;
  FOldFont.Free;
  inherited;
end;

procedure THoverButton.CMMouseEnter(var Msg: TMessage);
begin
  FOldFont.Assign(Font);
  Font.Assign(FHoverFont);
end;

procedure THoverButton.CMMouseLeave(var Msg: TMessage);
begin
  Font.Assign(FOldFont);
end;

Avatar of kretzschmar

ASKER

really fast, dragonslayer

for others,
if there is no different solution,
then i will grade enhancements,
which makes sense (maybe an onHover-event, etc)

q is open until next monday

meikl ;-)
Avatar of robert_marquardt
robert_marquardt

It would be unfair to post sources.
I currently work on the Jedi VCL sources and there are scores of components with hover effect.
hi robert,

>It would be unfair to post sources.

? unfair, why ?

if you can't post sources,
because of copyright violations or whatever,
then you can't participate in this q and
you will get no points of course.

btw.
the posted sources should be free of any law and order
violations, best self coded.

btw 2
i myself, have nothing to do with the jedi project

meikl ;-)


ASKER CERTIFIED SOLUTION
Avatar of DragonSlayer
DragonSlayer
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dragonslayer, the only one :-))

get your points.

robert,
if you will and can,
you could show now, how jedi does it
(just only if this may allowed)

meikl ;-)
Just like Dragonslayer. I find it unfair to earn points with code others have written.<br>
<br>
BTW i think i will start something similar (already started in fact).<br>
I will ask to develop or refactor several Jedi VCL components.
>I will ask to develop or refactor several Jedi VCL
>components

sounds interesting, but i'm not sure waht you mean?
The components of the Jedi VCL are currently a bunch of donations so the style and the quality of the implementation varies extremely.
Active controls (doing some blinking moving etc) for example use timers, threads or a loop with Sleep and ProcessMessages (yuk) to drive the effect.
This has to be refactored to only one mechanism and the components need a hierarchy tree. Properties like Blinking, Moving etc need to be refactored to a common Active.
The above is only an example for to even more work to do. Some components deserve an improvement, some components need to be united.........

I currently clean up the style of all the files (ca 500 files, ca 9 MB). That is using standard indents, proper capitalization of identifiers etc.
>I currently clean up the style of all the files (ca 500
>files, ca 9 MB). That is using standard indents, proper
>capitalization of identifiers etc.

puh, sounds like a "sisyphus"-work

robert, btw.,
it looks like you do much in the jedi-project.
how do you come to this?
My whole vacation 4 weeks from next week on will be dedicated to Jedi.

I wanted to write software to access USB. I needed to convert the Setup API to Pascal and soon became a member of Project Jedi.
Then i became interested in the JCL which was created then and some months later i discovered that i was regarded as a Jedi expert.
I still like to contibute heavily.
you have too much time, robert :-))
if you spent your whole vacation for sources

no girlfriend?

anyway, i think you do a good work
and jedi is a good project

meikl ;-)