Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

MGoettmann

@MGoettmann
About
Posts
5
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Invoke Constructor method of any class that extends an Interface without having to specifically cast each class
    M MGoettmann

    Pedro, have a look at Plug-ins and cast exceptions [^]. Martin

    C# question design help

  • Set 'visible' property to 'false' for all the opened forms
    M MGoettmann

    ouh... this becomes really complicated. To solve this particular issue, I would suggest to add an eventhandler in your form. this.VisibleChanged += new EventHandler(Form1_VisibleChanged); Here you can show/hide the dialog according to the actual form's Visible state. My solution is a sledgehammer method to get all running form objects - without having any idea of your application logic. Maybe you will run run into similar issues with other forms/controls. At this point you might consider implementing Stefan's solution and storing your forms references in a central list? btw: if *all* app's windows (incl. dialogs) were hidden... how to bring them back? regards Martin

    C# question

  • Set 'visible' property to 'false' for all the opened forms
    M MGoettmann

    oops, I'm using VS 2003 so I can't check that... As I said, it's a quick & dirty way;). Creating a Forms.Control object from a handle seems to work for some other UI controls (i.e. ToolStripDropDownMenu) that respond to EnumWindows(). However, try to replace the line Control hForm = System.Windows.Forms.Control.FromHandle(hWnd); with this one: System.Windows.Forms.Form hForm = System.Windows.Forms.Control.FromHandle(hWnd) as System.Windows.Forms.Form; in order to get forms only. hope that helps Martin

    C# question

  • Set 'visible' property to 'false' for all the opened forms
    M MGoettmann

    a quick and dirty way::) using System; using System.Runtime.InteropServices; using System.Windows.Forms; public class GetFormsCollection { private delegate bool WndEnumProc(System.IntPtr hWnd , int lParam); [DllImport("user32.dll", CharSet=CharSet.Auto)] private static extern bool EnumWindows (WndEnumProc lpEnumFunc, int lParam); public readonly System.Collections.ArrayList Forms; public GetFormsCollection() { Forms = new System.Collections.ArrayList(); EnumWindows(new WndEnumProc(EnumCallback), 0); } private bool EnumCallback(System.IntPtr hWnd, int lParam) { Control hForm = System.Windows.Forms.Control.FromHandle(hWnd); // hForm is null for handles not created by your app... if (hForm != null) this.Forms.Add(hForm); return true; } public static void SetVisiblity(bool fVisible) { foreach (System.Windows.Forms.Form objForm in new GetFormsCollection().Forms) { objForm.Visible = fVisible; } } } Martin

    C# question

  • Get a Month collection class
    M MGoettmann

    take a look at System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames see http://msdn2.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.monthnames.aspx for details Hope that helps Martin

    .NET (Core and Framework) csharp question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups