2 using System.Collections.Generic;
5 using System.Runtime.InteropServices;
9 namespace sage.ew.conta.plugins
14 static public class StyleHBDialog
16 private static readonly
string TMDICHILD =
"TMdiChildSP";
23 public static void _ApplyStyle(IntPtr handleHB, Control controlContainer)
26 if (_IsMdiChild(handleHB))
28 _SetOwner(handleHB, controlContainer.Handle);
29 User32dllCommands.MoveWindow(handleHB, 0, 0, controlContainer.Size.Width, controlContainer.Height,
false);
38 public static bool _IsMdiChild(IntPtr handleHB)
40 StringBuilder className =
new StringBuilder();
41 StringBuilder typeMDI =
new StringBuilder(TMDICHILD);
42 User32dllCommands.GetClassName(handleHB, className, 12);
44 return className.Equals(typeMDI);
52 public static void _SetParentAndCentre(IntPtr handleHB, Form mainFrm)
56 int styleGet = User32dllCommands.GetWindowLong(handleHB, (
int)
WindowLongFlags.GWL_STYLE);
60 User32dllCommands.SetWindowLong(handleHB, (
int)
WindowLongFlags.GWL_STYLE, (uint)styleGet);
61 User32dllCommands.SetParent(handleHB, mainFrm.Handle);
63 User32dllCommands.SendMessage(handleHB, User32dllCommands.WM_SYSCOMMAND, User32dllCommands.SC_RESTORE, 0);
64 _CenterWindow(handleHB, mainFrm);
77 public static void _SetOwner(IntPtr handleHB, IntPtr handleParent)
79 User32dllCommands.SetWindowLong32(handleHB, -8, handleParent);
86 public static void _BringToFront(IntPtr handleHB)
90 User32dllCommands.SetForegroundWindow(handleHB);
98 static void _CenterWindow(IntPtr handleHB, Form mainFrm)
101 User32dllCommands.GetWindowRect(
new HandleRef(mainFrm, handleHB), out rect);
103 Size monitorDimensions = mainFrm.Size;
104 int x1Pos = monitorDimensions.Width / 2 - (rect.Right - rect.Left) / 2;
105 int x2Pos = rect.Right - rect.Left;
106 int y1Pos = monitorDimensions.Height / 2 - (rect.Bottom - rect.Top) / 2;
107 int y2Pos = rect.Bottom - rect.Top;
109 User32dllCommands.SetWindowPos(handleHB, (IntPtr)0, x1Pos, y1Pos, x2Pos, y2Pos,
SetWindowPosFlags.SWP_SHOWWINDOW);
SetWindowPosFlags
Representa la posición de una ventana
WindowLongFlags
GWL Values