Correct the calculation for the Win32 window size. Account for the frame and caption size to avoid clipping the status lines.

This commit is contained in:
Peter 2013-02-20 22:24:24 +00:00
parent fb0c43ccf4
commit 571afca835
2 changed files with 19 additions and 41 deletions

View File

@ -79,6 +79,17 @@ x_show_alert(int is_fatal, const char *str)
return 0;
}
void get_default_window_size(LPRECT rect)
{
rect->left = 0;
rect->top = 0;
rect->bottom = X_A2_WINDOW_HEIGHT;
if (g_win_status_debug)
rect->bottom += (MAX_STATUS_LINES * 16) + 32;
rect->right = X_A2_WINDOW_WIDTH;
AdjustWindowRect(rect, WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE);
}
int WINAPI WinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
@ -95,8 +106,6 @@ main(int argc, char **argv)
WNDCLASS wndclass;
RECT rect;
int height;
wndclass.style = 0;
wndclass.lpfnWndProc = (WNDPROC)win_event_handler;
@ -115,17 +124,16 @@ main(int argc, char **argv)
exit(1);
}
height = X_A2_WINDOW_HEIGHT + (MAX_STATUS_LINES * 16) + 32;
// g_main_height = height;
// Create the window.
get_default_window_size(&rect);
HWND hwnd = CreateWindowEx(WS_EX_ACCEPTFILES, "gsport", "GSport - Apple //gs Emulator",
WS_TILED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT,
X_A2_WINDOW_WIDTH, height,
rect.right, rect.bottom,
NULL, NULL, GetModuleHandle(NULL), NULL);
printf("g_hwnd_main = %p, height = %d\n", hwnd, height);
printf("g_hwnd_main = %p, height = %d\n", hwnd, rect.bottom);
GetWindowRect(hwnd, &rect);
printf("...rect is: %ld, %ld, %ld, %ld\n", rect.left, rect.top,
rect.right, rect.bottom);

View File

@ -829,39 +829,6 @@ x_hide_pointer(int do_hide)
}
}
void
init_window(HWND hwnd,BOOL initFlag) {
RECT rect;
RECT wrect;
int adjx,adjy;
GetClientRect(hwnd,&rect);
GetWindowRect(hwnd,&wrect);
adjx=(wrect.right-wrect.left)-(rect.right-rect.left);
adjy=(wrect.bottom-wrect.top)-(rect.bottom-rect.top);
int win_height= X_A2_WINDOW_HEIGHT;
if (g_win_status_debug) {
win_height+=(MAX_STATUS_LINES * 16) + 32;
}
if (initFlag) {
SetWindowPos(hwnd,NULL,
g_main_window_saved_rect.left,
g_main_window_saved_rect.top,
X_A2_WINDOW_WIDTH+adjx,
win_height+adjy,
SWP_NOACTIVATE | SWP_NOZORDER);
} else {
SetWindowPos(hwnd,HWND_NOTOPMOST,
g_main_window_saved_rect.left,
g_main_window_saved_rect.top,
X_A2_WINDOW_WIDTH+adjx,
win_height+adjy,
SWP_SHOWWINDOW);
}
}
void
x_full_screen(int do_full)
{
@ -910,7 +877,10 @@ x_full_screen(int do_full)
style=GetWindowLong(g_hwnd_main,GWL_STYLE);
style |= WS_CAPTION;
SetWindowLong(g_hwnd_main,GWL_STYLE,style);
init_window(g_hwnd_main,FALSE);
SetWindowPos(g_hwnd_main, HWND_TOPMOST,
g_main_window_saved_rect.top, g_main_window_saved_rect.left,
g_main_window_saved_rect.right - g_main_window_saved_rect.left, g_main_window_saved_rect.bottom - g_main_window_saved_rect.top,
SWP_SHOWWINDOW);
g_win_fullscreen_state=!g_win_fullscreen_state;
}
}