I am experiencing a little problem with DWM extended glassframe in a windows form.
I have extended the glass frame of my winform and added a custom control that draws a tab onto it with a white background, pretty much like google chrome tabs. Then I have added some text in the tab region and up to here, everything work fine.
Now, I have another control (PictureBox) that has a transparent png as image, and, I'd like to allow this control to be dragged and dropped somewhere onto the tab. The result is that half of my PictureBox can be on the tab (white background with text) and the other half on the glass frame.
If my PictureBox has a transparent BackColor, everything is ok as long as I stay on the glass frame but when I get onto the tab, the DWM considers it as transparent and draws the glass instead of the tab background, and as I said, the png is not supposed to be specifically on the tab, or on the glass, it could be dropped across both of them.
Is there a way to handle this ?
Thanks for your help, much much much appreciated ;-))
Ps: I've already considered making a CopyFromScreen of the PictureBox region and set it as BackgroundImage, but it doesn't help that much as the part that would be on the glass wouldn't refresh if I move my WinForm.
Related
I have some troubles with redrawing images on c# Windows forms. I have some images to be drawn on panel. Everytime a panel_Paint event is raised, i draw my images. Everything was nice, untill I started to scroll my panel. The "redrawing" is for some reason noticeble to human eye. I mean, you can watch how the place, where image takes place, is for a very small time empty and image is drawn upon that place a bit later. This effect appeares each time I redraw my images. This effect reminds me the same as, when a Person scrolls something in folder on a PC without Graphic Card drivers installed.
Can i get rid of these visible "redrawings"?
I wish i could scroll my images without any lag.
I invalidate my panel with images, each time i move my mouse over other panel(this panel is some sort of scrollbar, that i am trying to implement).
EDIT: Problem resolved
I made custom borders for my application, like the VisualStudio 2012
There is one central mainform and 4 smaller, dynamically positioned border forms.
In the mainform I have overidden the events OnMove, OnSizeChanged, OnActivate, OnDeactivate.
In those events I set the location, size and color of the borders.
It works quite nicely, but there is some awful artifacts!
Those are the same artifacts that appear when resizing ANY window.
I made a video with my application to show what kind of atrifacts I mean.
Those appear when moving or resizing the window.
Obviously this problem IS solveable, because VisualStudio2012 does it too (meaning that it doesn't have the problem. Just try it, resize the VS2012 window, it won't flicker)
In my implementation I used the same way that VS2012 uses: 4 layered windows that make up the border of the form.
In case someone doesn't the glitches I'm talking about. Here's the video:
http://youtu.be/kKiPke8ruaI
What I need is a way to "synchronously" set the location and size of the 4 border windows.
I once wrote an app that could display photographs. I am trying to re-write it in Visual Studio with C# and give it new features. The application I am writing now does use scroll bars to facilitate viewing an over-sized image. The previous app would fill the form area with the image and you could drag and hold the mouse to move it about on the screen. If the image was bigger than the screen you'd simply move it about to view previously hidden areas. By making the form the same size as the image it was very elegant way of dealing with the 'problem' of viewing an image that is bigger than your screen dimensions.
The advantage of this over putting the image inside a statically re-sizable form with scroll-bars was that the image would fill the available screen space, and if the next image in the sequence (it is a browser that allows you to cycle through images) was small, the image app would only take up as much space as the image. You could easily move it to one side. You didn't have to manually resize the form that was displaying it to make room for other applications.
I am unable to implement the same feature in the new app because Visual Studio won't let me dynamically re-size the form to be taller or wider than the screen.
Does anyone know of a plugin or workaround to override this limitation?
I am open to suggestions to achieve the same goal, but I would still like to know if this limitation can be turned off, perhaps with a plugin or in code somehow. Below is a link to a video of the previous incarnation of the app, demonstrating the behavior I want to acheive by being able to set the form size larger than the screen dimensions...
Edit: A demo of the the previous application - and the behavior I want to implement...
http://youtu.be/J16EwuozvbQ
I think having a form bigger than the screen is not what you should search for. You can play with the position (top/left) coordination of the image on the form. You can have coordinates with minus values, so you will give the impression to the end user that he browse the image boundaries that's outside of the screen dimension.
Simply, you can create a Form with a PictureBox.
Then change the AutoScroll property of the Form (or the container of the PictureBox, if applicable) to true.
And then change the SizeMode property of the PictureBox to AutoSize.
You should end up with something like this:
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.
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.