How do I get Mouse Messages on my Control during design-time?

The design-time will forward the MouseEnter and MouseLeave messages to your Control by default. The MouseMove message are blocked by the designer. You can get MouseDown and Up messages in your Control if you override GetHitTest method in your designer and return true, as follows: protected override /*ControlDesigner*/ bool GetHitTest(Point point) { if(this.NeedMouseDown(point)) return true; else return false; }

How do I restrict my Container Control to parent only certain types of Controls, and vice-versa, during design-time?

To restrict your Container Control to parent only certain types of controls, override as follows in your designer: public class MyContainerControlDesigner : ParentControlDesigner { public override /*ParentControlDesigner*/ bool CanParent(Control control) { // My Children can only be of type TextBox. return (control is TextBox); } } To restrict your Control to get parented to by a certain type, do so in your Control’s designer: class MyControlDesigner : ControlDesigner { public override /*ControlDesigner*/ bool CanBeParentedTo(IDesigner parentDesigner) { // MyControl can be parent only by MyParent return (parentDesigner is MyParentDesigner); // or do this: // return (parentDesigner.Component is MyParent); } }

I need to encode the LParam argument of a mouse message. How do I do MakeLong , HiWord and LoWord type conversions

You can create static methods that encode and decode these values. Here are some. static int MakeLong(int LoWord, int HiWord) { return (HiWord << 16) | (LoWord & 0xffff); } static IntPtr MakeLParam(int LoWord, int HiWord) { return (IntPtr) ((HiWord << 16) | (LoWord & 0xffff)); } static int HiWord(int Number) { return (Number >> 16) & 0xffff; } static int LoWord(int Number) { return Number & 0xffff; }

How can I insert custom menu items (verbs) into my Component/Control designer’s Context Menu in design time?

You need to create custom ‘Verbs’ for your Component/Control designer. This will make your ‘verbs’ show up in the property browser and in the designer context menu. The designer throws an event when the user selects a verb and you can perform custom operation when you handle this event. You do this by overriding the Verbs property in your Designer class. Here is an example: public class MyControlExtDesigner : ControlDesigner { … public override DesignerVerbCollection Verbs { get { if (this.verbs == null) { this.verbs = new DesignerVerbCollection(); this.verbs.Add(new DesignerVerb(‘Add New Child’,new EventHandler(this.OnAdd))); } return this.verbs; } } private void OnAdd(object sender, EventArgs eevent) { // Code to add a new child inside your control. … } }