ReactOS 0.4.15-dev-7788-g1ad9096
childwnd.c File Reference
#include "regedit.h"
Include dependency graph for childwnd.c:

Go to the source code of this file.

Macros

#define MIN(a, b)   ((a < b) ? (a) : (b))
 

Functions

LPCWSTR get_root_key_name (HKEY hRootKey)
 
void ResizeWnd (int cx, int cy)
 
static void draw_splitbar (HWND hWnd, int x)
 
static void finish_splitbar (HWND hWnd, int x)
 
static void SuggestKeys (HKEY hRootKey, LPCWSTR pszKeyPath, LPWSTR pszSuggestions, size_t iSuggestionsLength)
 
LRESULT CALLBACK AddressBarProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID UpdateAddress (HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath, BOOL bSelectNone)
 
LRESULT CALLBACK ChildWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

ChildWndg_pChildWnd
 
static int last_split
 
HBITMAP SizingPattern = 0
 
HBRUSH SizingBrush = 0
 
WCHAR Suggestions [256]
 

Macro Definition Documentation

◆ MIN

#define MIN (   a,
  b 
)    ((a < b) ? (a) : (b))

Definition at line 137 of file childwnd.c.

Function Documentation

◆ AddressBarProc()

LRESULT CALLBACK AddressBarProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 210 of file childwnd.c.

211{
212 WNDPROC oldwndproc;
213 static WCHAR s_szNode[256];
215
216 switch (uMsg)
217 {
218 case WM_KEYUP:
219 if (wParam == VK_RETURN)
220 {
221 GetWindowTextW(hwnd, s_szNode, ARRAY_SIZE(s_szNode));
222 SelectNode(g_pChildWnd->hTreeWnd, s_szNode);
223 }
224 break;
225 default:
226 break;
227 }
228 return CallWindowProcW(oldwndproc, hwnd, uMsg, wParam, lParam);
229}
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:785
#define ARRAY_SIZE(A)
Definition: main.h:33
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HWND hTreeWnd
Definition: main.h:63
#define GetWindowLongPtr
Definition: treelist.c:73
#define GWLP_USERDATA
Definition: treelist.c:63
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WM_KEYUP
Definition: winuser.h:1716
#define VK_RETURN
Definition: winuser.h:2201
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ChildWndProc().

◆ ChildWndProc()

LRESULT CALLBACK ChildWndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 302 of file childwnd.c.

