How to find the location of the icon in the system tray - c#

I have a NotifyIcon control that appears in the system tray. How can I find the location (x, y) of the icon on the screen?
Thanks

Actually you can do this, here is code that shows you how and much more.
In any Mouse Event from NotifyIcon, simply look at Control.MousePosition, this contains the (x,y) of the mouse. The same can be done to position a ContextMenu on a form/control exactly where the form/control was clicked using these (x,y) values.
A good example of both of these is here:
More Here: http://code.msdn.microsoft.com/TheNotifyIconExample

After a long journey of trial and error, and the development of my own notify icon locator, I developed a way to find the best position icon, so far so good, until I saw this amazing project by #zhwang SuperNotifyIcon. This project has three ways to locate the notification icon, ranging from the inaccurate (like my own development) to the use of new in Windows 7 API. This is the definitive answer.

You can't. It isn't hard to get the window handle for the system tray, GetClassName() returns "ToolbarWindow32", the class name of the standard TOOLBAR common control. Beware that a 64-bit OS has two of them. Then you can send messages to it like TB_GETBUTTONINFO. Chief hang-ups are that you won't know what button ID to choose and the returned info does not include the button position.
Which is for the better, buttons move around without you being able to lock them.

Related

Microsoft Office UI Element Coordinates

This isn't my area of programming, but I have one of my junior programmers working on a Windows application that needs to reference the UI elements of a Microsoft Office application, namely to get the coordinates of a button or menu item, such as the coordinates of the compose email button in Outlook or the edit menu item label frame in Excel, for example.
Specifically, is there a way of programatically obtaining the exact coordinates of a UI element from an Office application that is running with a visible window? Is there some kind of API Microsoft provides to programmers to allow determining object metrics.
So far, this is all I could find:
https://msdn.microsoft.com/en-
us/library/system.windows.controls.frame(v=vs.110).aspx
Thanks for any help!
You can extract the coordinate in developer mode of where the mouse is. So by hovering over a button you can see where the coordinate is but any change in resolution or screen size will throw this off.
Many UI options have hotkeys. Have you thought about using those? e.g if you wanna code it to click on file, fire a "alt+f" event and it will

How to create a transparent window that both captures mouse events and allows them to pass through

I've tried searching for the answer to this issue but I've been unlucky trying to find it.
From similar questions on here I've been able to make my transparent window receive mouse events, but then the other applications running behind it don't get any mouse events (Set the background of the window to #01000000 (mostly transparent)).
Or the alternative I've also achieved: the transparent window gets no mouse events and they are all passed through.
Is there a way to combine these 2 and have a transparent window that both interprets mouse events and passes them to whatever is behind it? My end goal would be to display a *ping* graphic on the transparent window (which is the same width/height of my desktop resolution) any time the mouse is clicked on the screen while I'm using other applications.
Further edit:
I have a Canvas in my WPF window. It has MouseLeftButtonDown as an element which calls a method in the behind-code. This method does not seem to get called when I use the solution that I linked, or when I simply set the Window and Canvas to Transparent or #00000000.
I think a better approach would be to use windows hook to catch global mouse events, and simply let your application discard mouse hit tests. As far as I know, Windows hook are not directly available in the .NET framework, but they are PInvokable.
Microsoft provides a pretty straightforward guide for this here.

How to add an extra button to the window title bar, so it will be work as standard?

Firstly I want mention that I have already read all articles on SO on subject, but still have no answer for my question. Also my question slightly different than others.
Today a I have a look on Skype window. There is one extra button on it's title bar. But this button acts as native system button. Just look on glowing, it spreads out of the window. So I have the reasonable question. According to that we can see on the picture below, there is standard way to add extra button on title bar. But all answers on subj leads to hooking of WM_NCPAINT event and manual drawing of extra button. This approach is work but it could not yield such beautifull glowing as on the picture.
Does anybody knows the way to add standartized button on window's title bar?
Thanks in advance!
In Vista and Windows 7 there is a new thing called the Desktop Window Manager. This is used to draw the "Aero glass" window titlebars, and do the glow effects. The old Windows XP approach of implementing WM_NCPAINT handlers doesn't work with this new system, so you have to use a whole new API.
I'm sure I've seen some articles on doing what you're asking about, but can't find them right now. Some pages that might give you some leads are:
http://msdn.microsoft.com/en-us/magazine/cc163435.aspx
http://msdn.microsoft.com/en-us/library/aa969540(v=VS.85).aspx
http://delphihaven.wordpress.com/2010/04/19/setting-up-a-custom-titlebar/
Yes, this can be (and undoubtedly is) done by hooking WM_NCPAINT and painting their button in response to it. The "glowing" is just a matter of picking the appropriate color and shading (and possibly doing a bit of alpha blending to have some "glow" show up close to the button).

How to place a control over the task bar in windows using c#

i googled a lot and found out some info about the band object from which we can make the ad-in for the task bar, can i get some more tutorials from scratch & some sample programmes.
is there any other alternative way is there to place a control over the windows task bar apart from band objects?
Thanks in advance
If you want to place a textbox in the taskbar like the Google Desktop search bar, then you're not actually trying to place the control over the taskbar, you want to place it within the taskbar.
The proper solution here is a Desk Band. You can find an MSDN article explaining those here. I'm not really sure why you say that you want to avoid band objects. That's the right way to do this.
There's even a sample implementation in C# available on Code Project: Extending Explorer with Band Objects using .NET and Windows Forms
To make a window overlap the Taskbar you can set it's TopMost property to true. But then you will have to control the positioning yourself, and it will also overlap anything else beneath it, but it is a solution at least :)

Aero border and other controls in a TrayIcon menu

I'm writing a system tray app for Windows (with much info gleaned from this thread). I have the ContextMenu working - you can right click and execute functions that way.
I want to have a modern, rich interface pop up on a left click, however, much like most of the built in Windows 7 (and possibly Vista) tray icons have. By this I refer to the Aero lining, and apparent ability to add seemingly arbitrary controls (e.g. volume slider, network chooser).
I'm not really sure where to start. Is it a matter of creating a "normal" window and restricting it heavily? If so, how? (If it comes down to Windows Forms vs. WPF, the latter is preferable).
For what it's worth, you can display anything you like when you receive the mouse click on your notification icon. Usually it's a pop-up menu, but you could show a window instead.

Categories