From f5852bccf9fc3c9475c07117d7fc07eeec1148fd Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 28 Aug 2008 03:52:51 +0000 Subject: [PATCH] - Add Items to Connection ShellFolder Item Context Menu - Are not yet handled svn path=/trunk/; revision=35719 --- reactos/dll/win32/netshell/lang/de-DE.rc | 8 ++ reactos/dll/win32/netshell/lang/en-US.rc | 8 ++ reactos/dll/win32/netshell/resource.h | 9 ++ .../dll/win32/netshell/shfldr_netconnect.c | 95 ++++++++++++++++++- 4 files changed, 116 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/netshell/lang/de-DE.rc b/reactos/dll/win32/netshell/lang/de-DE.rc index d3273c9c3c9..4900a1add15 100644 --- a/reactos/dll/win32/netshell/lang/de-DE.rc +++ b/reactos/dll/win32/netshell/lang/de-DE.rc @@ -18,4 +18,12 @@ BEGIN IDS_STATUS_CONNECTED "Verbindung hergestellt" IDS_STATUS_OPERATIONAL "Verbindung hergestellt" + IDS_NET_ACTIVATE "Aktivieren" + IDS_NET_DEACTIVATE "Deaktivieren" + IDS_NET_STATUS "Status" + IDS_NET_REPAIR "Reparieren" + IDS_NET_CREATELINK "Verknüpfung erstellen" + IDS_NET_DELETE "Löschen" + IDS_NET_RENAME "Umbenennen" + IDS_NET_PROPERTIES "Eigenschaften" END diff --git a/reactos/dll/win32/netshell/lang/en-US.rc b/reactos/dll/win32/netshell/lang/en-US.rc index 61743df8f99..89a2256e3dd 100644 --- a/reactos/dll/win32/netshell/lang/en-US.rc +++ b/reactos/dll/win32/netshell/lang/en-US.rc @@ -16,5 +16,13 @@ BEGIN IDS_STATUS_CONNECTING "Acquiring network address" IDS_STATUS_CONNECTED "Connected" IDS_STATUS_OPERATIONAL "Connected" + + IDS_NET_ACTIVATE "Enable" + IDS_NET_DEACTIVATE "Disable" + IDS_NET_STATUS "Status" + IDS_NET_REPAIR "Repair" + IDS_NET_CREATELINK "Create Shortcut" + IDS_NET_DELETE "Delete" + IDS_NET_PROPERTIES "Properties" END diff --git a/reactos/dll/win32/netshell/resource.h b/reactos/dll/win32/netshell/resource.h index 79181a9a88e..9c11a18000e 100644 --- a/reactos/dll/win32/netshell/resource.h +++ b/reactos/dll/win32/netshell/resource.h @@ -29,3 +29,12 @@ #define IDS_STATUS_CONNECTING 10011 #define IDS_STATUS_CONNECTED 10012 #define IDS_STATUS_OPERATIONAL 10013 + +#define IDS_NET_ACTIVATE 10100 +#define IDS_NET_DEACTIVATE 10101 +#define IDS_NET_STATUS 10102 +#define IDS_NET_REPAIR 10103 +#define IDS_NET_CREATELINK 10104 +#define IDS_NET_DELETE 10105 +#define IDS_NET_RENAME 10106 +#define IDS_NET_PROPERTIES 10107 diff --git a/reactos/dll/win32/netshell/shfldr_netconnect.c b/reactos/dll/win32/netshell/shfldr_netconnect.c index 36a43ae60c9..7d1e334f9d6 100644 --- a/reactos/dll/win32/netshell/shfldr_netconnect.c +++ b/reactos/dll/win32/netshell/shfldr_netconnect.c @@ -380,7 +380,7 @@ static HRESULT WINAPI ISF_NetConnect_fnGetDisplayNameOf (IShellFolder2 * iface, val = _ILGetValueStruct(pidl); if (val) { - if (INetConnection_GetProperties((INetConnection*)val->pItem, &pProperties) == NOERROR) + if (INetConnection_GetProperties(val->pItem, &pProperties) == NOERROR) { if (pProperties->pszwName) { @@ -628,6 +628,51 @@ static ULONG WINAPI ISF_NetConnect_IContextMenu2_Release(IContextMenu2 * iface) return IShellFolder2_Release((IShellFolder2*)This); } +void WINAPI _InsertMenuItemW ( + HMENU hmenu, + UINT indexMenu, + BOOL fByPosition, + UINT wID, + UINT fType, + LPCWSTR dwTypeData, + UINT fState) +{ + MENUITEMINFOW mii; + WCHAR szText[100]; + + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + if (fType == MFT_SEPARATOR) + { + mii.fMask = MIIM_ID | MIIM_TYPE; + } + else if (fType == MFT_STRING) + { + mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE; + if ((ULONG_PTR)HIWORD((ULONG_PTR)dwTypeData) == 0) + { + if (LoadStringW(netshell_hInstance, LOWORD((ULONG_PTR)dwTypeData), szText, sizeof(szText)/sizeof(WCHAR))) + { + szText[(sizeof(szText)/sizeof(WCHAR))-1] = 0; + mii.dwTypeData = szText; + } + else + { + return; + } + } + else + { + mii.dwTypeData = (LPWSTR) dwTypeData; + } + mii.fState = fState; + } + + mii.wID = wID; + mii.fType = fType; + InsertMenuItemW( hmenu, indexMenu, fByPosition, &mii); +} + /************************************************************************** * ISF_NetConnect_IContextMenu_QueryContextMenu() */ @@ -639,10 +684,52 @@ static HRESULT WINAPI ISF_NetConnect_IContextMenu2_QueryContextMenu( UINT idCmdLast, UINT uFlags) { - int Count = 1; - //IGenericSFImpl * This = impl_from_IContextMenu2(iface); + IGenericSFImpl * This = impl_from_IContextMenu2(iface); + VALUEStruct * val; + NETCON_PROPERTIES * pProperties; - return MAKE_HRESULT(SEVERITY_SUCCESS, 0, Count); + val = _ILGetValueStruct(This->apidl); + if (!val) + return E_FAIL; + + if (INetConnection_GetProperties((INetConnection*)val->pItem, &pProperties) != NOERROR) + return E_FAIL; + + if (pProperties->Status == NCS_HARDWARE_DISABLED) + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_ACTIVATE, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_ACTIVATE), MFS_DEFAULT); + else + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_DEACTIVATE, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_DEACTIVATE), MFS_ENABLED); + + if (pProperties->Status == NCS_HARDWARE_DISABLED || pProperties->Status == NCS_MEDIA_DISCONNECTED || pProperties->Status == NCS_DISCONNECTED) + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_STATUS, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_STATUS), MFS_GRAYED); + else if (pProperties->Status == NCS_CONNECTED) + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_STATUS, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_STATUS), MFS_DEFAULT); + else + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_STATUS, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_STATUS), MFS_ENABLED); + + if (pProperties->Status == NCS_HARDWARE_DISABLED || pProperties->Status == NCS_MEDIA_DISCONNECTED) + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_REPAIR, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_REPAIR), MFS_GRAYED); + else + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_REPAIR, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_REPAIR), MFS_ENABLED); + + _InsertMenuItemW(hMenu, indexMenu++, TRUE, -1, MFT_SEPARATOR, NULL, MFS_ENABLED); + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_CREATELINK, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_CREATELINK), MFS_ENABLED); + + if (pProperties->dwCharacter & NCCF_ALLOW_REMOVAL) + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_DELETE, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_DELETE), MFS_ENABLED); + else + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_DELETE, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_DELETE), MFS_GRAYED); + + if (pProperties->dwCharacter & NCCF_ALLOW_RENAME) + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_RENAME, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_RENAME), MFS_ENABLED); + else + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_RENAME, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_RENAME), MFS_GRAYED); + + _InsertMenuItemW(hMenu, indexMenu++, TRUE, -1, MFT_SEPARATOR, NULL, MFS_ENABLED); + _InsertMenuItemW(hMenu, indexMenu++, TRUE, IDS_NET_PROPERTIES, MFT_STRING, MAKEINTRESOURCEW(IDS_NET_PROPERTIES), MFS_ENABLED); + + + return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 9); }