WinForms Aero Glass效果-Vista SP1-用户控件显示不正确吗? [英] WinForms Aero Glass effect - Vista SP1 - User controls are rendered inproperly?
本文介绍了WinForms Aero Glass效果-Vista SP1-用户控件显示不正确吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好.我正在尝试创建一个使用Aero Glass效果的WinForms应用程序.我已经成功调用了DwmExtendFrameIntoClient,并且出现了效果.
但是,当我在玻璃区域(组合框)的顶部放置一个控件时,该文本将变为透明的.
我该如何再次使黑色文本变得不透明?
Hello. I am attempting to create a WinForms application which uses the Aero Glass effect. I have successfully called DwmExtendFrameIntoClient and the effect is present.
However, when I place a control on top of the glass area (a combobox) the text is rendered transparent. This is obviously an undesirable outcome.
How would I go about making that black text opaque again?
推荐答案
我遇到了同样的问题.不幸的是,我从来没有想过(我个人更喜欢WinForms而不是WPF,因此我很沮丧地听到这是一个持续不断的问题,如果真的可以解决,那只能通过跳很多圈来实现).基本上,我被告知要使用WPF,WPF确实可以工作.放在玻璃板上的任何东西(如文本框)都可以正确呈现.
I had this same problem. Unfortunatly, I never figured it out (I much prefer WinForms to WPF as a personal preference, so I was bummed to hear this was a constant nagging point and if you do get it to work it's only by jumping through lots of hoops). Basically, I was told to use WPF and WPF did work. Anything placed on the glass like a text box rendered correctly.
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/316a178e-252b-480d-8cc9-85814c2073d8
My solution ended up being to create a WPF application and then include the WinForms controls that I wanted to use. I might also add, your code to call DwmExtendFrameIntoClient will work on WPF with a few modifications, specifically the pieces that find the window handle.
(there is some irony is that I'm answering this question while I was doing further searches for people who might have pulled this off on WinForms). ;P
Here's some VB code that shows you how to get the window handle from the WPF form (it assumes 'win' is a WPF Window... if you're actually calling it from that class then you can use 'Me' or 'this' from c#):
Dim hwnd As IntPtr = New System.Windows.Interop.WindowInteropHelper(win).Handle
If hwnd = IntPtr.Zero Then
Throw New System.Exception("Window handle must be valid. Try from WPF's Window Loaded() event.")
End If
win.Background = Brushes.Transparent
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent
DwmExtendFrameIntoClientArea(hwnd, margin)
这篇关于WinForms Aero Glass效果-Vista SP1-用户控件显示不正确吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文