modal window with non square borders - window

How do I make modal windows with non square borders, for instance a modal window which has a corner to indicate it's coming (sorta being shout) from a text.

Create your modal dialog window as you would normally and then call SetWindowRgn API to set the non-rectangular region you want to achieve.
Note that this will not allow you to do semi-transparent effects, it works only for opaque windows. If you want alpha blending, your window has to be top-level (alpha transparency is not supported for child windows) and you should be usign different APIs.
Also, this works for C++ clients using the native Win32 API. If you are writing C#/VB.Net code, you need to specify if you are using WinForms or WPF, as the solution is different for these.

Related

Is it possible to keep the Windows' compositor working normally when using a fullscreen OpenGL application?

Under Windows, when the DWM composition is active, there's a somehow "special path" for fullscreened OpenGL applications that prevents all other subwindows (popups, menus, tooltips) to be correctly layered on top of the fullscreened OpenGL window.
While this is useful for games and such, it's totally a pain for other fullscreen OpenGL applications (CAD, 3d editors, etc.). This problem is causing endless troubles for Qt users, see here, here, or here.
Is there a way to tell Windows not to enable the special path for a given application / fullscreen window? Either in the manifest, or via DWM APIs, I don't care.
Yes, this can be done by tricking Windows into thinking that the Window should be composited with transparency. For this you call DwmEnableBlurBehindWindow on the window. In case of a fullscreen WS_POPUP window this makes the window fully transparent (instead of the glass effect) and you can use the window's alpha channel to control the opacity; for a regular window with a title area and border you get the glassy effect then.
Now if you configure the pixelformat without an alpha channel or set the alpha channel to all 1 (full opacity) the compositor still has to assume some transparency may be present and goes through full composition.
Small update
Although WinXP and Win2k are beyond their EOL, it may be undesireable to hardlink the dwmapi.dll to the executable, e.g. if you have to support legacy systems with your software for some reason. For that I wrote a small wrapper library dwm_load that dynamically loads the dwmapi.dll if available or falls back to failsafe implementation of the DWM functions.

WinAPI create metro style application issues

I'm trying to implement simple metro style window using WinAPI (basicly like Visual Studio 2012 style) to run on Windows 7 and Windows 8, I know it a hard work and at begin, I have those problems:
1. Create a squared window
I can achieve this by create a borderless window (mean no border, no titlebar, only client area) but by this way, I can't resize this window and titlebar was lost of course. Are these any ways to create a squared corner window and still keep titlebar (including close, max, min, ... buttons)?
2. Owner draw close, maximize, minimize buttons
I can owner draw whole titlebar by catching WM_NCPAINT event but this way I see these buttons (close, maximize, minimize) go to the hell. How can I show these button in my way (I mean draw it by my ideas)?
3. Create shadow
You can see that if Visual Studio 2012's window do not maximized, it show a shadow, it look great and I want apply that effect to my simple window. How can I do that?
You need to write your own code that draws basic window elements, and handle mouse events by hand to make them interactive. (hooking WM_NCHITTEST may help for interactivity)
To make a shadow, make your window layered, then set a background image with an alpha-transparent shadow.
In addition to what SLaks said, which will work but is a lot of effort and will take time, you may want to consider whether you can use a framework in developing your program. If you can, then you may be able to use a framework toolkit to implement the "window chrome" leaving you free to work on the the important part of your application: the logic.
If you can use MFC, then I would recommend CodeJock's Toolkit Pro 2013; I am not affiliated with them in any way, but have used their product in the past and it's quite good.
I'm sure that there are other toolkits, some of which might target different frameworks, but I have no experience with them and no basis to recommend them.

How do I do 3d manipulations on live windows 7 window contents?

This is basically a scoping question, where would I look for the facility to render window contents to 3d surfaces and manipulate them? I mean can I have a program like a shell that composites live windows in 3d like the Vista DWM's 3d Task Switcher and can translate UI interactions back into 2d interactions for each window?
I've seen mention of DWM extensions here and there on the web but can't find any resources as to how that would work. Also there are guides to implementing DWM Thumbnails by relating two windows' HWNDs but that doesn't allow me to do arbitrary transforms on the window and is display only (you can't click on stuff in the thumbnail.)
Any ideas?
There is no interface for manipulating the DWM's 3D visuals. They are internal to the DWM.

Windows Phone 7 transparent WebBrowser

I want to a have a transparent WebBrowser component to be displayed on top of other components. I have been trying with a transparent Background WebBrowser property, different transparent colors for html page, but it doesn't seem to work.
It is any way in which I can do this?
You can't apply transparency to a WebBrowser control because it's not a "true" Silverlight control. It's a native control in a Silverlight wrapper so that it can be used LIKE a regular Silverlight control.
As a wrapped native control it handles its drawing itself and doesn't go through the Silverlight drawing pipeline and so can't have transparency applied at that time. As it doesn't make sense for the web browser to include transparency when used as a standalone app it doesn't have this facility built in and so can't be used when used in an embedded manner.
For workarounds, see the answers at Making WebBrowser Transparent

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)

Resources