Glass effect with DwmExtendFrameIntoClientArea

8 posts, 0 answers
  1. Julien
    Julien avatar
    3 posts
    Member since:
    Jul 2011

    Posted 06 Aug 2011 Link to this post

    Hi,

    I'm trying to get the Office 2010 look & feel so i'd like to apply glass effect on the RadRibbonWindow, wich works fine with a standard window (http://msdn.microsoft.com/en-us/library/ms748975.aspx).

    Have you already set a handler that would prevent that feature to work ?

    Regards.
    <telerik:RadRibbonWindow xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="TestRibbon.MainWindow"
            Title="MainWindow" Height="350" Width="525"
            Loaded="Window_Loaded" Background="Transparent">
    </telerik:RadRibbonWindow>

    public partial class MainWindow : RadRibbonWindow
    {
        public MainWindow()
        {
            InitializeComponent();
        }
     
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle;
                HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
                mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
     
                System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(mainWindowPtr);
                float DesktopDpiX = desktop.DpiX;
                float DesktopDpiY = desktop.DpiY;
     
                MARGINS margins = new MARGINS();
                margins.cxLeftWidth = Convert.ToInt32(0 * (DesktopDpiX / 96));
                margins.cxRightWidth = Convert.ToInt32(this.Width * (DesktopDpiX / 96));
                margins.cyTopHeight = Convert.ToInt32(0 * (DesktopDpiX / 96));
                margins.cyBottomHeight = Convert.ToInt32(this.Height * (DesktopDpiX / 96));
     
                int hr = DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
                if (hr < 0)
                {
                    MessageBox.Show("Can't apply glass...");
                }
            }
            catch (DllNotFoundException)
            {
                Application.Current.MainWindow.Background = Brushes.White;
            }
        }
     
        [StructLayout(LayoutKind.Sequential)]
        public struct MARGINS
        {
            public int cxLeftWidth;
            public int cxRightWidth;
            public int cyTopHeight;
            public int cyBottomHeight;
        };
     
        [DllImport("DwmApi.dll")]
        public static extern int DwmExtendFrameIntoClientArea(
            IntPtr hwnd,
            ref MARGINS pMarInset);
    }

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 10 Aug 2011 Link to this post

    Hi Julien,

     This feature is tightly coupled with your Windows Settings. Please check here==>
    Control Panel==>All Control Panel Items==>Personalization==>Window Color and Appearance whether
    EnableTransparency is set to Checked. Please let us know if this helps you.

    Greetings,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Julien
    Julien avatar
    3 posts
    Member since:
    Jul 2011

    Posted 11 Aug 2011 Link to this post

    Hi,

    It's not really the problem: it's easy set the window transparancy with AllowsTransparency="True" but that implies to set WindowStyle="None" and loosing the title bar, std resize border and std buttons.

    What I want is to have the QuickAccessToolbox in the title bar (and the resize features and standard sys buttons) like the first screen shot based on a RadRibbonWindow, but with the global window transparency like the second screen shot based on a standard window.

    The problem is that at some point the RadRibbonWindow must override some display parameters...

    Would you see any way to do it without having to recode the title bar move (and manage the onmousedown on all the ribbon to launch DragMove), the border risize and the std button on a standard window with transparency ?
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Aug 2011 Link to this post

    Hi Julien,

    I am not sure if I understood your scenario correctly. But we have a feature request to combine the Aero RadRibbonWindow with the RadRibbonView`s tabstrip like in the Office Application. If this is what you need then you can vote for its implementation here.

    Best wishes,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  6. Julien
    Julien avatar
    3 posts
    Member since:
    Jul 2011

    Posted 16 Aug 2011 Link to this post

    Not quite, I already have the two components merged as you could see in QuikToolbox-in-titlebar.png, it's just that the graphical effect using DwmExtendFrameIntoClientArea from DwmApi.dll won't apply. So the question is: did the developpers use any trick for rendering that would prevail on an effect working fine with a standard window ?

    Thanks in advance
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 18 Aug 2011 Link to this post

    Hi Julien,

    Unfortunately the RadRibbonView control doesn't support this functionality at the moment. However, based on your feedback we logged a feature request in our PITS and if the item gathers enough popularity, we will definitely consider implementing it.

    I updated your Telerik account for your feedback.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  8. Steve
    Steve avatar
    124 posts
    Member since:
    Jun 2011

    Posted 12 Oct 2011 Link to this post

    It seems to me that mimicing the Office 2010 look would necessitate this.
  9. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 14 Oct 2011 Link to this post

    Hi Steve,

    Thank you for your feedback. I can see your point on the matter and we'll definately consider the implementation of this feature.  However, please keep in mind that due to the many pressing tasks in our to-do list, we have to constantly prioritize them and the customers demand for a feature is a big factor in this process. And this is why we cannot bind to any time frames at the moment.

    Greetings,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
UI for WPF is Visual Studio 2017 Ready