Solved

C# : Taskbar Location

Posted on 2007-03-28
3
1,504 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Login 17 51
WCF Service Application cannot connect from TCP terminal 1 33
Moving code from one TFS branch to another 3 25
What Does This C# Code Block Do? 5 33
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

823 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