Solved

C# : Taskbar Location

Posted on 2007-03-28
3
1,503 Views
Last Modified: 2007-12-19
Hi,
I'm working in C#. I have created an application that runs in the system tray. When the user double-clicks the try  icon, a small form comes up in the bottom right corner of the screen, i.e. right above the system tray. The form is basically "sticky" to the tray.

Here is my question: How do I accomplish the same thing, even if the user has the taskbar docked somewhere else? Like at the top of the screen, or one of the sides?

It shouldn't be hard, since I figure all I have to do is find out *where* the taskbar is. Is it at the bottom, the top, or one of the sides.  But I can't find any documentation anywhere, that explains how to get the location of the taskbar.

- Sean
0
Comment
Question by:headzoo
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
ShazbotOK earned 250 total points
ID: 18811841
Use the MouseEventArgs to display the location for where your notifyIcon was clicked on... you can then use that to extrapulate the location to how to display your "Sticky note" form

Example:

myNotifyIcon.MouseDown += new MouseEventHandler(myForm_MouseDown);

void myForm_MouseDown(object sender, MouseEventArgs e)
{
      int x = e.X;
      int y = e.Y;
      // now you can assign the location of your form from the X & Y locations of the mouse
     //  if the MouseDown event is too early then you can use the OnClick event to show this
}
0
 

Author Comment

by:headzoo
ID: 18833084
Hi ShazbotOK,
Well that's not the best solution.  One of these days I'm going to need to know the location of the task bar without using the mouse position. Suppose I want to have an alert message come up from the task bar?  When that day comes I'll be right back here asking the question again.

That being said you answered the question as I asked it, so I'll give you the points.
0
 
LVL 12

Expert Comment

by:ShazbotOK
ID: 18835562
If you want to display a notice to the user then use this you could also do it to capture an onclick event - this function implicitly knows the location of the taskbar's system tray:

void myBalloonFunc()
        {
                MyNotifyIcon.BalloonTipClicked += new EventHandler(MyApp_BalloonTipClicked);
                MyNotifyIcon.ShowBalloonTip(3500,"Show My Notification", "BlahBlah",ToolTipIcon.Info)
        }

void MyApp_BalloonTipClicked(object sender, EventArgs e)
        {
                throw new Exception("The method or operation is not implemented.");
        }
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

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 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

15 Experts available now in Live!

Get 1:1 Help Now