public PreviewWindow(DialogDefinition dlg) { mDelegate = new Win32.DialogProcDelegate(DialogProc); mTemplate = new DialogTemplateEx(); ToStyle(dlg.ExStyle, ref mTemplate.exStyle); ToStyle(dlg.Style, ref mTemplate.style); // Ensure that we still show child windows, and do not center them mTemplate.style &= ~(WindowStyles.WS_CHILD | WindowStyles.DS_CENTER | WindowStyles.WS_DISABLED); // Enforce visibility mTemplate.style |= WindowStyles.WS_VISIBLE; mTemplate.style |= WindowStyles.DS_NOFAILCREATE; // HACK :) mTemplate.x = (short)dlg.Dimensions.Left; mTemplate.y = (short)dlg.Dimensions.Top; mTemplate.cx = (short)dlg.Dimensions.Width; mTemplate.cy = (short)dlg.Dimensions.Height; mTemplate.menu = null; mTemplate.windowClass = null; mTemplate.title = Cleanup(dlg.TextValue.Text); if (dlg.Font != null) { mTemplate.mFont = new Font() { Name = Cleanup(dlg.Font.Name), Size = dlg.Font.Size }; } uint id = 1; foreach (var dlgCtrl in dlg.Entries) { var ctrl = new DialogItemTemplateEx(); ctrl.exStyle = 0; ctrl.style = 0; ctrl.x = (short)dlgCtrl.Dimensions.Left; ctrl.y = (short)dlgCtrl.Dimensions.Top; ctrl.cx = (short)dlgCtrl.Dimensions.Width; ctrl.cy = (short)dlgCtrl.Dimensions.Height; ctrl.id = id++; ctrl.windowClass = ControlTypeToClass(dlgCtrl.EntryType.Name, Cleanup(dlgCtrl.GenericControlType), ref ctrl.style); ToStyle(dlgCtrl.Style, ref ctrl.style); ctrl.style |= WindowStyles.WS_CHILD | WindowStyles.WS_VISIBLE; ctrl.style &= ~WindowStyles.WS_POPUP; if (dlgCtrl.TextValue != null) { // FIXME: Ordinal for icon etc! ctrl.title = new sz_Or_Ord(Cleanup(dlgCtrl.TextValue?.Text)); } else { ctrl.title = null; } mTemplate.controls.Add(ctrl); } }
internal void WriteToStream(BinaryWriter bw) { DialogTemplateEx.DWordAlign(bw); bw.Write((uint)0); // helpID; bw.Write((uint)exStyle); bw.Write((uint)style); bw.Write(x); bw.Write(y); bw.Write(cx); bw.Write(cy); bw.Write(id); DialogTemplateEx.Write(bw, windowClass); DialogTemplateEx.Write(bw, title); bw.Write((ushort)0); // extraCount }