Win32 creating windows 7 status flyouts - windows

I am trying to create a Windows 7 status flyout like notification in the bottom right hand corner of my desktop. Any guidelines on how to accomplish this using win32 (and without having to write a ton of code) are much appreciated.
Thanks.

If you can use .Net, this or this shows how to create custom flyouts quite easily (both use P/Invoke so they should be pretty easy to port to anything else), even more simply you can use NotifyIcon.
Doing this from C or C++ you can either use Shell_NotifyIcon for the simple ballons or a custom (borderless) window animated with AnimateWindow or SetWindowPos and a WM_TIMER for the fancier slide-up/fade-in style popups/notifications.

Related

Managing no-client area

I've been searching a long time ago for a manner to enhance and skin the no-client area in windows, and many people say that there are only two ways, either you make a frame-less window and draw my own buttons or by hooking windows message like WM_PAINT, and I'm interested in the second approach, so is there anyway to achieve that because the big problem is that I'm using Qt, and maybe this photo will help emphasizing the problem.
What you're looking for is Non-client painting. Windows has a number of messages for handling the non-client area. Doing some web searches for 'QT Non-client paint' results in this thread, which gives a brief example of how to do non-client painting in QT.
Adobe Brackets (specifically the CEF wrapper source code, found here: https://github.com/adobe/brackets-shell/) provides source code for non-client painting; Spotify shares this code (see credits). I do not have experience with doing this in Qt; I tinkered with a 64-bit port of brackets-shell but didn't finish as I started playing with Electron. It's Windows specific, so maybe you could use Win32 API directly to wrap the Qt window's WndProc and implement that way?

How do I duplicate iTunes-style windows on Windows?

Can anyone provide some insight on how to "duplicate" an iTunes style window in Windows? Specifically I am looking for the following features:
1) rounded window
2) top and bottom toolbars
3) rounded text fields
I'm currently attempting a bit of cross-platform development with Real Studio and while I've discovered the mechanism by which to perform the rounded windows in OS X (declare method call to HIWindowSetContentBorderThickness or SetContentBorderThickness), I cannot find in the MSDN how to do similar things in Windows. Obviously Apple accomplished it in actually writing iTunes for Windows. Perhaps they wrote custom controls from the ground up.
SIDENOTE: I found this article from a few years back that briefly discusses it (http://discuss.joelonsoftware.com/default.asp?joel.3.454369.12), but this is pretty much all I could find.
Even if I can't duplicate it exactly, some direction on which Windows libraries might contain the functionality I need to do it "manually" would be nice. Any further assistance would be greatly appreciated.
There's no API for doing Apple-style rounded corners, but there are lower-level APIs for creating windows (both frame windows and controls) of any shape you want.
I don't use RealStudio, but I believe it allows you to access both .NET and native Win32 APIs, so:
If you're using .NET Windows.Forms, read Shaped Windows Forms and Controls in Visual Studio .NET. It's written for VB7, but should be easy to translate to your favorite language.
If you're using the raw Win32 API, there are at least two ways to do this. The simplest, but most limited, is to call the SetWindowRgn API, which sets the shape of your window to anything you can create as an HRGN. But that probably won't cut it for you. You don't want jagged edges; you want smooth curves, with alpha-blended borders, and maybe shadows. (At least that's what Apple does.) The Layered Windows API is the way to do this. It allows arbitrary shapes (even changing on the fly, if you use UpdateLayeredWindow—although you don't need that feature to emulate iTunes), alpha transparency, and complicated hit testing. Since the original article is very out of date, and doesn't cover all of the functionality, also see Layered Windows for the current documentation, which has links to the references.
there is a third party controls that do what you want. It works on Mac & Windows.
http://www.madebyfiga.com/fgsourcelist/
works well.
sb

What sort of GUI controls are used in Windows Resource Monitor?

I am new to GUI programming in Windows.
The Windows Resource Monitor (perfmon.exe /res) has four bars (CPU/Disk/Network/Memory) that have gradient backgrounds, as well as charts on the right for displaying recent CPU/Disk/Network/Memory usage.
I am wondering what kind of controls were used in this application. Are they readily available in C++ or in C#?
They are custom controls that are not available for external use, sorry.
You can use the Spy++ window finder tool (Spy++ is included with DevStudio) to find the window class names (and window boundaries).
http://msdn.microsoft.com/en-us/library/aa266028(v=vs.60).aspx
It shows that the overall window is a DirectUIHWND, the graphs are windows but the bars labelled CPU/Disk/Network, etc are not windows at all, the appear to be drawn directly in the resource monitors client area.
The implementation is not public for these controls, but I'm pretty sure they are incorporated using Windowless Controls.
Those bars remind me of Outlook bars. One old implementation is described in Code Project, and that one also has no windows on its own. Everything is painted inside.
Edit: That Code Project article was C# port. For C++ original go to Code Guru.

How does a Windows non-native user interface work?

Through experience I have found that the native windows forms/components don’t like to be changed. I know using Delphi or Visual Studio you are given native windows components to populate a form or window with and then you attach code on events that these components may do (onClick for example).
However, how do all of these programs like Word or google’s Chrome browser alter the standard windows’ window? I thought it was somehow protected?
Chrome seems to have tabs actually on the window’s frame?
I know you can also get toolkits like Swing and QT that have their own controls/components to populate a form. How do these work? (How does the operating system/computer know what a non-native button should act like? For example; Chrome's back and forward buttons, they're not native components?).
I can understand how OpenGL/DirectX window would work because you’re telling the computer exactly what to draw with polygons/quads.
I hope this question is clear!
Windows does not protect GUI elements. Windows and controls can be subclassed to handle various drawing operations in a custom way. For example, windows may override and reimplement the handling of the WM_NCPAINT message to draw a custom titlebar and frame:
http://msdn.microsoft.com/en-us/library/dd145212(VS.85).aspx
Some Windows controls have an "owner-draw" mode. If you use this, you get to draw the control (or at least vital parts of the control), while Windows takes care of responding to user input in the standard way.
Swing ant QT draw their own widgets at a low level using basic primitives, but they also have theme engines which can mimic the native controls.
Qt moved to native controls a while back. As for how swing does it, it gets a basic window from the OS. Then much like Opengl\Directx it does all of the drawing with in that window. As for where to position things that is what the layout managers do. Each manager has a layout style horizontal, vertical, grid, components it has to draw and a section of window it is expected to fill. From there it does some pretty easy math to allocate its space to its controls.
There's no magic: non native controls are simply drawn on a blank window. Or, instead of being drawn they may be represented as one of several bitmaps based on state (ie: a button may be represented as a .png for the normal state, another .png for the pressed state, etc)

How easy is it in DWM to make an 'always on top' thumbnail for an existing window

I really like when you hover over a window in Vista on the taskbar and it gives you a little preview. if it is video it even plays in the thumbnail.
Often I really wish I could 'tear off' this little window and keep it as an 'always on top' thumbnail on my screen. Maybe its a progress bar I'm watching, maybe its a video i want a little tiny preview of.
Isn't this the kind of thing that DWM makes it easy to program. Would this be a simple endeavor to program in nice managed C# - or would i end up getting all bogged down in tricky API stuff?
I am interested in both existing solutions and pointers on how to code something like this.
Sorry for the self-promotion here. :)
Just mentioning there's already an app that allows you to clone every top-level window and keep their preview "always on top": OnTopReplica.
The program is based on the Windows Forms Aero library, a .NET (c#) library that includes some DWM wrappers. No tricky API stuff needed (besides, the API is pretty simple anyway).
A very good preview of how to use this in C#:
http://community.bartdesmet.net/blogs/bart/archive/2006/10/05/4495.aspx
Yes, you can create your own taskbar-like thumbnails. You're going to have to do quite a bit of window handle manipulation though. How it works is basically that you create a child-window in your form that will be the thumbnail. You obtian the window handle of the top-level window you want a thumbnail of using the usual tricks. Then you call a DWM function DWMRegisterThumbnail to associate the two. You don't actually get involved in painting the thumbnail at all - once the windows are associated, the DWM compositing process takes care of painting a thumbnail of the top-level window in your form.
MSDN Documentation

Resources