DOTNET desktop programming plan. Window articles .visual studio.net style MDI window

xiaoxiao2021-03-06  41

The picture below is a normal MDI, window style, not very good looking. In fact, achieving this very simple code can get it. The cause is a friend asked me how to achieve it. I remembered it. I have done it before, but I didn't use .NET after several tests finally got it under. Net, I would like to share and 9CBS friends, time hasty Where you are not enough, please don't marry me in a detailed place. Specific method:

Establish a mdi window Form1using System.Runtime.InteropServices; this.IsMdiContainer = true; you declare a variable number of private System.Windows.Forms.MdiClient m_MdiClient; public const int MDIS_ALLCHILDSTYLES = 0x0001; public const int GWL_STYLE = -16; public const int GWL_EXSTYLE = -20; API statement several [DllImport ( "user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SetWindowLong (IntPtr hWnd, int nIndex, int dwNewLong); [DllImport ( "user32.dll", CharSet = CharSet .Auto] public static extern INTPTR getWindowlong (INTPTR HWND, INT NINDEX); in the Form1 constructor PUBLIC FORM1 ()

{

//

// Windows Form Designer Support

//

InitializationComponent ();

this.WindowState = formwindowstate.maximized;

INT ICNT = this.Controls.count;

For (INT i = 0; i

{

IF (this.Controls [i] is system.windows.forms.mdiclient)

{

THISTEM.WINDOWS.FORMS.MDICLIENT This.Controls [i];

INT Style = getWindowlong (m_mdiclient.handle, gwl_style) .toint32 ();

STYLE | = mdis_allchildstyles;

// Set the MDI area style to join, MDIS_AllChildStyles

/ / Remove step by the MDI child window [key to the upper right corner button]

Setwindowlong (m_mdiclient.handle, gwl_style, stop);

/ / Set the MDI area extension style

// Remove the MDI window depression, according to Windows for many years

// Extended style is 0 must be flat

SetWindowlong (m_mdiclient.handle, gwl_exstyle, 0);

m_mdiclient.controladded =

New ControleventHandler (m_mdiclient_controladded);

Break;

}

}

}

Write m_mdiclient_controladded event private void m_mdiclient_controladded (Object Sender, ControlEventargs E)

{

Form frm = E.Control as form;

IF (frm! = null)

{

// Change the added MDI sub-window, style, then maximize

FRM.FORMBORDERSTYLE = formborderstyle.none;

Frm.windowstate = formwindowstate.maximized;

}

}

Private Void Form1_Load (Object Sender, System.EventArgs E) in Form1 Load Event

{

FORM2 F2 = New Form2 ();

F2.mdiparent = this;

F2.show ();

f2.activate ();

}

Create a DataGrid Dock on a FORM2, the property selection Fill selection, the program can be seen

Reprint this article, please mark, reprint the address, and the author.

Fuyue 2005-3-13

转载请注明原文地址:https://www.9cbs.com/read-47590.html

New Post(0)