Solved

Form on taskbar (Like Windows MediaPlayer)

Posted on 2006-11-13
17
441 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:ciuly
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:ciuly
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:ciuly
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:ciuly
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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:
ciuly 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:ciuly
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:ciuly
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:ciuly
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

12 Experts available now in Live!

Get 1:1 Help Now