Non client painting on aero glass window - c#

Now Im customizing title bar of my application. My aim is to add one extra button on title bar. Im my previous question people have adviced me the way I can customize non client area. Thats works perfectly except one small thing - glowing! I can draw glowing in nonclient area but I cannot make it spreads out of the window. I also cant find any resource about this subj.
I looked into this sample and made my own test app for investigating non client drawing facilities. Screen shot of my app's window:
So you can see that system button glows out of the windows when my is clipped by borderframe.
For example, Skype's window have four custom buttons in title bar and they can "glow" out of the window frame:
Can anybody advise me to find out the way to draw button's glowing out of the window?
Thanks in advance!
[EDIT]
Thank you everybody for answers!

Skype cheats it, and has a little sliver along the top of their window; where they can draw it.
You can see it with Process Explorer to SpyXX:
See also
MSDN: Custom Window Frame Using DWM

I don't think it's possible to draw beyond your NC area, and I kind of doubt they are drawing the whole UI to exactly match DWM Aero effects.
Given how this looks, I wonder if they did some tricks with either the help or restore button of a CustomBorderForm, which would then get the DWM blur highlight effect "for free".
Here's the most relevant article I could find to this: http://geekswithblogs.net/kobush/articles/CustomBorderForms3.aspx
Followup - I think this custom chrome thread has more pointers to the same techniques (although different goal): Custom titlebars/chrome in a WinForms app

AFAIK, this is not possible, because the area outside your window's border simply does not belong to you.
The Skype screenshot is from a custom-drawn frame that most likely extends a bit beyond the visible borders, not from an Aero Glass frame. You can tell the difference if you look carefully.

Related

On Windows 10 Some FormBorderStyles has no borders

This is only an issue if you have Drop Shadows turned off in appearance settings.
I noticed some of our applications form windows had no borders. Specifically they have been missing the 1 pixel thick border for the left part, right part and bottom part of the form window. All of the forms had in common that they were using FormBorderStyle FixedToolWindow or SizableToolWindow. When it is like this it is hard to distinguish where one dialog stop and another one begins.
We find it plausible that some of our users will have their computers set up like this without the ability to change it.
Is there a way to get the dialog windows looking better without doing anything crazy like manually drawing all borders?
Quoting part of a comment by Hans Passant:
By design for Win10, the left/bottom/right borders are transparent. Still quite visible against the large drop-shadow, so visible that is hard to tell that the border is transparent...
Our application has its own grahpical style that made it especially hard to distinguish where one dialog stops and the other one begins.
The quick solution for us was to stop using FormBorderStyle FixedToolWindow or SizableToolWindow.
Long term we are going trough all our dialogs and the graphical style of our application to make the dialogs more easily distinguishable from each other with or without borders.

Opera and Firefox 4 draw on the form's caption, why can't I?

I've been trying to achieve this for months now and nothing seems to work!
Both Opera and Firefox 4 draw their menu button on the top-left corner. I can tell from a mile away that the button's ON THE FORM, because, when minimizing the form, the shrinking minimize effect shows the buttons, and the tabs.
I couldn't find any working ways or code in C# to do this, or in C++.
I know this is possible, but does any of you happen to know how?
You'd be helping a lot of people if you'd tell us.
search on internet how to draw anything on the non client area of a window.
in the times I was working with Visual C++ I was able to do so if I remember right taking care of the WM_NCPAINT which paints on the non client area, I do not have examples here but it should not be a problem to find some code on Internet.
I guess there are not builtin methods to do it in c# other than overriding the windowProc...
I think WM_NCPAINT should do the job for you, as indicated by Davide Piras.
Otherwise, the easiest way to have a customized title bar would be not to have a title bar at all. And then mimic the title bar functionality in the client area of the form.
You will have to handle a few messages by yourself, though.

How that overlay(?) form works in JING

OK, anyone can explain how Jing take screen shots with that overlay form? It appears that it take a full screen shot and records all visible window handles and let you select within the form a specific hwnd. could be true? if is, what are the big steps to achieve this? could be a simple picturebox or without a custom control i don't have a chance to freeze the screen while taking a screen shot?
Thank you!
I'm not familiar enough with Jing to know exactly what it uses. But there are two basic techniques. One is as you mention, capture the screen and display it in a topmost borderless form. The Vista/Win7 Snipping tool works that way. You'll find the code you need to get this started it in my answer in this thread.
The other, perhaps more likely to be used by Jing, is similar to what Spy++ does, allowing the user to move the mouse and draw a selection rectangle around the window. Its advantage is that it can deal with windows resizing or disappearing while you've got the tool running. You implement it by using a topmost form the size of the screen that has its TransparencyKey property set to the value of the BackColor. Fuchsia is a popular choice. You can draw on this form with the OnPaint() method, the drawing appears on top of all the windows. You'd need some P/Invoke (GetWindow) to iterate the underlying windows in their Z-order to know which window the user is pointing at. GetWindowRect() to get the window rectangle. Plus some hassle to deal with Aero lying about the border size.
You can find sample code to get you started on that technique in my answer in this thread.

Change the icon of the window of the minimize, close and maximize

Simple question. How can I change the icons of the close, minimize, maximize buttons. Can I do this in Winforms and WPF?
These Icons, the caption, and the border on your window are all drawn while processing the WM_NCPAINT message. So, the way you take over drawing this is by handling this message.
But you don't have access to the state information about the icons (i.e. which button you should draw in it's pressed state because the user is currently clicking on it.). You dont even know where exactly the mouse handling code thinks these icons are.
So to take over non-client paint, you also need to take over non-client mouse handling, and the whole problem just snowballs until you've written thousands of lines of code and your window still doesn't behave quite right when the user tries to drag it, etc.
And that's in unmanaged code, in managed code (C#/.Net) this is even harder because you also have to do interop to get to some of the APIs you need to use.
So the answer is: Yes its possible, but its harder in WinForms and WPF than it is in C++, and those that have attempted it are all bald now.
The real answer is that you shouldn't do this. Users expect all applications to work and look the same. Making them try an figure out what spiffy new icon you use means minimize is likely to make them unhappy.
Doing this isn't difficult but it is a lot of work - you have to basically replace the window frame and handle everything yourself, there is a lot of functionality in the default window frame you have to rewrite - you also have to write different code for Vista/7 with Aero enabled.
In WPF you use the various techniques in http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx
In WinForms you use the same basic techniques but I don't know of a page that summarizes all the details like the link above.
In wpf, you can set WindowStyle="None" for your Window and then set a custom TitleBar for that, with minimize, maximize and close button. I have done this earlier. You need to do some event handling to perform minimize, maximize, close, drag etc.
Yes, you have to create your own window style. Refer to FluidKit, GlassWindows for example.
If you want to control the look of those buttons, you'll have to create your own. This is one value of using Windows features to write windows applications (they come with a standard look and feel).

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