Solved

C# : Taskbar Location

Posted on 2007-03-28
3
1,510 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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