Skip to content

Instantly share code, notes, and snippets.

@k33ptoo
Last active June 6, 2018 07:02
Show Gist options
  • Save k33ptoo/41c0eabaf76f68e654e1 to your computer and use it in GitHub Desktop.
Save k33ptoo/41c0eabaf76f68e654e1 to your computer and use it in GitHub Desktop.
C#
protected override CreateParams CreateParams
{
get
{
const int CS_DROPSHADOW = 0x20000;
CreateParams cp = base.CreateParams;
cp.ClassStyle |= CS_DROPSHADOW;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
//add shadow
//reduce flicker
//add to root of form.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(new Form1());
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception");
// here you can log the exception ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment