Replaced nppcm with NppShell.

-Context menu icon properly rendered
-Incorporate dynamic icon for registered filetypes
-Dialog to allow change of various settings

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@543 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Harold Bruintjes 2009-09-22 23:18:54 +00:00
parent dfaed129b5
commit 3a11d6de66
20 changed files with 2505 additions and 808 deletions

View File

@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NppShell", "NppShell.vcproj", "{509B95C6-043E-4389-8351-77BDB042A6F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|Win32.ActiveCfg = Debug|Win32
{509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|Win32.Build.0 = Debug|Win32
{509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|x64.ActiveCfg = Debug|x64
{509B95C6-043E-4389-8351-77BDB042A6F9}.Debug|x64.Build.0 = Debug|x64
{509B95C6-043E-4389-8351-77BDB042A6F9}.Release|Win32.ActiveCfg = Release|Win32
{509B95C6-043E-4389-8351-77BDB042A6F9}.Release|Win32.Build.0 = Release|Win32
{509B95C6-043E-4389-8351-77BDB042A6F9}.Release|x64.ActiveCfg = Release|x64
{509B95C6-043E-4389-8351-77BDB042A6F9}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,429 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="NppShell"
ProjectGUID="{509B95C6-043E-4389-8351-77BDB042A6F9}"
RootNamespace="NppShell"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\..\build_$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory=".\..\build_$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="shell32.lib comctl32.lib shlwapi.lib"
OutputFile="$(OutDir)\..\$(ProjectName)_D.dll"
LinkIncremental="2"
ModuleDefinitionFile="..\src\export.def"
GenerateDebugInformation="true"
SubSystem="2"
BaseAddress="0x1C000000"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory=".\..\build_$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory=".\..\build_$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;WIN64;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_VC80_UPGRADE=0x0710;WIN64"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="shell32.lib comctl32.lib shlwapi.lib"
OutputFile="$(OutDir)\..\$(ProjectName)64_D.dll"
LinkIncremental="2"
ModuleDefinitionFile="..\src\export.def"
GenerateDebugInformation="true"
SubSystem="2"
BaseAddress="0x1C000000"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\..\build_$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory=".\..\build_$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
FavorSizeOrSpeed="1"
PreprocessorDefinitions="WIN32;_WINDOWS;"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="shell32.lib comctl32.lib shlwapi.lib"
OutputFile="$(OutDir)\..\$(ProjectName).dll"
LinkIncremental="1"
AdditionalLibraryDirectories=".\..\src\libs"
ModuleDefinitionFile="..\src\export.def"
GenerateDebugInformation="false"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory=".\..\build_$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory=".\..\build_$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
FavorSizeOrSpeed="1"
PreprocessorDefinitions="WIN32;WIN64;NDEBUG;_WINDOWS"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="2"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_VC80_UPGRADE=0x0710;WIN64"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="shell32.lib comctl32.lib shlwapi.lib"
OutputFile="$(OutDir)\..\$(ProjectName)64.dll"
LinkIncremental="1"
AdditionalLibraryDirectories=".\..\src\libs"
IgnoreAllDefaultLibraries="false"
ModuleDefinitionFile="..\src\export.def"
GenerateDebugInformation="false"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\src\export.def"
>
</File>
<File
RelativePath="..\src\NppShell.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\src\NppShell.h"
>
</File>
<File
RelativePath="..\src\resource.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\src\bitmap\npp.bmp"
>
</File>
<File
RelativePath="..\src\icon\npp.ico"
>
</File>
<File
RelativePath="..\src\icon\npp_0.ico"
>
</File>
<File
RelativePath="..\src\icon\npp_1.ico"
>
</File>
<File
RelativePath="..\src\NppShell.rc"
>
</File>
</Filter>
<Filter
Name="Documentation"
>
<File
RelativePath="..\doc\license.txt"
>
</File>
<File
RelativePath="..\doc\readme.txt"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,955 @@
#include "NppShell.h"
#include "resource.h"
//---------------------------------------------------------------------------
// Global variables
//---------------------------------------------------------------------------
UINT _cRef = 0; // COM Reference count.
HINSTANCE _hModule = NULL; // DLL Module.
//Menu
TCHAR szNppName[] = TEXT("notepad++.exe");
#ifdef UNICODE
TCHAR szDefaultMenutext[] = TEXT("Edit with &Notepad++");
#else
TCHAR szDefaultMenutext[] = TEXT("Edit with &Notepad++");
#endif
#ifdef WIN64
TCHAR szShellExtensionTitle[] = TEXT("Notepad++64");
#define sz64 TEXT("64")
#else
TCHAR szShellExtensionTitle[] = TEXT("Notepad++");
#define sz64 TEXT("")
#endif
#define szHelpTextA "Edits the selected file(s) with Notepad++"
#define szHelpTextW L"Edits the selected file(s) with Notepad++"
TCHAR szMenuTitle[TITLE_SIZE];
TCHAR szDefaultCustomcommand[] = TEXT("");
//Icon
DWORD isDynamic = 1;
DWORD maxText = 25;
DWORD iconID = 0;
DWORD showIcon = 1;
//Forward function declarations
BOOL RegisterServer();
BOOL UnregisterServer();
void MsgBox(LPTSTR lpszMsg);
void MsgBoxError(LPTSTR lpszMsg);
BOOL CheckNpp(LPCTSTR path);
INT_PTR CALLBACK DlgProcSettings(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
#ifdef UNICODE
#define _ttoi _wtoi
#else
#define _ttoi atoi
#endif
//Types
struct DOREGSTRUCT {
HKEY hRootKey;
LPTSTR szSubKey;
LPTSTR lpszValueName;
DWORD type;
LPTSTR szData;
};
//---------------------------------------------------------------------------
// DllMain
//---------------------------------------------------------------------------
extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
if (dwReason == DLL_PROCESS_ATTACH) {
_hModule = hInstance;
}
return TRUE;
}
//---------------------------------------------------------------------------
// DllCanUnloadNow
//---------------------------------------------------------------------------
STDAPI DllCanUnloadNow(void) {
return (_cRef == 0 ? S_OK : S_FALSE);
}
//---------------------------------------------------------------------------
// DllGetClassObject
//---------------------------------------------------------------------------
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut) {
*ppvOut = NULL;
if (IsEqualIID(rclsid, CLSID_ShellExtension)) {
CShellExtClassFactory *pcf = new CShellExtClassFactory;
return pcf->QueryInterface(riid, ppvOut);
}
return CLASS_E_CLASSNOTAVAILABLE;
}
//---------------------------------------------------------------------------
// DllRegisterServer
//---------------------------------------------------------------------------
STDAPI DllRegisterServer(void) {
return (RegisterServer() ? S_OK : E_FAIL);
}
//---------------------------------------------------------------------------
// DllUnregisterServer
//---------------------------------------------------------------------------
STDAPI DllUnregisterServer(void) {
return (UnregisterServer() ? S_OK : E_FAIL);
}
STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine) {
DialogBox(_hModule, MAKEINTRESOURCE(IDD_DIALOG_SETTINGS), NULL, (DLGPROC)&DlgProcSettings);
return S_OK;
}
//---------------------------------------------------------------------------
// RegisterServer
// Create registry entries and setup the shell extension
//---------------------------------------------------------------------------
BOOL RegisterServer() {
int i;
HKEY hKey;
LRESULT lResult;
DWORD dwDisp;
TCHAR szSubKey[MAX_PATH];
TCHAR szModule[MAX_PATH];
TCHAR szDefaultPath[MAX_PATH];
GetModuleFileName(_hModule, szDefaultPath, MAX_PATH);
TCHAR* pDest = StrRChr(szDefaultPath, NULL, TEXT('\\'));
pDest++;
pDest[0] = 0;
lstrcat(szDefaultPath, szNppName);
if (!CheckNpp(szDefaultPath)) {
MsgBoxError(TEXT("To register the Notepad++ shell extension properly,\r\nplace NppShell.dll in the same directory as the Notepad++ executable."));
//return FALSE;
}
//get this app's path and file name
GetModuleFileName(_hModule, szModule, MAX_PATH);
static DOREGSTRUCT ClsidEntries[] = {
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s"), NULL, REG_SZ, szShellExtensionTitle,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), NULL, REG_SZ, szModule,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), TEXT("ThreadingModel"), REG_SZ, TEXT("Apartment"),
//Settings
// Context menu
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Title"), REG_SZ, szDefaultMenutext,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Path"), REG_SZ, szDefaultPath,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Custom"), REG_SZ, szDefaultCustomcommand,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("ShowIcon"), REG_DWORD, (LPTSTR)&showIcon,
// Icon
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Dynamic"), REG_DWORD, (LPTSTR)&isDynamic,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Maxtext"), REG_DWORD, (LPTSTR)&maxText,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("IconID"), REG_DWORD, (LPTSTR)&iconID,
//Registration
// Context menu
HKEY_CLASSES_ROOT, TEXT("*\\shellex\\ContextMenuHandlers\\Notepad++")sz64, NULL, REG_SZ, szGUID,
// Icon
//HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"), NULL, REG_SZ, szGUID,
NULL, NULL, NULL, REG_SZ, NULL
};
static DOREGSTRUCT IconEntry = {HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"), NULL, REG_SZ, szGUID};
// First clear any old entries
UnregisterServer();
// Register the CLSID entries
for(i = 0; ClsidEntries[i].hRootKey; i++) {
wsprintf(szSubKey, ClsidEntries[i].szSubKey, szGUID);
lResult = RegCreateKeyEx(ClsidEntries[i].hRootKey, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp);
if (NOERROR == lResult) {
TCHAR szData[MAX_PATH];
// If necessary, create the value string
if (ClsidEntries[i].type == REG_SZ) {
wsprintf(szData, ClsidEntries[i].szData, szModule);
lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)szData, (lstrlen(szData) + 1) * sizeof(TCHAR));
} else {
lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)ClsidEntries[i].szData, sizeof(DWORD));
}
RegCloseKey(hKey);
}
else
return FALSE;
}
return TRUE;
}
//---------------------------------------------------------------------------
// UnregisterServer
//---------------------------------------------------------------------------
BOOL UnregisterServer() {
TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE];
wsprintf(szKeyTemp, TEXT("*\\shellex\\ContextMenuHandlers\\%s"), szShellExtensionTitle);
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
wsprintf(szKeyTemp, TEXT("Notepad++_file\\shellex\\IconHandler"));
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
wsprintf(szKeyTemp, TEXT("Notepad++_file\\shellex"));
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
wsprintf(szKeyTemp, TEXT("CLSID\\%s\\InprocServer32"), szGUID);
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID);
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
wsprintf(szKeyTemp, TEXT("CLSID\\%s"), szGUID);
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
return TRUE;
}
//---------------------------------------------------------------------------
// MsgBox
//---------------------------------------------------------------------------
void MsgBox(LPTSTR lpszMsg) {
MessageBox(NULL,
lpszMsg,
TEXT("Notepad++ Extension"),
MB_OK);
}
//---------------------------------------------------------------------------
// MsgBoxError
//---------------------------------------------------------------------------
void MsgBoxError(LPTSTR lpszMsg) {
MessageBox(NULL,
lpszMsg,
TEXT("Notepad++ Extension: Error"),
MB_OK | MB_ICONWARNING);
}
//---------------------------------------------------------------------------
// CheckNpp
// Check if the shell handler resides in the same directory as notepad++
//---------------------------------------------------------------------------
BOOL CheckNpp(LPCTSTR path) {
WIN32_FIND_DATA fd;
HANDLE findHandle;
findHandle = FindFirstFile(path, &fd);
if (findHandle == INVALID_HANDLE_VALUE) {
return FALSE;
} else {
FindClose(findHandle);
}
return TRUE;
}
INT_PTR CALLBACK DlgProcSettings(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
static TCHAR customCommand[MAX_PATH] = {0};
static TCHAR customText[TITLE_SIZE] = {0};
static TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE];
static DWORD showMenu = 2; //0 off, 1 on, 2 unknown
static DWORD showIcon = 2;
static DWORD isDynamic = 1; //0 off, 1 on
static DWORD useMenuIcon = 1; // 0 off, otherwise on
static DWORD iconType = 0; //0 classic, 1 modern
HKEY settingKey;
LONG result;
DWORD size = 0;
switch(uMsg) {
case WM_INITDIALOG: {
wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID);
result = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, KEY_READ, &settingKey);
if (result == ERROR_SUCCESS) {
size = sizeof(TCHAR)*TITLE_SIZE;
result = RegQueryValueEx(settingKey, TEXT("Title"), NULL, NULL, (LPBYTE)(customText), &size);
if (result != ERROR_SUCCESS) {
lstrcpyn(customText, szDefaultMenutext, TITLE_SIZE);
}
size = sizeof(TCHAR)*MAX_PATH;
result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, (LPBYTE)(customCommand), &size);
if (result != ERROR_SUCCESS) {
lstrcpyn(customCommand, TEXT(""), MAX_PATH);
}
size = sizeof(DWORD);
result = RegQueryValueEx(settingKey, TEXT("IconID"), NULL, NULL, (BYTE*)(&iconType), &size);
if (result != ERROR_SUCCESS) {
iconType = 0;
}
size = sizeof(DWORD);
result = RegQueryValueEx(settingKey, TEXT("Dynamic"), NULL, NULL, (BYTE*)(&isDynamic), &size);
if (result != ERROR_SUCCESS) {
isDynamic = 1;
}
size = sizeof(DWORD);
result = RegQueryValueEx(settingKey, TEXT("ShowIcon"), NULL, NULL, (BYTE*)(&useMenuIcon), &size);
if (result != ERROR_SUCCESS) {
useMenuIcon = 1;
}
RegCloseKey(settingKey);
}
Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_USECONTEXT), BST_INDETERMINATE);
Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_USEICON), BST_INDETERMINATE);
Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_CONTEXTICON), useMenuIcon?BST_CHECKED:BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hwndDlg, IDC_CHECK_ISDYNAMIC), isDynamic?BST_CHECKED:BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_CLASSIC), iconType!=0?BST_CHECKED:BST_UNCHECKED);
Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO_MODERN), iconType==0?BST_CHECKED:BST_UNCHECKED);
SetDlgItemText(hwndDlg, IDC_EDIT_MENU, customText);
SetDlgItemText(hwndDlg, IDC_EDIT_COMMAND, customCommand);
return TRUE;
break; }
case WM_COMMAND: {
switch(LOWORD(wParam)) {
case IDOK: {
//Store settings
GetDlgItemText(hwndDlg, IDC_EDIT_MENU, customText, TITLE_SIZE);
GetDlgItemText(hwndDlg, IDC_EDIT_COMMAND, customCommand, MAX_PATH);
int textLen = lstrlen(customText);
int commandLen = lstrlen(customCommand);
wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID);
result = RegCreateKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL);
if (result == ERROR_SUCCESS) {
result = RegSetValueEx(settingKey, TEXT("Title"), 0,REG_SZ, (LPBYTE)customText, (textLen+1)*sizeof(TCHAR));
result = RegSetValueEx(settingKey, TEXT("Custom"), 0,REG_SZ, (LPBYTE)customCommand, (commandLen+1)*sizeof(TCHAR));
result = RegSetValueEx(settingKey, TEXT("IconID"), 0, REG_DWORD, (LPBYTE)&iconType, sizeof(DWORD));
result = RegSetValueEx(settingKey, TEXT("Dynamic"), 0, REG_DWORD, (LPBYTE)&isDynamic, sizeof(DWORD));
result = RegSetValueEx(settingKey, TEXT("ShowIcon"), 0, REG_DWORD, (LPBYTE)&useMenuIcon, sizeof(DWORD));
RegCloseKey(settingKey);
}
if (showMenu == 1) {
result = RegCreateKeyEx(HKEY_CLASSES_ROOT, TEXT("*\\shellex\\ContextMenuHandlers\\Notepad++")sz64, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL);
if (result == ERROR_SUCCESS) {
result = RegSetValueEx(settingKey, NULL, 0,REG_SZ, (LPBYTE)szGUID, (lstrlen(szGUID)+1)*sizeof(TCHAR));
RegCloseKey(settingKey);
}
} else if (showMenu == 0) {
wsprintf(szKeyTemp, TEXT("*\\shellex\\ContextMenuHandlers\\%s")sz64, szShellExtensionTitle);
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
}
if (showIcon == 1) {
result = RegCreateKeyEx(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &settingKey, NULL);
if (result == ERROR_SUCCESS) {
result = RegSetValueEx(settingKey, NULL, 0,REG_SZ, (LPBYTE)szGUID, (lstrlen(szGUID)+1)*sizeof(TCHAR));
RegCloseKey(settingKey);
}
} else if (showIcon == 0) {
RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"));
RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex"));
}
PostMessage(hwndDlg, WM_CLOSE, 0, 0);
break; }
case IDC_CHECK_USECONTEXT: {
int state = Button_GetCheck((HWND)lParam);
if (state == BST_CHECKED)
showMenu = 1;
else if (state == BST_UNCHECKED)
showMenu = 0;
else
showMenu = 2;
break; }
case IDC_CHECK_USEICON: {
int state = Button_GetCheck((HWND)lParam);
if (state == BST_CHECKED)
showIcon = 1;
else if (state == BST_UNCHECKED)
showIcon = 0;
else
showIcon = 2;
break; }
case IDC_CHECK_CONTEXTICON: {
int state = Button_GetCheck((HWND)lParam);
if (state == BST_CHECKED)
useMenuIcon = 1;
else
useMenuIcon = 0;
break; }
case IDC_CHECK_ISDYNAMIC: {
int state = Button_GetCheck((HWND)lParam);
if (state == BST_CHECKED)
isDynamic = 1;
else
isDynamic = 0;
break; }
case IDC_RADIO_CLASSIC: {
int state = Button_GetCheck((HWND)lParam);
if (state == BST_CHECKED)
iconType = 1;
else
iconType = 0;
break; }
case IDC_RADIO_MODERN: {
int state = Button_GetCheck((HWND)lParam);
if (state == BST_CHECKED)
iconType = 0;
else
iconType = 1;
break; }
}
return TRUE;
break; }
case WM_CLOSE: {
EndDialog(hwndDlg, 0);
return TRUE;
break; }
}
return FALSE;
}
// --- CShellExtClassFactory ---
CShellExtClassFactory::CShellExtClassFactory() {
m_cRef = 0L;
_cRef++;
}
CShellExtClassFactory::~CShellExtClassFactory() {
_cRef--;
}
// *** IUnknown methods ***
STDMETHODIMP CShellExtClassFactory::QueryInterface(REFIID riid, LPVOID FAR *ppv) {
*ppv = NULL;
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) {
*ppv = (LPCLASSFACTORY)this;
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) CShellExtClassFactory::AddRef() {
return ++m_cRef;
}
STDMETHODIMP_(ULONG) CShellExtClassFactory::Release()
{
if (--m_cRef)
return m_cRef;
delete this;
return 0L;
}
// *** IClassFactory methods ***
STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) {
*ppvObj = NULL;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
CShellExt * pShellExt = new CShellExt();
if (!pShellExt)
return E_OUTOFMEMORY;
return pShellExt->QueryInterface(riid, ppvObj);
}
STDMETHODIMP CShellExtClassFactory::LockServer(BOOL fLock) {
return NOERROR;
}
// --- CShellExt ---
CShellExt::CShellExt() {
TCHAR szKeyTemp [MAX_PATH + GUID_STRING_SIZE];
m_cRef = 0L;
m_pDataObj = NULL;
_cRef++;
m_useCustom = false;
m_nameLength = 0;
m_nameMaxLength = maxText;
m_isDynamic = false;
m_iconID = 0;
m_showIcon = true;
GetModuleFileName(_hModule, m_szModule, MAX_PATH);
HKEY settingKey;
LONG result;
DWORD size = 0;
DWORD dyn = 0, siz = 0, id = 0, showicon;
wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID);
result = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, KEY_READ, &settingKey);
if (result == ERROR_SUCCESS) {
size = sizeof(TCHAR)*TITLE_SIZE;
result = RegQueryValueEx(settingKey, TEXT("Title"), NULL, NULL, (LPBYTE)(m_szMenuTitle), &size);
if (result != ERROR_SUCCESS) {
lstrcpyn(m_szMenuTitle, szDefaultMenutext, TITLE_SIZE);
}
size = sizeof(DWORD);
result = RegQueryValueEx(settingKey, TEXT("IconID"), NULL, NULL, (BYTE*)(&id), &size);
if (result == ERROR_SUCCESS) {
m_iconID = max(0,id);
}
size = sizeof(DWORD);
result = RegQueryValueEx(settingKey, TEXT("Dynamic"), NULL, NULL, (BYTE*)(&dyn), &size);
if (result == ERROR_SUCCESS && dyn != 0) {
m_isDynamic = true;
}
size = sizeof(DWORD);
result = RegQueryValueEx(settingKey, TEXT("Maxtext"), NULL, NULL, (BYTE*)(&siz), &size);
if (result == ERROR_SUCCESS) {
m_nameMaxLength = max(0,siz);
}
size = sizeof(DWORD);
result = RegQueryValueEx(settingKey, TEXT("ShowIcon"), NULL, NULL, (BYTE*)(&showicon), &size);
if (result == ERROR_SUCCESS) {
m_showIcon = (showicon != 0);
}
result = RegQueryValueEx(settingKey, TEXT("CustomIcon"), NULL, NULL, NULL, NULL);
if (result == ERROR_SUCCESS) {
m_useCustom = true;
size = MAX_PATH;
RegQueryValueEx(settingKey, TEXT("CustomIcon"), NULL, NULL, (BYTE*)m_szCustomPath, &size);
}
RegCloseKey(settingKey);
}
}
CShellExt::~CShellExt() {
if (m_pDataObj)
m_pDataObj->Release();
_cRef--;
}
// *** IUnknown methods ***
STDMETHODIMP CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv) {
*ppv = NULL;
if (IsEqualIID(riid, IID_IUnknown)) {
//*ppv = (LPUNKNOWN)this;
*ppv = (LPSHELLEXTINIT)this;
} else if (IsEqualIID(riid, IID_IShellExtInit)) {
*ppv = (LPSHELLEXTINIT)this;
} else if (IsEqualIID(riid, IID_IContextMenu)) {
*ppv = (LPCONTEXTMENU)this;
} else if (IsEqualIID(riid, IID_IContextMenu2)) {
*ppv = (LPCONTEXTMENU2)this;
} else if (IsEqualIID(riid, IID_IContextMenu3)) {
*ppv = (LPCONTEXTMENU3)this;
} else if (IsEqualIID(riid, IID_IPersistFile)) {
*ppv = (LPPERSISTFILE)this;
} else if (IsEqualIID(riid, IID_IExtractIcon)) {
*ppv = (LPEXTRACTICON)this;
}
if (*ppv) {
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) CShellExt::AddRef() {
return ++m_cRef;
}
STDMETHODIMP_(ULONG) CShellExt::Release() {
if (--m_cRef)
return m_cRef;
delete this;
return 0L;
}
// *** IShellExtInit methods ***
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey) {
HRESULT hres = 0;
if (m_pDataObj) {
m_pDataObj->Release();
m_pDataObj = NULL;
}
if (pDataObj) {
m_pDataObj = pDataObj;
pDataObj->AddRef();
}
return NOERROR;
}
// *** IContextMenu methods ***
STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) {
UINT idCmd = idCmdFirst;
DWORD size = TITLE_SIZE;
FORMATETC fmte = {
CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
HRESULT hres = m_pDataObj->GetData(&fmte, &m_stgMedium);
if (SUCCEEDED(hres)) {
if (m_stgMedium.hGlobal)
m_cbFiles = DragQueryFile((HDROP)m_stgMedium.hGlobal, (UINT)-1, 0, 0);
}
UINT nIndex = indexMenu++;
InsertMenu(hMenu, nIndex, MF_STRING|MF_BYPOSITION, idCmd++, m_szMenuTitle);
MENUITEMINFO mii;
ZeroMemory(&mii, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_BITMAP;
mii.hbmpItem = HBMMENU_CALLBACK;
SetMenuItemInfo(hMenu, nIndex, MF_BYPOSITION, &mii);
m_hMenu = hMenu;
m_menuID = idCmd;
return ResultFromShort(idCmd-idCmdFirst);
}
STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) {
HRESULT hr = E_INVALIDARG;
if (!HIWORD(lpcmi->lpVerb)) {
UINT idCmd = LOWORD(lpcmi->lpVerb);
switch(idCmd) {
case 0:
hr = InvokeNPP(lpcmi->hwnd, lpcmi->lpDirectory, lpcmi->lpVerb, lpcmi->lpParameters, lpcmi->nShow);
break;
}
}
return hr;
}
STDMETHODIMP CShellExt::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT FAR *reserved, LPSTR pszName, UINT cchMax) {
LPWSTR wBuffer = (LPWSTR) pszName;
if (uFlags == GCS_HELPTEXTA) {
lstrcpynA(pszName, szHelpTextA, cchMax);
return S_OK;
} else if (uFlags == GCS_HELPTEXTW) {
lstrcpynW(wBuffer, szHelpTextW, cchMax);
return S_OK;
}
return E_NOTIMPL;
}
STDMETHODIMP CShellExt::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) {
//Setup popup menu stuff (ownerdrawn)
DWORD menuIconWidth = GetSystemMetrics(SM_CXMENUCHECK);
DWORD menuIconHeight = GetSystemMetrics(SM_CYMENUCHECK);
DWORD menuIconPadding = 2; //+2 pixels on each side, is this fixed?
switch(uMsg) {
case WM_MEASUREITEM: { //for owner drawn menu
MEASUREITEMSTRUCT * pmis = (MEASUREITEMSTRUCT*) lParam;
//Keep 0, as we use the space used for checkmarks and whatnot
pmis->itemWidth = 0;//menuIconWidth + menuIconPadding;
pmis->itemHeight = 0;//menuItemHeight + menuIconPadding;
if (plResult)
*plResult = TRUE;
break; }
case WM_DRAWITEM: { //for owner drawn menu
//Assumes proper font already been set
DRAWITEMSTRUCT * lpdis = (DRAWITEMSTRUCT*) lParam;
UINT icon = IDI_ICON_NPP_BASE + m_iconID;
if (icon > IDI_ICON_NPP_MAX)
icon = IDI_ICON_NPP_MAX;
if (m_showIcon) {
HICON nppIcon = (HICON)LoadImage(_hModule, MAKEINTRESOURCE(icon), IMAGE_ICON, menuIconWidth, menuIconHeight, 0);
if (m_useCustom) {
HICON customIcon = (HICON)LoadImage(NULL, m_szCustomPath, IMAGE_ICON, menuIconWidth, menuIconHeight, LR_DEFAULTCOLOR|LR_LOADFROMFILE);
if (customIcon != NULL) {
DestroyIcon(nppIcon);
nppIcon = customIcon;
}
}
DrawIconEx(lpdis->hDC, menuIconPadding, menuIconPadding, nppIcon, menuIconWidth, menuIconHeight, 0, NULL, DI_NORMAL);
DestroyIcon(nppIcon);
}
if (plResult)
*plResult = TRUE;
break; }
}
return S_OK;
}
// *** IPersistFile methods ***
HRESULT STDMETHODCALLTYPE CShellExt::Load(LPCOLESTR pszFileName, DWORD dwMode) {
LPTSTR file[MAX_PATH];
#ifdef UNICODE
lstrcpyn((LPWSTR)file, pszFileName, MAX_PATH);
#else
WideCharToMultiByte(CP_ACP, 0, pszFileName, -1, (LPSTR)file, MAX_PATH, NULL, NULL);
#endif
m_szFilePath[0] = 0;
LPTSTR ext = PathFindExtension((LPTSTR)file);
if (ext[0] == '.') {
ext++;
}
int copySize = min(m_nameMaxLength+1, MAX_PATH); //+1 to take zero terminator in account
lstrcpyn(m_szFilePath, ext, copySize);
m_nameLength = lstrlen(m_szFilePath);
return S_OK;
}
// *** IExtractIcon methods ***
STDMETHODIMP CShellExt::GetIconLocation(UINT uFlags, LPTSTR szIconFile, UINT cchMax, int * piIndex, UINT * pwFlags) {
*pwFlags = 0;
if (uFlags & GIL_DEFAULTICON || m_szFilePath[0] == 0 || !m_isDynamic) { //return regular N++ icon if requested OR the extension is bad OR static icon
if (!m_useCustom) {
lstrcpyn(szIconFile, m_szModule, cchMax);
*piIndex = 0;
} else {
lstrcpyn(szIconFile, m_szCustomPath, cchMax);
*piIndex = 0;
}
return S_OK;
}
if(cchMax > 0) {
lstrcpyn(szIconFile, TEXT("NppShellIcon"), cchMax);
int len = lstrlen(szIconFile);
LPTSTR stringEnd = szIconFile+len;
lstrcpyn(szIconFile, m_szFilePath, cchMax-len);
}
*piIndex = 0;
*pwFlags |= GIL_NOTFILENAME;//|GIL_DONTCACHE|GIL_PERINSTANCE;
return S_OK;
}
STDMETHODIMP CShellExt::Extract(LPCTSTR pszFile, UINT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIconSize) {
WORD sizeSmall = HIWORD(nIconSize);
WORD sizeLarge = LOWORD(nIconSize);
ICONINFO iconinfo;
int iconID = IDI_ICON_NPP_BASE + m_iconID;
if (iconID > IDI_ICON_NPP_MAX)
iconID = IDI_ICON_NPP_BASE;
HICON iconSmall = (HICON)LoadImage(_hModule, MAKEINTRESOURCE(iconID), IMAGE_ICON, sizeSmall, sizeSmall, LR_DEFAULTCOLOR);
HICON iconLarge = (HICON)LoadImage(_hModule, MAKEINTRESOURCE(iconID), IMAGE_ICON, sizeLarge, sizeLarge, LR_DEFAULTCOLOR);
*phiconSmall = iconSmall;
*phiconLarge = iconLarge;
if (m_useCustom) {
HICON customSmall = (HICON)LoadImage(NULL, m_szCustomPath, IMAGE_ICON, sizeSmall, sizeSmall, LR_DEFAULTCOLOR|LR_LOADFROMFILE);
HICON customLarge = (HICON)LoadImage(NULL, m_szCustomPath, IMAGE_ICON, sizeLarge, sizeLarge, LR_DEFAULTCOLOR|LR_LOADFROMFILE);
if (customSmall != NULL) {
DestroyIcon(*phiconSmall);
*phiconSmall = customSmall;
}
if (customLarge != NULL) {
DestroyIcon(*phiconLarge);
*phiconLarge = customLarge;
}
}
if (!m_isDynamic)
return S_OK;
HICON newIconLarge;
HDC dcEditColor, dcEditMask;
HGDIOBJ oldBitmapColor, oldBitmapMask, oldFontColor;
HFONT font;
HBRUSH brush;
GetIconInfo(*phiconLarge, &iconinfo);
DestroyIcon(*phiconLarge);
dcEditColor = CreateCompatibleDC(GetDC(0));
dcEditMask = CreateCompatibleDC(GetDC(0));
oldBitmapColor = SelectObject(dcEditColor, iconinfo.hbmColor);
oldBitmapMask = SelectObject(dcEditMask, iconinfo.hbmMask);
LONG calSize = (LONG)(sizeLarge*2/5);
LOGFONT lf = {0};
lf.lfHeight = min(calSize, 15); //this is in pixels. Make no larger than 15 pixels (but smaller is allowed for small icons)
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = DEFAULT_CHARSET;
lstrcpyn(lf.lfFaceName, TEXT("Bitstream Vera Sans Mono"), LF_FACESIZE);
LOGBRUSH lbrush;
lbrush.lbStyle = BS_SOLID;
lbrush.lbHatch = 0;
RECT rect = {0};
COLORREF backGround = RGB(1, 1, 1);
COLORREF textColor = RGB(255,255,255);
//Grab the topleft pixel as the background color
COLORREF maskBack = GetPixel(dcEditColor, 0, 0);
if (backGround == maskBack)
backGround++; //add one, shouldn't be very visible
font = CreateFontIndirect(&lf);
lbrush.lbColor = backGround;
brush = CreateBrushIndirect(&lbrush);
oldFontColor = SelectObject(dcEditColor, font);
SetBkMode(dcEditColor, TRANSPARENT); //dont clear background when drawing text (doesnt change much, colors are the same)
SetBkColor(dcEditColor, backGround);
SetTextColor(dcEditColor, textColor);
SIZE stringSize;
GetTextExtentPoint32(dcEditColor, m_szFilePath, m_nameLength, &stringSize);
stringSize.cx = min(stringSize.cx, sizeLarge-2);
stringSize.cy = min(stringSize.cy, sizeLarge-2);
rect.top = sizeLarge - stringSize.cy - 2;
rect.left = sizeLarge - stringSize.cx - 1;
rect.bottom = sizeLarge;
rect.right = sizeLarge-1;
FillRect(dcEditColor, &rect, brush);
FillRect(dcEditMask, &rect, brush);
rect.top += 1;
rect.left -= 1;
rect.bottom -= 1;
rect.right += 1;
FillRect(dcEditColor, &rect, brush);
FillRect(dcEditMask, &rect, brush);
rect.left += 1;
DrawText(dcEditColor, m_szFilePath, m_nameLength, &rect, DT_BOTTOM|DT_SINGLELINE|DT_LEFT);
SetBkColor(dcEditColor, maskBack);
//BitBlt(dcEditMask, 0, 0, sizeLarge, sizeLarge, dcEditColor, 0, 0, SRCCOPY);
SelectObject(dcEditColor, oldFontColor);
SelectObject(dcEditColor, oldBitmapColor);
SelectObject(dcEditMask, oldBitmapMask);
DeleteDC(dcEditColor);
DeleteDC(dcEditMask);
DeleteBrush(brush);
newIconLarge = CreateIconIndirect(&iconinfo);
*phiconLarge = newIconLarge;
return S_OK;
}
// *** Private methods ***
STDMETHODIMP CShellExt::InvokeNPP(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd) {
TCHAR szFilename[MAX_PATH];
TCHAR szCustom[MAX_PATH];
LPTSTR pszCommand;
size_t bytesRequired = 1;
TCHAR szKeyTemp[MAX_PATH + GUID_STRING_SIZE];
DWORD regSize = 0;
DWORD pathSize = MAX_PATH;
HKEY settingKey;
LONG result;
FORMATETC fmte = {
CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
wsprintf(szKeyTemp, TEXT("CLSID\\%s\\Settings"), szGUID);
result = RegOpenKeyEx(HKEY_CLASSES_ROOT, szKeyTemp, 0, KEY_READ, &settingKey);
if (result != ERROR_SUCCESS) {
MsgBoxError(TEXT("Unable to open registry key."));
return E_FAIL;
}
result = RegQueryValueEx(settingKey, TEXT("Path"), NULL, NULL, NULL, &regSize);
if (result == ERROR_SUCCESS) {
bytesRequired += regSize+2;
} else {
MsgBoxError(TEXT("Cannot read path to executable."));
RegCloseKey(settingKey);
return E_FAIL;
}
result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, NULL, &regSize);
if (result == ERROR_SUCCESS) {
bytesRequired += regSize;
}
for (UINT i = 0; i < m_cbFiles; i++) {
bytesRequired += DragQueryFile((HDROP)m_stgMedium.hGlobal, i, NULL, 0);
bytesRequired += 3;
}
bytesRequired *= sizeof(TCHAR);
pszCommand = (LPTSTR)CoTaskMemAlloc(bytesRequired);
if (!pszCommand) {
MsgBoxError(TEXT("Insufficient memory available."));
RegCloseKey(settingKey);
return E_FAIL;
}
*pszCommand = 0;
regSize = (DWORD)MAX_PATH*sizeof(TCHAR);
result = RegQueryValueEx(settingKey, TEXT("Path"), NULL, NULL, (LPBYTE)(szFilename), &regSize);
szFilename[MAX_PATH-1] = 0;
lstrcat(pszCommand, TEXT("\""));
lstrcat(pszCommand, szFilename);
lstrcat(pszCommand, TEXT("\""));
result = RegQueryValueEx(settingKey, TEXT("Custom"), NULL, NULL, (LPBYTE)(szCustom), &pathSize);
if (result == ERROR_SUCCESS) {
lstrcat(pszCommand, TEXT(" "));
lstrcat(pszCommand, szCustom);
}
RegCloseKey(settingKey);
for (UINT i = 0; i < m_cbFiles; i++) {
DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFilename, MAX_PATH);
lstrcat(pszCommand, TEXT(" \""));
lstrcat(pszCommand, szFilename);
lstrcat(pszCommand, TEXT("\""));
}
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = iShowCmd; //SW_RESTORE;
if (!CreateProcess (NULL, pszCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
DWORD errorCode = GetLastError();
TCHAR * message = new TCHAR[512+bytesRequired];
wsprintf(message, TEXT("Error in CreateProcess (%d): Is this command correct?\r\n%s"), errorCode, pszCommand);
MsgBoxError(message);
delete [] message;
}
CoTaskMemFree(pszCommand);
return NOERROR;
}

