Form on taskbar (Like Windows MediaPlayer)

I am writing a small app and wondering how i can create a little form or something on the taskbar where i can put buttons and other things.  Similar to windows media player when you can minimise it and it displays on the task bar.
LVL 1
rafaelrglAsked:
Who is Participating?
 
2266180Connect With a Mentor Commented:
sorry. the image loaded in a small window and I didn't see the scroll bar and as it was it seems to be a complete desktop screenshot with the first line of black text.

so, to make it clear: the form IS in the taskbar. it is just above everything else. it's the top window.
anyway, I can only imagine that this would be a little difficult to do using a form. so I searched a little and found how to work with the taskbar buttons themselves: http://w-shadow.com/blog/2006/10/01/manipulating-taskbar-buttons/ It's not that trivial, but once you read through you should be able to do what you need.

the way windows media player does it though is by creating another toolbar and adding it to the taskbar. now from what I searched I found this on the VB TA: http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21293290.html (which contains quite some information. interesting to read). but if you just want to get down to bussines then (I read it so I know now what to search for :P ) you will have to do a bandobject/daskband. fun starts from here: http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20149653.html
0
 
2266180Commented:
well you would just create a form parented and assign as parent the taskbar. the rest is just to make it look better (hiding the caption bar)

procedure TForm1.Button1Click(Sender: TObject);
var f:tform; taskbar:hwnd;
begin
  taskbar:=findwindow('Shell_TrayWnd',nil);
  f:=tform.CreateParented(taskbar);
  SetWindowLong( f.Handle, // hide captionbar
     GWL_STYLE,
     GetWindowLong( f.Handle, GWL_STYLE )
     and not WS_CAPTION ) ;
  f.ClientHeight := f.Height;
  f.Show;
end;
0
 
rafaelrglAuthor Commented:
It shows on the left side, and I would like to show on the right side of the taskbar like widows media player.
0
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.

 
2266180Commented:
well just move it to the place you want it. (I don't use media player so I don't know what minimization you are talking about ;-) )

var f:tform; taskbar:hwnd; r:trect;
begin
  taskbar:=findwindow('Shell_TrayWnd',nil);
  f:=tform.CreateParented(taskbar);
  SetWindowLong( f.Handle, // hide captionbar
     GWL_STYLE,
     GetWindowLong( f.Handle, GWL_STYLE )
     and not WS_CAPTION ) ;
  f.ClientHeight := f.Height;
  GetWindowRect(FindWindowEx(taskbar,0,'TrayNotifyWnd',NIL),r);
  f.Left:=r.Left-f.Width;
  f.Show;
end;

this will place the form just before the tray. guess this is what you want. if not ... maybe a screen shot or some indications of how to achieve this? I have media player that ships with windows xp sp1.
0
 
rafaelrglAuthor Commented:
can you take a look to windows media player, you will see what I am talking about. It's great that application.
0
 
rafaelrglAuthor Commented:
here is the link with the print screen:

http://www.nucleodaweb.com/taskbar.jpg
0
 
2266180Commented:
well the code I last posted does that. whyy is it not good?
0
 
rafaelrglAuthor Commented:
becouse the last code does not show on taskbar.

http://www.nucleodaweb.com/taskbar2.jpg
0
 
2266180Commented:
you're doing something wrong. create a new application, put that code at a button click. start the app, click the button: it will show it on the taskbar. don't modify that code in any way or you will introduce bugs. teh code, as it is works like a charm.

this is my test app unit I just made for a doublecheck:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var f:tform; taskbar:hwnd; r:trect;
begin
  taskbar:=findwindow('Shell_TrayWnd',nil);
  f:=tform.CreateParented(taskbar);
  SetWindowLong( f.Handle, // hide captionbar
     GWL_STYLE,
     GetWindowLong( f.Handle, GWL_STYLE )
     and not WS_CAPTION ) ;
  f.ClientHeight := f.Height;
  GetWindowRect(FindWindowEx(taskbar,0,'TrayNotifyWnd',NIL),r);
  f.Left:=r.Left-f.Width;
  f.Show;
end;

end.

think otherwise: since the first code worked, and the second code all it does is move the window to the right, and it doesn't work for you, it means that you did something wrong.
0
 
rafaelrglAuthor Commented:
you did not see the printscreen that I did take from my pc.

look here and you will see what i am talking about.

http://www.nucleodaweb.com/taskbar2.jpg
0
 
rafaelrglAuthor Commented:

http://www.microsoft.com/msj/1199/bandobj/bandobj.aspx

there's a code in C++ but I really want in delphi, do you mind?

0
 
rafaelrglAuthor Commented:
take a look on that picture, that's what I want to do!!!

http://www.microsoft.com/msj/1199/bandobj/bandobjfig12.gif
0
 
2266180Commented:
I know that is what you want. that's what I said you need as well :) ("you will have to do a bandobject/daskband. fun starts from here:")

If you want me to do a small demo for you then please give me time till the weekend. I'm a day behind my project (the type I'm getting paid for ;) ) and I must make it up.
0
 
rafaelrglAuthor Commented:
Thank's ciuly. you help me a lot, when you get time, if you can send me a example, i'm going to be so glad.
0
 
2266180Commented:
ok. then just post a reminder message on friday night. just to make sure I don't forget :D
thanks
0
 
2266180Commented:
hi. you forgot to ping me :P lucky I went through my emails looking for old questions to archive :)
anyway, I looked over the article you posted: way too big for me to translate it. so I did another searching for almost an hour (yes, I was looking for ready made stuff :D) and then I found the following stuff:
- there used to be a component (set?) named zDeskBar or yDeskBar or soemthing like that which is now included in JEDI as jvDeskBand. didn't try it out.
- there is this article: http://delphi-notes.blogspot.com/2005/12/deskbands-with-delphi.html with source on BDN which actually works. it's in german. all you need to know is that the comment with the GUID probably means that you need to change the guid (since ctrl+shift+G generates a new GUID.)

you can star from any of the above 2 possibilities as a skeleton and work on that to include your functionality.
0
 
AmigoJackCommented:
yep, ciuly intuitively translated it right. when i experimented on deskbands it wasnt the purest fun, because basical behaviour worked fine (like showing it) and then minorities rapidly crashed the shell (like moving, resizing it).

one thing was very new to me reading the MSJ article: hiding/closing a deskband will the shell NOT release its memory - restoring/showing the deskband (again) will allocate its own memory for it! so i wonder if the mediaplayer is indirectly also a "mem-eater". i dont use it either, so just try it yourself, always switching between the actual mediaplayer application (its main window) and the deskband while watching your memories in the taskmanager.

anyway, thanks also ciuly for finding out :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.