LRESULT CALLBACK WndProcAbout(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { const WCHAR * url; POINT pt; switch (message) { case WM_CREATE: assert(!gHwndAbout); break; case WM_ERASEBKGND: // do nothing, helps to avoid flicker return TRUE; case WM_PAINT: OnPaintAbout(hwnd); break; case WM_SETCURSOR: if (GetCursorPosInHwnd(hwnd, pt)) { StaticLinkInfo linkInfo; if (GetStaticLink(gLinkInfo, pt.x, pt.y, &linkInfo)) { CreateInfotipForLink(linkInfo); SetCursor(gCursorHand); return TRUE; } } ClearInfotip(); return DefWindowProc(hwnd, message, wParam, lParam); case WM_LBUTTONDOWN: gClickedURL = GetStaticLink(gLinkInfo, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_LBUTTONUP: url = GetStaticLink(gLinkInfo, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); if (url && url == gClickedURL) LaunchBrowser(url); break; case WM_CHAR: if (VK_ESCAPE == wParam) DestroyWindow(hwnd); break; case WM_DESTROY: ClearInfotip(); assert(gHwndAbout); gHwndAbout = NULL; break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
static void DrawResizeLine(SplitterWnd *w, bool erasePrev, bool drawCurr) { PointI pos; GetCursorPosInHwnd(GetParent(w->hwnd), pos); bool isVert = w->type != SplitterHoriz; if (erasePrev) { DrawResizeLineVH(w, isVert, w->prevResizeLinePos); } if (drawCurr) { DrawResizeLineVH(w, isVert, pos); } w->prevResizeLinePos = pos; }
LRESULT CALLBACK NotificationWnd::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { NotificationWnd *wnd = (NotificationWnd *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (WM_ERASEBKGND == msg) { // do nothing, helps to avoid flicker return TRUE; } if (WM_TIMER == msg && TIMEOUT_TIMER_ID == wParam) { if (wnd->notificationCb) wnd->notificationCb->RemoveNotification(wnd); else delete wnd; return 0; } if (WM_PAINT == msg && wnd) { NotificationWndOnPaint(hwnd, wnd); return 0; } if (WM_SETCURSOR == msg && wnd->hasCancel) { PointI pt; if (GetCursorPosInHwnd(hwnd, pt) && GetCancelRect(hwnd).Contains(pt)) { SetCursor(IDC_HAND); return TRUE; } } if (WM_LBUTTONUP == msg && wnd->hasCancel) { if (GetCancelRect(hwnd).Contains(PointI(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))) { if (wnd->notificationCb) wnd->notificationCb->RemoveNotification(wnd); else delete wnd; return 0; } } return DefWindowProc(hwnd, msg, wParam, lParam); }
static bool IsMouseOverClose(LabelWithCloseWnd *w) { PointI p; GetCursorPosInHwnd(w->hwnd, p); return w->closeBtnPos.Contains(p); }
LRESULT CALLBACK NotificationWnd::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)\ { NotificationWnd *wnd = (NotificationWnd *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (WM_ERASEBKGND == message) { // do nothing, helps to avoid flicker return TRUE; } if (WM_TIMER == message && TIMEOUT_TIMER_ID == wParam) { if (wnd->notificationCb) wnd->notificationCb->RemoveNotification(wnd); else delete wnd; return 0; } if (WM_PAINT == message && wnd) { PAINTSTRUCT ps; HDC hdcWnd = BeginPaint(hwnd, &ps); ClientRect rect(hwnd); DoubleBuffer buffer(hwnd, rect); HDC hdc = buffer.GetDC(); HFONT oldfnt = SelectFont(hdc, wnd->font); RECT rTmp = rect.ToRECT(); DrawFrameControl(hdc, &rTmp, DFC_BUTTON, DFCS_BUTTONPUSH); if (wnd->highlight) { SetBkMode(hdc, OPAQUE); SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); } else { SetBkMode(hdc, TRANSPARENT); SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); } rect.Inflate(-PADDING, -PADDING); RectI rectMsg = rect; if (wnd->hasProgress) rectMsg.dy -= PROGRESS_HEIGHT + PADDING / 2; if (wnd->hasCancel) rectMsg.dx -= 20; ScopedMem<WCHAR> text(win::GetText(hwnd)); rTmp = rectMsg.ToRECT(); DrawText(hdc, text, -1, &rTmp, DT_SINGLELINE | DT_NOPREFIX); if (wnd->hasCancel) { rTmp = GetCancelRect(hwnd).ToRECT(); DrawFrameControl(hdc, &rTmp, DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_FLAT); } if (wnd->hasProgress) { rect.dx = wnd->progressWidth; rect.y += rectMsg.dy + PADDING / 2; rect.dy = PROGRESS_HEIGHT; PaintRect(hdc, rect); rect.x += 2; rect.dx = (wnd->progressWidth - 3) * wnd->progress / 100; rect.y += 2; rect.dy -= 3; HBRUSH brush = GetStockBrush(BLACK_BRUSH); rTmp = rect.ToRECT(); FillRect(hdc, &rTmp, brush); DeleteObject(brush); } SelectFont(hdc, oldfnt); buffer.Flush(hdcWnd); EndPaint(hwnd, &ps); return 0; } if (WM_SETCURSOR == message && wnd->hasCancel) { POINT pt; if (GetCursorPosInHwnd(hwnd, pt) && GetCancelRect(hwnd).Contains(PointI(pt.x, pt.y))) { SetCursor(LoadCursor(NULL, IDC_HAND)); return TRUE; } } if (WM_LBUTTONUP == message && wnd->hasCancel) { if (GetCancelRect(hwnd).Contains(PointI(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))) { if (wnd->notificationCb) wnd->notificationCb->RemoveNotification(wnd); else delete wnd; return 0; } } return DefWindowProc(hwnd, message, wParam, lParam); }