+ fe->colours = NULL;
+ fe->brushes = NULL;
+ fe->pens = NULL;
+
+ fe->puzz_scale = 1.0;
+
+ #ifdef _WIN32_WCE
+ MultiByteToWideChar (CP_ACP, 0, nogame, -1, wGameName, 256);
+ fe->hwnd = CreateWindowEx(0, wClassName, wGameName,
+ WS_VISIBLE,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL, NULL, inst, NULL);
+
+ {
+ SHMENUBARINFO mbi;
+ RECT rc, rcBar, rcTB, rcClient;
+
+ memset (&mbi, 0, sizeof(SHMENUBARINFO));
+ mbi.cbSize = sizeof(SHMENUBARINFO);
+ mbi.hwndParent = fe->hwnd;
+ mbi.nToolBarId = IDR_MENUBAR1;
+ mbi.hInstRes = inst;
+
+ SHCreateMenuBar(&mbi);
+
+ GetWindowRect(fe->hwnd, &rc);
+ GetWindowRect(mbi.hwndMB, &rcBar);
+ rc.bottom -= rcBar.bottom - rcBar.top;
+ MoveWindow(fe->hwnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE);
+
+ fe->numpad = NULL;
+ }
+#else
+ fe->hwnd = CreateWindowEx(0, CLASSNAME, nogame,
+ WS_OVERLAPPEDWINDOW &~
+ (WS_MAXIMIZEBOX),
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL, NULL, inst, NULL);
+ if (!fe->hwnd) {
+ DWORD lerr = GetLastError();
+ printf("no window: 0x%x\n", lerr);
+ }
+#endif
+
+ fe->gamemenu = NULL;
+ fe->presets = NULL;
+
+ fe->statusbar = NULL;
+ fe->bitmap = NULL;
+
+ SetWindowLong(fe->hwnd, GWL_USERDATA, (LONG)fe);
+
+ return fe;
+}
+
+/*
+ * Populate a frontend structure with a (new) game and midend structure, and
+ * create any window furniture that it needs.
+ *
+ * Previously-allocated memory and window furniture will be freed by this function.
+ */
+static int new_game(frontend *fe, const game *game, char *game_id, char **error)
+{
+ int x, y;
+ RECT r;
+
+ fe->game = game;
+
+ if (fe->me) midend_free(fe->me);
+ fe->me = midend_new(fe, fe->game, &win_drawing, fe);
+
+ if (game_id) {
+ *error = midend_game_id(fe->me, game_id);
+ if (*error) {
+ midend_free(fe->me);
+ sfree(fe);
+ return -1;
+ }
+ }
+
+ midend_new_game(fe->me);
+