How do I make my custom dialog droppable in the design surface like a component?
Set the Designer attribute for your custom dialog to be ComponentDesigner (instead of the default ControlDesigner). That should make it droppable in the design surface as a component.
Can I trace the caught Exception without breaking into the debugger?
Yes, there are framework classes that will give you the Call Stack information at a particular point. [C#] public static void TraceExceptionCatched(Exception e) { StackTrace st = new StackTrace(1, true); StackFrame sf = st.GetFrame(StackTrace.METHODS_TO_SKIP); if (sf != null) { MethodBase mb = sf.GetMethod(); Trace.WriteLine(e.ToString()); StringBuilder sb = new StringBuilder(); sb.Append(‘catched in File ‘); sb.Append(sf.GetFileName()); sb.Append(‘, line ‘); sb.Append(sf.GetFileLineNumber()); Trace.WriteLine(sb.ToString()); sb = new StringBuilder(); sb.Append(‘in method ‘); sb.Append(mb.ReflectedType.Name); sb.Append(‘.’); sb.Append(mb.Name); sb.Append(‘(‘); bool first = true; foreach (ParameterInfo pi in mb.GetParameters()) { if (!first) sb.Append(‘, ‘); first = false; sb.Append(pi.ParameterType.Name); sb.Append(‘ ‘); sb.Append(pi.Name); } sb.Append(‘);’); Trace.WriteLine(sb.ToString()); } } You could then call this method from the Catch portion of a try/catch block.
Can I trace the Call Stack at any particular point without breaking into the debugger?
Yes, there are classes in the framework that will provide you call stack information that you can trace to the output: [C#] public static void TraceCallStack() { StackTrace st = new StackTrace(1, true); StackFrame sf = st.GetFrame(StackTrace.METHODS_TO_SKIP); if (sf != null) { MethodBase mb = sf.GetMethod(); StringBuilder sb = new StringBuilder(); sb.Append(mb.ReflectedType.Name); sb.Append(‘.’); sb.Append(mb.Name); sb.Append(‘(‘); bool first = true; foreach (ParameterInfo pi in mb.GetParameters()) { if (!first) sb.Append(‘, ‘); first = false; sb.Append(pi.ParameterType.Name); sb.Append(‘ ‘); sb.Append(pi.Name); } sb.Append(‘);’); int n = StackTrace.METHODS_TO_SKIP+1; sf = st.GetFrame(n); if (sf != null) { sb.Append(‘ called from ‘); do { mb = sf.GetMethod(); sb.Append(mb.ReflectedType.Name); sb.Append(‘.’); sb.Append(mb.Name); sb.Append(‘:’); sf = st.GetFrame(++n); } while (sf != null); } Trace.WriteLine(sb.ToString()); } }
How do I create a non-modal top level form that always stays on top of all the app’s windows (like the VS.Net find dialog)?
Make your main form the ‘Owner’ of the form in question. Refer to Form.Owner in class reference for more information. [C#] findReplaceDialog.Owner = this; // Your main form. findReplaceDialog.TopLevel = false; [VB.Net] findReplaceDialog.Owner = Me ’ Your main form. findReplaceDialog.TopLevel = False
How do menu shortcuts work?
The focused control’s ProcessCmdKey will be called first. 1) The Control class implementation of this method will check if there is a ContextMenu associated with the Control and if so let the context menu handle the shortcut. 2) If not handled, the ProcessCmdKey of the parent will be called recursively until the Form is reached. 3) When the Form is reached it’s MainMenu will be requested to handle the key. You can override ProcessCmdKey of any Control and interrupt the normal processing. Note that you can also override the ProcessCmdKey method is the MainMenu and ContextMenu classes (this is not documented) to override default processing.