View File

@ -0,0 +1,118 @@
//---------------------------------------------------------------------------
// Copyright 2002-2003 by Andre Burgaud <andre@burgaud.com>
// Copyright 2009 by Harry <harrybharry@users.sourceforge.net>
// See license.txt
//---------------------------------------------------------------------------
#ifndef STRICT
#define STRICT
#endif
#define INC_OLE2
#include <windows.h>
#include <windowsx.h>
#include <shlobj.h>
#include <shlwapi.h>
#define GUID_SIZE 128
#define GUID_STRING_SIZE 40
#define TITLE_SIZE 64
#ifdef ARRAYSIZE
#undef ARRAYSIZE
#endif
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
#define MAX_CMD_LENGTH 32767
#define ResultFromShort(i) ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i)))
#define INITGUID
#include <initguid.h>
#include <shlguid.h>
#ifdef WIN64
// {B298D29A-A6ED-11DE-BA8C-A68E55D89593}
DEFINE_GUID(CLSID_ShellExtension, 0xB298D29A, 0xA6ED, 0x11DE, 0xBA, 0x8C, 0xA6, 0x8E, 0x55, 0xD8, 0x95, 0x93);
TCHAR szGUID[] = TEXT("{B298D29A-A6ED-11DE-BA8C-A68E55D89593}");
#else
// {00F3C2EC-A6EE-11DE-A03A-EF8F55D89593}
DEFINE_GUID(CLSID_ShellExtension, 0x00F3C2EC, 0xA6EE, 0x11DE, 0xA0, 0x3A, 0xEF, 0x8F, 0x55, 0xD8, 0x95, 0x93);
TCHAR szGUID[] = TEXT("{00F3C2EC-A6EE-11DE-A03A-EF8F55D89593}");
#endif
class CShellExtClassFactory : public IClassFactory {
protected:
ULONG m_cRef;
public:
CShellExtClassFactory();
~CShellExtClassFactory();
// *** IUnknown methods ***
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// *** IClassFactory methods ***
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
STDMETHODIMP LockServer(BOOL);
};
class CShellExt : public IContextMenu3, IShellExtInit, IPersistFile, IExtractIcon {
private:
//
ULONG m_cRef;
// Menu variables
UINT m_cbFiles;
STGMEDIUM m_stgMedium;
LPDATAOBJECT m_pDataObj;
TCHAR m_szDllDir[MAX_PATH];
TCHAR m_szMenuTitle[TITLE_SIZE];
UINT m_menuID;
HMENU m_hMenu;
bool m_showIcon;
// Icon variables
TCHAR m_szFilePath[MAX_PATH];
TCHAR m_szModule[MAX_PATH];
TCHAR m_szCustomPath[MAX_PATH];
bool m_useCustom;
int m_nameLength;
int m_nameMaxLength;
bool m_isDynamic;
int m_iconID;
// *** Private methods ***
STDMETHODIMP InvokeNPP(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
public:
CShellExt();
~CShellExt();
// *** IUnknown methods ***
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// *** IShellExtInit methods ***
STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID);
// *** IContextMenu methods ***
STDMETHODIMP QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
STDMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT FAR *reserved, LPSTR pszName, UINT cchMax);
STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam) { return HandleMenuMsg2(uMsg, wParam, lParam, NULL); };
STDMETHODIMP HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
// *** IPersistFile methods ***
STDMETHODIMP GetClassID(CLSID *pClassID) { return E_NOTIMPL; };
STDMETHODIMP IsDirty(void) { return E_NOTIMPL; };
STDMETHODIMP Save(LPCOLESTR pszFileName, BOOL fRemember) { return E_NOTIMPL; };
STDMETHODIMP SaveCompleted(LPCOLESTR pszFileName) { return E_NOTIMPL; };
STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName) { return E_NOTIMPL; };
STDMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwMode);
// *** IExtractIcon methods ***
STDMETHODIMP GetIconLocation(UINT uFlags, LPTSTR szIconFile, UINT cchMax, int * piIndex, UINT * pwFlags);
STDMETHODIMP Extract(LPCTSTR pszFile, UINT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIconSize);
};

