/* display or remove 'wait' message */ void info_wait(int id) { HWND hwnd; POINT pt; if (id) load_string(id, szWait, sizeof(szWait)); else szWait[0] = '\0'; InvalidateRect(hwndimg, (LPRECT)&info_rect, FALSE); UpdateWindow(hwndimg); if (szWait[0] != '\0') { GetCursorPos(&pt); hwnd = WindowFromPoint(pt); if ((hwnd == hwndimg) || IsChild(hwndimg,hwnd)) SetCursor(hcWait); } else { /* set cursor to that of active window */ hwnd = GetActiveWindow(); if (hwnd == hwnd_fullscreen) { SetCursor(NULL); return; } if ( (image.open) && ((hwnd == hwndimg) || (hwnd == hwndimgchild)) ) { if (in_child_client_area()) { SetCursor(GetClassCursor(hwndimgchild)); return; } } SetCursor(GetClassCursor(hwnd)); } }
HWND WINAPI SetParent(HWND hWndChild, HWND hWndNewParent) { HWND32 hWndChild32, hWnd32Parent, hWndFrame32; HWND hWndOldParent,hWndFrame; WINCREATESTRUCT wcs; RECT rcOldFrame; RECT rcOldChild; RECT rcFrame; RECT rcChild; RECT rcParent; DWORD dwOldStyle; APISTR((LF_API, "SetParent(hWndChild:%.04x,hWndNewParent:%.04x)\n", hWndChild, hWndNewParent)); if (!(hWndChild32 = GETHWND32(hWndChild))) { return(0); } if ((hWndOldParent = hWndChild32->hWndParent) == hWndNewParent) { RELEASEWININFO(hWndChild32); return hWndOldParent; } if (hWndNewParent) { if (!(hWnd32Parent = GETHWND32(hWndNewParent))) { RELEASEWININFO(hWndChild32); return hWndOldParent; } } GetWindowRect(hWndChild,&rcOldChild); RemoveFromList(hWndChild32); dwOldStyle = hWndChild32->dwStyle; hWndFrame = GetWindowFrame(hWndChild); GetWindowRect(hWndFrame,&rcOldFrame); hWndFrame32 = GETHWND32(hWndFrame); hWndChild32->hWndParent = hWndNewParent; hWndFrame32->hWndParent = hWndNewParent; if (hWndNewParent) { hWndChild32->dwStyle &= ~WS_POPUP; hWndChild32->dwStyle |= WS_CHILD; hWndFrame32->dwStyle &= ~WS_POPUP; hWndFrame32->dwStyle |= WS_CHILD; } else { hWndChild32->dwStyle &= ~WS_CHILD; hWndChild32->dwStyle |= WS_POPUP; hWndFrame32->dwStyle &= ~WS_CHILD; hWndFrame32->dwStyle |= WS_POPUP; } TWIN_InsertAsFirstSibling(hWndChild32); if ((dwOldStyle & WS_CHILD) && (hWndNewParent == 0)) { POINT pt; HICON hIcon; HCURSOR hCursor; memset((LPSTR)&wcs,0,sizeof(WINCREATESTRUCT)); wcs.lpszName = hWndChild32->lpWindowName; wcs.dwStyle = hWndChild32->dwStyle; wcs.dwExStyle = hWndFrame32->dwExStyle; wcs.nBorder = hWndChild32->wXBorder; if ((hIcon = GetClassIcon(hWndChild))) FillIconData(&wcs,hIcon); if ((hCursor = GetClassCursor(hWndChild))) FillCursorData(&wcs,hCursor); wcs.hWndFrame = Get32WindowFrame(hWndChild32); wcs.hWndClient = hWndChild; pt.x = hWndFrame32->rWnd.left; pt.y = hWndFrame32->rWnd.top; ClientToScreen(hWndOldParent,&pt); SetRect(&wcs.rcFrame,pt.x,pt.y, pt.x + hWndFrame32->wWidth, pt.y + hWndFrame32->wHeight); hWndFrame32->lpDrvData = (LPVOID)DRVCALL_WINDOWS(PWSH_CREATEWINDOW, 0,0,&wcs); } else if (!(dwOldStyle & WS_CHILD) && hWndNewParent) { DRVCALL_WINDOWS(PWSH_DESTROYWINDOW,0L,0L, WIN_GETDRVDATA(Get32WindowFrame(hWndChild32))); } TWIN_ReparentDC(hWndChild); RELEASEWININFO(hWndChild32); RELEASEWININFO(hWndFrame32); RELEASEWININFO(hWnd32Parent); if (hWndOldParent && IsWindowVisible(hWndOldParent)) { ScreenToClientRect(hWndOldParent, &rcOldFrame, &rcParent); InvalidateRect(hWndOldParent, &rcParent, TRUE); ScreenToClientRect(hWndOldParent, &rcOldChild, &rcParent); InvalidateRect(hWndOldParent, &rcParent, TRUE); } if (IsWindowVisible(hWndChild)) { GetClientRect(hWndFrame,&rcFrame); InvalidateRect(hWndFrame, &rcFrame, TRUE); GetClientRect(hWndChild,&rcChild); InvalidateRect(hWndChild, &rcChild, TRUE); } return hWndOldParent; }