How do I make my child Form fill the entire mdi client without being maximized?
Here is how it can be done. This takes into account all docked controls (including menus) in the mdi parent form. [C#] private void FillActiveChildFormToClient() { Form child = this.ActiveMdiChild; Rectangle mdiClientArea = Rectangle.Empty; foreach(Control c in this.Controls) { if(c is MdiClient) mdiClientArea = c.ClientRectangle; } child.Bounds = mdiClientArea; } [VB.Net] Private Sub FillActiveChildFormToClient() Dim child As Form = Me.ActiveMdiChild Dim mdiClientArea As Rectangle = Rectangle.Empty Dim c As Control For Each c In Me.Controls If TypeOf c Is MdiClient Then mdiClientArea = c.ClientRectangle End If Next child.Bounds = mdiClientArea End Sub
How do I get a count of the gdi handles currently in use in my application?
You can do so using the native GetGuiResources api. Here is a sample: /// /// uiFlags: 0 – Count of GDI objects /// uiFlags: 1 – Count of USER objects /// – Win32 GDI objects (pens, brushes, fonts, palettes, regions, device contexts, bitmap headers) /// – Win32 USER objects: /// – WIN32 resources (accelerator tables, bitmap resources, dialog box templates, font resources, menu resources, raw data resources, string table entries, message table entries, cursors/icons) /// – Other USER objects (windows, menus) /// [DllImport(‘User32’)] extern public static int GetGuiResources(IntPtr hProcess, int uiFlags); public static int GetGuiResourcesGDICount() { return GetGuiResources(Process.GetCurrentProcess().Handle, 0); } public static int GetGuiResourcesUserCount() { return GetGuiResources(Process.GetCurrentProcess().Handle, 1); } ’ ’ uiFlags: 0 – Count of GDI objects ’ uiFlags: 1 – Count of USER objects ’ – Win32 GDI objects (pens, brushes, fonts, palettes, regions, device contexts, bitmap headers) ’ – Win32 USER objects: ’ – WIN32 resources (accelerator tables, bitmap resources, dialog box templates, font resources, menu resources, raw data resources, string table entries, message table entries, cursors/icons) ’ – Other USER objects (windows, menus) ’ _ extern Public static Integer GetGuiResources(IntPtr hProcess, Integer uiFlags) Public Shared Function GetGuiResourcesGDICount() As Integer Return GetGuiResources(Process.GetCurrentProcess().Handle,0) End Function Public Shared Function GetGuiResourcesUserCount() As Integer Return GetGuiResources(Process.GetCurrentProcess().Handle,1) End Function
Is EnableVisualStyles method to support XP styles in my app broken?
Microsoft has confirmed that calling EnableVisualStyles in the main method resulting in some ImageList corruption is a bug. There however seems to be a workaround posted by Martin Robins in the newsgroup which worksaround this issue: public virtual void Main() { Application.EnableVisualStyles(); // Calling DoEvents after the above method call seems to fix this issue: Application.DoEvents(); Application.Run(new Form1()); }
How do I create windows shortcuts on my desktop programatically in .Net?
The following article explains how shortcuts can be created programatically: Creating and Modifying Shortcuts
How can I add a custom verb to the file and folder context menus in the explorer shell?
The article at www.vbaccelerator.com shows you how it is done in .net: Associating Applications with Any File or Folder