+ GdkWindowPrivate *private;
+ RECT r;
+ guint width;
+ guint height;
+
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
+ width = r.right - r.left;
+ height = r.bottom - r.top;
+
+ gdk_parent_root = gdk_win32_window_alloc ();
+ private = (GdkWindowPrivate *) gdk_parent_root;
+
+ GDK_DRAWABLE_WIN32DATA (gdk_parent_root)->xid = gdk_root_window;
+ private->drawable.window_type = GDK_WINDOW_ROOT;
+ private->drawable.width = width;
+ private->drawable.height = height;
+
+ gdk_xid_table_insert (&gdk_root_window, gdk_parent_root);
+}
+
+/* RegisterGdkClass
+ * is a wrapper function for RegisterWindowClassEx.
+ * It creates at least one unique class for every
+ * GdkWindowType. If support for single window-specific icons
+ * is ever needed (e.g Dialog specific), every such window should
+ * get its own class
+ */
+ATOM
+RegisterGdkClass (GdkDrawableType wtype)
+{
+ static ATOM klassTOPLEVEL = 0;
+ static ATOM klassDIALOG = 0;
+ static ATOM klassCHILD = 0;
+ static ATOM klassTEMP = 0;
+ static HICON hAppIcon = NULL;
+ static WNDCLASSEX wcl;
+ ATOM klass = 0;
+
+ wcl.cbSize = sizeof(WNDCLASSEX);
+ wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
+ * on WM_SIZE and WM_MOVE. Flicker, Performance!
+ */
+ wcl.lpfnWndProc = gdk_WindowProc;
+ wcl.cbClsExtra = 0;
+ wcl.cbWndExtra = 0;
+ wcl.hInstance = gdk_ProgInstance;
+ wcl.hIcon = 0;
+ /* initialize once! */
+ if (0 == hAppIcon)
+ {
+ gchar sLoc [_MAX_PATH+1];
+ HINSTANCE hInst = GetModuleHandle(NULL);
+
+ if (0 != GetModuleFileName(hInst, sLoc, _MAX_PATH))
+ {
+ hAppIcon = ExtractIcon(hInst, sLoc, 0);
+ if (0 == hAppIcon)
+ {
+ char *gdklibname = g_strdup_printf ("gdk-%s.dll", GDK_VERSION);
+
+ hAppIcon = ExtractIcon(hInst, gdklibname, 0);
+ g_free (gdklibname);
+ }
+
+ if (0 == hAppIcon)
+ hAppIcon = LoadIcon (NULL, IDI_APPLICATION);
+ }
+ }
+
+ wcl.lpszMenuName = NULL;
+ wcl.hIconSm = 0;
+
+ /* initialize once per class */
+#define ONCE_PER_CLASS() \
+ wcl.hIcon = CopyIcon (hAppIcon); \
+ wcl.hIconSm = CopyIcon (hAppIcon); \
+ wcl.hbrBackground = CreateSolidBrush( RGB(0,0,0)); \
+ wcl.hCursor = LoadCursor (NULL, IDC_ARROW);
+
+ switch (wtype)
+ {
+ case GDK_WINDOW_TOPLEVEL:
+ if (0 == klassTOPLEVEL)
+ {
+ wcl.lpszClassName = "gdkWindowToplevel";