childwnd.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. /*
  2. * Regedit child window
  3. *
  4. * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
  21. #include <windows.h>
  22. #include <commctrl.h>
  23. #include "main.h"
  24. #include "wine/debug.h"
  25. #include "wine/heap.h"
  26. WINE_DEFAULT_DEBUG_CHANNEL(regedit);
  27. ChildWnd* g_pChildWnd;
  28. static int last_split;
  29. static const WCHAR wszLastKey[] = L"LastKey";
  30. static const WCHAR wszKeyName[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit";
  31. /*******************************************************************************
  32. * Local module support methods
  33. */
  34. static LPCWSTR GetRootKeyName(HKEY hRootKey)
  35. {
  36. if(hRootKey == HKEY_CLASSES_ROOT)
  37. return reg_class_namesW[INDEX_HKEY_CLASSES_ROOT];
  38. if(hRootKey == HKEY_CURRENT_USER)
  39. return reg_class_namesW[INDEX_HKEY_CURRENT_USER];
  40. if(hRootKey == HKEY_LOCAL_MACHINE)
  41. return reg_class_namesW[INDEX_HKEY_LOCAL_MACHINE];
  42. if(hRootKey == HKEY_USERS)
  43. return reg_class_namesW[INDEX_HKEY_USERS];
  44. if(hRootKey == HKEY_CURRENT_CONFIG)
  45. return reg_class_namesW[INDEX_HKEY_CURRENT_CONFIG];
  46. if(hRootKey == HKEY_DYN_DATA)
  47. return reg_class_namesW[INDEX_HKEY_DYN_DATA];
  48. else
  49. return L"Unknown HKEY. Please report.";
  50. }
  51. static void draw_splitbar(HWND hWnd, int x)
  52. {
  53. RECT rt;
  54. HDC hdc = GetDC(hWnd);
  55. GetClientRect(hWnd, &rt);
  56. rt.left = x - SPLIT_WIDTH/2;
  57. rt.right = x + SPLIT_WIDTH/2+1;
  58. InvertRect(hdc, &rt);
  59. ReleaseDC(hWnd, hdc);
  60. }
  61. static void ResizeWnd(int cx, int cy)
  62. {
  63. HDWP hdwp = BeginDeferWindowPos(2);
  64. RECT rt = {0, 0, cx, cy};
  65. cx = g_pChildWnd->nSplitPos + SPLIT_WIDTH/2;
  66. DeferWindowPos(hdwp, g_pChildWnd->hTreeWnd, 0, rt.left, rt.top, g_pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
  67. DeferWindowPos(hdwp, g_pChildWnd->hListWnd, 0, rt.left+cx , rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
  68. EndDeferWindowPos(hdwp);
  69. }
  70. static void OnPaint(HWND hWnd)
  71. {
  72. PAINTSTRUCT ps;
  73. RECT rt;
  74. GetClientRect(hWnd, &rt);
  75. BeginPaint(hWnd, &ps);
  76. FillRect(ps.hdc, &rt, GetSysColorBrush(COLOR_BTNFACE));
  77. EndPaint(hWnd, &ps);
  78. }
  79. static LPWSTR CombinePaths(LPCWSTR pPaths[], int nPaths) {
  80. int i, len, pos;
  81. LPWSTR combined;
  82. for (i=0, len=0; i<nPaths; i++) {
  83. if (pPaths[i] && *pPaths[i]) {
  84. len += lstrlenW(pPaths[i])+1;
  85. }
  86. }
  87. combined = heap_xalloc(len * sizeof(WCHAR));
  88. *combined = '\0';
  89. for (i=0, pos=0; i<nPaths; i++) {
  90. if (pPaths[i] && *pPaths[i]) {
  91. int llen = lstrlenW(pPaths[i]);
  92. if (!*combined)
  93. lstrcpyW(combined, pPaths[i]);
  94. else {
  95. combined[pos++] = '\\';
  96. lstrcpyW(combined+pos, pPaths[i]);
  97. }
  98. pos += llen;
  99. }
  100. }
  101. return combined;
  102. }
  103. static LPWSTR GetPathRoot(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
  104. LPCWSTR parts[2] = {0,0};
  105. WCHAR text[260];
  106. HKEY hRootKey = NULL;
  107. if (!hItem)
  108. hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0);
  109. heap_free(GetItemPath(hwndTV, hItem, &hRootKey));
  110. if (!bFull && !hRootKey)
  111. return NULL;
  112. if (hRootKey)
  113. parts[1] = GetRootKeyName(hRootKey);
  114. if (bFull) {
  115. DWORD dwSize = ARRAY_SIZE(text);
  116. GetComputerNameW(text, &dwSize);
  117. parts[0] = text;
  118. }
  119. return CombinePaths(parts, 2);
  120. }
  121. LPWSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
  122. LPWSTR parts[2];
  123. LPWSTR ret;
  124. HKEY hRootKey = NULL;
  125. parts[0] = GetPathRoot(hwndTV, hItem, bFull);
  126. parts[1] = GetItemPath(hwndTV, hItem, &hRootKey);
  127. ret = CombinePaths((LPCWSTR *)parts, 2);
  128. heap_free(parts[0]);
  129. heap_free(parts[1]);
  130. return ret;
  131. }
  132. static void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BOOL bRefreshLV)
  133. {
  134. if (bRefreshLV) {
  135. LPWSTR keyPath;
  136. HKEY hRootKey = NULL;
  137. HTREEITEM rootitem;
  138. rootitem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_ROOT, 0);
  139. if (rootitem == hItem)
  140. {
  141. SendMessageW(hwndLV, LVM_DELETEALLITEMS, 0, 0);
  142. UpdateStatusBar();
  143. return;
  144. }
  145. keyPath = GetItemPath(hwndTV, hItem, &hRootKey);
  146. RefreshListView(hwndLV, hRootKey, keyPath, NULL);
  147. heap_free(keyPath);
  148. }
  149. UpdateStatusBar();
  150. }
  151. /*******************************************************************************
  152. * finish_splitbar [internal]
  153. *
  154. * make the splitbar invisible and resize the windows
  155. * (helper for ChildWndProc)
  156. */
  157. static void finish_splitbar(HWND hWnd, int x)
  158. {
  159. RECT rt;
  160. draw_splitbar(hWnd, last_split);
  161. last_split = -1;
  162. GetClientRect(hWnd, &rt);
  163. g_pChildWnd->nSplitPos = x;
  164. ResizeWnd(rt.right, rt.bottom);
  165. ReleaseCapture();
  166. }
  167. /*******************************************************************************
  168. *
  169. * FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
  170. *
  171. * PURPOSE: Processes WM_COMMAND messages for the main frame window.
  172. *
  173. */
  174. static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  175. {
  176. switch (LOWORD(wParam)) {
  177. /* Parse the menu selections: */
  178. case ID_REGISTRY_EXIT:
  179. DestroyWindow(hWnd);
  180. break;
  181. case ID_VIEW_REFRESH:
  182. WINE_TRACE("Is this ever called or is it just dead code?\n");
  183. /* TODO */
  184. break;
  185. case ID_SWITCH_PANELS:
  186. g_pChildWnd->nFocusPanel = !g_pChildWnd->nFocusPanel;
  187. SetFocus(g_pChildWnd->nFocusPanel? g_pChildWnd->hListWnd: g_pChildWnd->hTreeWnd);
  188. break;
  189. default:
  190. return FALSE;
  191. }
  192. return TRUE;
  193. }
  194. /*******************************************************************************
  195. * get_last_key [internal]
  196. *
  197. * open last key
  198. *
  199. */
  200. static void get_last_key(HWND hwndTV)
  201. {
  202. HKEY hkey;
  203. WCHAR wszVal[KEY_MAX_LEN];
  204. DWORD dwSize = sizeof(wszVal);
  205. if (RegCreateKeyExW(HKEY_CURRENT_USER, wszKeyName, 0, NULL, 0, KEY_READ, NULL, &hkey, NULL) == ERROR_SUCCESS)
  206. {
  207. HTREEITEM selection = NULL;
  208. if (RegQueryValueExW(hkey, wszLastKey, NULL, NULL, (LPBYTE)wszVal, &dwSize) == ERROR_SUCCESS)
  209. {
  210. if (lstrcmpW(wszVal, g_pChildWnd->szPath))
  211. selection = FindPathInTree(hwndTV, wszVal);
  212. }
  213. if(!selection)
  214. {
  215. selection = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
  216. SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)selection );
  217. }
  218. else
  219. SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)selection);
  220. RegCloseKey(hkey);
  221. }
  222. }
  223. /*******************************************************************************
  224. * set_last_key [internal]
  225. *
  226. * save last key
  227. *
  228. */
  229. static void set_last_key(HWND hwndTV)
  230. {
  231. HKEY hkey;
  232. if (RegCreateKeyExW(HKEY_CURRENT_USER, wszKeyName, 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL) == ERROR_SUCCESS)
  233. {
  234. HTREEITEM selection = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_CARET, 0);
  235. HTREEITEM root = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
  236. WCHAR *value;
  237. if (selection == root)
  238. value = g_pChildWnd->szPath;
  239. else
  240. value = GetItemFullPath(g_pChildWnd->hTreeWnd, selection, FALSE);
  241. RegSetValueExW(hkey, wszLastKey, 0, REG_SZ, (LPBYTE)value, (lstrlenW(value) + 1) * sizeof(WCHAR));
  242. if (selection != root)
  243. heap_free(value);
  244. RegCloseKey(hkey);
  245. }
  246. }
  247. static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  248. {
  249. switch (((NMHDR *)lParam)->code)
  250. {
  251. case NM_SETFOCUS:
  252. g_pChildWnd->nFocusPanel = 0;
  253. break;
  254. case TVN_BEGINLABELEDITW:
  255. {
  256. HKEY hRootKey;
  257. WCHAR *path;
  258. if (!GetWindowLongPtrW(g_pChildWnd->hTreeWnd, GWLP_USERDATA))
  259. return 1;
  260. path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
  261. if (!path || !*path)
  262. return 1;
  263. return 0;
  264. }
  265. case TVN_ENDLABELEDITW:
  266. {
  267. HKEY hRootKey;
  268. NMTVDISPINFOW *dispInfo = (NMTVDISPINFOW *)lParam;
  269. WCHAR *path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
  270. BOOL res = RenameKey(hWnd, hRootKey, path, dispInfo->item.pszText);
  271. heap_free(path);
  272. if (res)
  273. {
  274. TVITEMW item;
  275. item.mask = TVIF_HANDLE | TVIF_TEXT;
  276. item.hItem = dispInfo->item.hItem;
  277. item.pszText = dispInfo->item.pszText;
  278. SendMessageW(g_pChildWnd->hTreeWnd, TVM_SETITEMW, 0, (LPARAM)&item);
  279. path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
  280. update_listview_path(path);
  281. heap_free(path);
  282. UpdateStatusBar();
  283. }
  284. SetWindowLongPtrW(g_pChildWnd->hTreeWnd, GWLP_USERDATA, 0);
  285. return res;
  286. }
  287. case TVN_ITEMEXPANDINGW:
  288. return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEWW *)lParam);
  289. case TVN_SELCHANGEDW:
  290. OnTreeSelectionChanged(g_pChildWnd->hTreeWnd, g_pChildWnd->hListWnd,
  291. ((NMTREEVIEWW *)lParam)->itemNew.hItem, TRUE);
  292. break;
  293. }
  294. return 0;
  295. }
  296. static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  297. {
  298. switch (((NMHDR *)lParam)->code)
  299. {
  300. case NM_DBLCLK:
  301. {
  302. NMITEMACTIVATE *nmitem = (NMITEMACTIVATE *)lParam;
  303. if (nmitem->iItem != -1)
  304. {
  305. LVITEMW item;
  306. item.state = 0;
  307. item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
  308. SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMSTATE, (UINT)-1, (LPARAM)&item);
  309. item.state = LVIS_FOCUSED | LVIS_SELECTED;
  310. item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
  311. SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMSTATE, nmitem->iItem, (LPARAM)&item);
  312. SendMessageW(hFrameWnd, WM_COMMAND, ID_EDIT_MODIFY, 0);
  313. }
  314. break;
  315. }
  316. case NM_RETURN:
  317. {
  318. int cnt = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1,
  319. MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
  320. if (cnt != -1)
  321. SendMessageW(hFrameWnd, WM_COMMAND, ID_EDIT_MODIFY, 0);
  322. break;
  323. }
  324. case NM_SETFOCUS:
  325. g_pChildWnd->nFocusPanel = 1;
  326. break;
  327. case LVN_BEGINLABELEDITW:
  328. if (!((NMLVDISPINFOW *)lParam)->item.iItem)
  329. return 1;
  330. return 0;
  331. case LVN_COLUMNCLICK:
  332. if (g_columnToSort == ((NMLISTVIEW *)lParam)->iSubItem)
  333. g_invertSort = !g_invertSort;
  334. else
  335. {
  336. g_columnToSort = ((NMLISTVIEW *)lParam)->iSubItem;
  337. g_invertSort = FALSE;
  338. }
  339. SendMessageW(g_pChildWnd->hListWnd, LVM_SORTITEMS,
  340. (WPARAM)g_pChildWnd->hListWnd, (LPARAM)CompareFunc);
  341. break;
  342. case LVN_DELETEITEM:
  343. {
  344. NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
  345. LINE_INFO *info = (LINE_INFO *)nmlv->lParam;
  346. heap_free(info->name);
  347. heap_free(info->val);
  348. heap_free(info);
  349. break;
  350. }
  351. case LVN_ENDLABELEDITW:
  352. {
  353. NMLVDISPINFOW *dispInfo = (NMLVDISPINFOW *)lParam;
  354. WCHAR *oldName = GetItemText(g_pChildWnd->hListWnd, dispInfo->item.iItem);
  355. LONG ret;
  356. if (!oldName) return -1; /* cannot rename a default value */
  357. ret = RenameValue(g_pChildWnd->hListWnd, g_currentRootKey, g_currentPath,
  358. oldName, dispInfo->item.pszText);
  359. if (ret)
  360. {
  361. dispInfo->item.iSubItem = 0;
  362. SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMTEXTW,
  363. dispInfo->item.iItem, (LPARAM)&dispInfo->item);
  364. }
  365. heap_free(oldName);
  366. return 0;
  367. }
  368. case LVN_GETDISPINFOW:
  369. OnGetDispInfo((NMLVDISPINFOW *)lParam);
  370. break;
  371. }
  372. return 0;
  373. }
  374. #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
  375. #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
  376. /*******************************************************************************
  377. *
  378. * FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
  379. *
  380. * PURPOSE: Processes messages for the child windows.
  381. *
  382. * WM_COMMAND - process the application menu
  383. * WM_PAINT - Paint the main window
  384. * WM_DESTROY - post a quit message and return
  385. *
  386. */
  387. LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  388. {
  389. switch (message) {
  390. case WM_CREATE:
  391. g_pChildWnd = heap_xalloc(sizeof(ChildWnd));
  392. if (!g_pChildWnd) return 0;
  393. LoadStringW(hInst, IDS_REGISTRY_ROOT_NAME, g_pChildWnd->szPath, MAX_PATH);
  394. g_pChildWnd->nSplitPos = 250;
  395. g_pChildWnd->hWnd = hWnd;
  396. g_pChildWnd->hTreeWnd = CreateTreeView(hWnd, g_pChildWnd->szPath, TREE_WINDOW);
  397. g_pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, g_pChildWnd->szPath*/);
  398. g_pChildWnd->nFocusPanel = 1;
  399. SetFocus(g_pChildWnd->hTreeWnd);
  400. get_last_key(g_pChildWnd->hTreeWnd);
  401. break;
  402. case WM_COMMAND:
  403. if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
  404. goto def;
  405. }
  406. break;
  407. case WM_PAINT:
  408. OnPaint(hWnd);
  409. return 0;
  410. case WM_SETCURSOR:
  411. if (LOWORD(lParam) == HTCLIENT) {
  412. POINT pt;
  413. GetCursorPos(&pt);
  414. ScreenToClient(hWnd, &pt);
  415. if (pt.x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
  416. SetCursor(LoadCursorW(0, (LPCWSTR)IDC_SIZEWE));
  417. return TRUE;
  418. }
  419. }
  420. goto def;
  421. case WM_DESTROY:
  422. set_last_key(g_pChildWnd->hTreeWnd);
  423. heap_free(g_pChildWnd);
  424. g_pChildWnd = NULL;
  425. PostQuitMessage(0);
  426. break;
  427. case WM_LBUTTONDOWN: {
  428. RECT rt;
  429. int x = (short)LOWORD(lParam);
  430. GetClientRect(hWnd, &rt);
  431. if (x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
  432. last_split = g_pChildWnd->nSplitPos;
  433. draw_splitbar(hWnd, last_split);
  434. SetCapture(hWnd);
  435. }
  436. break;
  437. }
  438. /* WM_RBUTTONDOWN sets the splitbar the same way as WM_LBUTTONUP */
  439. case WM_LBUTTONUP:
  440. case WM_RBUTTONDOWN:
  441. if (GetCapture() == hWnd) {
  442. finish_splitbar(hWnd, LOWORD(lParam));
  443. }
  444. break;
  445. case WM_CAPTURECHANGED:
  446. if (GetCapture()==hWnd && last_split>=0)
  447. draw_splitbar(hWnd, last_split);
  448. break;
  449. case WM_CONTEXTMENU:
  450. {
  451. POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
  452. short int menu_id = -1;
  453. if ((HWND)wParam == g_pChildWnd->hTreeWnd)
  454. {
  455. TVHITTESTINFO ht;
  456. ht.pt = pt;
  457. ScreenToClient(g_pChildWnd->hTreeWnd, &ht.pt);
  458. if (SendMessageW(g_pChildWnd->hTreeWnd, TVM_HITTEST, 0, (LPARAM)&ht))
  459. {
  460. HTREEITEM root;
  461. SendMessageW(g_pChildWnd->hTreeWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)ht.hItem);
  462. root = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
  463. menu_id = (ht.hItem == root) ? PM_COMPUTER : PM_TREEVIEW;
  464. }
  465. }
  466. else
  467. {
  468. int sel = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1,
  469. MAKELPARAM(LVNI_SELECTED, 0));
  470. menu_id = (sel == -1) ? PM_NEW_VALUE : PM_MODIFY_VALUE;
  471. }
  472. TrackPopupMenu(GetSubMenu(hPopupMenus, menu_id), TPM_RIGHTBUTTON,
  473. pt.x, pt.y, 0, hFrameWnd, NULL);
  474. break;
  475. }
  476. case WM_KEYDOWN:
  477. if (wParam == VK_ESCAPE)
  478. if (GetCapture() == hWnd) {
  479. RECT rt;
  480. draw_splitbar(hWnd, last_split);
  481. GetClientRect(hWnd, &rt);
  482. ResizeWnd(rt.right, rt.bottom);
  483. last_split = -1;
  484. ReleaseCapture();
  485. SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW));
  486. }
  487. break;
  488. case WM_MOUSEMOVE:
  489. if (GetCapture() == hWnd) {
  490. RECT rt;
  491. int x = LOWORD(lParam);
  492. HDC hdc = GetDC(hWnd);
  493. GetClientRect(hWnd, &rt);
  494. rt.left = last_split-SPLIT_WIDTH/2;
  495. rt.right = last_split+SPLIT_WIDTH/2+1;
  496. InvertRect(hdc, &rt);
  497. last_split = x;
  498. rt.left = x-SPLIT_WIDTH/2;
  499. rt.right = x+SPLIT_WIDTH/2+1;
  500. InvertRect(hdc, &rt);
  501. ReleaseDC(hWnd, hdc);
  502. }
  503. break;
  504. case WM_SETFOCUS:
  505. if (g_pChildWnd != NULL) {
  506. SetFocus(g_pChildWnd->nFocusPanel? g_pChildWnd->hListWnd: g_pChildWnd->hTreeWnd);
  507. }
  508. break;
  509. case WM_TIMER:
  510. break;
  511. case WM_NOTIFY:
  512. if (wParam == TREE_WINDOW && g_pChildWnd)
  513. return treeview_notify(hWnd, message, wParam, lParam);
  514. else if (wParam == LIST_WINDOW && g_pChildWnd)
  515. return listview_notify(hWnd, message, wParam, lParam);
  516. break;
  517. case WM_SIZE:
  518. if (wParam != SIZE_MINIMIZED && g_pChildWnd != NULL) {
  519. ResizeWnd(LOWORD(lParam), HIWORD(lParam));
  520. }
  521. /* fall through */
  522. default: def:
  523. return DefWindowProcW(hWnd, message, wParam, lParam);
  524. }
  525. return 0;
  526. }