303{
304 BOOL Result;
305 RECT rc;
306
307 switch (message)
308 {
309 case WM_CREATE:
310 {
311 WNDPROC oldproc;
312 HFONT hFont;
314 DWORD style;
315
316 /* Load "My Computer" string */
318
320 if (!g_pChildWnd) return 0;
321
323 g_pChildWnd->nSplitPos = 190;
325
329 hWnd, (HMENU)0, hInst, 0);
330
333 g_pChildWnd->hAddressBtnWnd = CreateWindowExW(0, L"Button", L"\x00BB", style,
335 hWnd, (HMENU)0, hInst, 0);
337 IMAGE_ICON, 12, 12, 0);
339
340 GetClientRect(hWnd, &rc);
344
345 /* set the address bar and button font */
347 {
351 (WPARAM)hFont,
352 0);
355 (WPARAM)hFont,
356 0);
357 }
358 /* Subclass the AddressBar */
362 break;
363 }
364 case WM_COMMAND:
365 if(HIWORD(wParam) == BN_CLICKED)
366 {
368 }
369 break; //goto def;
370 case WM_SETCURSOR:
371 if (LOWORD(lParam) == HTCLIENT)
372 {
373 POINT pt;
377 {
379 return TRUE;
380 }
381 }
382 goto def;
383 case WM_DESTROY:
391 break;
392 case WM_LBUTTONDOWN:
393 {
394 RECT rt;
395 int x = (short)LOWORD(lParam);
396 GetClientRect(hWnd, &rt);
398 {
402 }
403 break;
404 }
405
406 case WM_LBUTTONUP:
407 case WM_RBUTTONDOWN:
408 if (GetCapture() == hWnd)
409 {
411 }
412 break;
413
415 if (GetCapture()==hWnd && last_split>=0)
417 break;
418
419 case WM_KEYDOWN:
420 if (wParam == VK_ESCAPE)
421 if (GetCapture() == hWnd)
422 {
423 RECT rt;
425 GetClientRect(hWnd, &rt);
426 ResizeWnd(rt.right, rt.bottom);
427 last_split = -1;
430 }
431 break;
432
433 case WM_MOUSEMOVE:
434 if (GetCapture() == hWnd)
435 {
436 HDC hdc;
437 RECT rt;
438 HGDIOBJ OldObj;
439 int x = LOWORD(lParam);
440 if(!SizingPattern)
441 {
442 const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
443 SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
444 }
445 if(!SizingBrush)
446 {
448 }
449
450 GetClientRect(hWnd, &rt);
451 x = (SHORT) min(max(x, SPLIT_MIN), rt.right - SPLIT_MIN);
452 if(last_split != x)
453 {
456 hdc = GetDC(hWnd);
457 OldObj = SelectObject(hdc, SizingBrush);
458 PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
459 last_split = x;
460 rt.left = x-SPLIT_WIDTH/2;
461 rt.right = x+SPLIT_WIDTH/2+1;
462 PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
463 SelectObject(hdc, OldObj);
465 }
466 }
467 break;
468
469 case WM_SETFOCUS:
470 if (g_pChildWnd != NULL)
471 {
473 }
474 break;
475
476 case WM_TIMER:
477 break;
478
479 case WM_NOTIFY:
480 if (g_pChildWnd == NULL) break;
481
482 if (((LPNMHDR)lParam)->idFrom == TREE_WINDOW)
483 {
485 {
486 goto def;
487 }
488
489 return Result;
490 }
491 else
492 {
493 if (((LPNMHDR)lParam)->idFrom == LIST_WINDOW)
494 {
496 {
497 goto def;
498 }
499
500 return Result;
501 }
502 else
503 {
504 goto def;
505 }
506 }
507 break;
508
509 case WM_CONTEXTMENU:
510 {
511 POINT pt;
513 {
514 int i, cnt;
515 BOOL IsDefault;
516 pt.x = (short) LOWORD(lParam);
517 pt.y = (short) HIWORD(lParam);
520 if (pt.x == -1 && pt.y == -1)
521 {
522 RECT rc;
523 if (i != -1)
524 {
525 rc.left = LVIR_BOUNDS;
527 pt.x = rc.left + 8;
528 pt.y = rc.top + 8;
529 }
530 else
531 pt.x = pt.y = 0;
533 }
534 if(i == -1)
535 {
537 }
538 else
539 {
542 IsDefault = IsDefaultValue(g_pChildWnd->hListWnd, i);
543 if(cnt == 1)
545 else
549
551 }
552 }
553 else if ((HWND)wParam == g_pChildWnd->hTreeWnd)
554 {
555 TVHITTESTINFO hti;
556 HMENU hContextMenu;
558 MENUITEMINFOW mii;
559 WCHAR resource[256];
560 WCHAR buffer[256];
561 LPWSTR s;
562 LPCWSTR keyPath;
563 HKEY hRootKey;
564 int iLastPos;
565 WORD wID;
566 BOOL isRoot;
567
568 pt.x = (short) LOWORD(lParam);
569 pt.y = (short) HIWORD(lParam);
570
571 if (pt.x == -1 && pt.y == -1)
572 {
573 RECT rc;
575 if (hti.hItem != NULL)
576 {
578 pt.x = rc.left + 8;
579 pt.y = rc.top + 8;
581 hti.flags = TVHT_ONITEM;
582 }
583 else
584 hti.flags = 0;
585 }
586 else
587 {
588 hti.pt.x = pt.x;
589 hti.pt.y = pt.y;
592 }
593
594 if (hti.flags & TVHT_ONITEM)
595 {
597
598 isRoot = (TreeView_GetParent(g_pChildWnd->hTreeWnd, hti.hItem) == NULL);
599 hContextMenu = GetSubMenu(hPopupMenus, isRoot ? PM_ROOTITEM : PM_TREECONTEXT);
600
601 memset(&item, 0, sizeof(item));
603 item.hItem = hti.hItem;
605
606 /* Set the Expand/Collapse menu item appropriately */
608 memset(&mii, 0, sizeof(mii));
609 mii.cbSize = sizeof(mii);
611 mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED;
613 mii.dwTypeData = (LPWSTR) buffer;
614 SetMenuItemInfo(hContextMenu, 0, TRUE, &mii);
615
616 if (isRoot == FALSE)
617 {
618 /* Remove any existing suggestions */
619 memset(&mii, 0, sizeof(mii));
620 mii.cbSize = sizeof(mii);
621 mii.fMask = MIIM_ID;
622 GetMenuItemInfo(hContextMenu, GetMenuItemCount(hContextMenu) - 1, TRUE, &mii);
623 if ((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX))
624 {
625 do
626 {
627 iLastPos = GetMenuItemCount(hContextMenu) - 1;
628 GetMenuItemInfo(hContextMenu, iLastPos, TRUE, &mii);
629 RemoveMenu(hContextMenu, iLastPos, MF_BYPOSITION);
630 }
631 while((mii.wID >= ID_TREE_SUGGESTION_MIN) && (mii.wID <= ID_TREE_SUGGESTION_MAX));
632 }
633
634 /* Come up with suggestions */
635 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, NULL, &hRootKey);
636 SuggestKeys(hRootKey, keyPath, Suggestions, ARRAY_SIZE(Suggestions));
637 if (Suggestions[0])
638 {
639 AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL);
640
642
643 s = Suggestions;
645 while(*s && (wID <= ID_TREE_SUGGESTION_MAX))
646 {
648
649 memset(&mii, 0, sizeof(mii));
650 mii.cbSize = sizeof(mii);
651 mii.fMask = MIIM_STRING | MIIM_ID;
652 mii.wID = wID++;
653 mii.dwTypeData = buffer;
654 InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii);
655
656 s += wcslen(s) + 1;
657 }
658 }
659 }
660 TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
661 }
662 }
663 break;
664 }
665
666 case WM_SIZE:
668 {
670 }
671 /* fall through */
672 default:
673def:
675 }
676 return 0;
677}
Arabic default style
Definition: afstyles.h:94
HWND hWnd
Definition: settings.c:17
BOOL CreateListView(PMAIN_WND_INFO Info)
Definition: listview.c:355
static void finish_splitbar(HWND hWnd, int x)
Definition: childwnd.c:120
static int last_split
Definition: childwnd.c:24
static void draw_splitbar(HWND hWnd, int x)
Definition: childwnd.c:90
LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:210
HBRUSH SizingBrush
Definition: childwnd.c:26
HBITMAP SizingPattern
Definition: childwnd.c:25
WCHAR Suggestions[256]
Definition: childwnd.c:27
static void SuggestKeys(HKEY hRootKey, LPCWSTR pszKeyPath, LPWSTR pszSuggestions, size_t iSuggestionsLength)
Definition: childwnd.c:139
void ResizeWnd(int cx, int cy)
Definition: childwnd.c:41
BOOL IsDefaultValue(HWND hwndLV, int i)
Definition: listview.c:108
BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
Definition: listview.c:545
void DestroyListView(HWND hwndLV)
Definition: listview.c:655
HMENU hPopupMenus
Definition: main.c:38
HWND hFrameWnd
Definition: main.c:35
void DestroyMainMenu()
Definition: main.c:164
HFONT hFont
Definition: main.c:53
HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, HMENU id)
Definition: treeview.c:752
#define PM_TREECONTEXT
Definition: main.h:37
#define LIST_WINDOW
Definition: main.h:28
#define SPLIT_MIN
Definition: main.h:31
BOOL TreeWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
Definition: treeview.c:641
#define TREE_WINDOW
Definition: main.h:27
#define PM_NEW
Definition: main.h:36
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
#define PM_ROOTITEM
Definition: main.h:38
#define PM_MODIFYVALUE
Definition: main.h:35
#define ID_TREE_SUGGESTION_MIN
Definition: resource.h:156
#define IDS_MY_COMPUTER
Definition: resource.h:129
#define IDS_COLLAPSE
Definition: resource.h:191
#define IDI_ARROW
Definition: resource.h:37
#define ID_EDIT_MODIFY
Definition: resource.h:62
#define ID_TREE_EXPANDBRANCH
Definition: resource.h:93
#define ID_TREE_COLLAPSEBRANCH
Definition: resource.h:95
#define IDS_GOTO_SUGGESTED_KEY
Definition: resource.h:194
#define ID_EDIT_MODIFY_BIN
Definition: resource.h:122
#define IDS_EXPAND
Definition: resource.h:190
#define ID_TREE_SUGGESTION_MAX
Definition: resource.h:157
#define ID_EDIT_RENAME
Definition: resource.h:58
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
HINSTANCE hInst
Definition: dxdiag.c:13
#define SPLIT_WIDTH
Definition: eventvwr.c:45
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble s
Definition: gl.h:2039
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
static ATOM item
Definition: dde.c:856
#define min(a, b)
Definition: monoChain.cc:55
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define WS_TABSTOP
Definition: pedump.c:634
#define WS_VISIBLE
Definition: pedump.c:620
short SHORT
Definition: pedump.c:59
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
static VOID DestroyTreeView(HWND hTreeView)
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3481
#define TVHT_ONITEM
Definition: commctrl.h:3527
#define LVNI_SELECTED
Definition: commctrl.h:2424
#define LVNI_FOCUSED
Definition: commctrl.h:2423
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TreeView_GetItemRect(hwnd, hitem, prc, code)
Definition: commctrl.h:3429
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2709
#define LVM_GETITEMRECT
Definition: commctrl.h:2477
#define TVIS_EXPANDED
Definition: commctrl.h:3284
#define TVIF_CHILDREN
Definition: commctrl.h:3272
#define TreeView_HitTest(hwnd, lpht)
Definition: commctrl.h:3513
#define TVIF_STATE
Definition: commctrl.h:3269
#define LVIR_BOUNDS
Definition: commctrl.h:2472
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_NOTIFY
Definition: richedit.h:61
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define memset(x, y, z)
Definition: compat.h:39
Definition: main.h:61
int nSplitPos
Definition: main.h:69
WCHAR szPath[MAX_PATH]
Definition: main.h:71
HWND hAddressBtnWnd
Definition: main.h:66
int nFocusPanel
Definition: main.h:68
HICON hArrowIcon
Definition: main.h:67
HWND hListWnd
Definition: main.h:64
HWND hAddressBarWnd
Definition: main.h:65
HWND hWnd
Definition: main.h:62
Definition: tftpd.h:60
LPWSTR dwTypeData
Definition: winuser.h:3269
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
HTREEITEM hItem
Definition: commctrl.h:3521
#define max(a, b)
Definition: svc.c:63
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define PATINVERT
Definition: wingdi.h:328
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
HWND WINAPI SetCapture(_In_ HWND hWnd)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define MIIM_STRING
Definition: winuser.h:727
#define MIIM_ID
Definition: winuser.h:722
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IMAGE_ICON
Definition: winuser.h:212
#define AppendMenu
Definition: winuser.h:5731
#define WM_CAPTURECHANGED
Definition: winuser.h:1808
#define TPM_RIGHTBUTTON
Definition: winuser.h:2380
#define WM_CREATE
Definition: winuser.h:1608
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define BS_ICON
Definition: winuser.h:264
#define WM_SIZE
Definition: winuser.h:1611
#define WM_COMMAND
Definition: winuser.h:1740
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2203
#define IDC_ARROW
Definition: winuser.h:687
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2670
#define InsertMenuItem
Definition: winuser.h:5804
#define WM_SETFOCUS
Definition: winuser.h:1613
#define SetMenuItemInfo
Definition: winuser.h:5850
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_MOUSEMOVE
Definition: winuser.h:1775
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define SIZE_MINIMIZED
Definition: winuser.h:2506
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2105
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define MIIM_STATE
Definition: winuser.h:721
#define MFS_DEFAULT
Definition: winuser.h:748
#define BM_SETIMAGE
Definition: winuser.h:1922
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MF_ENABLED
Definition: winuser.h:128
#define MFS_GRAYED
Definition: winuser.h:751
#define MF_SEPARATOR
Definition: winuser.h:137
#define BS_FLAT
Definition: winuser.h:280
#define WM_SETFONT
Definition: winuser.h:1650
#define WM_TIMER
Definition: winuser.h:1742
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define HTCLIENT
Definition: winuser.h:2475
#define BS_VCENTER
Definition: winuser.h:279
HDC WINAPI GetDC(_In_opt_ HWND)
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WM_SETCURSOR
Definition: winuser.h:1636
#define BN_CLICKED
Definition: winuser.h:1925
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define WM_DESTROY
Definition: winuser.h:1609
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WM_KEYDOWN
Definition: winuser.h:1715
#define BS_CENTER
Definition: winuser.h:260
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDC_SIZEWE
Definition: winuser.h:694
#define GetMenuItemInfo
Definition: winuser.h:5788
#define VK_ESCAPE
Definition: winuser.h:2214
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053
#define MF_GRAYED
Definition: winuser.h:129
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
#define MF_DISABLED
Definition: winuser.h:130
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by InitInstance().

