Windows 7 DWM weirdness - c#

I'm looking to write a FOSS "Alt+Tab" replacement (window switcher) for Windows, since there are a few features I feel it's (still) lacking; but I'm noticing two quirks I can't seem to fix:
#1. (Somewhat Unrelated) In the default Windows 7 window switcher, one computer allows left clicking on a thumbnail to focus the window; however on another, similarly specced computer, I have to use a right click. The only difference between these two fresh installs is the theme. Any ideas?
#2. (Directly Related) In both the default Windows 7 window switcher and the DWM API output, minimized windows often have no thumbnail, and instead show only the taskbar. This has been a long running problem with the Windows API, and in the past I've seen the popular recommendation being "restore (un-minimize) the window, take a screenshot, then re-minimize" - but this is sloppy and causes flickering, etc. Has anyone done this successfully using the newer DWM API?
If sharing code, I'd prefer C# syntax, but VB.NET will do as well. Thanks!

Related

How can i find the order of the taskbar items in Windows 7?

I would like to establish what is the order of the taskbar items in Windows 7. The reason is that I would like to create an script (written in AutoHotkey or C#) that restore a set of icons to a previous determined order. I wan't to do this because any Virtual Desktop solutions for Windows forget the great and important point of keeping the taskbar item's order, i.e between desktop changes the order of the taskbar items are completely ignored and lost. The reason of why they ignore that fact is maybe because all of them rely in the HIDE/UNHIDE approach, they save what windows are active in any desktop and then between switches they Hide or UnHide the corresponding windows.
I already found a semi solution writted in QT/C++ (Location of app on the Windows 7 Taskbar) that base his function in find the left-upper pixel position of an item based in his color. I don't like that approach because the use of different themes or visual styles would break his functioning. I hope someone has another suggestion. This question differs from that in the link that I'm only interested in the order not in the exact pixel position of any button.
You may want to start with the Windows® API Code Pack for Microsoft® .NET Framework. This API allows you access to several Windows APIs (including certain taskbar functions) from managed code.
However, I'm not certain yet that it allows for functionality regarding the task bar in general vs. a specific application's taskbar entry. I will continue researching this and update if/when I find more information.

How can I write windows 7 desktop gadgets using c# & WPF?

I want to write a desktop gadget that will group icons on my desktop (using c# & WPF).
It will be a docked window that I can drag icons to it and they will stay their. Also there can be couple of this windows.
Where do I begin?
**I saw all the post here about it but I got lost. Please direct me to examples and explanation pages.
To expand on cevik's answer:
You cannot create WPF applications as gadgets BUT you have two options (which aren't as bad as you'd expect).
The reason is that widgets are composed mainly of web pages (HTML) and not executable (*.exe).
The problem of course is that WPF will only work with & produce executables.
First option - Windows API:
When I said you can't what I really meant is you can't use the Windows Vista/7 gadget platform to make your widgets.
However, you can always achieve a similar effect by using the Windows API.
The Windows API will let you do stuff to windows such as making them always on the background of other programs, which sounds to me like ~80% there (The rest would be stuff like making sure your window doesn't get re-sized or minimized, etc.).
Just as a note, the function you'd be looking for to make the window behind all other windows would be SetWindowPos (specifically the second parameter).
However make sure there isn't a library which already implements these stuff because it can be rather difficult (and consist of A LOT of surprises).
Second option - Silverlight
silverlight can be perceived as WPF for the web.
That obviously solves our problem.
However there is a cost to it, as expected.
Silverlight doesn't have all the features WPF has (possibly not all of the .NET framework as-well, not sure about that as I'm not really using it).
However it should be more than enough to get you by so you should definitely check it out.
Once you have your Silverlight application (and webpage) you'll have to create a manifest & install the gadget to your desktop. See here how to do so.
Maybe this will help you.
Template to easily get started on developing a Sideber Gadget using Silverlight 3.0 or 4.0 controls in C#.

WPF application that claims desktop real estate similar to windows taskbar

I'm building a WPF application that is designed to act as a notification toolbar for sending messages to users of an enterprise software platform. It's a bar that is a specific height, stretching all the way across the bottom of the user's desktop, sitting directly above the Windows taskbar.
What I'd like to do is to have my application "claim" or "reserve" the space it takes up and not allow any applications to load behind it. For example, if you were to resize your windows taskbar and make it larger, it will move icons and shortcuts, and maximizing windows will only use the desktop area that is not already being used by the taskbar.
Any idea how this could be pulled off? It's already set to be the topmost item on the desktop, so that's not my question. Right now if you opened another app and maximized it, then the bottom X pixels will be hidden behind my toolbar application.
(Note that I've added Windows 7 and Windows XP tags - I'd love to be able to implement this functionality on WinXP and up, but if I'm not able to do so on a particular version or versions, I can come up with a workaround)
These are called AppBars in Windows and you can use the SHAppBarMessage function to "dock" your window to a side of a monitor. Then other windows, when maximized, will not obscure the docked window.
Here's a link to a similar question that has more information, including a link to a CodeProject page that walks you through creating one.

WIndows Mobile full screen problem

I have a windows mobile professional 6.1 application and I want it to be full screen in all pages so I put the code below into my every pages constructor;
this.WindowState = FormWindowState.Maximized;
this works OK but "sometimes" for example when I use
MessageBox.Show("alert");
or when I try to connect internet within application and there is a problem and Windows shows me some messages popping up from the top of the screen..in this cases I lose my full screen and the top menu bar of windows becomes visible again..
any ideas?
You can use SHFullScreen to hide the start icon and other system areas of the screen. There is an undocumented function named AllKeys which will allow you to block some of the hardware keys (notes, recorder, green + red phone keys) from running. It will require a lot of work because there are many ways to run programs and the taskbar has a habit of reappearing after a program is run. Simply calling SHFullScreen once is not enough. You'll have to handle WM_ACTIVATE messages and call SHFullScreen again and force your program to the top again. It's a struggle against the operating system to have a true kiosk application on Windows Mobile.
Getting an app to "kiosk mode" in Windows Mobile is challenging becasue the platform simply isn't designed for it. This page has a lot of links to resources of getting it working. Using your favorite search engine to look for "compact framework kiosk mode" is likely to bring up more as well.

How do you place controls on the chrome of a WPF Window when the user is on Windows XP?

How can you place controls on a frame of a WPF window? I took a look at this but I don't know how to do this in WPF. link textThe problem comes when The application has to run on Windows XP where there is no DWM support. Also, if this is running on Vista without DWM, could the article still work?
The article will not work, at least not exactly as written.
In order to do this on XP, you use the same basic technique, but you need to actually "draw" the chrome yourself, since the DWM doesn't exist in order to do it for you.

Categories