From 649643aad73cb871503f581786b139e5d895bd9f Mon Sep 17 00:00:00 2001 From: Thomas Weidenmueller Date: Fri, 16 Jan 2004 02:14:19 +0000 Subject: [PATCH] Added context menu support. --- programs/regedit/En.rc | 23 +++++++++++++++++++++++ programs/regedit/listview.c | 7 +++++++ programs/regedit/main.c | 2 ++ programs/regedit/main.h | 4 ++++ programs/regedit/resource.h | 2 ++ 5 files changed, 38 insertions(+) diff --git a/programs/regedit/En.rc b/programs/regedit/En.rc index 06848532e0e..f7503368a7d 100644 --- a/programs/regedit/En.rc +++ b/programs/regedit/En.rc @@ -102,6 +102,29 @@ BEGIN END END +IDR_POPUP_MENUS MENU DISCARDABLE +BEGIN + POPUP "" + BEGIN + MENUITEM "&Modify", ID_EDIT_MODIFY + MENUITEM "Modify Binary Data", ID_EDIT_MODIFY_BIN + MENUITEM SEPARATOR + MENUITEM "&Delete\tDel", ID_EDIT_DELETE + MENUITEM "&Rename", ID_EDIT_RENAME + END + POPUP "" + BEGIN + POPUP "&New" + BEGIN + MENUITEM "&Key", ID_EDIT_NEW_KEY + MENUITEM SEPARATOR + MENUITEM "&String Value", ID_EDIT_NEW_STRINGVALUE + MENUITEM "&Binary Value", ID_EDIT_NEW_BINARYVALUE + MENUITEM "&DWORD Value", ID_EDIT_NEW_DWORDVALUE + END + END +END + /* * Dialog diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c index c383ca16b4f..bb75321ed20 100644 --- a/programs/regedit/listview.c +++ b/programs/regedit/listview.c @@ -346,6 +346,13 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); } break; + case WM_CONTEXTMENU: { + POINTS pt = MAKEPOINTS(lParam); + int cnt = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED | LVNI_SELECTED); + TrackPopupMenu(GetSubMenu(hPopupMenus, cnt == -1 ? PM_NEW : PM_MODIFYVALUE), + TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL); + break; + } case WM_KEYDOWN: if (wParam == VK_TAB) { /*TODO: SetFocus(Globals.hDriveBar) */ diff --git a/programs/regedit/main.c b/programs/regedit/main.c index 8df9291840e..8dbaba9a2a5 100644 --- a/programs/regedit/main.c +++ b/programs/regedit/main.c @@ -42,6 +42,7 @@ HINSTANCE hInst; HWND hFrameWnd; HWND hStatusBar; HMENU hMenuFrame; +HMENU hPopupMenus = 0; UINT nClipboardFormat; LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT"); @@ -104,6 +105,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) hChildWndClass = hChildWndClass; /* warning eater */ hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU)); + hPopupMenus = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_MENUS)); /* Initialize the Windows Common Controls DLL */ InitCommonControls(); diff --git a/programs/regedit/main.h b/programs/regedit/main.h index f91d5e791ce..eed6f85733b 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -32,6 +32,9 @@ #define COUNT_OF(a) (sizeof(a)/sizeof(a[0])) +#define PM_MODIFYVALUE 0 +#define PM_NEW 1 + extern HINSTANCE hInst; /******************************************************************************/ @@ -64,6 +67,7 @@ extern HINSTANCE hInst; extern HWND hFrameWnd; extern HMENU hMenuFrame; extern HWND hStatusBar; +extern HMENU hPopupMenus; extern HFONT hFont; extern enum OPTION_FLAGS Options; diff --git a/programs/regedit/resource.h b/programs/regedit/resource.h index 2869dd5ca3e..40cb2a54060 100644 --- a/programs/regedit/resource.h +++ b/programs/regedit/resource.h @@ -41,6 +41,7 @@ #define IDD_DIALOG2 132 #define IDB_CLOSED_FILE 133 #define IDB_ROOT 134 +#define IDR_POPUP_MENUS 137 #define IDC_LICENSE_EDIT 1029 #define ID_REGISTRY_EXIT 32770 #define ID_FAVOURITES_ADDTOFAVOURITES 32772 @@ -114,6 +115,7 @@ #define IDC_DWORD_DEC 32854 #define IDS_NEWKEY 32860 #define IDS_NEWVALUE 32861 +#define ID_EDIT_MODIFY_BIN 32870 #define IDD_EDIT_STRING 2000 #define IDC_VALUE_NAME 2001