Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to extend the size of the top edge of the client area to enter non GUI components that location. I am using the code below to this, however, by turning the extended area code is blank, you do not get the transparency of Windows 7 Professional, which is the OS I'm using.
I am new to programming and C # Windows API. I thank the attention.

C#
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace InstrumentalCsharp
    {
    public partial class WExplorerPadrao : Form
    {

        [StructLayout(LayoutKind.Sequential)]
        public struct MARGINS
        {
            public int cxLeftWidth;      // width of left border that retains  its size
            public int cxRightWidth;     // width of right border that retains its size
            public int cyTopHeight;      // height of top border that retains its size
            public int cyBottomHeight;   // height of bottom border that retains its size
        };

    [DllImport("dwmapi.dll", PreserveSig = false)]
    public static extern void DwmExtendFrameIntoClientArea(IntPtr hwnd, ref     MARGINS margins);

    [DllImport("dwmapi.dll", PreserveSig = false)]
    public static extern bool DwmIsCompositionEnabled();


        public WExplorerPadrao()
        {
            InitializeComponent();
        }

    protected void WExplorerPadrao_Load(object sender, System.EventArgs e)
        {
            WExplorerPadrao.MARGINS margins = new WExplorerPadrao.MARGINS();
            margins.cxLeftWidth = 0;
            margins.cxRightWidth = 0;
            margins.cyTopHeight = 20;
            margins.cyBottomHeight = 0;
            IntPtr hwnd = this.Handle;
            WExplorerPadrao.DwmExtendFrameIntoClientArea(hwnd, ref margins);
        }
    }
}


What I have tried:

I tried extend the top of non client area in other languages, however, the result is the same as I described above.
Posted
Updated 1-Oct-16 4:28am

1 solution

You can't "expand the size of the non-client area". But you can position a window off the visible screen. Simply set the position of the "non-client area" window to a negative Y coordinate, and make sure the window's height is appropriate. So if your window is positioned at 0,-100, then your window height should be larger than Math.Abs(pos.Y).

Finally, set your window not to appear in the task bar (if necessary).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900