ich versuche gerade, ne wpf-app mit aero-glass (vergrößerter border) zu schreiben. dabei hab ich mich an diesen msdn-post gehalten. allerdings hab ich jetzt diesen fehler:
Zitat
den code hab ich mit instant vb übersetzt, weil er im msdn-post nur in c# stand:
' Obtain the window handle for WPF application
Dim mainWindowPtr As IntPtr = (New WindowInteropHelper(Me)).Handle
Dim mainWindowSrc As HwndSource = HwndSource.FromHwnd(mainWindowPtr)
mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0)
' Get System Dpi
Dim desktop As System.Drawing.Graphics = System.Drawing.Graphics.FromHwnd(mainWindowPtr)
Dim DesktopDpiX As Single = desktop.DpiX
Dim DesktopDpiY As Single = desktop.DpiY
' Set Margins
Dim margins As New MARGINS()
' Extend glass frame into client area
' Note that the default desktop Dpi is 96dpi. The margins are
' adjusted for the system Dpi.
margins.bsLeft = Convert.ToInt32(5 * (DesktopDpiX / 96))
margins.bsRight = Convert.ToInt32(5 * (DesktopDpiX / 96))
margins.bsTop = Convert.ToInt32((CInt(Fix(topBar.ActualHeight)) + 5) * (DesktopDpiX / 96))
margins.bsBottom = Convert.ToInt32(5 * (DesktopDpiX / 96))
Dim hr As Integer = DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, margins)
'
If hr < 0 Then
End If
originaler code:
// Obtain the window handle for WPF application
IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle;
HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
// Get System Dpi
System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(mainWindowPtr);
float DesktopDpiX = desktop.DpiX;
float DesktopDpiY = desktop.DpiY;
// Set Margins
NonClientRegionAPI.MARGINS margins = new NonClientRegionAPI.MARGINS();
// Extend glass frame into client area
// Note that the default desktop Dpi is 96dpi. The margins are
// adjusted for the system Dpi.
margins.cxLeftWidth = Convert.ToInt32(5 * (DesktopDpiX / 96));
margins.cxRightWidth = Convert.ToInt32(5 * (DesktopDpiX / 96));
margins.cyTopHeight = Convert.ToInt32(((int)topBar.ActualHeight + 5) * (DesktopDpiX / 96));
margins.cyBottomHeight = Convert.ToInt32(5 * (DesktopDpiX / 96));
int hr = NonClientRegionAPI.DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
//
if (hr < 0)
{
//DwmExtendFrameIntoClientArea Failed
}
Dieser Beitrag wurde von ::YC Tech:: bearbeitet: 28. Januar 2013 - 17:48

Hilfe
Neues Thema
Antworten

Nach oben




