Click here to Skip to main content
15,920,005 members
Home / Discussions / WPF
   

WPF

 
QuestionAnybody using DwmExtendFrameIntoClientArea? Pin
SledgeHammer019-Jan-15 11:59
SledgeHammer019-Jan-15 11:59 
Just using the stock example from Microsoft:

void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle;
    HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);

    //mainWindowSrc.CompositionTarget.RenderMode = RenderMode.SoftwareOnly;          //  <=== UNCOMMENT THIS LINE

    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
    MARGINS margins = 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.cxLeftWidth = Convert.ToInt32(5 * (DesktopDpiX / 96));
    margins.cxRightWidth = Convert.ToInt32(5 * (DesktopDpiX / 96));
    margins.cyTopHeight = Convert.ToInt32(((int)90) * (DesktopDpiX / 96));
    margins.cyBottomHeight = Convert.ToInt32(5 * (DesktopDpiX / 96));

    int hr = DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
    //
    if (hr < 0)
    {
        //DwmExtendFrameIntoClientArea Failed
    }
}


On my machine, I get a white rectangle over the entire window for about 1 second and then the window redraws properly.

This code works on .NET 4.5.1, but this seems to have cropped up in .NET 4.5.2.
AnswerRe: Anybody using DwmExtendFrameIntoClientArea? Pin
Richard Deeming12-Jan-15 2:31
mveRichard Deeming12-Jan-15 2:31 
GeneralRe: Anybody using DwmExtendFrameIntoClientArea? Pin
SledgeHammer0112-Jan-15 4:52
SledgeHammer0112-Jan-15 4:52 
QuestionWhere to go to learn wpf? Pin
MrGlass35-Jan-15 8:44
MrGlass35-Jan-15 8:44 
AnswerRe: Where to go to learn wpf? Pin
SledgeHammer015-Jan-15 9:59
SledgeHammer015-Jan-15 9:59 
AnswerRe: Where to go to learn wpf? Pin
Mycroft Holmes5-Jan-15 12:11
professionalMycroft Holmes5-Jan-15 12:11 
GeneralRe: Where to go to learn wpf? Pin
SledgeHammer015-Jan-15 12:58
SledgeHammer015-Jan-15 12:58 
GeneralRe: Where to go to learn wpf? Pin
Mycroft Holmes5-Jan-15 13:21
professionalMycroft Holmes5-Jan-15 13:21 
AnswerRe: Where to go to learn wpf? Pin
Richard MacCutchan5-Jan-15 22:43
mveRichard MacCutchan5-Jan-15 22:43 
AnswerRe: Where to go to learn wpf? Pin
Vimalsoft(Pty) Ltd12-Jan-15 20:56
professionalVimalsoft(Pty) Ltd12-Jan-15 20:56 
AnswerRe: Where to go to learn wpf? Pin
Subramanyam Shankar17-Mar-15 1:04
professionalSubramanyam Shankar17-Mar-15 1:04 
QuestionMultithreaded Windows with Data Binding Pin
Dominick Marciano5-Jan-15 8:30
professionalDominick Marciano5-Jan-15 8:30 
AnswerRe: Multithreaded Windows with Data Binding Pin
Afzaal Ahmad Zeeshan9-Jan-15 8:41
professionalAfzaal Ahmad Zeeshan9-Jan-15 8:41 
AnswerRe: Multithreaded Windows with Data Binding Pin
SledgeHammer0111-Jan-15 8:37
SledgeHammer0111-Jan-15 8:37 
QuestionWPF DataGrid with ComBox Bound To Enums - Show Descriptions Pin
Kevin Marois5-Jan-15 7:03
professionalKevin Marois5-Jan-15 7:03 
AnswerRe: WPF DataGrid with ComBox Bound To Enums - Show Descriptions Pin
Pete O'Hanlon5-Jan-15 7:19
mvePete O'Hanlon5-Jan-15 7:19 
QuestionGetting error when i drag&drop in WPF Pin
VisualLive1-Jan-15 17:35
VisualLive1-Jan-15 17:35 
AnswerRe: Getting error when i drag&drop in WPF Pin
Afzaal Ahmad Zeeshan9-Jan-15 8:44
professionalAfzaal Ahmad Zeeshan9-Jan-15 8:44 
AnswerRe: Getting error when i drag&drop in WPF Pin
Vimalsoft(Pty) Ltd11-Jan-15 23:52
professionalVimalsoft(Pty) Ltd11-Jan-15 23:52 
QuestionLoop in Dispatch.Invoke Not Updating UI Pin
Dominick Marciano31-Dec-14 16:15
professionalDominick Marciano31-Dec-14 16:15 
QuestionSelectionChanged Event is not firing on View Load in MVVM Pin
Ashfaque Hussain29-Dec-14 20:15
Ashfaque Hussain29-Dec-14 20:15 
QuestionSilverlight? A future? Pin
Sean McPoland26-Dec-14 23:46
Sean McPoland26-Dec-14 23:46 
AnswerRe: Silverlight? A future? Pin
Richard MacCutchan26-Dec-14 23:57
mveRichard MacCutchan26-Dec-14 23:57 
AnswerRe: Silverlight? A future? Pin
Pete O'Hanlon27-Dec-14 2:03
mvePete O'Hanlon27-Dec-14 2:03 
QuestionWhat are those automation peer in WPF? Pin
Super Lloyd22-Dec-14 0:55
Super Lloyd22-Dec-14 0:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.