Solved

C# : Taskbar Location

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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