◆ draw_splitbar()

static void draw_splitbar ( HWND  hWnd,
int  x 
)
static

Definition at line 90 of file childwnd.c.

91{
92 RECT rt;
93 HGDIOBJ OldObj;
94 HDC hdc = GetDC(hWnd);
95
96 if(!SizingPattern)
97 {
98 const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
99 SizingPattern = CreateBitmap(8, 8, 1, 1, Pattern);
100 }
101 if(!SizingBrush)
102 {
104 }
105 GetClientRect(hWnd, &rt);
106 rt.left = x - SPLIT_WIDTH/2;
107 rt.right = x + SPLIT_WIDTH/2+1;
108 OldObj = SelectObject(hdc, SizingBrush);
109 PatBlt(hdc, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, PATINVERT);
110 SelectObject(hdc, OldObj);
112}

Referenced by ChildWndProc(), and finish_splitbar().

◆ finish_splitbar()

static void finish_splitbar ( HWND  hWnd,
int  x 
)
static

Definition at line 120 of file childwnd.c.

121{
122 RECT rt;
123
125 last_split = -1;
126 GetClientRect(hWnd, &rt);
128 ResizeWnd(rt.right, rt.bottom);
130}

Referenced by ChildWndProc().

◆ get_root_key_name()

LPCWSTR get_root_key_name ( HKEY  hRootKey)

