Window with Taskbar behavior

Hi all,

How can I create a window (form) the acts like the windows task bar.  This means it resize it self whe the mouse enter and leaves.

cechetoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TheNeilConnect With a Mentor Commented:
Getting the form to detect when the mouse is over it is a doddle but the difficulty comes when you try to detect the mouse leaving the form. What you could do is add a timer and get the mouse co-ordinates while the mouse is over your form.

PROCEDURE TForm1.OnMouseMove(Sender : TObject);
BEGIN
  IF Form1.Height < 5
  THEN
  BEGIN
    Form1.Height := 100;
    Timer1.Enabled := TRUE;
  END;
END;

Then create a TTimer component (disabled to start with and with the interval set to about 10) and add the following to it's Timer event:

PROCEDURE TForm1.TimerTimer(Sender : TObject);
VAR
  MousePos : TPoint;
BEGIN
  MousePos := Mouse.CursorPos;
  IF (MousePos.x >= Left) AND (MousePos.x < (Left + Width)
    AND ((MousePos.y > Top) AND (MousePos.y < (Top + Height))
  THEN
  BEGIN

  END
  ELSE
  BEGIN
    Timer1.Enabled := FALSE;
    Height := 5;
  END
END;

This will detect when the mouse is over the form, resizing it and turning the timer on. Then all the time the mouse is over your form, the timer will be checking the mouse position. As soon as the mouse goes outside your form it will detect it, resize the form and turn the timer off.

The Neil
0
 
nricoCommented:
What do you mean "When the mouse enters and leaves"?
The taskbar doesn't automatically resize itself when the mouse enters and leaves...

Oh, got it! You're hiding your taskbar.

Well, your form has two events
OnMouseOver and OnMouseOut (I believe those are the names) that occur when the mouse enters respectively leaves the form, so perhaps you could use those.
0
 
AttarSoftwareCommented:
You can have a timer on your form that each time it fires, it checks to see where the mouse is (using GetCursorPos), and if the mouse is near enough, resize the form...

Tim.
 
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
nricoCommented:
Ex:

Procedure Form1.Form1MouseOver(Sender:TObject);
Begin
  Form1.Width:=300;
  Form1.Height:=200;
End;

Procedure Form1.Form1MouseOut(Sender:TObject);
Begin
  Form1.Width:=50;
  Form1.Height:=50;
End;

Align the form to any side of the screen to simulate the effect.
0
 
duke_nCommented:
I had a form-class somewhere that does it. You want me to send it to ya?
0
 
duke_nCommented:
(makes the form act fully like a taksbar, that is)
0
 
cechetoAuthor Commented:
Ok nico, I think your aproach is the correct, The correct events are OnMouseEnter and OnMouseLeave, (The names really don't matter) wich respond to the windows messages CN_OnMouseEnter and CN_OnMouseLeave.  I have also attached a timer that wait for a time before closing.

The problem I have is that whe I move the mouse over the form (speccially whe I change from one component to another) the form hides and restores itself.
0
 
cechetoAuthor Commented:
Please duke_n, send your form (It could help a lot) (cecheto@teleline.es)
0
 
cechetoAuthor Commented:
The Neil got the solved the problem I had (Important to check the mouse position before hiding the form)
0
 
TheNeilCommented:
Cecheto

Depends which idea you go with. Certain solutions would get around that for you... (and wouldn't need doing anything that Delphi doesn't do itself)

The Neil
0
 
TheNeilCommented:
Cecheto

Depends which idea you go with. Certain solutions would get around that for you... (and wouldn't need doing anything that Delphi doesn't do itself)

The Neil
0
 
dygCommented:
You can use Application Desktop Toolbars API. See Win32 help
0
 
cechetoAuthor Commented:
nrico and TheNeil got the answers, who gets the points?
0
 
TheNeilCommented:
Well, nrico got an answer before me but I think that mine is a little easier (then again I'm a little biased). If nrico agrees, you could delete this question and then post a question for each of us with half the points

The Neil
0
 
duke_nCommented:
Hey!
Wait for my class to arrive! :-)
I sent it rared(takes only 360K this way) assuming that if you're an expert then you have winrar. otherwise www.rarsoft.com
0
 
intheCommented:
duke_n are you sending appbar14 by any chance ?
if so this is good delphi example of creating a taskbar form,and shouldnt be overlooked ..then agin maybe too deep for this purpose..
0
 
duke_nCommented:
some appbar, yes
0
 
cechetoAuthor Commented:
Thanks a lot for you component Duke_n, but it's far more advanced than what I am looking for.  Anyway I saw the demos and it works perfectly. I'll take a look inside to see how it works.  Then, who get's the points? All of you have help a lot (Is there a way to divide the points?)
0
 
ptmcompCommented:
Sorry, I didn't read all the comments. My suggestion is: Make your window a top most window. Don't really hide it, just move it out of the screen so that rests a one pixel line at the screen border. When the mouse moves over it, then move it in the visible area. When the mouse leaves move it outside till there's the one pixel line...
Regards, ptm.
0
 
cechetoAuthor Commented:
I have given the points to TheNeil because he fixed the problems I was having, any way the full answer is build with rnicos comments also
0
 
TheNeilCommented:
Thanks cecheto

The Neil
0
All Courses

From novice to tech pro — start learning today.