Get Position of Taskbar button | Newbie | | Join Date: Jul 2009
Posts: 11
| | |
This is specifically for Windows 7, but any insight would be great. My app currently starts up and shows a form at the cursor position, but this is not feasible for what I would like as the user can quickly move the mouse after launching the application. So how would I got about getting the position of the task bar button and showing the window there?
| | Familiar Sight | | Join Date: Jul 2009 Location: Calgary, Alberta, Canada
Posts: 232
| | | re: Get Position of Taskbar button http://forums.devshed.com/c-programm...-c-295635.html http://support.microsoft.com/kb/179908
It looks like you need to use some of the windows dlls to make the call you need, which means you'll need to make use of DLLImport. I won't try to explain it here because I'm pretty new at using it myself, and don't have a good understanding of the windows libraries themselves.
Google should be able to help you figure out what you need, or hopefully someone here with more experience in that area can help you. Those two links should get you started though.
Good luck!
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,782
| | | re: Get Position of Taskbar button
Correct me if I am wrong but... The taskbar is on the primary monitor. That's what makes that monitor "primary", right? So just get the WorkingArea of the primary screen.
Do a little reading on MSDN for System.Windows.Forms.Screen.AllScreens;
|  | Moderator | | Join Date: Apr 2007 Location: New England
Posts: 7,161
| | | re: Get Position of Taskbar button
When you say taskbar button, you mean the launcher that sits in the menu bars (similar to the "quick launch" bar in XP)?
Why does your form need to popup right next to the launcher?
| | Newbie | | Join Date: Jul 2009
Posts: 11
| | | re: Get Position of Taskbar button
My program pops up like an extension of the task bar to perform some things, that is why I need it to be over the top of the button clicked.
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,782
| | | re: Get Position of Taskbar button
Are you saying it acts like a context menu for any button (application) on the task menu? So you want your form to open directly above some other program button in the task bar?
So if I have "notepad" open, there is a "notepad" button on the taskbar. You want your program's form to open right above the "notepad" button in the taskbar when I click on the "notepad" button? Is that right?
| | Newbie | | Join Date: Jul 2009
Posts: 11
| | | re: Get Position of Taskbar button
tlhintoq, that is exactly what i'm talking about =)
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,782
| | | re: Get Position of Taskbar button
What happens with the standard behavior of clicking on a taskbar button if your app is intercepting it?
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,782
| | | re: Get Position of Taskbar button
You know you can't just go with "above" the button, right?
Taskbar can be moved to the top of the screen, or left or right sides.
Instead of basing your opening on the current cursor position, what about basing it on the position when then the mouse was clicked?
| | Newbie | | Join Date: Jul 2009
Posts: 11
| | | re: Get Position of Taskbar button
Yes, I'm aware it can be moved. I'm doing it via cursor position because clicking the button launches my application as it is pinned to the task bar (Windows 7).
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,782
| | | re: Get Position of Taskbar button
Taskbar buttons are still just part of a controls collection. You should be able to go through them to get their positions. Just like going through a collection of controls on a form to get all the buttons, textboxes, labels etc. Right?
|  | Similar C# / C Sharp bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,501 network members.
|