showing the autohiding windows taskbar - c#

I have defined the windows taskbar as auto-hiding. Now I am showing for a way to show the taskbar from C#-code. Can somebody help me perhaps with a little code-snipped?

The taskbar in an AppBar. Which can be controlled using the SHAppBarMessage API.
Here is a separate article on AppBar's which can help you better understand how to use the API:
http://www.codeproject.com/Articles/3728/C-does-Shell-Part-3
Edit:
If you need to find the handle for the Taskbar itself, you can use the FindWindow method. The taskbar is named "Shell_traywnd"

Related

How to take a screenshot of a partially hidden window in a programmatic way without brining it to front?

Is it possible to take a screenshot of a partially hidden window without brining it to front? I know this is possible because the Screen Capture API already does this.
https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture
The picture shows the popup when you initiate a capture process. You can see the same popup on Discord or Slack whenever you would like to share your screen. In the popup, you can see the list of the windows that I have open. Some of the windows are partially or completely hidden. However the popup shows the entire contents of them, which is surprising to me. The popup does not show minimized windows, which is fine. This works cross-platform.
I would like to know how the Screen Capture API does this as I have never succeeded in doing so. I personally tried with Win32 + GDI32 APIs but I was unable to take the screenshot of a hidden window. I would prefer a cross-platform solution but for now I am only targeting Windows 10+.
Thank you in advance.
#simon-mourier Thank you for the comment. That was helpful.
https://blogs.windows.com/windowsdeveloper/2019/09/16/new-ways-to-do-screen-capture/
#NothingIsImpossible

How add a skype-like notification count to a c# program icon

I'm working on a project and we'd like to add a notification count the way skype does.
A number pops near the icon in the windows taskbar to indicate how many messages the user have received.
This is the result we're trying to achieve: http://it.tinypic.com/r/2guclkk/8
Looking around the internet haven't led to anything, so is there any API I can use in C# to achieve this?
I solved using the WindowsAPICodePack: Windows API Code Pack: Where is it?
The method is SetIconOverlay():
public void SetOverlayIcon(IntPtr windowHandle, Icon icon, string accessibilityText);
If you want that in taskbar, you might want to use overlay icons, which are described here, if you are using WPF: How to add dynamic text as Taskbar Icon overlay?
If you are using Forms you might want to use this: https://msdn.microsoft.com/en-us/library/system.windows.shell.taskbariteminfo.overlay%28v=vs.100%29.aspx
If you want to do the same in system tray, it is a duplicit question: How can I overlay system-tray icon ? WPF, and the answer is probably to draw the desired number at runtime to the icon and change the system tray icon.

How do you update the Window's Desktop WorkingArea?

I am developing a security and kiosk library in my framework. The problem here is I have the proper methods and routines to disable various features of the Windows Shell. The main feature I am discussing here is the Windows Taskbar.
I have properly disabled, and hid the Windows Taskbar. The problem is that the WorkingArea of the Window's desktop is not updated by ShowWindow/EnableWindow calls to the Taskbar, and still leaves the reserved space for the Taskbar on the desktop.
After reading almost all the topics regarding this, I am dissappointed. I am not looking to simply make my program "Full Screen", "Top Most", those are not acceptable answers. I am actually looking to either unregister the Taskbar as an AppBar, or update the WorkingArea. Any other solution is not what I am looking for as they are just "workarounds" and not actually resolutions.
Any links, whitepapers, or code samples/guidance is appreciated.
You are going to have to be more flexible if you want a solution. The only odds you'll have for a 'perfect' solution is SHAppBarMessage with ABM_REMOVE. The odds aren't good, especially on Win7. I don't want to try this myself, I like my taskbar :)

Minimise any program to system tray

Hey, I am trying to make a program that minimises any program to the system tray instead of normally minimising it. Is this possible? I have been looking around on google but cant find anything.
Icons in the system tray are called "Notification Icons".
To do this to your own application, If your using WinForms you can use the NotifyIcon class to display icons in the system tray. Then all you have to do it set the window to not be displayed in the task bar.
If you're using WPF there isn't a replacement, you still have to use the old WinForms NotifyIcon class, check out this MSDN sample for more information on this.
If you want to hide another app, what you need to do is use API calls to make the changes to the state of the applications window.
You can use FindWindow to get a handle to the window you want to hide, then you can use GetWindowLong to get the windows state. Then you need to remove the WS_EX_APPWINDOW flag from the state and use the SetWindowLong method to apply the new style, this will remove it from the task bar. You can then use the Get/SetWindowState methods to find out the state of the window and hide/minimise it.
You still just need to use the NotifyIcon class to display your own icon in the systray.
Good luck with all of that. It's not something I've tried personally, but I've used all these method calls in other ways. If you haven't done API stuff from C# before you might find you need to do a bit of googling to figure out your DllImports for the version API methods. Shouldn't be anything too hard though.
Crazyd22 has found a codeproject article that uses a slightly different set of API methods but achieves pretty much the same effect. (See comments below.)

C# Set Window Behind Desktop Icons

Assume i have an empty form 100px by 100px at 0,0 coordinates on the screen. It has no border style. Is there any way to have this positioned BEHIND the desktop icons?
I would assume this would involve the process Progman because thats what contains the desktop icons. But no matter what i try... getting window handles and changing parents etc, i cant seem to get the window to appear behind the icons.
Any ideas?
Essentially you want to draw on the desktop wallpaper. The desktop hierarchy looks like this:
"Program Manager" Progman
"" SHELLDLL_DefView
"FolderView" SysListView32
It's the SysListView32 that actually draws the desktop icons, so that's what you have to hook. And you can't just stick your form on top of it; you have to grab a WindowDC to that handle and draw on the DC.
It can be done - it has been done, but you're going to be using a lot of interop. Forget about doing this with a traditional Winforms Form. I don't think I've even seen it done in C#, although somebody did it in python, if that helps. I'm not a python coder myself, but the code is pretty short and easy to understand.
There is a solution to this problem, at least for Windows 8. I postet it in form of an article on CodeProject, so you can read about it here:
http://www.codeproject.com/Articles/856020/Draw-behind-Desktop-Icons-in-Windows
This works for simple drawing, windows forms, wpf, directx, etc. The solution presented in that article is only for Windows 8.
Google-fu led me to this MSDN forum question:
http://social.msdn.microsoft.com/Forums/en/winformsdesigner/thread/c61d0705-d9ec-436a-b0a6-6ffa0ecec0cc
And this is a blog post regard the major pitfalls with using GetDesktopWindow() or dealing with the desktop handle (as per your other question: C# Position Window On Desktop)
http://blogs.msdn.com/oldnewthing/archive/2004/02/24/79212.aspx
You also don't want to pass GetDesktopWindow() as your hwndParent. If you create a child window whose parent is GetDesktopWindow(), your window is now glued to the desktop window. If your window then calls something like MessageBox(), well that's a modal dialog, and then the rules above kick in and the desktop gets disabled and the machine is toast.
Anyway, I suspect that it probably CAN be done, but whether you should is another question.

Categories

Resources