SDK implements separators (continued)

zhaozj2021-02-16  50

In the SDK implementation partition, I introduced how to implement dynamic separation. This article will be introduced, how to implement a static separator (i.e., the separated partition is separated).

The sliding strip on the upper side is a "dynamic" separator, that is, the size of the window has also changed while moving the separator. I will introduce a "static" partition, that is, a vertical line appears when dragging the separator, indicating the separation result of the separator. If the dynamic separator is playing games with the rectangle, the static separator is playing with graphics.

First of all please look at my code: LRESULT CALLBACK ProcSplitter (HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) {static int x; switch (Msg) {case WM_LBUTTONDOWN: {HDC hdc; RECT rectTree; SetCapture (hwnd); GetWindowRect (HTREE, & Recttree); HDC = getdc (getParent (hwnd)); SelectObject (HDC, Createpen (PS_SOLID, 2, 0)); SETROP2 (HDC, R2_NOTXORPEN); x = RectTree.right - RectTree.Left; MoveToex (HDC , X, 0, NULL; LINETO (HDC, X, RectTree.bottom - RectTree.top); ReleaseDC (GetParent (HWND), HDC);} Break; Case WM_LButtonup: {HDWP HDWP; HDC HDC; Rect Rect, RectTree , rectStatus; GetClientRect (GetParent (hwnd), & rect); GetWindowRect (hTree, & rectTree); GetClientRect (hStatus, & rectStatus); hdc = GetDC (GetParent (hwnd)); SelectObject (hdc, CreatePen (PS_SOLID, 2, 0)) SETROP2 (HDC, R2_NOTXORPEN); MoveToex (HDC, X, 0, Null); Lineto (HDC, X, RectTree.bottom - RectTree.top); ReleaseDC (GetParent (HWND), HDC); ReleaseCapture (); HDWP = BegindeferWindowPOS (3); DeferWindowPOS (HDWP, Htree, NULL, 0, 0, X, Rect.bottom - RectStatus.Bottom, SWP_Nomove | SWP_NOZORDER); DeferWindowPos (HDWP, HSplitter, Null, X, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER ); DeferWindowPOS (HDWP, HLIST, NULL, X 2, 0, Rect.right - X - 2, Rect.Bottom - RectStatus.bottom, SWP_NOZORDER); EnddeferWindowPos (HDWP);} Break; Case WM_MouseMove: {IF ( wParam & MK_LBUTTON) == MK_LBUTTON && GetCapture () == hwnd) {HDC hdc; RECT rectTree; GetWindowRect (hTree, & rectTree); hdc = GetDC (GetParent (hwnd)); SelectObject (hdc, CreatePen (PS_SOLID, 2, 0 ))); SETROP2 (HDC, R2_NOTXORPEN); MoveToex (HDC, X, 0, NULL);

转载请注明原文地址:https://www.9cbs.com/read-22544.html

New Post(0)