Changed the CenterWindow function and added comments.

This commit is contained in:
rheiny 2006-08-03 19:41:39 +00:00
parent c08f71181e
commit 16f13d5d22
2 changed files with 13 additions and 16 deletions

View File

@ -59,28 +59,27 @@ static SCROLLINFO si;
/**
BOOL CenterWindow(HWND hwndDlg) { * Centers a window relative to its parent window.
HWND hwndParent; *
RECT rect, rectP; * @param hwndDlg Handle of the window to center.
int width, height; **/
int screenwidth, screenheight; void CenterWindow(HWND hwndDlg) {
int x, y; //TODO: This function should probably moved into the generic Win32 window file
//move the window relative to its parent //move the window relative to its parent
hwndParent = GetParent(hwndDlg); HWND hwndParent = GetParent(hwndDlg);
GetWindowRect(hwndDlg, &rect); GetWindowRect(hwndDlg, &rect);
GetWindowRect(hwndParent, &rectP); GetWindowRect(hwndParent, &rectP);
width = rect.right - rect.left; unsigned int width = rect.right - rect.left;
height = rect.bottom - rect.top; unsigned height = rect.bottom - rect.top;
x = ((rectP.right-rectP.left) - width) / 2 + rectP.left; x = ((rectP.right-rectP.left) - width) / 2 + rectP.left;
y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top; y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top;
screenwidth = GetSystemMetrics(SM_CXSCREEN); unsigned screenwidth = GetSystemMetrics(SM_CXSCREEN);
screenheight = GetSystemMetrics(SM_CYSCREEN); unsigned screenheight = GetSystemMetrics(SM_CYSCREEN);
//make sure that the dialog box never moves outside of the screen //make sure that the dialog box never moves outside of the screen
if(x < 0) x = 0; if(x < 0) x = 0;
@ -89,8 +88,6 @@ BOOL CenterWindow(HWND hwndDlg) {
if(y + height > screenheight) y = screenheight - height; if(y + height > screenheight) y = screenheight - height;
MoveWindow(hwndDlg, x, y, width, height, FALSE); MoveWindow(hwndDlg, x, y, width, height, FALSE);
return TRUE;
} }
int NewBreak(HWND hwndDlg, int num, int enable) { int NewBreak(HWND hwndDlg, int num, int enable) {

View File

@ -11,7 +11,7 @@ extern HWND hDebug;
extern int childwnd,numWPs; //mbg merge 7/18/06 had to make extern extern int childwnd,numWPs; //mbg merge 7/18/06 had to make extern
BOOL CenterWindow(HWND hwndDlg); void CenterWindow(HWND hwndDlg);
void DoPatcher(int address,HWND hParent); void DoPatcher(int address,HWND hParent);
void UpdatePatcher(HWND hwndDlg); void UpdatePatcher(HWND hwndDlg);
int GetEditHex(HWND hwndDlg, int id); int GetEditHex(HWND hwndDlg, int id);