}
}
+
+static void
+main_wnd_save_sizepos() {
+ RECT r;
+ khm_handle csp_cw;
+ khm_handle csp_mw;
+ const wchar_t * wconfig;
+
+ KillTimer(khm_hwnd_main, MW_RESIZE_TIMER);
+
+ if (khm_main_wnd_mode == KHM_MAIN_WND_MINI)
+ wconfig = L"Windows\\MainMini";
+ else
+ wconfig = L"Windows\\Main";
+
+ GetWindowRect(khm_hwnd_main, &r);
+
+ if (KHM_SUCCEEDED(khc_open_space(NULL,
+ L"CredWindow",
+ KHM_PERM_WRITE,
+ &csp_cw))) {
+ if (KHM_SUCCEEDED(khc_open_space(csp_cw,
+ wconfig,
+ KHM_PERM_WRITE,
+ &csp_mw))) {
+ khm_int32 t;
+
+ khc_write_int32(csp_mw, L"XPos", r.left);
+ khc_write_int32(csp_mw, L"YPos", r.top);
+ khc_write_int32(csp_mw, L"Width", r.right - r.left);
+ khc_write_int32(csp_mw, L"Height", r.bottom - r.top);
+
+ if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"Dock", &t)) &&
+ t != KHM_DOCK_NONE) {
+ khc_write_int32(csp_mw, L"Dock", KHM_DOCK_AUTO);
+ }
+
+ khc_close_space(csp_mw);
+ }
+
+ khc_close_space(csp_cw);
+ }
+}
+
LRESULT CALLBACK
khm_main_wnd_proc(HWND hwnd,
UINT uMsg,
case WM_TIMER:
if (wParam == MW_RESIZE_TIMER) {
- RECT r;
- khm_handle csp_cw;
- khm_handle csp_mw;
- const wchar_t * wconfig;
-
- if (khm_main_wnd_mode == KHM_MAIN_WND_MINI)
- wconfig = L"Windows\\MainMini";
- else
- wconfig = L"Windows\\Main";
-
- KillTimer(hwnd, wParam);
-
- GetWindowRect(hwnd, &r);
-
- if (KHM_SUCCEEDED(khc_open_space(NULL,
- L"CredWindow",
- KHM_PERM_WRITE,
- &csp_cw))) {
- if (KHM_SUCCEEDED(khc_open_space(csp_cw,
- wconfig,
- KHM_PERM_WRITE,
- &csp_mw))) {
- khm_int32 t;
-
- khc_write_int32(csp_mw, L"XPos", r.left);
- khc_write_int32(csp_mw, L"YPos", r.top);
- khc_write_int32(csp_mw, L"Width",
- r.right - r.left);
- khc_write_int32(csp_mw, L"Height",
- r.bottom - r.top);
-
- if (KHM_SUCCEEDED(khc_read_int32(csp_mw, L"Dock", &t)) &&
- t != KHM_DOCK_NONE) {
- khc_write_int32(csp_mw, L"Dock", KHM_DOCK_AUTO);
- }
-
- khc_close_space(csp_mw);
- }
- khc_close_space(csp_cw);
- }
+ main_wnd_save_sizepos();
return 0;
khui_refresh_actions();
+ /*
+ * set the window position before the global khm_main_wnd_mode
+ * is updated. otherwise, the windows position for the wrong
+ * mode will be set. Do not set the window position if the
+ * main application window has not yet been created.
+ */
+ if (khm_hwnd_main)
+ main_wnd_save_sizepos();
+
khm_main_wnd_mode = mode;
if (khm_hwnd_main) {
khm_get_main_window_rect(&r);