Solved

Form on taskbar (Like Windows MediaPlayer)

Posted on 2006-11-13
17
443 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:rafaelrgl
  • 8
  • 8
17 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 17936808
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
 
LVL 1

Author Comment

by:rafaelrgl
ID: 17940412
It shows on the left side, and I would like to show on the right side of the taskbar like widows media player.
0
 
LVL 28

Expert Comment

by:2266180
ID: 17941248
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
 
LVL 1

Author Comment

by:rafaelrgl
ID: 17951181
can you take a look to windows media player, you will see what I am talking about. It's great that application.
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 17951210
here is the link with the print screen:

http://www.nucleodaweb.com/taskbar.jpg
0
 
LVL 28

Expert Comment

by:2266180
ID: 17953826
well the code I last posted does that. whyy is it not good?
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 17960471
becouse the last code does not show on taskbar.

http://www.nucleodaweb.com/taskbar2.jpg
0
 
LVL 28

Expert Comment

by:2266180
ID: 17960564
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:rafaelrgl
ID: 17962713
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
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 17963588
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
 
LVL 1

Author Comment

by:rafaelrgl
ID: 17992907

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
 
LVL 1

Author Comment

by:rafaelrgl
ID: 17992925
take a look on that picture, that's what I want to do!!!

http://www.microsoft.com/msj/1199/bandobj/bandobjfig12.gif
0
 
LVL 28

Expert Comment

by:2266180
ID: 17993787
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
 
LVL 1

Author Comment

by:rafaelrgl
ID: 18000257
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
 
LVL 28

Expert Comment

by:2266180
ID: 18001732
ok. then just post a reminder message on friday night. just to make sure I don't forget :D
thanks
0
 
LVL 28

Expert Comment

by:2266180
ID: 18013806
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
 
LVL 12

Expert Comment

by:AmigoJack
ID: 18013927
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending Gmail through Delphi 3 91
Virtuailstring tree compare node issue 14 105
Multiple image collision 13 69
Installshield for Embarcadero EX 10.1 Berlin 4 20
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

861 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

23 Experts available now in Live!

Get 1:1 Help Now