Handling Right Click/Left Click of Task-bar Button in c# - c#

I have a form (having Taskbar button shown in Taskbar) and I want to handle left/right clicks of this Task-bar button. I searched everywhere but could find the right answer. There are some related queries posted in stack-overflow as well:
Using wndproc in C# to minimize form on leftclick of taskbar
How to Detect Right Click on the Taskbar
But, nobody seems to have given a proper answer to "How to do" it?
Is there any pointers or code snippet how to do it?
Please note that I am talking about Task-bar app button (please don't confuse with Systray menu or Notification area). I have explicitly stated it because I have seen this confusion several places.

Your application doesn't get a say in how the task bar button is handled. The task bar is owned by windows, and is used by windows to control display and positioning of your application's windows. Basically your request is out-of-bounds in the windows playground.
Sorry.

what you can do is to use TaskbarManager out of the ApicodePack library
Windows 7 Taskbar C# Quick Reference
where you are able to handle such events.

Related

Completely Modal WPF Window?

I have a requirement that specifies that a notification tray application that uses WPF must (based on some conditions) pop-up a window that is globally modal. This should prevent the user from doing anything (even outside of the Tray application) until they have satisfied some other conditions at which time it will enable the close button and allow the user to close it.
How does one make such a window? I have the window displaying and it evaluates the conditions and whatnot, but it is only modal to the application (i.e. it only blocks execution and UI for the application it is running under.
I imagine I could create a borderless window and maybe disable the minimize functionality, but they would still be able to access the start menu. Any takers? What I am striving for functionality-wise is similar to the Windows UAC/Admin privilege request window.
This is not a duplicate of the question provided by the duplicate box at the top. That question pertains to Windows Forms and is not applicable to WPF. As it happens I received an answer that worked well for me, and it was not the answer to the question provided above. Not that it matters really, but I would like the duplicate tag taken off. I like to think that I research my questions pretty well before posting, and adding that tag implies that I do not.
EDIT
This question is not a duplicate of the question that was linked int he Duplicate Question box. That question was answered with in a Windows Forms flavor, and I am using WPF, a completely different UI framework.
Use the Window.ShowDialog() method. More info can be found here
See the second comment by sixlettervariables.
One solution could be to make a semi transparent WPF window that covers the entire screen (actually you should say: all screens) and show the modal window using Window.ShowDialog() with the owner being that window. All you need to do then is prevent task switching (which is not an easy task), but maybe doing that is enough?
Something like UAC does - for example like in the answer to this?

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).

What "growl" type notification windows are available for WPF (windows that appear and fade after X seconds)?

I wanted to know if there are any good "growl" type notification windows available as open source or guided tutorials for WPF applications. I'm looking for a window that can appear when users save for example, notifying them that the save was successful and then disappears after X seconds (with a fade out) without the user needing to take the explicit action to close the notification window. This way for messages/notifications that require no confirmation, like the example, the user would not have to click "OK" to make the messagebox or dialog close.
This link could help you:
http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx
It is a Pure WPF implementation of the NotifyIcon class from WinForms and supports almost everything normal WPF controls do :)
Cheers
Why don't you use GrowlForWindows?
You can use C# or VB.

How to Detect Right Click on the Taskbar

I've got a Windows Forms application in C# that starts off with a loading dialog. As expected, a button for the app shows up in the Windows taskbar.
I would like to detect right-clicks that might be done to that button.
Ultimately, I hope to disable the right-click or simply have the loading dialog regain focus. I've seen that some people use custom libraries and packages (interop, for example) to achieve some Win32 functionality, but I'd personally like to avoid this. Is it impossible to do without such libraries/packages?
How about just not showing the form in the taskbar by setting Form.ShowInTaskbar to false?

C# Autohide form

I've a winforms app that "docks" to the taskbar
I'd like to autohide the form and make it appear only when the mouse goes near/over the form
any suggestions ?
Install a global hook onto the mouse-move event and check to see if it is within the form boundaries. Should work even with the form hidden. If not just store the location as a rectangle and check against that.
Code for a simple and handy global hook implementation can be found at:
http://www.codeproject.com/KB/cs/globalhook.aspx
I've used this method to create "hotspot" functionality to a user desktop.
I'm not sure it is exactly answering your question, but there is a sample of this on Codeplex...
http://remoteaccessmonitor.codeplex.com/
Browse the source code and check out the MinimizeToTray.cs file - it has examples of pop up messages when hiding and I think its default behaviour is to re-appear on click (although I imagine this could be changed).
You could.
Poll mouse coords until it's within a certain radius of your app.
Position an invisible, always-on-top form above the docked app and have it fire a MouseEnter event.
That's all I can think of really. Either.

Categories