View File

@ -0,0 +1,143 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,0,0
PRODUCTVERSION 0,1,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x3L
#else
FILEFLAGS 0x2L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
#ifdef WIN64
VALUE "FileDescription", "ShellHandler for Notepad++ (64 bit)"
#else
VALUE "FileDescription", "ShellHandler for Notepad++"
#endif
VALUE "FileVersion", "0.1"
VALUE "LegalCopyright", "Copyright © 2008"
#ifdef WIN64
VALUE "OriginalFilename", "NppShell64.dll"
#else
VALUE "OriginalFilename", "NppShell.dll"
#endif
VALUE "ProductVersion", "0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON_NPP_0 ICON "icon\\npp_0.ico"
IDI_ICON_NPP_1 ICON "icon\\npp_1.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP_NPP BITMAP "bitmap\\npp.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG_SETTINGS DIALOGEX 0, 0, 286, 149
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "NppShell Settings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Context Menu",IDC_STATIC,6,6,132,114
CONTROL "Add context menu item",IDC_CHECK_USECONTEXT,"Button",BS_AUTO3STATE | WS_TABSTOP,18,24,90,10
CONTROL "Show icon",IDC_CHECK_CONTEXTICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,42,48,10
LTEXT "Menu text",IDC_STATIC,18,54,34,8
EDITTEXT IDC_EDIT_MENU,24,66,102,14,ES_AUTOHSCROLL
LTEXT "Command line params",IDC_STATIC,18,84,70,8
EDITTEXT IDC_EDIT_COMMAND,24,96,102,14,ES_AUTOHSCROLL
GROUPBOX "Dynamic Icon",IDC_STATIC,144,6,132,114
CONTROL "Show dynamic icon",IDC_CHECK_USEICON,"Button",BS_AUTO3STATE | WS_TABSTOP,156,24,76,10
CONTROL "Show extension",IDC_CHECK_ISDYNAMIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,42,67,10
CONTROL "Use classic icon",IDC_RADIO_CLASSIC,"Button",BS_AUTORADIOBUTTON | WS_GROUP,156,60,65,10
CONTROL "Use modern icon",IDC_RADIO_MODERN,"Button",BS_AUTORADIOBUTTON,156,72,69,10
DEFPUSHBUTTON "Apply",IDOK,222,126,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG_SETTINGS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 279
TOPMARGIN, 7
BOTTOMMARGIN, 142
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,809 @@
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#ifndef __AFXRES_H__
#define __AFXRES_H__
#ifdef RC_INVOKED
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
#include "winres.h" // extract from windows header
#endif
#endif
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif
#ifdef APSTUDIO_INVOKED
#define APSTUDIO_HIDDEN_SYMBOLS
#endif
/////////////////////////////////////////////////////////////////////////////
// MFC resource types (see Technical note TN024 for implementation details)
#ifndef RC_INVOKED
#define RT_DLGINIT MAKEINTRESOURCE(240)
#define RT_TOOLBAR MAKEINTRESOURCE(241)
#endif
/////////////////////////////////////////////////////////////////////////////
#ifdef APSTUDIO_INVOKED
#undef APSTUDIO_HIDDEN_SYMBOLS
#endif
/////////////////////////////////////////////////////////////////////////////
// General style bits etc
// ControlBar styles
#define CBRS_ALIGN_LEFT 0x1000L
#define CBRS_ALIGN_TOP 0x2000L
#define CBRS_ALIGN_RIGHT 0x4000L
#define CBRS_ALIGN_BOTTOM 0x8000L
#define CBRS_ALIGN_ANY 0xF000L
#define CBRS_BORDER_LEFT 0x0100L
#define CBRS_BORDER_TOP 0x0200L
#define CBRS_BORDER_RIGHT 0x0400L
#define CBRS_BORDER_BOTTOM 0x0800L
#define CBRS_BORDER_ANY 0x0F00L
#define CBRS_TOOLTIPS 0x0010L
#define CBRS_FLYBY 0x0020L
#define CBRS_FLOAT_MULTI 0x0040L
#define CBRS_BORDER_3D 0x0080L
#define CBRS_HIDE_INPLACE 0x0008L
#define CBRS_SIZE_DYNAMIC 0x0004L
#define CBRS_SIZE_FIXED 0x0002L
#define CBRS_FLOATING 0x0001L
#define CBRS_GRIPPER 0x00400000L
#define CBRS_ORIENT_HORZ (CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM)
#define CBRS_ORIENT_VERT (CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT)
#define CBRS_ORIENT_ANY (CBRS_ORIENT_HORZ|CBRS_ORIENT_VERT)
#define CBRS_ALL 0x0040FFFFL
// the CBRS_ style is made up of an alignment style and a draw border style
// the alignment styles are mutually exclusive
// the draw border styles may be combined
#define CBRS_NOALIGN 0x00000000L
#define CBRS_LEFT (CBRS_ALIGN_LEFT|CBRS_BORDER_RIGHT)
#define CBRS_TOP (CBRS_ALIGN_TOP|CBRS_BORDER_BOTTOM)
#define CBRS_RIGHT (CBRS_ALIGN_RIGHT|CBRS_BORDER_LEFT)
#define CBRS_BOTTOM (CBRS_ALIGN_BOTTOM|CBRS_BORDER_TOP)
/////////////////////////////////////////////////////////////////////////////
// Standard window components
// Mode indicators in status bar - these are routed like commands
#define ID_INDICATOR_EXT 0xE700 // extended selection indicator
#define ID_INDICATOR_CAPS 0xE701 // cap lock indicator
#define ID_INDICATOR_NUM 0xE702 // num lock indicator
#define ID_INDICATOR_SCRL 0xE703 // scroll lock indicator
#define ID_INDICATOR_OVR 0xE704 // overtype mode indicator
#define ID_INDICATOR_REC 0xE705 // record mode indicator
#define ID_INDICATOR_KANA 0xE706 // kana lock indicator
#define ID_SEPARATOR 0 // special separator value
#ifndef RC_INVOKED // code only
// Standard control bars (IDW = window ID)
#define AFX_IDW_CONTROLBAR_FIRST 0xE800
#define AFX_IDW_CONTROLBAR_LAST 0xE8FF
#define AFX_IDW_TOOLBAR 0xE800 // main Toolbar for window
#define AFX_IDW_STATUS_BAR 0xE801 // Status bar window
#define AFX_IDW_PREVIEW_BAR 0xE802 // PrintPreview Dialog Bar
#define AFX_IDW_RESIZE_BAR 0xE803 // OLE in-place resize bar
#define AFX_IDW_REBAR 0xE804 // COMCTL32 "rebar" Bar
#define AFX_IDW_DIALOGBAR 0xE805 // CDialogBar
// Note: If your application supports docking toolbars, you should
// not use the following IDs for your own toolbars. The IDs chosen
// are at the top of the first 32 such that the bars will be hidden
// while in print preview mode, and are not likely to conflict with
// IDs your application may have used succesfully in the past.
#define AFX_IDW_DOCKBAR_TOP 0xE81B
#define AFX_IDW_DOCKBAR_LEFT 0xE81C
#define AFX_IDW_DOCKBAR_RIGHT 0xE81D
#define AFX_IDW_DOCKBAR_BOTTOM 0xE81E
#define AFX_IDW_DOCKBAR_FLOAT 0xE81F
// Macro for mapping standard control bars to bitmask (limit of 32)
#define AFX_CONTROLBAR_MASK(nIDC) (1L << (nIDC - AFX_IDW_CONTROLBAR_FIRST))
// parts of Main Frame
#define AFX_IDW_PANE_FIRST 0xE900 // first pane (256 max)
#define AFX_IDW_PANE_LAST 0xE9ff
#define AFX_IDW_HSCROLL_FIRST 0xEA00 // first Horz scrollbar (16 max)
#define AFX_IDW_VSCROLL_FIRST 0xEA10 // first Vert scrollbar (16 max)
#define AFX_IDW_SIZE_BOX 0xEA20 // size box for splitters
#define AFX_IDW_PANE_SAVE 0xEA21 // to shift AFX_IDW_PANE_FIRST
#endif //!RC_INVOKED
#ifndef APSTUDIO_INVOKED
// common style for form views
#define AFX_WS_DEFAULT_VIEW (WS_CHILD | WS_VISIBLE | WS_BORDER)
#endif //!APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Standard app configurable strings
// for application title (defaults to EXE name or name in constructor)
#define AFX_IDS_APP_TITLE 0xE000
// idle message bar line
#define AFX_IDS_IDLEMESSAGE 0xE001
// message bar line when in shift-F1 help mode
#define AFX_IDS_HELPMODEMESSAGE 0xE002
// document title when editing OLE embedding
#define AFX_IDS_APP_TITLE_EMBEDDING 0xE003
// company name
#define AFX_IDS_COMPANY_NAME 0xE004
// object name when server is inplace
#define AFX_IDS_OBJ_TITLE_INPLACE 0xE005
/////////////////////////////////////////////////////////////////////////////
// Standard Commands
// File commands
#define ID_FILE_NEW 0xE100
#define ID_FILE_OPEN 0xE101
#define ID_FILE_CLOSE 0xE102
#define ID_FILE_SAVE 0xE103
#define ID_FILE_SAVE_AS 0xE104
#define ID_FILE_PAGE_SETUP 0xE105
#define ID_FILE_PRINT_SETUP 0xE106
#define ID_FILE_PRINT 0xE107
#define ID_FILE_PRINT_DIRECT 0xE108
#define ID_FILE_PRINT_PREVIEW 0xE109
#define ID_FILE_UPDATE 0xE10A
#define ID_FILE_SAVE_COPY_AS 0xE10B
#define ID_FILE_SEND_MAIL 0xE10C
#define ID_FILE_NEW_FRAME 0xE10D
#define ID_FILE_MRU_FIRST 0xE110
#define ID_FILE_MRU_FILE1 0xE110 // range - 16 max
#define ID_FILE_MRU_FILE2 0xE111
#define ID_FILE_MRU_FILE3 0xE112
#define ID_FILE_MRU_FILE4 0xE113
#define ID_FILE_MRU_FILE5 0xE114
#define ID_FILE_MRU_FILE6 0xE115
#define ID_FILE_MRU_FILE7 0xE116
#define ID_FILE_MRU_FILE8 0xE117
#define ID_FILE_MRU_FILE9 0xE118
#define ID_FILE_MRU_FILE10 0xE119
#define ID_FILE_MRU_FILE11 0xE11A
#define ID_FILE_MRU_FILE12 0xE11B
#define ID_FILE_MRU_FILE13 0xE11C
#define ID_FILE_MRU_FILE14 0xE11D
#define ID_FILE_MRU_FILE15 0xE11E
#define ID_FILE_MRU_FILE16 0xE11F
#define ID_FILE_MRU_LAST 0xE11F
// Edit commands
#define ID_EDIT_CLEAR 0xE120
#define ID_EDIT_CLEAR_ALL 0xE121
#define ID_EDIT_COPY 0xE122
#define ID_EDIT_CUT 0xE123
#define ID_EDIT_FIND 0xE124
#define ID_EDIT_PASTE 0xE125
#define ID_EDIT_PASTE_LINK 0xE126
#define ID_EDIT_PASTE_SPECIAL 0xE127
#define ID_EDIT_REPEAT 0xE128
#define ID_EDIT_REPLACE 0xE129
#define ID_EDIT_SELECT_ALL 0xE12A
#define ID_EDIT_UNDO 0xE12B
#define ID_EDIT_REDO 0xE12C
// Window commands
#define ID_WINDOW_NEW 0xE130
#define ID_WINDOW_ARRANGE 0xE131
#define ID_WINDOW_CASCADE 0xE132
#define ID_WINDOW_TILE_HORZ 0xE133
#define ID_WINDOW_TILE_VERT 0xE134
#define ID_WINDOW_SPLIT 0xE135
#ifndef RC_INVOKED // code only
#define AFX_IDM_WINDOW_FIRST 0xE130
#define AFX_IDM_WINDOW_LAST 0xE13F
#define AFX_IDM_FIRST_MDICHILD 0xFF00 // window list starts here
#endif //!RC_INVOKED
// Help and App commands
#define ID_APP_ABOUT 0xE140
#define ID_APP_EXIT 0xE141
#define ID_HELP_INDEX 0xE142
#define ID_HELP_FINDER 0xE143
#define ID_HELP_USING 0xE144
#define ID_CONTEXT_HELP 0xE145 // shift-F1
// special commands for processing help
#define ID_HELP 0xE146 // first attempt for F1
#define ID_DEFAULT_HELP 0xE147 // last attempt
// Misc
#define ID_NEXT_PANE 0xE150
#define ID_PREV_PANE 0xE151
// Format
#define ID_FORMAT_FONT 0xE160
// OLE commands
#define ID_OLE_INSERT_NEW 0xE200
#define ID_OLE_EDIT_LINKS 0xE201
#define ID_OLE_EDIT_CONVERT 0xE202
#define ID_OLE_EDIT_CHANGE_ICON 0xE203
#define ID_OLE_EDIT_PROPERTIES 0xE204
#define ID_OLE_VERB_FIRST 0xE210 // range - 16 max
#ifndef RC_INVOKED // code only
#define ID_OLE_VERB_LAST 0xE21F
#endif //!RC_INVOKED
// for print preview dialog bar
#define AFX_ID_PREVIEW_CLOSE 0xE300
#define AFX_ID_PREVIEW_NUMPAGE 0xE301 // One/Two Page button
#define AFX_ID_PREVIEW_NEXT 0xE302
#define AFX_ID_PREVIEW_PREV 0xE303
#define AFX_ID_PREVIEW_PRINT 0xE304
#define AFX_ID_PREVIEW_ZOOMIN 0xE305
#define AFX_ID_PREVIEW_ZOOMOUT 0xE306
// View commands (same number used as IDW used for control bar)
#define ID_VIEW_TOOLBAR 0xE800
#define ID_VIEW_STATUS_BAR 0xE801
#define ID_VIEW_REBAR 0xE804
#define ID_VIEW_AUTOARRANGE 0xE805
// E810 -> E81F must be kept in order for RANGE macros
#define ID_VIEW_SMALLICON 0xE810
#define ID_VIEW_LARGEICON 0xE811
#define ID_VIEW_LIST 0xE812
#define ID_VIEW_DETAILS 0xE813
#define ID_VIEW_LINEUP 0xE814
#define ID_VIEW_BYNAME 0xE815
#define AFX_ID_VIEW_MINIMUM ID_VIEW_SMALLICON
#define AFX_ID_VIEW_MAXIMUM ID_VIEW_BYNAME
// E800 -> E8FF reserved for other control bar commands
// RecordForm commands
#define ID_RECORD_FIRST 0xE900
#define ID_RECORD_LAST 0xE901
#define ID_RECORD_NEXT 0xE902
#define ID_RECORD_PREV 0xE903
/////////////////////////////////////////////////////////////////////////////
// Standard control IDs
#ifdef IDC_STATIC
#undef IDC_STATIC
#endif
#define IDC_STATIC (-1) // all static controls
/////////////////////////////////////////////////////////////////////////////
// Standard string error/warnings
#ifndef RC_INVOKED // code only
#define AFX_IDS_SCFIRST 0xEF00
#endif //!RC_INVOKED
#define AFX_IDS_SCSIZE 0xEF00
#define AFX_IDS_SCMOVE 0xEF01
#define AFX_IDS_SCMINIMIZE 0xEF02
#define AFX_IDS_SCMAXIMIZE 0xEF03
#define AFX_IDS_SCNEXTWINDOW 0xEF04
#define AFX_IDS_SCPREVWINDOW 0xEF05
#define AFX_IDS_SCCLOSE 0xEF06
#define AFX_IDS_SCRESTORE 0xEF12
#define AFX_IDS_SCTASKLIST 0xEF13
#define AFX_IDS_MDICHILD 0xEF1F
#define AFX_IDS_DESKACCESSORY 0xEFDA
// General strings
#define AFX_IDS_OPENFILE 0xF000
#define AFX_IDS_SAVEFILE 0xF001
#define AFX_IDS_ALLFILTER 0xF002
#define AFX_IDS_UNTITLED 0xF003
#define AFX_IDS_SAVEFILECOPY 0xF004
#define AFX_IDS_PREVIEW_CLOSE 0xF005
#define AFX_IDS_UNNAMED_FILE 0xF006
#define AFX_IDS_HIDE 0xF011
// MFC Standard Exception Error messages
#define AFX_IDP_NO_ERROR_AVAILABLE 0xF020
#define AFX_IDS_NOT_SUPPORTED_EXCEPTION 0xF021
#define AFX_IDS_RESOURCE_EXCEPTION 0xF022
#define AFX_IDS_MEMORY_EXCEPTION 0xF023
#define AFX_IDS_USER_EXCEPTION 0xF024
#define AFX_IDS_INVALID_ARG_EXCEPTION 0xF025
// Printing and print preview strings
#define AFX_IDS_PRINTONPORT 0xF040
#define AFX_IDS_ONEPAGE 0xF041
#define AFX_IDS_TWOPAGE 0xF042
#define AFX_IDS_PRINTPAGENUM 0xF043
#define AFX_IDS_PREVIEWPAGEDESC 0xF044
#define AFX_IDS_PRINTDEFAULTEXT 0xF045
#define AFX_IDS_PRINTDEFAULT 0xF046
#define AFX_IDS_PRINTFILTER 0xF047
#define AFX_IDS_PRINTCAPTION 0xF048
#define AFX_IDS_PRINTTOFILE 0xF049
// OLE strings
#define AFX_IDS_OBJECT_MENUITEM 0xF080
#define AFX_IDS_EDIT_VERB 0xF081
#define AFX_IDS_ACTIVATE_VERB 0xF082
#define AFX_IDS_CHANGE_LINK 0xF083
#define AFX_IDS_AUTO 0xF084
#define AFX_IDS_MANUAL 0xF085
#define AFX_IDS_FROZEN 0xF086
#define AFX_IDS_ALL_FILES 0xF087
// dynamically changing menu items
#define AFX_IDS_SAVE_MENU 0xF088
#define AFX_IDS_UPDATE_MENU 0xF089
#define AFX_IDS_SAVE_AS_MENU 0xF08A
#define AFX_IDS_SAVE_COPY_AS_MENU 0xF08B
#define AFX_IDS_EXIT_MENU 0xF08C
#define AFX_IDS_UPDATING_ITEMS 0xF08D
// COlePasteSpecialDialog defines
#define AFX_IDS_METAFILE_FORMAT 0xF08E
#define AFX_IDS_DIB_FORMAT 0xF08F
#define AFX_IDS_BITMAP_FORMAT 0xF090
#define AFX_IDS_LINKSOURCE_FORMAT 0xF091
#define AFX_IDS_EMBED_FORMAT 0xF092
// other OLE utility strings
#define AFX_IDS_PASTELINKEDTYPE 0xF094
#define AFX_IDS_UNKNOWNTYPE 0xF095
#define AFX_IDS_RTF_FORMAT 0xF096
#define AFX_IDS_TEXT_FORMAT 0xF097
// OLE datatype format error strings
#define AFX_IDS_INVALID_CURRENCY 0xF098
#define AFX_IDS_INVALID_DATETIME 0xF099
#define AFX_IDS_INVALID_DATETIMESPAN 0xF09A
// General error / prompt strings
#define AFX_IDP_INVALID_FILENAME 0xF100
#define AFX_IDP_FAILED_TO_OPEN_DOC 0xF101
#define AFX_IDP_FAILED_TO_SAVE_DOC 0xF102
#define AFX_IDP_ASK_TO_SAVE 0xF103
#define AFX_IDP_FAILED_TO_CREATE_DOC 0xF104
#define AFX_IDP_FILE_TOO_LARGE 0xF105
#define AFX_IDP_FAILED_TO_START_PRINT 0xF106
#define AFX_IDP_FAILED_TO_LAUNCH_HELP 0xF107
#define AFX_IDP_INTERNAL_FAILURE 0xF108 // general failure
#define AFX_IDP_COMMAND_FAILURE 0xF109 // command failure
#define AFX_IDP_FAILED_MEMORY_ALLOC 0xF10A
#define AFX_IDP_UNREG_DONE 0xF10B
#define AFX_IDP_UNREG_FAILURE 0xF10C
#define AFX_IDP_DLL_LOAD_FAILED 0xF10D
#define AFX_IDP_DLL_BAD_VERSION 0xF10E
// DDV parse errors
#define AFX_IDP_PARSE_INT 0xF110
#define AFX_IDP_PARSE_REAL 0xF111
#define AFX_IDP_PARSE_INT_RANGE 0xF112
#define AFX_IDP_PARSE_REAL_RANGE 0xF113
#define AFX_IDP_PARSE_STRING_SIZE 0xF114
#define AFX_IDP_PARSE_RADIO_BUTTON 0xF115
#define AFX_IDP_PARSE_BYTE 0xF116
#define AFX_IDP_PARSE_UINT 0xF117
#define AFX_IDP_PARSE_DATETIME 0xF118
#define AFX_IDP_PARSE_CURRENCY 0xF119
#define AFX_IDP_PARSE_GUID 0xF11A
#define AFX_IDP_PARSE_TIME 0xF11B
#define AFX_IDP_PARSE_DATE 0xF11C
// CFile/CArchive error strings for user failure
#define AFX_IDP_FAILED_INVALID_FORMAT 0xF120
#define AFX_IDP_FAILED_INVALID_PATH 0xF121
#define AFX_IDP_FAILED_DISK_FULL 0xF122
#define AFX_IDP_FAILED_ACCESS_READ 0xF123
#define AFX_IDP_FAILED_ACCESS_WRITE 0xF124
#define AFX_IDP_FAILED_IO_ERROR_READ 0xF125
#define AFX_IDP_FAILED_IO_ERROR_WRITE 0xF126
// Script errors / prompt strings
#define AFX_IDP_SCRIPT_ERROR 0xF130
#define AFX_IDP_SCRIPT_DISPATCH_EXCEPTION 0xF131
// OLE errors / prompt strings
#define AFX_IDP_STATIC_OBJECT 0xF180
#define AFX_IDP_FAILED_TO_CONNECT 0xF181
#define AFX_IDP_SERVER_BUSY 0xF182
#define AFX_IDP_BAD_VERB 0xF183
#define AFX_IDS_NOT_DOCOBJECT 0xF184
#define AFX_IDP_FAILED_TO_NOTIFY 0xF185
#define AFX_IDP_FAILED_TO_LAUNCH 0xF186
#define AFX_IDP_ASK_TO_UPDATE 0xF187
#define AFX_IDP_FAILED_TO_UPDATE 0xF188
#define AFX_IDP_FAILED_TO_REGISTER 0xF189
#define AFX_IDP_FAILED_TO_AUTO_REGISTER 0xF18A
#define AFX_IDP_FAILED_TO_CONVERT 0xF18B
#define AFX_IDP_GET_NOT_SUPPORTED 0xF18C
#define AFX_IDP_SET_NOT_SUPPORTED 0xF18D
#define AFX_IDP_ASK_TO_DISCARD 0xF18E
#define AFX_IDP_FAILED_TO_CREATE 0xF18F
// MAPI errors / prompt strings
#define AFX_IDP_FAILED_MAPI_LOAD 0xF190
#define AFX_IDP_INVALID_MAPI_DLL 0xF191
#define AFX_IDP_FAILED_MAPI_SEND 0xF192
#define AFX_IDP_FILE_NONE 0xF1A0
#define AFX_IDP_FILE_GENERIC 0xF1A1
#define AFX_IDP_FILE_NOT_FOUND 0xF1A2
#define AFX_IDP_FILE_BAD_PATH 0xF1A3
#define AFX_IDP_FILE_TOO_MANY_OPEN 0xF1A4
#define AFX_IDP_FILE_ACCESS_DENIED 0xF1A5
#define AFX_IDP_FILE_INVALID_FILE 0xF1A6
#define AFX_IDP_FILE_REMOVE_CURRENT 0xF1A7
#define AFX_IDP_FILE_DIR_FULL 0xF1A8
#define AFX_IDP_FILE_BAD_SEEK 0xF1A9
#define AFX_IDP_FILE_HARD_IO 0xF1AA
#define AFX_IDP_FILE_SHARING 0xF1AB
#define AFX_IDP_FILE_LOCKING 0xF1AC
#define AFX_IDP_FILE_DISKFULL 0xF1AD
#define AFX_IDP_FILE_EOF 0xF1AE
#define AFX_IDP_ARCH_NONE 0xF1B0
#define AFX_IDP_ARCH_GENERIC 0xF1B1
#define AFX_IDP_ARCH_READONLY 0xF1B2
#define AFX_IDP_ARCH_ENDOFFILE 0xF1B3
#define AFX_IDP_ARCH_WRITEONLY 0xF1B4
#define AFX_IDP_ARCH_BADINDEX 0xF1B5
#define AFX_IDP_ARCH_BADCLASS 0xF1B6
#define AFX_IDP_ARCH_BADSCHEMA 0xF1B7
#define AFX_IDS_OCC_SCALEUNITS_PIXELS 0xF1C0
// 0xf200-0xf20f reserved
// font names and point sizes
#define AFX_IDS_STATUS_FONT 0xF230
#define AFX_IDS_TOOLTIP_FONT 0xF231
#define AFX_IDS_UNICODE_FONT 0xF232
#define AFX_IDS_MINI_FONT 0xF233
// ODBC Database errors / prompt strings
#ifndef RC_INVOKED // code only
#define AFX_IDP_SQL_FIRST 0xF280
#endif //!RC_INVOKED
#define AFX_IDP_SQL_CONNECT_FAIL 0xF281
#define AFX_IDP_SQL_RECORDSET_FORWARD_ONLY 0xF282
#define AFX_IDP_SQL_EMPTY_COLUMN_LIST 0xF283
#define AFX_IDP_SQL_FIELD_SCHEMA_MISMATCH 0xF284
#define AFX_IDP_SQL_ILLEGAL_MODE 0xF285
#define AFX_IDP_SQL_MULTIPLE_ROWS_AFFECTED 0xF286
#define AFX_IDP_SQL_NO_CURRENT_RECORD 0xF287
#define AFX_IDP_SQL_NO_ROWS_AFFECTED 0xF288
#define AFX_IDP_SQL_RECORDSET_READONLY 0xF289
#define AFX_IDP_SQL_SQL_NO_TOTAL 0xF28A
#define AFX_IDP_SQL_ODBC_LOAD_FAILED 0xF28B
#define AFX_IDP_SQL_DYNASET_NOT_SUPPORTED 0xF28C
#define AFX_IDP_SQL_SNAPSHOT_NOT_SUPPORTED 0xF28D
#define AFX_IDP_SQL_API_CONFORMANCE 0xF28E
#define AFX_IDP_SQL_SQL_CONFORMANCE 0xF28F
#define AFX_IDP_SQL_NO_DATA_FOUND 0xF290
#define AFX_IDP_SQL_ROW_UPDATE_NOT_SUPPORTED 0xF291
#define AFX_IDP_SQL_ODBC_V2_REQUIRED 0xF292
#define AFX_IDP_SQL_NO_POSITIONED_UPDATES 0xF293
#define AFX_IDP_SQL_LOCK_MODE_NOT_SUPPORTED 0xF294
#define AFX_IDP_SQL_DATA_TRUNCATED 0xF295
#define AFX_IDP_SQL_ROW_FETCH 0xF296
#define AFX_IDP_SQL_INCORRECT_ODBC 0xF297
#define AFX_IDP_SQL_UPDATE_DELETE_FAILED 0xF298
#define AFX_IDP_SQL_DYNAMIC_CURSOR_NOT_SUPPORTED 0xF299
#define AFX_IDP_SQL_FIELD_NOT_FOUND 0xF29A
#define AFX_IDP_SQL_BOOKMARKS_NOT_SUPPORTED 0xF29B
#define AFX_IDP_SQL_BOOKMARKS_NOT_ENABLED 0xF29C
// ODBC Database strings
#define AFX_IDS_DELETED 0xF29D
// DAO Database errors / prompt strings
#ifndef RC_INVOKED // code only
#define AFX_IDP_DAO_FIRST 0xF2B0
#endif //!RC_INVOKED
#define AFX_IDP_DAO_ENGINE_INITIALIZATION 0xF2B0
#define AFX_IDP_DAO_DFX_BIND 0xF2B1
#define AFX_IDP_DAO_OBJECT_NOT_OPEN 0xF2B2
// ICDAORecordset::GetRows Errors
// These are not placed in DAO Errors collection
// and must be handled directly by MFC.
#define AFX_IDP_DAO_ROWTOOSHORT 0xF2B3
#define AFX_IDP_DAO_BADBINDINFO 0xF2B4
#define AFX_IDP_DAO_COLUMNUNAVAILABLE 0xF2B5
/////////////////////////////////////////////////////////////////////////////
// Strings for ISAPI support
#define AFX_IDS_HTTP_TITLE 0xF2D1
#define AFX_IDS_HTTP_NO_TEXT 0xF2D2
#define AFX_IDS_HTTP_BAD_REQUEST 0xF2D3
#define AFX_IDS_HTTP_AUTH_REQUIRED 0xF2D4
#define AFX_IDS_HTTP_FORBIDDEN 0xF2D5
#define AFX_IDS_HTTP_NOT_FOUND 0xF2D6
#define AFX_IDS_HTTP_SERVER_ERROR 0xF2D7
#define AFX_IDS_HTTP_NOT_IMPLEMENTED 0xF2D8
/////////////////////////////////////////////////////////////////////////////
// Strings for Accessibility support for CCheckListBox
#define AFX_IDS_CHECKLISTBOX_UNCHECK 0xF2E1
#define AFX_IDS_CHECKLISTBOX_CHECK 0xF2E2
#define AFX_IDS_CHECKLISTBOX_MIXED 0xF2E3
/////////////////////////////////////////////////////////////////////////////
// AFX implementation - control IDs (AFX_IDC)
// Parts of dialogs
#define AFX_IDC_LISTBOX 100
#define AFX_IDC_CHANGE 101
#define AFX_IDC_BROWSER 102
// for print dialog
#define AFX_IDC_PRINT_DOCNAME 201
#define AFX_IDC_PRINT_PRINTERNAME 202
#define AFX_IDC_PRINT_PORTNAME 203
#define AFX_IDC_PRINT_PAGENUM 204
// Property Sheet control id's (determined with Spy++)
#define ID_APPLY_NOW 0x3021
#define ID_WIZBACK 0x3023
#define ID_WIZNEXT 0x3024
#define ID_WIZFINISH 0x3025
#define AFX_IDC_TAB_CONTROL 0x3020
/////////////////////////////////////////////////////////////////////////////
// IDRs for standard components
#ifndef RC_INVOKED // code only
// These are really COMMDLG dialogs, so there usually isn't a resource
// for them, but these IDs are used as help IDs.
#define AFX_IDD_FILEOPEN 28676
#define AFX_IDD_FILESAVE 28677
#define AFX_IDD_FONT 28678
#define AFX_IDD_COLOR 28679
#define AFX_IDD_PRINT 28680
#define AFX_IDD_PRINTSETUP 28681
#define AFX_IDD_FIND 28682
#define AFX_IDD_REPLACE 28683
#endif //!RC_INVOKED
// Standard dialogs app should leave alone (0x7801->)
#define AFX_IDD_NEWTYPEDLG 30721
#define AFX_IDD_PRINTDLG 30722
#define AFX_IDD_PREVIEW_TOOLBAR 30723
// Dialogs defined for OLE2UI library
#define AFX_IDD_INSERTOBJECT 30724
#define AFX_IDD_CHANGEICON 30725
#define AFX_IDD_CONVERT 30726
#define AFX_IDD_PASTESPECIAL 30727
#define AFX_IDD_EDITLINKS 30728
#define AFX_IDD_FILEBROWSE 30729
#define AFX_IDD_BUSY 30730
#define AFX_IDD_OBJECTPROPERTIES 30732
#define AFX_IDD_CHANGESOURCE 30733
// Standard cursors (0x7901->)
// AFX_IDC = Cursor resources
#define AFX_IDC_CONTEXTHELP 30977 // context sensitive help
#define AFX_IDC_MAGNIFY 30978 // print preview zoom
#define AFX_IDC_SMALLARROWS 30979 // splitter
#define AFX_IDC_HSPLITBAR 30980 // splitter
#define AFX_IDC_VSPLITBAR 30981 // splitter
#define AFX_IDC_NODROPCRSR 30982 // No Drop Cursor
#define AFX_IDC_TRACKNWSE 30983 // tracker
#define AFX_IDC_TRACKNESW 30984 // tracker
#define AFX_IDC_TRACKNS 30985 // tracker
#define AFX_IDC_TRACKWE 30986 // tracker
#define AFX_IDC_TRACK4WAY 30987 // tracker
#define AFX_IDC_MOVE4WAY 30988 // resize bar (server only)
// Wheel mouse cursors
// NOTE: values must be in this order! See CScrollView::OnTimer()
#define AFX_IDC_MOUSE_PAN_NW 30998 // pan east
#define AFX_IDC_MOUSE_PAN_N 30999 // pan northeast
#define AFX_IDC_MOUSE_PAN_NE 31000 // pan north
#define AFX_IDC_MOUSE_PAN_W 31001 // pan northwest
#define AFX_IDC_MOUSE_PAN_HV 31002 // pan both axis
#define AFX_IDC_MOUSE_PAN_E 31003 // pan west
#define AFX_IDC_MOUSE_PAN_SW 31004 // pan south-west
#define AFX_IDC_MOUSE_PAN_S 31005 // pan south
#define AFX_IDC_MOUSE_PAN_SE 31006 // pan south-east
#define AFX_IDC_MOUSE_PAN_HORZ 31007 // pan X-axis
#define AFX_IDC_MOUSE_PAN_VERT 31008 // pan Y-axis
// Wheel mouse bitmaps
#define AFX_IDC_MOUSE_ORG_HORZ 31009 // anchor for horz only
#define AFX_IDC_MOUSE_ORG_VERT 31010 // anchor for vert only
#define AFX_IDC_MOUSE_ORG_HV 31011 // anchor for horz/vert
#define AFX_IDC_MOUSE_MASK 31012
// Mini frame window bitmap ID
#define AFX_IDB_MINIFRAME_MENU 30994
// CheckListBox checks bitmap ID
#define AFX_IDB_CHECKLISTBOX_95 30996
// AFX standard accelerator resources
#define AFX_IDR_PREVIEW_ACCEL 30997
// AFX standard ICON IDs (for MFC V1 apps) (0x7A01->)
#define AFX_IDI_STD_MDIFRAME 31233
#define AFX_IDI_STD_FRAME 31234
/////////////////////////////////////////////////////////////////////////////
// AFX OLE control implementation - control IDs (AFX_IDC)
// Font property page
#define AFX_IDC_FONTPROP 1000
#define AFX_IDC_FONTNAMES 1001
#define AFX_IDC_FONTSTYLES 1002
#define AFX_IDC_FONTSIZES 1003
#define AFX_IDC_STRIKEOUT 1004
#define AFX_IDC_UNDERLINE 1005
#define AFX_IDC_SAMPLEBOX 1006
// Color property page
#define AFX_IDC_COLOR_BLACK 1100
#define AFX_IDC_COLOR_WHITE 1101
#define AFX_IDC_COLOR_RED 1102
#define AFX_IDC_COLOR_GREEN 1103
#define AFX_IDC_COLOR_BLUE 1104
#define AFX_IDC_COLOR_YELLOW 1105
#define AFX_IDC_COLOR_MAGENTA 1106
#define AFX_IDC_COLOR_CYAN 1107
#define AFX_IDC_COLOR_GRAY 1108
#define AFX_IDC_COLOR_LIGHTGRAY 1109
#define AFX_IDC_COLOR_DARKRED 1110
#define AFX_IDC_COLOR_DARKGREEN 1111
#define AFX_IDC_COLOR_DARKBLUE 1112
#define AFX_IDC_COLOR_LIGHTBROWN 1113
#define AFX_IDC_COLOR_DARKMAGENTA 1114
#define AFX_IDC_COLOR_DARKCYAN 1115
#define AFX_IDC_COLORPROP 1116
#define AFX_IDC_SYSTEMCOLORS 1117
// Picture porperty page
#define AFX_IDC_PROPNAME 1201
#define AFX_IDC_PICTURE 1202
#define AFX_IDC_BROWSE 1203
#define AFX_IDC_CLEAR 1204
/////////////////////////////////////////////////////////////////////////////
// IDRs for OLE control standard components
// Standard propery page dialogs app should leave alone (0x7E01->)
#define AFX_IDD_PROPPAGE_COLOR 32257
#define AFX_IDD_PROPPAGE_FONT 32258
#define AFX_IDD_PROPPAGE_PICTURE 32259
#define AFX_IDB_TRUETYPE 32384
/////////////////////////////////////////////////////////////////////////////
// Standard OLE control strings
// OLE Control page strings
#define AFX_IDS_PROPPAGE_UNKNOWN 0xFE01
#define AFX_IDS_COLOR_DESKTOP 0xFE04
#define AFX_IDS_COLOR_APPWORKSPACE 0xFE05
#define AFX_IDS_COLOR_WNDBACKGND 0xFE06
#define AFX_IDS_COLOR_WNDTEXT 0xFE07
#define AFX_IDS_COLOR_MENUBAR 0xFE08
#define AFX_IDS_COLOR_MENUTEXT 0xFE09
#define AFX_IDS_COLOR_ACTIVEBAR 0xFE0A
#define AFX_IDS_COLOR_INACTIVEBAR 0xFE0B
#define AFX_IDS_COLOR_ACTIVETEXT 0xFE0C
#define AFX_IDS_COLOR_INACTIVETEXT 0xFE0D
#define AFX_IDS_COLOR_ACTIVEBORDER 0xFE0E
#define AFX_IDS_COLOR_INACTIVEBORDER 0xFE0F
#define AFX_IDS_COLOR_WNDFRAME 0xFE10
#define AFX_IDS_COLOR_SCROLLBARS 0xFE11
#define AFX_IDS_COLOR_BTNFACE 0xFE12
#define AFX_IDS_COLOR_BTNSHADOW 0xFE13
#define AFX_IDS_COLOR_BTNTEXT 0xFE14
#define AFX_IDS_COLOR_BTNHIGHLIGHT 0xFE15
#define AFX_IDS_COLOR_DISABLEDTEXT 0xFE16
#define AFX_IDS_COLOR_HIGHLIGHT 0xFE17
#define AFX_IDS_COLOR_HIGHLIGHTTEXT 0xFE18
#define AFX_IDS_REGULAR 0xFE19
#define AFX_IDS_BOLD 0xFE1A
#define AFX_IDS_ITALIC 0xFE1B
#define AFX_IDS_BOLDITALIC 0xFE1C
#define AFX_IDS_SAMPLETEXT 0xFE1D
#define AFX_IDS_DISPLAYSTRING_FONT 0xFE1E
#define AFX_IDS_DISPLAYSTRING_COLOR 0xFE1F
#define AFX_IDS_DISPLAYSTRING_PICTURE 0xFE20
#define AFX_IDS_PICTUREFILTER 0xFE21
#define AFX_IDS_PICTYPE_UNKNOWN 0xFE22
#define AFX_IDS_PICTYPE_NONE 0xFE23
#define AFX_IDS_PICTYPE_BITMAP 0xFE24
#define AFX_IDS_PICTYPE_METAFILE 0xFE25
#define AFX_IDS_PICTYPE_ICON 0xFE26
#define AFX_IDS_COLOR_PPG 0xFE28
#define AFX_IDS_COLOR_PPG_CAPTION 0xFE29
#define AFX_IDS_FONT_PPG 0xFE2A
#define AFX_IDS_FONT_PPG_CAPTION 0xFE2B
#define AFX_IDS_PICTURE_PPG 0xFE2C
#define AFX_IDS_PICTURE_PPG_CAPTION 0xFE2D
#define AFX_IDS_PICTUREBROWSETITLE 0xFE30
#define AFX_IDS_BORDERSTYLE_0 0xFE31
#define AFX_IDS_BORDERSTYLE_1 0xFE32
// OLE Control verb names
#define AFX_IDS_VERB_EDIT 0xFE40
#define AFX_IDS_VERB_PROPERTIES 0xFE41
// OLE Control internal error messages
#define AFX_IDP_PICTURECANTOPEN 0xFE83
#define AFX_IDP_PICTURECANTLOAD 0xFE84
#define AFX_IDP_PICTURETOOLARGE 0xFE85
#define AFX_IDP_PICTUREREADFAILED 0xFE86
// Standard OLE Control error strings
#define AFX_IDP_E_ILLEGALFUNCTIONCALL 0xFEA0
#define AFX_IDP_E_OVERFLOW 0xFEA1
#define AFX_IDP_E_OUTOFMEMORY 0xFEA2
#define AFX_IDP_E_DIVISIONBYZERO 0xFEA3
#define AFX_IDP_E_OUTOFSTRINGSPACE 0xFEA4
#define AFX_IDP_E_OUTOFSTACKSPACE 0xFEA5
#define AFX_IDP_E_BADFILENAMEORNUMBER 0xFEA6
#define AFX_IDP_E_FILENOTFOUND 0xFEA7
#define AFX_IDP_E_BADFILEMODE 0xFEA8
#define AFX_IDP_E_FILEALREADYOPEN 0xFEA9
#define AFX_IDP_E_DEVICEIOERROR 0xFEAA
#define AFX_IDP_E_FILEALREADYEXISTS 0xFEAB
#define AFX_IDP_E_BADRECORDLENGTH 0xFEAC
#define AFX_IDP_E_DISKFULL 0xFEAD
#define AFX_IDP_E_BADRECORDNUMBER 0xFEAE
#define AFX_IDP_E_BADFILENAME 0xFEAF
#define AFX_IDP_E_TOOMANYFILES 0xFEB0
#define AFX_IDP_E_DEVICEUNAVAILABLE 0xFEB1
#define AFX_IDP_E_PERMISSIONDENIED 0xFEB2
#define AFX_IDP_E_DISKNOTREADY 0xFEB3
#define AFX_IDP_E_PATHFILEACCESSERROR 0xFEB4
#define AFX_IDP_E_PATHNOTFOUND 0xFEB5
#define AFX_IDP_E_INVALIDPATTERNSTRING 0xFEB6
#define AFX_IDP_E_INVALIDUSEOFNULL 0xFEB7
#define AFX_IDP_E_INVALIDFILEFORMAT 0xFEB8
#define AFX_IDP_E_INVALIDPROPERTYVALUE 0xFEB9
#define AFX_IDP_E_INVALIDPROPERTYARRAYINDEX 0xFEBA
#define AFX_IDP_E_SETNOTSUPPORTEDATRUNTIME 0xFEBB
#define AFX_IDP_E_SETNOTSUPPORTED 0xFEBC
#define AFX_IDP_E_NEEDPROPERTYARRAYINDEX 0xFEBD
#define AFX_IDP_E_SETNOTPERMITTED 0xFEBE
#define AFX_IDP_E_GETNOTSUPPORTEDATRUNTIME 0xFEBF
#define AFX_IDP_E_GETNOTSUPPORTED 0xFEC0
#define AFX_IDP_E_PROPERTYNOTFOUND 0xFEC1
#define AFX_IDP_E_INVALIDCLIPBOARDFORMAT 0xFEC2
#define AFX_IDP_E_INVALIDPICTURE 0xFEC3
#define AFX_IDP_E_PRINTERERROR 0xFEC4
#define AFX_IDP_E_CANTSAVEFILETOTEMP 0xFEC5
#define AFX_IDP_E_SEARCHTEXTNOTFOUND 0xFEC6
#define AFX_IDP_E_REPLACEMENTSTOOLONG 0xFEC7
/////////////////////////////////////////////////////////////////////////////
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, on)
#endif
#endif //__AFXRES_H__
/////////////////////////////////////////////////////////////////////////////

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,6 @@
EXPORTS
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllInstall PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -0,0 +1,19 @@
#define IDB_BITMAP_NPP 101
#define IDI_ICON_NPP_BASE 102
#define IDI_ICON_NPP_0 102
#define IDI_ICON_NPP_1 103
#define IDI_ICON_NPP_MAX 103
#define IDD_DIALOG_SETTINGS 101
#define IDC_CHECK_USECONTEXT 1000
#define IDC_CHECK_CONTEXTICON 1001
#define IDC_EDIT_MENU 1002
#define IDC_EDIT_COMMAND 1003
#define IDC_CHECK_USEICON 1004
#define IDC_CHECK_ISDYNAMIC 1005
#define IDC_RADIO_CLASSIC 1006
#define IDC_RADIO_MODERN 1007
#define IDC_STATIC -1

