winhelp: Removed a couple of internal windows' handle and replaced them with control IDs.

This commit is contained in:
Eric Pouech 2008-04-18 21:34:29 +02:00 committed by Alexandre Julliard
parent 8169f0ff9d
commit 7eba95de27
2 changed files with 23 additions and 23 deletions

View File

@ -457,19 +457,21 @@ void WINHELP_LayoutMainWindow(WINHELP_WINDOW* win)
{ {
RECT rect, button_box_rect; RECT rect, button_box_rect;
INT text_top = 0; INT text_top = 0;
HWND hButtonBoxWnd = GetDlgItem(win->hMainWnd, CTL_ID_BUTTON);
HWND hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
GetClientRect(win->hMainWnd, &rect); GetClientRect(win->hMainWnd, &rect);
/* Update button box and text Window */ /* Update button box and text Window */
SetWindowPos(win->hButtonBoxWnd, HWND_TOP, SetWindowPos(hButtonBoxWnd, HWND_TOP,
rect.left, rect.top, rect.left, rect.top,
rect.right - rect.left, rect.right - rect.left,
rect.bottom - rect.top, 0); rect.bottom - rect.top, 0);
if (GetWindowRect(win->hButtonBoxWnd, &button_box_rect)) if (GetWindowRect(hButtonBoxWnd, &button_box_rect))
text_top = rect.top + button_box_rect.bottom - button_box_rect.top; text_top = rect.top + button_box_rect.bottom - button_box_rect.top;
SetWindowPos(win->hTextWnd, HWND_TOP, SetWindowPos(hTextWnd, HWND_TOP,
rect.left, text_top, rect.left, text_top,
rect.right - rect.left, rect.right - rect.left,
rect.bottom - text_top, 0); rect.bottom - text_top, 0);
@ -484,17 +486,16 @@ void WINHELP_LayoutMainWindow(WINHELP_WINDOW* win)
static BOOL WINHELP_ReuseWindow(WINHELP_WINDOW* win, WINHELP_WINDOW* oldwin, static BOOL WINHELP_ReuseWindow(WINHELP_WINDOW* win, WINHELP_WINDOW* oldwin,
HLPFILE_PAGE* page, int nCmdShow) HLPFILE_PAGE* page, int nCmdShow)
{ {
HWND hTextWnd = GetDlgItem(oldwin->hMainWnd, CTL_ID_TEXT);
unsigned int i; unsigned int i;
win->hMainWnd = oldwin->hMainWnd; win->hMainWnd = oldwin->hMainWnd;
win->hButtonBoxWnd = oldwin->hButtonBoxWnd;
win->hTextWnd = oldwin->hTextWnd;
win->hHistoryWnd = oldwin->hHistoryWnd; win->hHistoryWnd = oldwin->hHistoryWnd;
oldwin->hMainWnd = oldwin->hButtonBoxWnd = oldwin->hTextWnd = oldwin->hHistoryWnd = 0; oldwin->hMainWnd = oldwin->hHistoryWnd = 0;
win->hBrush = CreateSolidBrush(win->info->sr_color); win->hBrush = CreateSolidBrush(win->info->sr_color);
SetWindowLongPtr(win->hMainWnd, 0, (ULONG_PTR)win); SetWindowLongPtr(win->hMainWnd, 0, (ULONG_PTR)win);
SetWindowLongPtr(win->hTextWnd, 0, (ULONG_PTR)win); SetWindowLongPtr(hTextWnd, 0, (ULONG_PTR)win);
SetWindowLongPtr(win->hHistoryWnd, 0, (ULONG_PTR)win); SetWindowLongPtr(win->hHistoryWnd, 0, (ULONG_PTR)win);
WINHELP_InitFonts(win->hMainWnd); WINHELP_InitFonts(win->hMainWnd);
@ -502,11 +503,11 @@ static BOOL WINHELP_ReuseWindow(WINHELP_WINDOW* win, WINHELP_WINDOW* oldwin,
if (page) if (page)
SetWindowText(win->hMainWnd, page->file->lpszTitle); SetWindowText(win->hMainWnd, page->file->lpszTitle);
WINHELP_SetupText(win->hTextWnd); WINHELP_SetupText(hTextWnd);
InvalidateRect(win->hTextWnd, NULL, TRUE); InvalidateRect(hTextWnd, NULL, TRUE);
WINHELP_LayoutMainWindow(win); WINHELP_LayoutMainWindow(win);
ShowWindow(win->hMainWnd, nCmdShow); ShowWindow(win->hMainWnd, nCmdShow);
UpdateWindow(win->hTextWnd); UpdateWindow(hTextWnd);
if (!(win->info->win_style & WS_POPUP)) if (!(win->info->win_style & WS_POPUP))
{ {
@ -661,7 +662,7 @@ BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE* page, HLPFILE_WINDOWINFO* wi,
Globals.hInstance, win); Globals.hInstance, win);
/* Create button box and text Window */ /* Create button box and text Window */
if (!bPopup) if (!bPopup)
win->hButtonBoxWnd = CreateWindow(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE, CreateWindow(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, hWnd, (HMENU)CTL_ID_BUTTON, Globals.hInstance, NULL); 0, 0, 0, 0, hWnd, (HMENU)CTL_ID_BUTTON, Globals.hInstance, NULL);
CreateWindow(TEXT_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE, CreateWindow(TEXT_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE,
@ -730,6 +731,7 @@ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
WINHELP_BUTTON *button; WINHELP_BUTTON *button;
RECT rect; RECT rect;
INT curPos, min, max, dy, keyDelta; INT curPos, min, max, dy, keyDelta;
HWND hTextWnd;
WINHELP_CheckPopup(msg); WINHELP_CheckPopup(msg);
@ -799,12 +801,13 @@ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
case VK_PRIOR: case VK_PRIOR:
case VK_NEXT: case VK_NEXT:
win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0); win = (WINHELP_WINDOW*) GetWindowLongPtr(hWnd, 0);
curPos = GetScrollPos(win->hTextWnd, SB_VERT); hTextWnd = GetDlgItem(win->hMainWnd, CTL_ID_TEXT);
GetScrollRange(win->hTextWnd, SB_VERT, &min, &max); curPos = GetScrollPos(hTextWnd, SB_VERT);
GetScrollRange(hTextWnd, SB_VERT, &min, &max);
if (keyDelta == 0) if (keyDelta == 0)
{ {
GetClientRect(win->hTextWnd, &rect); GetClientRect(hTextWnd, &rect);
keyDelta = (rect.bottom - rect.top) / 2; keyDelta = (rect.bottom - rect.top) / 2;
if (wParam == VK_PRIOR) if (wParam == VK_PRIOR)
keyDelta = -keyDelta; keyDelta = -keyDelta;
@ -816,10 +819,10 @@ static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
else if (curPos < min) else if (curPos < min)
curPos = min; curPos = min;
dy = GetScrollPos(win->hTextWnd, SB_VERT) - curPos; dy = GetScrollPos(hTextWnd, SB_VERT) - curPos;
SetScrollPos(win->hTextWnd, SB_VERT, curPos, TRUE); SetScrollPos(hTextWnd, SB_VERT, curPos, TRUE);
ScrollWindow(win->hTextWnd, 0, dy, NULL, NULL); ScrollWindow(hTextWnd, 0, dy, NULL, NULL);
UpdateWindow(win->hTextWnd); UpdateWindow(hTextWnd);
return 0; return 0;
case VK_ESCAPE: case VK_ESCAPE:
@ -973,7 +976,6 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
case WM_NCCREATE: case WM_NCCREATE:
win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams; win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams;
SetWindowLongPtr(hWnd, 0, (ULONG_PTR) win); SetWindowLongPtr(hWnd, 0, (ULONG_PTR) win);
win->hTextWnd = hWnd;
win->hBrush = CreateSolidBrush(win->info->sr_color); win->hBrush = CreateSolidBrush(win->info->sr_color);
WINHELP_InitFonts(hWnd); WINHELP_InitFonts(hWnd);
break; break;
@ -1926,7 +1928,7 @@ WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW* win, WPARAM wParam, LPARAM
POINT mouse; POINT mouse;
WINHELP_LINE *line; WINHELP_LINE *line;
WINHELP_LINE_PART *part; WINHELP_LINE_PART *part;
int scroll_pos = GetScrollPos(win->hTextWnd, SB_VERT); int scroll_pos = GetScrollPos(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), SB_VERT);
mouse.x = LOWORD(lParam); mouse.x = LOWORD(lParam);
mouse.y = HIWORD(lParam); mouse.y = HIWORD(lParam);

View File

@ -100,8 +100,6 @@ typedef struct tagWinHelp
WINHELP_LINE* first_line; WINHELP_LINE* first_line;
HWND hMainWnd; HWND hMainWnd;
HWND hButtonBoxWnd;
HWND hTextWnd;
HWND hShadowWnd; HWND hShadowWnd;
HWND hHistoryWnd; HWND hHistoryWnd;