Definition at line 29 of file childwnd.c.

30{
31 if (hRootKey == HKEY_CLASSES_ROOT) return L"HKEY_CLASSES_ROOT";
32 if (hRootKey == HKEY_CURRENT_USER) return L"HKEY_CURRENT_USER";
33 if (hRootKey == HKEY_LOCAL_MACHINE) return L"HKEY_LOCAL_MACHINE";
34 if (hRootKey == HKEY_USERS) return L"HKEY_USERS";
35 if (hRootKey == HKEY_CURRENT_CONFIG) return L"HKEY_CURRENT_CONFIG";
36 if (hRootKey == HKEY_DYN_DATA) return L"HKEY_DYN_DATA";
37
38 return L"UNKNOWN HKEY, PLEASE REPORT";
39}
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define HKEY_DYN_DATA
Definition: winreg.h:16
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_USERS
Definition: winreg.h:13

Referenced by SaveSettings(), and UpdateAddress().

◆ ResizeWnd()

void ResizeWnd ( int  cx,
int  cy 
)

Definition at line 41 of file childwnd.c.

42{
43 HDWP hdwp = BeginDeferWindowPos(4);
44 RECT rt, rs, rb;
45 const int nButtonWidth = 44;
46 const int nButtonHeight = 22;
47 int cyEdge = GetSystemMetrics(SM_CYEDGE);
49 SetRect(&rt, 0, 0, cx, cy);
50 cy = 0;
51 if (hStatusBar != NULL)
52 {
54 cy = rs.bottom - rs.top;
55 }
58 if (hdwp)
60 rt.left, rt.top,
61 rt.right - rt.left - nButtonWidth, nButtonHeight,
62 uFlags);
63 if (hdwp)
65 rt.right - nButtonWidth, rt.top,
66 nButtonWidth, nButtonHeight,
67 uFlags);
68 if (hdwp)
70 rt.left,
71 rt.top + nButtonHeight + cyEdge,
73 rt.bottom - rt.top - cy - 2 * cyEdge,
74 uFlags);
75 if (hdwp)
77 rt.left + cx,
78 rt.top + nButtonHeight + cyEdge,
79 rt.right - cx,
80 rt.bottom - rt.top - cy - 2 * cyEdge,
81 uFlags);
82 if (hdwp)
84}
HWND hStatusBar
Definition: main.c:36
UINT uFlags
Definition: api.c:59
unsigned int UINT
Definition: ndis.h:50
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define SWP_NOACTIVATE
Definition: winuser.h:1242
#define SM_CYEDGE
Definition: winuser.h:1009
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOZORDER
Definition: winuser.h:1247
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
HDWP WINAPI BeginDeferWindowPos(_In_ int)