View File

@ -1,24 +0,0 @@
TARGETOS = BOTH
!include <win32.mak>
lflags = /NODEFAULTLIB /INCREMENTAL:NO /RELEASE /NOLOGO
dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll
all: nppcm.dll
nppcm.dll: nppcm.obj nppcm.res
$(implib) -machine:$(CPU) -def:nppcm.def $** -out:nppcm.lib
$(link) $(dlllflags) -base:0x1C000000 -out:$*.dll $** $(olelibsdll) shell32.lib nppcm.lib comctl32.lib nppcm.exp
.cpp.obj:
$(cc) $(cflags) $(cvarsdll) $*.cpp
nppcm.res: nppcm.rc
$(rc) $(rcflags) $(rcvars) nppcm.rc
clean:
-1 del nppcm.dll nppcm.obj nppcm.exp nppcm.res
zip:
-1 del *.zip
perl abpack.pl

View File

@ -1,19 +0,0 @@
Copyright (c) 2003 Andre Burgaud (http://www.burgaud.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,481 +0,0 @@
//---------------------------------------------------------------------------
// Copyright 2002-2003 by Andre Burgaud <andre@burgaud.com>
// See license.txt
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// wscitecm.cpp
// Defines the entry point for the DLL application.
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Modified by Don HO <don.h@free.fr>
// to meet the need of Notepad++
//---------------------------------------------------------------------------
#ifndef STRICT
#define STRICT
#endif
#define INC_OLE2
#define UNICODE
#ifdef UNICODE
#define generic_strrchr wcsrchr
#else
#define generic_strrchr strrchr
#endif
#include <windows.h>
#include <windowsx.h>
#include <shlobj.h>
#define GUID_SIZE 128
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
#define MAX_FILES 10
#define MAX_CMDSTR (MAX_PATH * MAX_FILES)
#define ResultFromShort(i) ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i)))
#pragma data_seg(".text")
#define INITGUID
#include <initguid.h>
#include <shlguid.h>
#include "resource.h"
#include "nppcm.h"
#pragma data_seg()
//---------------------------------------------------------------------------
// Global variables
//---------------------------------------------------------------------------
UINT _cRef = 0; // COM Reference count.
HINSTANCE _hModule = NULL; // DLL Module.
typedef struct{
HKEY hRootKey;
LPTSTR szSubKey;
LPTSTR lpszValueName;
LPTSTR szData;
} DOREGSTRUCT, *LPDOREGSTRUCT;
TCHAR szNppName[] = TEXT("notepad++.exe");
TCHAR szShellExtensionTitle[] = TEXT("Notepad++");
BOOL RegisterServer(CLSID, LPTSTR);
BOOL UnregisterServer(CLSID, LPTSTR);
void MsgBox(LPTSTR);
void MsgBoxDebug(LPTSTR);
void MsgBoxError(LPTSTR);
//---------------------------------------------------------------------------
// DllMain
//---------------------------------------------------------------------------
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
if (dwReason == DLL_PROCESS_ATTACH) {
_hModule = hInstance;
}
return 1;
}
//---------------------------------------------------------------------------
// DllCanUnloadNow
//---------------------------------------------------------------------------
STDAPI DllCanUnloadNow(void) {
return (_cRef == 0 ? S_OK : S_FALSE);
}
//---------------------------------------------------------------------------
// DllGetClassObject
//---------------------------------------------------------------------------
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut) {
*ppvOut = NULL;
if (IsEqualIID(rclsid, CLSID_ShellExtension)) {
CShellExtClassFactory *pcf = new CShellExtClassFactory;
return pcf->QueryInterface(riid, ppvOut);
}
return CLASS_E_CLASSNOTAVAILABLE;
}
//---------------------------------------------------------------------------
// DllRegisterServer
//---------------------------------------------------------------------------
STDAPI DllRegisterServer() {
return (RegisterServer(CLSID_ShellExtension, szShellExtensionTitle) ? S_OK : E_FAIL);
}
//---------------------------------------------------------------------------
// DllUnregisterServer
//---------------------------------------------------------------------------
STDAPI DllUnregisterServer(void) {
return (UnregisterServer(CLSID_ShellExtension, szShellExtensionTitle) ? S_OK : E_FAIL);
}
//---------------------------------------------------------------------------
// CheckNpp
//---------------------------------------------------------------------------
BOOL CheckNpp() {
TCHAR szModuleFullName[MAX_PATH];
TCHAR szExeFullName[MAX_PATH];
int nLenPath = 0;
TCHAR* pDest;
LPTSTR *lpFilePart = NULL;
GetModuleFileName(_hModule, szModuleFullName, MAX_PATH);
pDest = generic_strrchr(szModuleFullName, '\\' );
pDest++;
pDest[0] = 0;
DWORD dw = SearchPath(szModuleFullName, szShellExtensionTitle, TEXT(".exe"), MAX_PATH, szExeFullName, lpFilePart);
return (dw ? TRUE : FALSE);
}
//---------------------------------------------------------------------------
// RegisterServer
//---------------------------------------------------------------------------
BOOL RegisterServer(CLSID clsid, LPTSTR lpszTitle) {
int i;
HKEY hKey;
LRESULT lResult;
DWORD dwDisp;
TCHAR szSubKey[MAX_PATH];
TCHAR szCLSID[MAX_PATH];
TCHAR szModule[MAX_PATH];
LPWSTR pwsz;
if (!CheckNpp()) {
MsgBoxError(TEXT("To register the Notepad++ context menu extension,\r\ninstall nppcm.dll in the same directory than Notepad++.exe."));
return FALSE;
}
StringFromIID(clsid, &pwsz);
if(pwsz) {
#ifdef UNICODE
lstrcpy(szCLSID, pwsz);
#else
WideCharToMultiByte(CP_ACP, 0, pwsz, -1, szCLSID, ARRAYSIZE(szCLSID), NULL, NULL);
#endif
//free the string
LPMALLOC pMalloc;
CoGetMalloc(1, &pMalloc);
pMalloc->Free(pwsz);
pMalloc->Release();
}
//get this app's path and file name
GetModuleFileName(_hModule, szModule, MAX_PATH);
DOREGSTRUCT ClsidEntries[] = {
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s"), NULL, lpszTitle,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), NULL, szModule,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), TEXT("ThreadingModel"), TEXT("Apartment"),
HKEY_CLASSES_ROOT, TEXT("*\\shellex\\ContextMenuHandlers\\Notepad++"), NULL, szCLSID,
NULL, NULL, NULL, NULL
};
// Register the CLSID entries
for(i = 0; ClsidEntries[i].hRootKey; i++) {
// Create the sub key string - for this case, insert the file extension
wsprintf(szSubKey, ClsidEntries[i].szSubKey, szCLSID);
lResult = RegCreateKeyEx(ClsidEntries[i].hRootKey, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp);
if(NOERROR == lResult) {
TCHAR szData[MAX_PATH];
// If necessary, create the value string
wsprintf(szData, ClsidEntries[i].szData, szModule);
lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, REG_SZ, (LPBYTE)szData, (lstrlen(szData) + 1) * sizeof(TCHAR));
RegCloseKey(hKey);
}
else
return FALSE;
}
return TRUE;
}
//---------------------------------------------------------------------------
// UnregisterServer
//---------------------------------------------------------------------------
BOOL UnregisterServer(CLSID clsid, LPTSTR lpszTitle) {
TCHAR szCLSID[GUID_SIZE + 1];
TCHAR szCLSIDKey[GUID_SIZE + 32];
TCHAR szKeyTemp[MAX_PATH + GUID_SIZE];
LPWSTR pwsz;
StringFromIID(clsid, &pwsz);
if(pwsz) {
#ifdef UNICODE
lstrcpy(szCLSID, pwsz);
#else
WideCharToMultiByte(CP_ACP, 0, pwsz, -1, szCLSID, ARRAYSIZE(szCLSID), NULL, NULL);
#endif
//free the string
LPMALLOC pMalloc;
CoGetMalloc(1, &pMalloc);
pMalloc->Free(pwsz);
pMalloc->Release();
}
lstrcpy(szCLSIDKey, TEXT("CLSID\\"));
lstrcat(szCLSIDKey, szCLSID);
wsprintf(szKeyTemp, TEXT("*\\shellex\\ContextMenuHandlers\\%s"), lpszTitle);
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
wsprintf(szKeyTemp, TEXT("%s\\%s"), szCLSIDKey, TEXT("InprocServer32"));
RegDeleteKey(HKEY_CLASSES_ROOT, szKeyTemp);
RegDeleteKey(HKEY_CLASSES_ROOT, szCLSIDKey);
return TRUE;
}
//---------------------------------------------------------------------------
// MsgBoxDebug
//---------------------------------------------------------------------------
void MsgBoxDebug(LPTSTR lpszMsg) {
MessageBox(NULL,
lpszMsg,
TEXT("DEBUG"),
MB_OK);
}
//---------------------------------------------------------------------------
// MsgBox
//---------------------------------------------------------------------------
void MsgBox(LPTSTR lpszMsg) {
MessageBox(NULL,
lpszMsg,
TEXT("Notepad++ Extension"),
MB_OK);
}
//---------------------------------------------------------------------------
// MsgBoxError
//---------------------------------------------------------------------------
void MsgBoxError(LPTSTR lpszMsg) {
MessageBox(NULL,
lpszMsg,
TEXT("Notepad++ Extension"),
MB_OK | MB_ICONSTOP);
}
//---------------------------------------------------------------------------
// CShellExtClassFactory
//---------------------------------------------------------------------------
CShellExtClassFactory::CShellExtClassFactory() {
m_cRef = 0L;
_cRef++;
}
CShellExtClassFactory::~CShellExtClassFactory() {
_cRef--;
}
STDMETHODIMP CShellExtClassFactory::QueryInterface(REFIID riid, LPVOID FAR *ppv) {
*ppv = NULL;
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) {
*ppv = (LPCLASSFACTORY)this;
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) CShellExtClassFactory::AddRef() {
return ++m_cRef;
}
STDMETHODIMP_(ULONG) CShellExtClassFactory::Release()
{
if (--m_cRef)
return m_cRef;
delete this;
return 0L;
}
STDMETHODIMP CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj) {
*ppvObj = NULL;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
LPCSHELLEXT pShellExt = new CShellExt();
if (NULL == pShellExt)
return E_OUTOFMEMORY;
return pShellExt->QueryInterface(riid, ppvObj);
}
STDMETHODIMP CShellExtClassFactory::LockServer(BOOL fLock) {
return NOERROR;
}
//---------------------------------------------------------------------------
// CShellExt
//---------------------------------------------------------------------------
CShellExt::CShellExt() {
m_cRef = 0L;
m_pDataObj = NULL;
_cRef++;
m_hNppBmp = LoadBitmap(_hModule, MAKEINTRESOURCE(IDB_NPP));
HRESULT hr;
hr = SHGetMalloc(&m_pAlloc);
if (FAILED(hr))
m_pAlloc = NULL;
}
CShellExt::~CShellExt() {
if (m_pDataObj)
m_pDataObj->Release();
_cRef--;
m_pAlloc->Release();
}
STDMETHODIMP CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv) {
*ppv = NULL;
if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown)) {
*ppv = (LPSHELLEXTINIT)this;
}
else if (IsEqualIID(riid, IID_IContextMenu)) {
*ppv = (LPCONTEXTMENU)this;
}
if (*ppv) {
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) CShellExt::AddRef() {
return ++m_cRef;
}
STDMETHODIMP_(ULONG) CShellExt::Release() {
if (--m_cRef)
return m_cRef;
delete this;
return 0L;
}
STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey) {
HRESULT hres = 0;
if (m_pDataObj)
m_pDataObj->Release();
if (pDataObj) {
m_pDataObj = pDataObj;
pDataObj->AddRef();
}
return NOERROR;
}
STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) {
UINT idCmd = idCmdFirst;
BOOL bAppendItems=TRUE;
TCHAR szItemNpp[] = TEXT("Edit with &Notepad++");
FORMATETC fmte = {
CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
HRESULT hres = m_pDataObj->GetData(&fmte, &m_stgMedium);
if (SUCCEEDED(hres)) {
if (m_stgMedium.hGlobal)
m_cbFiles = DragQueryFile((HDROP)m_stgMedium.hGlobal, (UINT)-1, 0, 0);
}
UINT nIndex = indexMenu++;
InsertMenu(hMenu, nIndex, MF_STRING|MF_BYPOSITION, idCmd++, szItemNpp);
if (m_hNppBmp) {
SetMenuItemBitmaps (hMenu, nIndex, MF_BYPOSITION, m_hNppBmp, m_hNppBmp);
}
return ResultFromShort(idCmd-idCmdFirst);
}
STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) {
HRESULT hr = E_INVALIDARG;
if (!HIWORD(lpcmi->lpVerb)) {
UINT idCmd = LOWORD(lpcmi->lpVerb);
switch(idCmd) {
case 0:
hr = InvokeNpp(lpcmi->hwnd, lpcmi->lpDirectory, lpcmi->lpVerb, lpcmi->lpParameters, lpcmi->nShow);
break;
}
}
return hr;
}
STDMETHODIMP CShellExt::GetCommandString(UINT idCmd, UINT uFlags, UINT FAR *reserved, LPSTR pszName, UINT cchMax) {
if (uFlags == GCS_HELPTEXT && cchMax > 35)
strcpy(pszName, "Edits the selected file(s) with Notepad++");
return NOERROR;
}
static void getNppName(TCHAR *name) {
TCHAR szModuleFullName[MAX_PATH];
int nLenPath = 0;
TCHAR* pDest;
name[0] = 0;
GetModuleFileName(_hModule, szModuleFullName, MAX_PATH);
pDest = generic_strrchr(szModuleFullName, '\\' );
pDest++;
pDest[0] = 0;
lstrcpy(name, szModuleFullName);
lstrcat(name, szNppName);
if (name[0] == 0)
lstrcpy(name, szNppName);
}
STDMETHODIMP CShellExt::InvokeNpp(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd) {
TCHAR szFileUserClickedOn[MAX_PATH];
LPTSTR pszCommand;
UINT i;
FORMATETC fmte = {
CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
pszCommand = (LPTSTR)m_pAlloc->Alloc(MAX_PATH * (m_cbFiles + 1) * sizeof(TCHAR));
if (pszCommand)
getNppName(pszCommand);
else {
MsgBoxError(TEXT("Insufficient memory available."));
return E_FAIL;
}
for (i = 0; i < m_cbFiles; i++) {
DragQueryFile((HDROP)m_stgMedium.hGlobal, i, szFileUserClickedOn, MAX_PATH);
lstrcat(pszCommand, TEXT(" \""));
lstrcat(pszCommand, szFileUserClickedOn);
lstrcat(pszCommand, TEXT("\""));
}
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_RESTORE;
if (!CreateProcess (NULL, pszCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
MessageBox(hParent,
TEXT("Error creating process: nppcm.dll needs to be in the same directory than notepad++.exe"),
TEXT("Notepad++ Extension"),
MB_OK);
}
m_pAlloc->Free(pszCommand);
return NOERROR;
}

View File

@ -1,10 +0,0 @@
;nppcm.def : Declares the module parameters for the DLL.
LIBRARY nppcm
DESCRIPTION 'Notepad++ Shell Extension'
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

View File

@ -1,79 +0,0 @@
//---------------------------------------------------------------------------
// Copyright 2002-2003 by Andre Burgaud <andre@burgaud.com>
// See license.txt
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// wscitecm.h
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Modified by Don HO <don.h@free.fr>
// to meet the need of Notepad++
//---------------------------------------------------------------------------
// {120b94b5-2e6a-4f13-94d0-414bcb64fa0f}
DEFINE_GUID(CLSID_ShellExtension, 0x120b94b5, 0x2e6a, 0x4f13, 0x94, 0xd0, 0x41, 0x4b, 0xcb, 0x64, 0xfa, 0x0f);
class CShellExtClassFactory : public IClassFactory {
protected:
ULONG m_cRef;
public:
CShellExtClassFactory();
~CShellExtClassFactory();
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
STDMETHODIMP LockServer(BOOL);
};
typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
class CShellExt : public IContextMenu, IShellExtInit {
public:
protected:
ULONG m_cRef;
UINT m_cbFiles;
STGMEDIUM m_stgMedium;
LPDATAOBJECT m_pDataObj;
HBITMAP m_hNppBmp;
LPMALLOC m_pAlloc;
TCHAR m_szDllDir [MAX_PATH];
STDMETHODIMP InvokeNpp(HWND hParent,
LPCSTR pszWorkingDir,
LPCSTR pszCmd,
LPCSTR pszParam,
int iShowCmd);
public:
CShellExt();
~CShellExt();
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP QueryContextMenu(HMENU hMenu,
UINT indexMenu,
UINT idCmdFirst,
UINT idCmdLast,
UINT uFlags);
STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
STDMETHODIMP GetCommandString(UINT idCmd,
UINT uFlags,
UINT FAR *reserved,
LPSTR pszName,
UINT cchMax);
STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder,
LPDATAOBJECT pDataObj,
HKEY hKeyID);
};
typedef CShellExt *LPCSHELLEXT;

View File

@ -1,116 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,0
PRODUCTVERSION 1,3,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x3L
#else
FILEFLAGS 0x2L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "Burgaud.com\0"
VALUE "FileDescription", "Context Handler Menu for Notepad++\0"
VALUE "FileVersion", "1.3\0"
VALUE "InternalName", "\0"
VALUE "LegalCopyright", "Copyright © 2000-2003 Andre Burgaud\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "nppcm.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "\0"
VALUE "ProductVersion", "1.3\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_NPP BITMAP DISCARDABLE "npp.bmp"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,62 +0,0 @@
Overview
--------
nppcm.dll is a shell extension component for Notepad++.
This component is modified from the MIT open source project WSciTEcm
(Context Menu Extension for SciTE), made by Andre Burgaud <andre@burgaud.com>,
to meet the need of Notepad++.
Installing this Context Menu Handler (nppcm.dll) creates a new command
"Edit with Notepad++" in the context menu of Windows Explorer.
You can quickly open one or several selected files in Windows Explorer:
right click on the selection and click on the command "Edit with Notepad++".
The manual installation is describe in the following sections.
Installation
------------
1) Copy nppcm.dll in Notepad++ directory.
2) In Notepad++ directory installation, type the command "regsvr32 nppcm.dll".
This will register the dll.
If everything goes well, you should have "Edit with Notepad++"
when you right click on selected file(s) in Windows Explorer.
Uninstallation
--------------
In Notepad++ directory installation, type the command "regsvr32 /u nppcm.dll".
Unload the dll
--------------
If you try to delete or override the dll file and you get the error "Access is
denied.", the library is already loaded.
There are several options to workaround this issue:
Solution 1:
- Close all the Windows Explorer instances open on your desktop and copy
nppcm.dll using the command line (Example : "C:/>cp nppcm.dll <npp_directory>").
Solution 2:
- Reboot the computer and delete or override nppcm.dll (with the command line)
before starting Windows Explorer and using the context menu (right-click).
Solution 3:
- Open a command line window
- Type CTRL+ALT+DEL to display the Windows Task Manager, display the Process tab
and "kill" the explorer.exe process.
- If your exlorer did not restart automatically, start it manually from the command line window
(c:/>explorer)
- Delete or override nppcm.dll before using the context menu (Example: "C:/>cp nppcm.dll <npp_directory>").
Build
-----
nppcm.dll is built with Visual C++ 6.0. A Makefile is provided with the
sources: in the source directory, type "nmake". Ensure that all the
environment variables and paths are set correctly. To do so, use the command
file "VCVARS32.BAT" available in the bin directory of Visual C++ installation.
License
-------
Copyright 2002-2003 by Andre Burgaud <andre@burgaud.com>
See license.txt

View File

@ -1,17 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by wscitecm.rc
//
#define IDI_SCITE 101
#define IDB_NPP 102
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif