/// <summary>Win32 API dialog generic resource control template</summary> /// <param name="control">Defines the dimensions and style of a control in a dialog box.</param> /// <param name="controlEx">A block of text used by an extended dialog box template to describe the extended dialog box.</param> /// <param name="itemClass">Type of dialog item template (predefined control or COM control)</param> /// <param name="itemText">Item title text</param> /// <param name="extraData">Control item extended data</param> public DialogItemTemplate(WinUser.DLGITEMTEMPLATE?control, WinUser.DLGITEMTEMPLATEEX?controlEx, ResourceBase.SzInt itemClass, ResourceBase.SzInt itemText, Byte[] extraData) { if (control == null && controlEx == null) { throw new ArgumentNullException("control or controlEx must be not null"); } if (control != null) { this.Styles = control.Value.style; this.StylesEx = control.Value.dwExtendedStyle; this.X = control.Value.x; this.Y = control.Value.y; this.CX = control.Value.cx; this.CY = control.Value.cy; this.ControlID = control.Value.id; } if (controlEx != null) { this.HelpID = controlEx.Value.helpID; this.Styles = controlEx.Value.style; this.StylesEx = controlEx.Value.exStyle; this.X = controlEx.Value.x; this.Y = controlEx.Value.y; this.CX = controlEx.Value.cx; this.CY = controlEx.Value.cy; this.ControlID = controlEx.Value.id; } if (!itemClass.IsEmpty) { switch (itemClass.Type) { case ResourceBase.SzInt.SzIntResult.Index: this.ItemSystemClass = (DialogItemTemplate.ControlSystemClass)itemClass.Index; break; case ResourceBase.SzInt.SzIntResult.Name: this.ItemClass = itemClass.Name; break; default: throw new NotSupportedException(); } } if (!itemText.IsEmpty) { this.ItemText = itemText; } this.ExtraData = extraData; }
/// <summary>Create instance of dialog TextBox resource control template</summary> /// <param name="control"></param> /// <param name="controlEx"></param> /// <param name="itemClass"></param> /// <param name="itemText"></param> /// <param name="extraData"></param> public DialogEditTemplate(WinUser.DLGITEMTEMPLATE?control, WinUser.DLGITEMTEMPLATEEX?controlEx, ResourceBase.SzInt itemClass, ResourceBase.SzInt itemText, Byte[] extraData) : base(control, controlEx, itemClass, itemText, extraData) { }
/// <summary>Create instance of extended Win32 API tempate control described by itemClass member</summary> /// <param name="control">Defines the dimensions and style of a control in a dialog box.</param> /// <param name="controlEx">A block of text used by an extended dialog box template to describe the extended dialog box.</param> /// <param name="itemClass">Type of dialog item template (predefined control or COM control)</param> /// <param name="itemText">Item title text</param> /// <param name="extraData">Control item extended data</param> /// <returns>Win32 API dialog item template</returns> public static DialogItemTemplate CreateDialogItem(WinUser.DLGITEMTEMPLATE?control, WinUser.DLGITEMTEMPLATEEX?controlEx, ResourceBase.SzInt itemClass, ResourceBase.SzInt itemText, Byte[] extraData) { if (itemClass.IsEmpty || itemClass.Type == ResourceBase.SzInt.SzIntResult.Name) { return(new DialogItemTemplate(control, controlEx, itemClass, itemText, extraData)); } else { switch ((DialogItemTemplate.ControlSystemClass)itemClass.Index) { case ControlSystemClass.Button: return(new DialogButtonTemplate(control, controlEx, itemClass, itemText, extraData)); case ControlSystemClass.Edit: return(new DialogEditTemplate(control, controlEx, itemClass, itemText, extraData)); default: return(new DialogItemTemplate(control, controlEx, itemClass, itemText, extraData)); } } }