Referenced by ChildWndProc(), and finish_splitbar().

◆ SuggestKeys()

static void SuggestKeys ( HKEY  hRootKey,
LPCWSTR  pszKeyPath,
LPWSTR  pszSuggestions,
size_t  iSuggestionsLength 
)
static

Definition at line 139 of file childwnd.c.

141{
142 WCHAR szBuffer[256];
143 WCHAR szLastFound[256];
144 size_t i;
145 HKEY hOtherKey, hSubKey;
146 BOOL bFound;
147
148 memset(pszSuggestions, 0, iSuggestionsLength * sizeof(*pszSuggestions));
149 iSuggestionsLength--;
150
151 /* Are we a root key in HKEY_CLASSES_ROOT? */
152 if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !wcschr(pszKeyPath, L'\\'))
153 {
154 do
155 {
156 bFound = FALSE;
157
158 /* Check default key */
159 if (QueryStringValue(hRootKey, pszKeyPath, NULL,
160 szBuffer, ARRAY_SIZE(szBuffer)) == ERROR_SUCCESS)
161 {
162 /* Sanity check this key; it cannot be empty, nor can it be a
163 * loop back */
164 if ((szBuffer[0] != L'\0') && _wcsicmp(szBuffer, pszKeyPath))
165 {
166 if (RegOpenKeyW(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS)
167 {
168 lstrcpynW(pszSuggestions, L"HKCR\\", (int) iSuggestionsLength);
169 i = wcslen(pszSuggestions);
170 pszSuggestions += i;
171 iSuggestionsLength -= i;
172
173 lstrcpynW(pszSuggestions, szBuffer, (int) iSuggestionsLength);
174 i = MIN(wcslen(pszSuggestions) + 1, iSuggestionsLength);
175 pszSuggestions += i;
176 iSuggestionsLength -= i;
177 RegCloseKey(hOtherKey);
178
179 bFound = TRUE;
180 StringCbCopyW(szLastFound, sizeof(szLastFound), szBuffer);
181 pszKeyPath = szLastFound;
182 }
183 }
184 }
185 }
186 while(bFound && (iSuggestionsLength > 0));
187
188 /* Check CLSID key */
189 if (RegOpenKeyW(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS)
190 {
191 if (QueryStringValue(hSubKey, L"CLSID", NULL, szBuffer,
192 ARRAY_SIZE(szBuffer)) == ERROR_SUCCESS)
193 {
194 lstrcpynW(pszSuggestions, L"HKCR\\CLSID\\", (int)iSuggestionsLength);
195 i = wcslen(pszSuggestions);
196 pszSuggestions += i;
197 iSuggestionsLength -= i;
198
199 lstrcpynW(pszSuggestions, szBuffer, (int)iSuggestionsLength);
200 i = MIN(wcslen(pszSuggestions) + 1, iSuggestionsLength);
201 pszSuggestions += i;
202 iSuggestionsLength -= i;
203 }
204 RegCloseKey(hSubKey);
205 }
206 }
207}
LONG QueryStringValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPTSTR pszBuffer, DWORD dwBufferLen)
Definition: settings.c:19
#define MIN(a, b)
Definition: childwnd.c:137
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3297
#define wcschr
Definition: compat.h:17
#define lstrcpynW
Definition: compat.h:738
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166

