// HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps ) public static int BeginPaint(int hwnd, int lps) { WinWindow win = WinWindow.get(hwnd); if (lps == 0) return 0; Caret.HideCaret(hwnd); int rgn = WinRegion.CreateRectRgn(0, 0, win.rectWindow.width(), win.rectWindow.height()); Message.SendMessageA(hwnd, WM_NCPAINT, rgn, 0); GdiObj.DeleteObject(rgn); WinDC dc = win.getDC(); if (win.invalidationRect == null) { new WinRect(0, 0, win.rectClient.width(), win.rectClient.height()).write(lps + 8); } else { dc.clipX = win.invalidationRect.left; dc.clipY = win.invalidationRect.top; dc.clipCx = win.invalidationRect.width(); dc.clipCy = win.invalidationRect.height(); win.invalidationRect.write(lps + 8); } int hdc = dc.handle; writed(lps, hdc); writed(lps + 4, Message.SendMessageA(hwnd, WM_ERASEBKGND, hdc, 0)); return readd(lps); }
// HDC WINAPI GetDC(HWND hwnd) public static int GetDC(int hwnd) { WinWindow win; if (hwnd == 0) { win = WinWindow.get(StaticData.desktopWindow); } else win = WinWindow.get(hwnd); if (win == null) return 0; WinDC dc = win.getDC(); dc.open(); return dc.handle; }
// int GetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase) public static int GetUpdateRgn(int hWnd, int hRgn, int bErase) { WinWindow win = WinWindow.get(hWnd); WinRegion rgn = WinRegion.get(hRgn); if (win == null || rgn == null) return ERROR; if (win.needsPainting()) { if (bErase != 0) { rgn.rects.clear(); rgn.rects.add(new WinRect(0, 0, win.rectWindow.width(), win.rectWindow.height())); Message.SendMessageA(hWnd, WM_NCPAINT, hRgn, 0); int hdc = win.getDC().handle; Message.SendMessageA(hWnd, WM_ERASEBKGND, hdc, 0); ReleaseDC(hWnd, hdc); } rgn.rects.clear(); rgn.rects.add(new WinRect(0, 0, win.rectClient.width(), win.rectClient.height())); return SIMPLEREGION; } return NULLREGION; }