[REGEDIT] Reduce flickering and fix rendering (#7747)
authorKatayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
Thu, 13 Mar 2025 10:33:14 +0000 (19:33 +0900)
committerGitHub <noreply@github.com>
Thu, 13 Mar 2025 10:33:14 +0000 (19:33 +0900)
JIRA issue: CORE-19970
- Fix status bar toggling.
- Improve behaviour of splitter.
- Add (WS_CLIPCHILDREN |
  WS_CLIPSIBLINGS) style to
  ChildWnd.

base/applications/regedit/childwnd.c
base/applications/regedit/framewnd.c

index 1cd0dc7..6ba0758 100644 (file)
@@ -11,7 +11,7 @@
 #include <shlguid.h>
 
 ChildWnd* g_pChildWnd;
-static int last_split;
+static int last_split = -1;
 HBITMAP SizingPattern;
 HBRUSH  SizingBrush;
 WCHAR Suggestions[256];
@@ -99,16 +99,20 @@ extern void ResizeWnd(int cx, int cy)
     const int nButtonWidth = 44;
     const int nButtonHeight = 22;
     int cyEdge = GetSystemMetrics(SM_CYEDGE);
-    const UINT uFlags = SWP_NOZORDER | SWP_NOACTIVATE;
-    SetRect(&rt, 0, 0, cx, cy);
+    const UINT uFlags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS;
+
     cy = 0;
-    if (hStatusBar != NULL)
+    if (IsWindowVisible(hStatusBar))
     {
         GetWindowRect(hStatusBar, &rs);
         cy = rs.bottom - rs.top;
     }
+
     GetWindowRect(g_pChildWnd->hAddressBtnWnd, &rb);
 
+    GetClientRect(g_pChildWnd->hWnd, &rt);
+    RedrawWindow(g_pChildWnd->hWnd, &rt, NULL, RDW_INVALIDATE | RDW_NOCHILDREN);
+
     g_pChildWnd->nSplitPos = ClampSplitBarX(g_pChildWnd->hWnd, g_pChildWnd->nSplitPos);
 
     cx = g_pChildWnd->nSplitPos + SPLIT_WIDTH / 2;
@@ -148,7 +152,7 @@ static void draw_splitbar(HWND hWnd, int x)
 {
     RECT rt;
     HGDIOBJ OldObj;
-    HDC hdc = GetDC(hWnd);
+    HDC hdc = GetDCEx(hWnd, NULL, DCX_CACHE);
 
     if(!SizingPattern)
     {
@@ -159,7 +163,10 @@ static void draw_splitbar(HWND hWnd, int x)
     {
         SizingBrush = CreatePatternBrush(SizingPattern);
     }
-    GetClientRect(hWnd, &rt);
+
+    GetWindowRect(g_pChildWnd->hTreeWnd, &rt);
+    MapWindowPoints(NULL, hWnd, (POINT *)&rt, sizeof(rt) / sizeof(POINT));
+
     rt.left = x - SPLIT_WIDTH/2;
     rt.right = x + SPLIT_WIDTH/2+1;
     OldObj = SelectObject(hdc, SizingBrush);
index e22f383..95f5cf9 100644 (file)
@@ -1446,7 +1446,8 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
         // For now, the Help dialog item is disabled because of lacking of HTML Help support
         EnableMenuItem(GetMenu(hWnd), ID_HELP_HELPTOPICS, MF_BYCOMMAND | MF_GRAYED);
         GetClientRect(hWnd, &rc);
-        CreateWindowExW(0, szChildClass, NULL, WS_CHILD | WS_VISIBLE,
+        CreateWindowExW(0, szChildClass, NULL,
+                        WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
                         rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
                         hWnd, (HMENU)0, hInst, 0);
         break;