Referenced by ChildWndProc().

◆ UpdateAddress()

VOID UpdateAddress ( HTREEITEM  hItem,
HKEY  hRootKey,
LPCWSTR  pszPath,
BOOL  bSelectNone 
)

Definition at line 232 of file childwnd.c.

233{
234 LPCWSTR keyPath, rootName;
235 LPWSTR fullPath;
236 DWORD cbFullPath;
237
238 /* Wipe the listview, the status bar and the address bar if the root key was selected */
240 {
244 return;
245 }
246
247 if (pszPath == NULL)
248 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, hItem, &hRootKey);
249 else
250 keyPath = pszPath;
251
252 if (keyPath)
253 {
254 RefreshListView(g_pChildWnd->hListWnd, hRootKey, keyPath, bSelectNone);
255 rootName = get_root_key_name(hRootKey);
256 cbFullPath = (wcslen(rootName) + 1 + wcslen(keyPath) + 1) * sizeof(WCHAR);
257 fullPath = malloc(cbFullPath);
258 if (fullPath)
259 {
260 /* set (correct) the address bar text */
261 if (keyPath[0] != UNICODE_NULL)
262 StringCbPrintfW(fullPath, cbFullPath, L"%s%s%s", rootName,
263 ((keyPath[0] == L'\\') ? L"" : L"\\"), keyPath);
264 else
265 StringCbCopyW(fullPath, cbFullPath, rootName);
266
269 free(fullPath);
270
271 /* disable hive manipulation items temporarily (enable only if necessary) */
274 /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
275 if (_wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") == 0 ||
276 _wcsicmp(rootName, L"HKEY_USERS") == 0)
277 {
278 /*
279 * enable the unload menu item if at the root, otherwise
280 * enable the load menu item if there is no slash in
281 * keyPath (ie. immediate child selected)
282 */
283 if (keyPath[0] == UNICODE_NULL)
285 else if (!wcschr(keyPath, L'\\'))
287 }
288 }
289 }
290}
LPCWSTR get_root_key_name(HKEY hRootKey)
Definition: childwnd.c:29
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath, BOOL bSelectNone)
Definition: listview.c:672
HMENU hMenuFrame
Definition: main.c:37
#define ID_REGISTRY_UNLOADHIVE
Definition: resource.h:105
#define ID_REGISTRY_LOADHIVE
Definition: resource.h:104
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define UNICODE_NULL
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2414
#define SB_SETTEXTW
Definition: commctrl.h:1942
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
#define WM_SETTEXT
Definition: winuser.h:1617

Referenced by TreeWndNotifyProc().

Variable Documentation

◆ g_pChildWnd

◆ last_split

int last_split
static

Definition at line 24 of file childwnd.c.

Referenced by ChildWndProc(), and finish_splitbar().

◆ SizingBrush

HBRUSH SizingBrush = 0

Definition at line 26 of file childwnd.c.

Referenced by ChildWndProc(), and draw_splitbar().

◆ SizingPattern

HBITMAP SizingPattern = 0

Definition at line 25 of file childwnd.c.

Referenced by ChildWndProc(), and draw_splitbar().

◆ Suggestions

WCHAR Suggestions[256]

Definition at line 27 of file childwnd.c.

Referenced by _CmdWndProc(), and ChildWndProc().