Max Char in TextBox C#?

Look at the MaxLength property of the TextBox – it stores the maximum number of characters the control can take; as per the documentation, it is changeable. Usually the default is big enough, though. (Although I imagine that since you’re asing the question, it may not be!) From the docs, you can see that the … Read more

How to draw custom button in Window Titlebar with Windows Forms?

The following will work in XP, I have no Vista machine handy to test it, but I think your issues are steming from an incorrect hWnd somehow. Anyway, on with the poorly commented code. // The state of our little button ButtonState _buttState = ButtonState.Normal; Rectangle _buttPosition = new Rectangle(); [DllImport(“user32.dll”)] private static extern IntPtr … Read more

PowerShell: Job Event Action with Form not executed

There are a lot of (StackOverflow) questions and answers about this ‘enduring mystique’ of combining form (or WPF) events with .NET events (like EngineEvents, ObjectEvents and WmiEvents) in PowerShell: Do Jobs really work in background in powershell? WPF events not working in Powershell – Carousel like feature in multi-threaded script is it possible to control … Read more

Restore WindowState from Minimized

I use the following extension method: using System.Runtime.InteropServices; namespace System.Windows.Forms { public static class Extensions { [DllImport( “user32.dll” )] private static extern int ShowWindow( IntPtr hWnd, uint Msg ); private const uint SW_RESTORE = 0x09; public static void Restore( this Form form ) { if (form.WindowState == FormWindowState.Minimized) { ShowWindow(form.Handle, SW_RESTORE); } } } } … Read more

MSI register dll – Self-Registration considered harmful

Nice answer from Chris Painter, adding for reference: how to register DLL’s properly in wix 3.9. And one with WiX-focus: Registering COM EXE with WIX. Self-Registration considered harmful The proper way to register a COM file is to extract the COM registry information from the file and add to the appropriate family of COM tables … Read more