diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..bdb0cab
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,17 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2782193
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,220 @@
+#################
+## Eclipse
+#################
+
+*.pydevproject
+.project
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.settings/
+.loadpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+
+[Dd]ebug/
+[Rr]elease/
+x64/
+build/
+[Bb]in/
+[Oo]bj/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.log
+*.scc
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+*.ncrunch*
+.*crunch*.local.xml
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.Publish.xml
+*.pubxml
+*.publishproj
+
+# NuGet Packages Directory
+## TODO: If you have NuGet Package Restore enabled, uncomment the next line
+packages/
+
+# Windows Azure Build Output
+csx
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+sql/
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.[Pp]ublish.xml
+*.pfx
+*.publishsettings
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+App_Data/*.mdf
+App_Data/*.ldf
+
+#############
+## Windows detritus
+#############
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Mac crap
+.DS_Store
+
+
+#############
+## Python
+#############
+
+*.py[cod]
+
+# Packages
+*.egg
+*.egg-info
+dist/
+build/
+eggs/
+parts/
+var/
+sdist/
+develop-eggs/
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+#Translations
+*.mo
+
+#Mr Developer
+.mr.developer.cfg
+*.opendb
+/FBE.h
+installer/Input/
+installer/*.exe
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..975ba46
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,13 @@
+# FictionBook Editor Changelog
+
+## v2.6.8
+
+* Upgade Visual Studio solution and projects to VS2015 version;
+* Add missing ExportHTML and FBV projects from [FBTools](https://haali.su/pocketpc/files/FictionBook%20Tools%20v2.0%20Setup.exe);
+* Add missing files from FBE distribution (genres.txt_L, genres.rus.txt_L);
+* Upgrade bundled [WTL v8.1](https://sourceforge.net/projects/wtl/) to v9.1 using [NuGet packaging system](https://www.nuget.org/). WTL sources are automatically restored when you build solution first time;
+* Upgrade [PCRE v7.9](http://www.pcre.org/) to v8.37, PCRE is now build from sources;
+* Upgrade [Hunspell](http://hunspell.sourceforge.net/) to v1.3.3, Hunspell is now build from sources;
+* Fix installer to propertly work under Windows Vista and higher (set `RequestExecutionLevel` to `admin`);
+* Remove references to [UAC plugin](http://nsis.sourceforge.net/UAC_plug-in) from installer, it's needed for Windows 2000 only, but we don't support it;
+* Add version info to all exe's and dll's.
\ No newline at end of file
diff --git a/ExportHTML/ExportHTML.cpp b/ExportHTML/ExportHTML.cpp
new file mode 100644
index 0000000..8dc18ed
--- /dev/null
+++ b/ExportHTML/ExportHTML.cpp
@@ -0,0 +1,72 @@
+#include "stdafx.h"
+#include "resource.h"
+
+#include "utils.h"
+#include "FBE.h"
+
+#include "ExportHTML.h"
+
+#include
+
+// {E242A6D3-84BF-4285-9FAA-160F95370668}
+DEFINE_GUID(CLSID_ExportHTMLPlugin,
+0xe242a6d3, 0x84bf, 0x4285, 0x9f, 0xaa, 0x16, 0xf, 0x95, 0x37, 0x6, 0x68);
+
+CComModule _Module;
+CRegKey _Settings;
+CString _SettingsPath;
+
+BEGIN_OBJECT_MAP(ObjectMap)
+ OBJECT_ENTRY(CLSID_ExportHTMLPlugin, ExportHTMLPlugin)
+END_OBJECT_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// DLL Entry Point
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _Module.Init(ObjectMap, hInstance);
+ DisableThreadLibraryCalls(hInstance);
+ U::InitSettings();
+ }
+ else if (dwReason == DLL_PROCESS_DETACH) {
+ _Module.Term();
+ }
+ return TRUE; // ok
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Used to determine whether the DLL can be unloaded by OLE
+
+STDAPI DllCanUnloadNow(void)
+{
+ return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Returns a class factory to create an object of the requested type
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+{
+ return _Module.GetClassObject(rclsid, riid, ppv);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - Adds entries to the system registry
+
+STDAPI DllRegisterServer(void)
+{
+ // registers object, typelib and all interfaces in typelib
+ return _Module.RegisterServer();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - Removes entries from the system registry
+
+STDAPI DllUnregisterServer(void)
+{
+ return _Module.UnregisterServer();
+}
diff --git a/ExportHTML/ExportHTML.def b/ExportHTML/ExportHTML.def
new file mode 100644
index 0000000..2f3c6c6
--- /dev/null
+++ b/ExportHTML/ExportHTML.def
@@ -0,0 +1,7 @@
+LIBRARY "ExportHTML.DLL"
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
diff --git a/ExportHTML/ExportHTML.h b/ExportHTML/ExportHTML.h
new file mode 100644
index 0000000..688b2a2
--- /dev/null
+++ b/ExportHTML/ExportHTML.h
@@ -0,0 +1,23 @@
+#ifndef EXPORTHTML_H
+#define EXPORTHTML_H
+
+EXTERN_C const GUID CLSID_ExportHTMLPlugin;
+
+class ExportHTMLPlugin :
+ public CComObjectRoot,
+ public CComCoClass,
+ public IFBEExportPlugin
+{
+public:
+ DECLARE_REGISTRY_RESOURCEID(IDR_EXPORTHTML)
+
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(ExportHTMLPlugin)
+ COM_INTERFACE_ENTRY(IFBEExportPlugin)
+ END_COM_MAP()
+
+ // IFBEExportPlugin
+ STDMETHOD(Export)(long hWnd,BSTR filename,IDispatch *doc);
+};
+#endif
\ No newline at end of file
diff --git a/ExportHTML/ExportHTML.rc b/ExportHTML/ExportHTML.rc
new file mode 100644
index 0000000..7c6d5ad
--- /dev/null
+++ b/ExportHTML/ExportHTML.rc
@@ -0,0 +1,101 @@
+//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
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+#ifdef _WIN32
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_EXPORTHTML REGISTRY DISCARDABLE "ExportHTML.rgs"
+
+#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
+
+#endif // Russian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// 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
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_CUSTOMSAVEDLG DIALOG DISCARDABLE 0, 0, 330, 32
+STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS
+FONT 8, "MS Shell Dlg"
+BEGIN
+ LTEXT "XSL Template:",IDC_STATIC,68,2,53,8
+ EDITTEXT IDC_TEMPLATE,130,0,164,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_BROWSE,297,0,15,12
+ CONTROL "Include document description",IDC_DOCINFO,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,69,19,108,8
+ LTEXT "TOC depth:",IDC_STATIC,186,19,42,8
+ EDITTEXT IDC_TOCDEPTH,228,17,19,12,ES_NUMBER
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/ExportHTML/ExportHTML.rgs b/ExportHTML/ExportHTML.rgs
new file mode 100644
index 0000000..1da62b0
--- /dev/null
+++ b/ExportHTML/ExportHTML.rgs
@@ -0,0 +1,35 @@
+HKCR
+{
+ NoRemove CLSID
+ {
+ ForceRemove {E242A6D3-84BF-4285-9FAA-160F95370668} = s 'ExportHTMLPlugin Class'
+ {
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ }
+ }
+}
+
+HKLM
+{
+ NoRemove Software
+ {
+ NoRemove Haali
+ {
+ NoRemove FBE
+ {
+ NoRemove Plugins
+ {
+ ForceRemove {E242A6D3-84BF-4285-9FAA-160F95370668} = s 'Export FB2 to HTML'
+ {
+ val Type = s 'Export'
+ val Menu = s 'To HTML'
+ val Icon = s '%MODULE%'
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/ExportHTML/ExportHTML.vcxproj b/ExportHTML/ExportHTML.vcxproj
new file mode 100644
index 0000000..7c64ab5
--- /dev/null
+++ b/ExportHTML/ExportHTML.vcxproj
@@ -0,0 +1,157 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {F15BE191-947B-40DB-934C-507D5011441C}
+ Win32Proj
+ 8.1
+
+
+
+ DynamicLibrary
+ true
+ v140_xp
+ Static
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140_xp
+ Static
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v140_xp
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140_xp
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+
+ WIN32;_DEBUG;_WINDOWS;_USRDLL;EXPORTHTML_EXPORTS;%(PreprocessorDefinitions)
+ MultiThreadedDebug
+ Level3
+ ProgramDatabase
+ Disabled
+ ..\;
+ /Zc:threadSafeInit-
+
+
+ MachineX86
+ true
+ Windows
+ ExportHTML.def
+
+
+
+
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;EXPORTHTML_EXPORTS;%(PreprocessorDefinitions)
+ MultiThreaded
+ Level3
+ ProgramDatabase
+ ..\;
+ /Zc:threadSafeInit-
+
+
+ MachineX86
+ true
+ Windows
+ true
+ true
+ ExportHTML.def
+
+
+
+
+ ExportHTML.def
+
+
+ ..\;
+ MultiThreadedDebug
+ /Zc:threadSafeInit-
+
+
+
+
+ ExportHTML.def
+
+
+ ..\;
+ MultiThreaded
+ /Zc:threadSafeInit-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ExportHTML/ExportHTML.vcxproj.filters b/ExportHTML/ExportHTML.vcxproj.filters
new file mode 100644
index 0000000..9fb142b
--- /dev/null
+++ b/ExportHTML/ExportHTML.vcxproj.filters
@@ -0,0 +1,59 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Source Files
+
+
+ Resource Files
+
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Resource Files
+
+
+
\ No newline at end of file
diff --git a/ExportHTML/ExportHTMLImpl.cpp b/ExportHTML/ExportHTMLImpl.cpp
new file mode 100644
index 0000000..1e7c9a4
--- /dev/null
+++ b/ExportHTML/ExportHTMLImpl.cpp
@@ -0,0 +1,367 @@
+#include "stdafx.h"
+#include "resource.h"
+
+#include "utils.h"
+#include "FBE.h"
+
+#include "ExportHTML.h"
+
+class CCustomSaveDialog : public CFileDialogImpl
+{
+public:
+ HWND m_hDlg;
+ CString m_template;
+ bool m_includedesc;
+ int m_tocdepth;
+
+ CCustomSaveDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
+ LPCTSTR lpszDefExt = NULL,
+ LPCTSTR lpszFileName = NULL,
+ DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ LPCTSTR lpszFilter = NULL,
+ HWND hWndParent = NULL)
+ : CFileDialogImpl(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent),
+ m_hDlg(NULL), m_includedesc(true), m_tocdepth(1)
+ {
+ m_ofn.lpTemplateName=MAKEINTRESOURCE(IDD_CUSTOMSAVEDLG);
+ }
+
+ BEGIN_MSG_MAP(CCustomSaveDialog)
+ if (uMsg==WM_INITDIALOG)
+ return OnInitDialog(hWnd,uMsg,wParam,lParam);
+
+ MESSAGE_HANDLER(WM_SIZE,OnSize)
+
+ COMMAND_ID_HANDLER(IDC_BROWSE,OnBrowse);
+
+ CHAIN_MSG_MAP(CFileDialogImpl)
+ END_MSG_MAP()
+
+ LRESULT OnInitDialog(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) {
+ // save window handles
+ m_hDlg=hWnd;
+
+ // read saved template name
+ m_template=U::QuerySV(_Settings,_T("Template"),U::GetProgDirFile(_T("html.xsl")));
+ ::SetDlgItemText(hWnd,IDC_TEMPLATE,m_template);
+ m_includedesc=U::QueryIV(_Settings,_T("IncludeDesc"),1)!=0;
+ ::SendDlgItemMessage(hWnd,IDC_DOCINFO,BM_SETCHECK,
+ m_includedesc ? BST_CHECKED : BST_UNCHECKED,0);
+ m_tocdepth=U::QueryIV(_Settings,_T("TOCDepth"),1);
+ ::SetDlgItemInt(hWnd,IDC_TOCDEPTH,m_tocdepth,FALSE);
+ return TRUE;
+ }
+
+ LRESULT OnSize(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled) {
+ // make combobox the same size as std controls
+ RECT rc_std,rc_my;
+ HWND hCB=::GetDlgItem(m_hDlg,IDC_TEMPLATE);
+ ::GetWindowRect(hCB,&rc_my);
+ ::GetWindowRect(GetFileDialogWindow().GetDlgItem(cmb1),&rc_std);
+ POINT pt={rc_my.left,rc_my.top};
+ ::ScreenToClient(m_hDlg,&pt);
+ ::MoveWindow(hCB,pt.x,pt.y,rc_std.right-rc_std.left,rc_my.bottom-rc_my.top,TRUE);
+ hCB=::GetDlgItem(m_hDlg,IDC_BROWSE);
+ ::GetWindowRect(hCB,&rc_my);
+ ::MoveWindow(hCB,
+ pt.x+rc_std.right-rc_std.left+10,pt.y,
+ rc_my.right-rc_my.left,rc_my.bottom-rc_my.top,TRUE);
+
+ return 0;
+ }
+
+ LRESULT OnBrowse(WORD, WORD, HWND, BOOL&) {
+ CFileDialog dlg(
+ TRUE,
+ _T("xsl"),
+ NULL,
+ OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,
+ _T("XSL Templates (*.xsl;*.xslt)\0*.xsl;*.xslt\0All files (*.*)\0*.*\0\0")
+ );
+
+ if (dlg.DoModal(*this)==IDOK)
+ ::SetDlgItemText(m_hDlg,IDC_TEMPLATE,dlg.m_szFileName);
+
+ return 0;
+ }
+
+ BOOL OnFileOK(LPOFNOTIFY on) {
+ m_template=U::GetWindowText(::GetDlgItem(m_hDlg,IDC_TEMPLATE));
+ _Settings.SetStringValue(_T("Template"),m_template);
+ m_includedesc=::SendDlgItemMessage(m_hDlg,IDC_DOCINFO,BM_GETCHECK,0,0)==BST_CHECKED;
+ _Settings.SetDWORDValue(_T("IncludeDesc"),m_includedesc);
+ m_tocdepth=::GetDlgItemInt(m_hDlg,IDC_TOCDEPTH,NULL,FALSE);
+ if (m_tocdepth<0)
+ m_tocdepth=0;
+ if (m_tocdepth>10)
+ m_tocdepth=10;
+ _Settings.SetDWORDValue(_T("TOCDepth"),m_tocdepth);
+ return TRUE;
+ }
+};
+
+HRESULT ExportHTMLPlugin::Export(long hWnd,BSTR filename,IDispatch *doc) {
+ HANDLE hOut=INVALID_HANDLE_VALUE;
+
+ try {
+ // * construct doc pointer
+ MSXML2::IXMLDOMDocument2Ptr source(doc);
+
+ // * ask the user where he wants his html
+ CCustomSaveDialog dlg(FALSE,_T("html"),filename,
+ OFN_HIDEREADONLY|OFN_NOREADONLYRETURN|OFN_OVERWRITEPROMPT|OFN_ENABLETEMPLATE,
+ _T("Web Page, complete (*.html;*.htm)\0*.htm;*.html\0")
+ _T("Web Archive, single file (*.mht)\0*.mht\0")
+ _T("Web Page, HTML only (*.html;*.htm)\0*.htm;*.html\0")
+ );
+ dlg.m_ofn.nFilterIndex=1;
+ if (dlg.DoModal((HWND)hWnd)!=IDOK)
+ return S_FALSE;
+
+ // * load template
+ MSXML2::IXMLDOMDocument2Ptr tdoc(U::CreateDocument(true));
+ if (!U::LoadXml(tdoc,dlg.m_template))
+ return S_FALSE;
+ MSXML2::IXSLTemplatePtr tmpl(U::CreateTemplate());
+ tmpl->stylesheet=tdoc;
+
+ // * create processor
+ MSXML2::IXSLProcessorPtr proc(tmpl->createProcessor());
+
+ // * setup input
+ proc->input=doc;
+
+ // * install template parameters
+ proc->addParameter(L"includedesc",dlg.m_includedesc,_bstr_t());
+ proc->addParameter(L"tocdepth",(long)dlg.m_tocdepth,_bstr_t());
+
+ bool fImages=dlg.m_ofn.nFilterIndex<=2;
+ bool fMIME=dlg.m_ofn.nFilterIndex==2;
+
+ CString dfile(dlg.m_szFileName);
+
+ // * open the file
+ hOut=::CreateFile(dlg.m_szFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
+ if (hOut==INVALID_HANDLE_VALUE) {
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("Export HTML"),_T("Can't open %s: %s"),
+ dlg.m_szFileName,(const TCHAR *)U::Win32ErrMsg(::GetLastError()));
+ return S_FALSE;
+ }
+
+ // * construct images directory
+ int cp=dfile.ReverseFind(_T('.'));
+ if (cp>=0)
+ dfile.Delete(cp,dfile.GetLength()-cp);
+ dfile+=_T("_files");
+ if (fImages) {
+ // construct a relative path
+ CString relpath(dfile);
+ cp=relpath.ReverseFind(_T('\\'));
+ if (cp>=0)
+ relpath.Delete(0,cp+1);
+
+ // see if it is ascii only
+ bool fAscii=true;
+ for (int i=0;i127) {
+ fAscii=false;
+ break;
+ }
+
+ if (fAscii && !fMIME) {
+ relpath+=_T('/');
+ proc->addParameter(L"imgprefix",(const TCHAR *)relpath,_bstr_t());
+
+ if (!::CreateDirectory(dfile,NULL) && ::GetLastError()!=ERROR_ALREADY_EXISTS) {
+ DWORD de=::GetLastError();
+ CloseHandle(hOut);
+ ::DeleteFile(dlg.m_szFileName);
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("Export HTML"),_T("Can't create directory %s: %s"),
+ (const TCHAR *)dfile,(const TCHAR *)U::Win32ErrMsg(de));
+ return S_FALSE;
+ }
+ } else
+ dfile.Delete(cp,dfile.GetLength()-cp);
+
+ proc->addParameter(L"saveimages",true,_bstr_t());
+ }
+
+ char boundary[256];
+
+ // * write relevant MIME headers
+ if (fMIME) {
+ // format date
+ char date[256]; time_t tt; time(&tt);
+ strftime(date,sizeof(date),"%a, %d %b %Y %H:%M:%S +0000",gmtime(&tt));
+
+ // construct some random mime boundary
+ _snprintf(boundary,sizeof(boundary),"------NextPart---%08X.%08X",tt,rand());
+
+ // construct mime header
+ char mime_hdr[2048];
+ _snprintf(mime_hdr,sizeof(mime_hdr),
+ "From: \r\n"
+ "Date: %s\r\n" // Thu, 17 Apr 2003 07:34:30 +0400
+ "MIME-Version: 1.0\r\n"
+ "Content-Type: multipart/related; boundary=\"%s\"; type=\"text/html\"\r\n"
+ "\r\n"
+ "This is a multi-part message in MIME format.\r\n"
+ "\r\n"
+ "%s\r\n"
+ "Content-Type: text/html; charset=\"utf-8\"\r\n"
+ "Content-Transfer-Encoding: 8bit\r\n"
+ "\r\n",
+ date,boundary+2,boundary);
+
+ DWORD len=strlen(mime_hdr);
+ DWORD nw;
+ BOOL fWr=WriteFile(hOut,mime_hdr,len,&nw,NULL);
+ if (!fWr || nw!=len) {
+ if (!fWr)
+ U::MessageBox(MB_OK|MB_ICONERROR,
+ _T("Export HTML"),_T("Can't write to %s: %s"),
+ dlg.m_szFileName,(const TCHAR *)U::Win32ErrMsg(::GetLastError()));
+ else
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("Export HTML"),_T("Can't write to %s: short write."),
+ dlg.m_szFileName);
+ ::CloseHandle(hOut);
+ ::DeleteFile(dlg.m_szFileName);
+ return S_FALSE;
+ }
+ }
+
+ // * transform
+ proc->output=(IUnknown*)U::NewStream(hOut,!fMIME);
+ proc->transform();
+
+ // * save images
+ if (fImages) {
+ if (dfile.IsEmpty() || dfile[dfile.GetLength()-1]!=_T('\\'))
+ dfile+=_T('\\');
+ MSXML2::IXMLDOMNodeListPtr bins(source->selectNodes(L"/fb:FictionBook/fb:binary"));
+ for (long l=0;llength;++l) {
+ try {
+ MSXML2::IXMLDOMElementPtr be(bins->item[l]);
+ _variant_t id(be->getAttribute(L"id"));
+ _variant_t ct(be->getAttribute(L"content-type"));
+ if (V_VT(&id)!=VT_BSTR || V_VT(&ct)!=VT_BSTR)
+ continue;
+
+ if (fMIME) {
+ // get base64 data
+ _bstr_t data(be->text);
+
+ // allocate buffer
+ char *buffer=(char*)malloc(data.length()+1024);
+ if (buffer==NULL)
+ continue;
+
+ // construct a MIME header
+ _snprintf(buffer,1024,
+ "\r\n"
+ "%s\r\n"
+ "Content-Type: %S\r\n"
+ "Content-Transfer-Encoding: base64\r\n"
+ "Content-Location: %S\r\n"
+ "\r\n",
+ boundary,V_BSTR(&ct),V_BSTR(&id));
+ DWORD hlen=strlen(buffer);
+
+ // convert data to ascii
+ DWORD mlen=WideCharToMultiByte(CP_ACP,0,
+ data,data.length(),
+ buffer+hlen,data.length(),
+ NULL,NULL);
+
+ // write a new mime header+data
+ DWORD nw;
+ BOOL fWr=WriteFile(hOut,buffer,hlen+mlen,&nw,NULL);
+ DWORD de=::GetLastError();
+ free(buffer);
+
+ if (!fWr || nw!=hlen+mlen) {
+ if (!fWr)
+ U::MessageBox(MB_OK|MB_ICONERROR,
+ _T("Export HTML"),_T("Can't write to %s: %s"),
+ dlg.m_szFileName,(const TCHAR *)U::Win32ErrMsg(de));
+ else
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("Export HTML"),_T("Can't write to %s: short write."),
+ dlg.m_szFileName);
+ ::CloseHandle(hOut);
+ ::DeleteFile(dlg.m_szFileName);
+ return S_FALSE;
+ }
+ } else {
+ be->PutdataType(L"bin.base64");
+ _variant_t data(be->nodeTypedValue);
+ if (V_VT(&data)!=(VT_ARRAY|VT_UI1) || ::SafeArrayGetDim(V_ARRAY(&data))!=1)
+ continue;
+ DWORD len=V_ARRAY(&data)->rgsabound[0].cElements;
+ void *buffer;
+ ::SafeArrayAccessData(V_ARRAY(&data),&buffer);
+ CString fname(dfile);
+ fname+=V_BSTR(&id);
+ HANDLE hFile=::CreateFile(fname,GENERIC_WRITE,0,NULL,CREATE_NEW,0,NULL);
+ if (hFile==INVALID_HANDLE_VALUE && ::GetLastError()==ERROR_FILE_EXISTS) {
+ if (U::MessageBox(MB_YESNO|MB_ICONEXCLAMATION,_T("Export HTML"),
+ _T("%s already exists.\nDo you want to replace it?"),
+ (const TCHAR *)fname)!=IDYES)
+ goto skip;
+ hFile=::CreateFile(fname,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
+ }
+ if (hFile!=INVALID_HANDLE_VALUE) {
+ DWORD wr;
+ BOOL fWr=::WriteFile(hFile,buffer,len,&wr,NULL);
+ DWORD de=::GetLastError();
+ ::CloseHandle(hFile);
+ if (!fWr || wr!=len) {
+ if (!fWr)
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("Export HTML"),_T("Can't write to %s: %s"),
+ (const TCHAR *)fname,(const TCHAR *)U::Win32ErrMsg(de));
+ else
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("Export HTML"),_T("Can't write to %s: short write."),
+ (const TCHAR *)fname);
+ ::DeleteFile(fname);
+ }
+ } else {
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("Export HTML"),_T("Can't open %s: %s"),
+ (const TCHAR *)fname,(const TCHAR *)U::Win32ErrMsg(::GetLastError()));
+ }
+ skip:
+ ::SafeArrayUnaccessData(V_ARRAY(&data));
+ }
+ }
+ catch (_com_error&) { }
+ }
+ }
+
+ // * write a final mime boundary
+ if (fMIME) {
+ char mime_tmp[256];
+ _snprintf(mime_tmp,sizeof(mime_tmp),"\r\n%s\r\n",boundary);
+ DWORD len=strlen(mime_tmp);
+ DWORD nw;
+ BOOL fWr=WriteFile(hOut,mime_tmp,len,&nw,NULL);
+ if (!fWr || nw!=len) {
+ if (!fWr)
+ U::MessageBox(MB_OK|MB_ICONERROR,
+ _T("Export HTML"),_T("Can't write to %s: %s"),
+ dlg.m_szFileName,(const TCHAR *)U::Win32ErrMsg(::GetLastError()));
+ else
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("Export HTML"),_T("Can't write to %s: short write."),
+ dlg.m_szFileName);
+ ::CloseHandle(hOut);
+ ::DeleteFile(dlg.m_szFileName);
+ return S_FALSE;
+ }
+ ::CloseHandle(hOut);
+ }
+ }
+ catch (_com_error& e) {
+ if (hOut!=INVALID_HANDLE_VALUE)
+ CloseHandle(hOut);
+ U::ReportError(e);
+ return S_FALSE;
+ }
+ return S_OK;
+}
\ No newline at end of file
diff --git a/ExportHTML/StdAfx.cpp b/ExportHTML/StdAfx.cpp
new file mode 100644
index 0000000..354baec
--- /dev/null
+++ b/ExportHTML/StdAfx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// ShellExt.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/ExportHTML/StdAfx.h b/ExportHTML/StdAfx.h
new file mode 100644
index 0000000..7dd8645
--- /dev/null
+++ b/ExportHTML/StdAfx.h
@@ -0,0 +1,67 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_)
+#define AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+// check for unicode
+#ifndef UNICODE
+#error This program requires unicode support to run
+#endif
+
+// Change these values to use different versions
+#define WINVER 0x0501
+#define _WIN32_WINNT 0x0501
+#define _WIN32_IE 0x0501
+
+// Insert your headers here
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#define _ATL_APARTMENT_THREADED
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
+
+// turns off ATL's hiding of some common and often safely ignored warning messages
+#define _ATL_ALL_WARNINGS
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+extern CComModule _Module;
+
+#include
+#include
+#include
+
+extern CRegKey _Settings;
+extern CString _SettingsPath;
+
+#include
+#include
+
+// control IDs
+#include
+
+#import
+
+// C library
+#include
+
+// use com utils
+using namespace _com_util;
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_)
diff --git a/ExportHTML/Utils.cpp b/ExportHTML/Utils.cpp
new file mode 100644
index 0000000..ecf88ac
--- /dev/null
+++ b/ExportHTML/Utils.cpp
@@ -0,0 +1,493 @@
+#include "stdafx.h"
+
+#include "utils.h"
+
+namespace U {
+
+HandleStreamPtr NewStream(HANDLE& hf,bool fClose) {
+ HandleStream *hs;
+ CheckError(HandleStream::CreateInstance(&hs));
+ hs->SetHandle(hf,fClose);
+ if (fClose)
+ hf=INVALID_HANDLE_VALUE;
+ return hs;
+}
+
+void NormalizeInplace(CString& s) {
+ int len=s.GetLength();
+ TCHAR *p=s.GetBuffer(len);
+ TCHAR *r=p;
+ TCHAR *q=p;
+ TCHAR *e=p+len;
+ int state=0;
+
+ while (p 32) {
+ *q++=*p;
+ state=1;
+ }
+ break;
+ case 1:
+ if ((unsigned)*p > 32)
+ *q++=*p;
+ else
+ state=2;
+ break;
+ case 2:
+ if ((unsigned)*p > 32) {
+ *q++=_T(' ');
+ *q++=*p;
+ state=1;
+ }
+ break;
+ }
+ ++p;
+ }
+ s.ReleaseBuffer(q-r);
+}
+
+void RemoveSpaces(wchar_t *zstr) {
+ wchar_t *q=zstr;
+
+ while (*zstr) {
+ if (*zstr > 32)
+ *q++=*zstr;
+ ++zstr;
+ }
+ *q=L'\0';
+}
+
+int scmp(const wchar_t *s1,const wchar_t *s2) {
+ bool f1=!s1 || !*s1;
+ bool f2=!s2 || !*s2;
+ if (f1 && f2)
+ return 0;
+ if (f1)
+ return -1;
+ if (f2)
+ return 1;
+ return wcscmp(s1,s2);
+}
+
+CString GetMimeType(const CString& filename) {
+ CString fn(filename);
+ int cp=fn.ReverseFind(_T('.'));
+ if (cp<0)
+os:
+ return _T("application/octet-stream");
+ fn.Delete(0,cp);
+ CRegKey rk;
+ if (rk.Open(HKEY_CLASSES_ROOT,fn,KEY_READ)!=ERROR_SUCCESS)
+ goto os;
+ CString ret;
+ ULONG len=128;
+ TCHAR *rbuf=ret.GetBuffer(len);
+ rbuf[0]=_T('\0');
+ LONG rv=rk.QueryStringValue(_T("Content Type"),rbuf,&len);
+ ret.ReleaseBuffer();
+ if (rv!=ERROR_SUCCESS)
+ goto os;
+ return ret;
+}
+
+bool is_whitespace(const wchar_t *spc) {
+ while (*spc) {
+ if (!iswspace(*spc) && *spc!=160)
+ return false;
+ ++spc;
+ }
+ return true;
+}
+
+CString GetFileTitle(const TCHAR *filename) {
+ CString ret;
+ TCHAR *buf=ret.GetBuffer(MAX_PATH);
+ if (::GetFileTitle(filename,buf,MAX_PATH))
+ ret.ReleaseBuffer(0);
+ else
+ ret.ReleaseBuffer();
+ return ret;
+}
+
+DWORD QueryIV(HKEY hKey,const TCHAR *name,DWORD defval) {
+ DWORD dw;
+ DWORD len=sizeof(DWORD);
+ DWORD type=REG_DWORD;
+ if (::RegQueryValueEx(hKey,name,NULL,&type,(BYTE*)&dw,&len)!=ERROR_SUCCESS ||
+ type!=REG_DWORD || len!=sizeof(DWORD))
+ return defval;
+ return dw;
+}
+
+CString QuerySV(HKEY hKey,const TCHAR *name,const TCHAR *def) {
+ CString ret;
+ DWORD type=REG_SZ;
+ DWORD len=0;
+ if (::RegQueryValueEx(hKey,name,NULL,&type,NULL,&len)!=ERROR_SUCCESS ||
+ (type!=REG_SZ && type!=REG_EXPAND_SZ))
+ return def ? def : CString();
+ TCHAR *cp=ret.GetBuffer(len/sizeof(TCHAR));
+ if (::RegQueryValueEx(hKey,name,NULL,&type,(BYTE*)cp,&len)!=ERROR_SUCCESS) {
+ ret.ReleaseBuffer(0);
+ return def ? def : CString();
+ }
+ ret.ReleaseBuffer(len/sizeof(TCHAR));
+ return ret;
+}
+
+HFONT CreatePtFont(int sizept,const TCHAR *facename,bool fBold,bool fItalic)
+{
+ HDC hDC=CreateDC(_T("DISPLAY"),NULL,NULL,NULL);
+ HFONT hFont=::CreateFont(
+ -MulDiv(sizept, GetDeviceCaps(hDC, LOGPIXELSY), 72),
+ 0,
+ 0,
+ 0,
+ fBold ? FW_BOLD : FW_NORMAL,
+ fItalic,
+ 0,
+ 0,
+ DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS,
+ CLIP_DEFAULT_PRECIS,
+ DEFAULT_QUALITY,
+ DEFAULT_PITCH|FF_DONTCARE,
+ facename);
+ DeleteDC(hDC);
+ return hFont;
+}
+
+CString GetCharName(int ch) {
+ CString num;
+ num.Format(_T("U+%04X"),ch);
+
+#if 0
+ static bool fTriedDll;
+ static HMODULE hDll;
+ if (!hDll) {
+ if (fTriedDll)
+ return num;
+ hDll=LoadLibrary(_T("getuname.dll"));
+ fTriedDll=true;
+ if (!hDll)
+ return num;
+ }
+ int cur=num.GetLength();
+ TCHAR *buf=num.GetBuffer(cur+101);
+ int nch=LoadString(hDll,ch,buf+cur+1,100);
+ if (nch) {
+ buf[cur]=' ';
+ num.ReleaseBuffer(cur+1+nch);
+ } else
+ num.ReleaseBuffer(cur);
+#endif
+ return num;
+}
+
+// path names
+CString GetFullPathName(const CString& filename) {
+ CString ret;
+ int len=MAX_PATH;
+ for (;;) {
+ TCHAR *buf=ret.GetBuffer(len);
+ TCHAR *final;
+ int nlen=::GetFullPathName(filename,len,buf,&final);
+ if (nlen==0) // failed
+ return filename;
+ if (nlen>len) {
+ ret.ReleaseBuffer(0);
+ len=nlen;
+ } else {
+ ret.ReleaseBuffer(nlen);
+ break;
+ }
+ }
+
+ typedef DWORD (__stdcall *GLPN)(LPCTSTR,LPTSTR,DWORD);
+ static bool checked=false;
+ static GLPN glpn;
+
+ if (!checked) {
+ HMODULE hDll=::GetModuleHandle(_T("kernel32.dll"));
+ if (hDll) {
+ glpn=(GLPN)::GetProcAddress(hDll,"GetLongPathName"
+#ifdef UNICODE
+ "W"
+#else
+ "A"
+#endif
+ );
+ }
+ checked=true;
+ }
+
+ if (glpn) {
+ CString r2;
+ for (;;) {
+ TCHAR *buf=r2.GetBuffer(len);
+ int nlen=glpn(ret,buf,len);
+ if (nlen==0)
+ return ret;
+ if (nlen>len) {
+ r2.ReleaseBuffer(0);
+ len=nlen;
+ } else {
+ r2.ReleaseBuffer(nlen);
+ return r2;
+ }
+ }
+ } else
+ return ret;
+}
+
+CString UrlFromPath(const CString& path) {
+ CString ret;
+ DWORD size=MAX_PATH*3;
+ TCHAR *cp=ret.GetBuffer(size);
+ if (FAILED(UrlCreateFromPath(path,cp,&size,0)))
+ return CString();
+ ret.ReleaseBuffer(size);
+ ret.FreeExtra();
+ return ret;
+}
+
+CString Win32ErrMsg(DWORD code) {
+ CString ret;
+ TCHAR *buf=ret.GetBuffer(1024);
+ int len=::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,code,0,buf,1024,NULL);
+ ret.ReleaseBuffer(len);
+ if (len==0)
+ ret.Format(_T("Unknown error %x"),code);
+ return ret;
+}
+
+CString GetProgDir() {
+ CString exedir;
+ TCHAR *cp=exedir.GetBuffer(MAX_PATH);
+ DWORD len=::GetModuleFileName(_Module.GetModuleInstance(),cp,MAX_PATH);
+ exedir.ReleaseBuffer(len);
+ int p=len;
+ while (p>0 && exedir[p-1]!=_T('\\'))
+ --p;
+ exedir.Delete(p,len-p);
+ return exedir;
+}
+
+CString GetProgDirFile(const CString& filename) {
+ CString exedir;
+ TCHAR *cp=exedir.GetBuffer(MAX_PATH);
+ DWORD len=::GetModuleFileName(_Module.GetModuleInstance(),cp,MAX_PATH);
+ exedir.ReleaseBuffer(len);
+ int p=len;
+ while (p>0 && exedir[p-1]!=_T('\\'))
+ --p;
+ exedir.Delete(p,len-p);
+ CString tryname(exedir+filename);
+ DWORD attr=::GetFileAttributes(tryname);
+ if (attr!=INVALID_FILE_ATTRIBUTES)
+ goto ok;
+ tryname=exedir+_T("..\\")+filename;
+ attr=::GetFileAttributes(tryname);
+ if (attr!=INVALID_FILE_ATTRIBUTES)
+ goto ok;
+ tryname=filename;
+ok:
+ return GetFullPathName(tryname);
+}
+
+void ReportError(HRESULT hr) {
+ CString err(Win32ErrMsg(hr));
+ ::MessageBox(::GetActiveWindow(),err,_T("Error"),MB_OK|MB_ICONERROR);
+}
+
+void ReportError(_com_error& e) {
+ CString err;
+ err.Format(_T("Code: %08lx [%s]"),e.Error(),e.ErrorMessage());
+ _bstr_t src(e.Source());
+ if (src.length()>0) {
+ err+=_T("\nSource: ");
+ err+=(const wchar_t *)src;
+ }
+ src=e.Description();
+ if (src.length()>0) {
+ err+=_T("\nDescription: ");
+ err+=(const wchar_t *)src;
+ }
+ ::MessageBox(::GetActiveWindow(),err,_T("COM Error"),MB_OK|MB_ICONERROR);
+}
+
+UINT MessageBox(UINT type,const TCHAR *title,const TCHAR *msg,...) {
+ CString str;
+ va_list ap;
+ va_start(ap,msg);
+ str.FormatV(msg,ap);
+ va_end(ap);
+ return ::MessageBox(::GetActiveWindow(),str,title,type);
+}
+
+CString GetWindowText(HWND hWnd) {
+ CString ret;
+ int tl=::GetWindowTextLength(hWnd);
+ TCHAR *cp=ret.GetBuffer(tl+1);
+ ::GetWindowText(hWnd,cp,tl+1);
+ ret.ReleaseBuffer();
+ return ret;
+}
+
+CString GetCBString(HWND hWnd,int idx) {
+ LRESULT len=::SendMessage(hWnd,CB_GETLBTEXTLEN,idx,0);
+ if (len==CB_ERR)
+ return CString();
+ CString ret;
+ TCHAR *cp=ret.GetBuffer(len+1);
+ len=::SendMessage(hWnd,CB_GETLBTEXT,idx,(LPARAM)cp);
+ if (len==CB_ERR)
+ ret.ReleaseBuffer(0);
+ else
+ ret.ReleaseBuffer(len);
+ return ret;
+}
+
+MSXML2::IXMLDOMDocument2Ptr CreateDocument(bool fFreeThreaded)
+{
+ MSXML2::IXMLDOMDocument2Ptr doc;
+ wchar_t *cls=fFreeThreaded ?
+ L"Msxml2.FreeThreadedDOMDocument.4.0" : L"Msxml2.DOMDocument.4.0";
+ CheckError(doc.CreateInstance(cls));
+ return doc;
+}
+
+MSXML2::IXSLTemplatePtr CreateTemplate() {
+ MSXML2::IXSLTemplatePtr tp;
+ CheckError(tp.CreateInstance(L"Msxml2.XSLTemplate.4.0"));
+ return tp;
+}
+
+void ReportParseError(MSXML2::IXMLDOMDocument2Ptr doc)
+{
+ try {
+ MSXML2::IXMLDOMParseErrorPtr err(doc->parseError);
+ long line=err->line;
+ long col=err->linepos;
+ _bstr_t url(err->url);
+ _bstr_t reason(err->reason);
+ CString msg;
+ if (line && col)
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("XML Parse Error"),
+ _T("At %s, line %d, column %d: %s"),(const TCHAR *)url,
+ line,col,(const TCHAR *)reason);
+ else
+ U::MessageBox(MB_OK|MB_ICONERROR,_T("XML Parse Error"),
+ _T("At %s: %s"),(const TCHAR *)url,(const TCHAR *)reason);
+ }
+ catch (_com_error& e) {
+ ReportError(e);
+ }
+}
+
+bool LoadXml(MSXML2::IXMLDOMDocument2Ptr doc,const CString& url)
+{
+ doc->put_async(VARIANT_FALSE);
+ _variant_t vturl((const TCHAR *)url);
+ VARIANT_BOOL flag;
+ HRESULT hr=doc->raw_load(vturl,&flag);
+ if (FAILED(hr)) {
+ ReportError(hr);
+ return false;
+ }
+ if (flag!=VARIANT_TRUE) {
+ ReportParseError(doc);
+ return false;
+ }
+ return true;
+}
+
+HRESULT LoadFile(const TCHAR *filename,VARIANT *vt) {
+ HRESULT hr;
+
+ HANDLE hFile=::CreateFile(filename,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_SEQUENTIAL_SCAN,
+ NULL);
+ if (hFile==INVALID_HANDLE_VALUE)
+ return HRESULT_FROM_WIN32(::GetLastError());
+
+ DWORD fsz=::GetFileSize(hFile,NULL);
+ if (fsz==INVALID_FILE_SIZE) {
+ hr=HRESULT_FROM_WIN32(::GetLastError());
+cfexit:
+ CloseHandle(hFile);
+ return hr;
+ }
+
+ SAFEARRAY *sa=::SafeArrayCreateVector(VT_UI1,0,fsz);
+ if (sa==NULL) {
+ hr=E_OUTOFMEMORY;
+ goto cfexit;
+ }
+
+ void *pv;
+ if (FAILED(hr=::SafeArrayAccessData(sa,&pv))) {
+ ::SafeArrayDestroy(sa);
+ goto cfexit;
+ }
+
+ DWORD nrd;
+ BOOL fRd=::ReadFile(hFile,pv,fsz,&nrd,NULL);
+ DWORD err=::GetLastError();
+
+ ::SafeArrayUnaccessData(sa);
+ ::CloseHandle(hFile);
+
+ if (!fRd) {
+ ::SafeArrayDestroy(sa);
+ return HRESULT_FROM_WIN32(err);
+ }
+
+ if (nrd!=fsz) {
+ ::SafeArrayDestroy(sa);
+ return E_FAIL;
+ }
+
+ V_VT(vt)=VT_ARRAY|VT_UI1;
+ V_ARRAY(vt)=sa;
+
+ return S_OK;
+}
+
+void InitSettings() {
+ TCHAR filepath[MAX_PATH];
+ DWORD pathlen=::GetModuleFileName(_Module.GetModuleInstance(),filepath,MAX_PATH);
+ TCHAR *appname;
+ if (pathlen==0)
+ appname=_T("FBE"); // fallback
+ else {
+ CString tmp=GetFullPathName(filepath);
+ int pos=tmp.ReverseFind(_T('\\'));
+ if (pos>=0)
+ tmp.Delete(0,pos+1);
+ pos=tmp.ReverseFind(_T('.'));
+ if (pos>=0) {
+ const TCHAR *cp=tmp;
+ cp+=pos;
+ if (_tcsicmp(cp,_T(".exe"))==0 || _tcsicmp(cp,_T(".dll"))==0)
+ tmp.Delete(pos,tmp.GetLength()-pos);
+ }
+ if (tmp.IsEmpty())
+ appname=_T("FBE");
+ else {
+ lstrcpyn(filepath,tmp,MAX_PATH);
+ appname=filepath;
+ }
+ }
+ _SettingsPath=_T("Software\\Haali\\");
+ _SettingsPath+=appname;
+ _Settings.Create(HKEY_CURRENT_USER,_SettingsPath);
+}
+
+}
diff --git a/ExportHTML/packages.config b/ExportHTML/packages.config
new file mode 100644
index 0000000..7df3378
--- /dev/null
+++ b/ExportHTML/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/ExportHTML/resource.h b/ExportHTML/resource.h
new file mode 100644
index 0000000..f5f0331
--- /dev/null
+++ b/ExportHTML/resource.h
@@ -0,0 +1,21 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by ExportHTML.rc
+//
+#define IDR_EXPORTHTML 101
+#define IDD_CUSTOMSAVEDLG 102
+#define IDC_BROWSE 1001
+#define IDC_TEMPLATE 1002
+#define IDC_DOCINFO 1003
+#define IDC_TOCDEPTH 1004
+
+// 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 1005
+#define _APS_NEXT_SYMED_VALUE 102
+#endif
+#endif
diff --git a/ExportHTML/utils.h b/ExportHTML/utils.h
new file mode 100644
index 0000000..1db12f9
--- /dev/null
+++ b/ExportHTML/utils.h
@@ -0,0 +1,118 @@
+#ifndef UTILS_H
+#define UTILS_H
+
+namespace U { // place all utilities into their own namespace
+
+ // loading data into array
+ HRESULT LoadFile(const TCHAR *filename,VARIANT *vt);
+
+ // a generic stream
+ class HandleStreamImpl: public CComObjectRoot, public IStream {
+ private:
+ HANDLE m_handle;
+ bool m_close;
+
+ public:
+ typedef IStream Interface;
+
+ HandleStreamImpl() : m_handle(INVALID_HANDLE_VALUE), m_close(true) { }
+ virtual ~HandleStreamImpl() { if (m_close) CloseHandle(m_handle); }
+
+ void SetHandle(HANDLE hf,bool cl=true) { m_handle=hf; m_close=cl; }
+
+ BEGIN_COM_MAP(HandleStreamImpl)
+ COM_INTERFACE_ENTRY(ISequentialStream)
+ COM_INTERFACE_ENTRY(IStream)
+ END_COM_MAP()
+
+ // ISequentialStream
+ STDMETHOD(Read)(void *pv,ULONG cb,ULONG *pcbRead) {
+ DWORD nrd;
+ if (ReadFile(m_handle,pv,cb,&nrd,NULL)) {
+ *pcbRead=nrd;
+ return S_OK;
+ }
+ if (GetLastError()==ERROR_BROKEN_PIPE) { // treat as eof
+ *pcbRead=0;
+ return S_OK;
+ }
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+ STDMETHOD(Write)(const void *pv,ULONG cb,ULONG *pcbWr) {
+ DWORD nwr;
+ if (WriteFile(m_handle,pv,cb,&nwr,NULL)) {
+ *pcbWr=nwr;
+ return S_OK;
+ }
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ // IStream
+ STDMETHOD(Seek)(LARGE_INTEGER,DWORD,ULARGE_INTEGER*) { return E_NOTIMPL; }
+ STDMETHOD(SetSize)(ULARGE_INTEGER) { return E_NOTIMPL; }
+ STDMETHOD(CopyTo)(IStream*,ULARGE_INTEGER,ULARGE_INTEGER*,ULARGE_INTEGER*) { return E_NOTIMPL; }
+ STDMETHOD(Commit)(DWORD) { return E_NOTIMPL; }
+ STDMETHOD(Revert)() { return E_NOTIMPL; }
+ STDMETHOD(LockRegion)(ULARGE_INTEGER,ULARGE_INTEGER,DWORD) { return E_NOTIMPL; }
+ STDMETHOD(UnlockRegion)(ULARGE_INTEGER,ULARGE_INTEGER,DWORD) { return E_NOTIMPL; }
+ STDMETHOD(Stat)(STATSTG*,DWORD) { return E_NOTIMPL; }
+ STDMETHOD(Clone)(IStream**) { return E_NOTIMPL; }
+ };
+
+ typedef CComObject HandleStream;
+ typedef CComPtr HandleStreamPtr;
+ HandleStreamPtr NewStream(HANDLE& hf,bool fClose=true);
+
+ // strings
+ int scmp(const wchar_t *s1,const wchar_t *s2);
+ CString GetMimeType(const CString& filename);
+ bool is_whitespace(const wchar_t *spc);
+ void NormalizeInplace(CString& s);
+ void RemoveSpaces(wchar_t *zstr);
+ extern inline CString Normalize(const CString& s) { CString p(s); NormalizeInplace(p); return p; }
+ CString GetFileTitle(const TCHAR *filename);
+ extern inline void StrAppend(CString& s1,const CString& s2) {
+ if (!s2.IsEmpty()) {
+ s1+=_T(' ');
+ s1+=s2;
+ }
+ }
+ CString UrlFromPath(const CString& path);
+
+ // settings in the registry
+ CString QuerySV(HKEY hKey,const TCHAR *name,const TCHAR *def=NULL);
+ DWORD QueryIV(HKEY hKey,const TCHAR *name,DWORD defval=0);
+ void InitSettings();
+ extern inline DWORD GetSettingI(const TCHAR *name,DWORD defval=0) {
+ return U::QueryIV(_Settings,name,defval);
+ }
+
+ extern inline CString GetSettingS(const TCHAR *name,const TCHAR *def=NULL) {
+ return U::QuerySV(_Settings,name,def);
+ }
+
+ // windows api
+ HFONT CreatePtFont(int sizept,const TCHAR *facename,bool fBold=false,bool fItalic=false);
+ CString GetFullPathName(const CString& filename);
+ CString Win32ErrMsg(DWORD code);
+ CString GetWindowText(HWND hWnd);
+ void ReportError(HRESULT hr);
+ void ReportError(_com_error& e);
+ UINT MessageBox(UINT type,const TCHAR *title,const TCHAR *msg,...);
+ CString GetProgDir();
+ CString GetProgDirFile(const CString& filename);
+ CString GetCBString(HWND hCB,int idx);
+
+ // unicode char names (win2k/xp only)
+ CString GetCharName(int ch);
+
+ // msxml support
+ MSXML2::IXMLDOMDocument2Ptr CreateDocument(bool fFreeThreaded=false);
+ void ReportParseError(MSXML2::IXMLDOMDocument2Ptr doc);
+ bool LoadXml(MSXML2::IXMLDOMDocument2Ptr doc,
+ const CString& url);
+ MSXML2::IXSLTemplatePtr CreateTemplate();
+
+} // namespace
+
+#endif
\ No newline at end of file
diff --git a/FBE.rc b/FBE.rc
index 750cf84..09bfb49 100644
--- a/FBE.rc
+++ b/FBE.rc
@@ -1,1243 +1,1282 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "atlres.h"
-#include "res1.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// Russian (Russia) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
-LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
-#pragma code_page(1251)
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-3 TEXTINCLUDE
-BEGIN
- "1 TYPELIB ""FBE.tlb""\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // Russian (Russia) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""atlres.h""\r\n"
- "#include ""res1.h""\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
-BEGIN
- IDD_SETTING_OTHER, DIALOG
- BEGIN
- LEFTMARGIN, 6
- RIGHTMARGIN, 219
- TOPMARGIN, 11
- BOTTOMMARGIN, 209
- END
-
- IDD_TOOLS_SETTINGS, DIALOG
- BEGIN
- RIGHTMARGIN, 265
- BOTTOMMARGIN, 275
- END
-
- IDD_TABLE, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 253
- TOPMARGIN, 7
- BOTTOMMARGIN, 39
- END
-
- IDD_WORDS, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 361
- TOPMARGIN, 7
- BOTTOMMARGIN, 316
- END
-
- IDD_REPLACE, DIALOG
- BEGIN
- END
-
- IDD_OPTIONS, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 217
- TOPMARGIN, 7
- BOTTOMMARGIN, 206
- END
-
- IDD_INPUTBOX, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 280
- TOPMARGIN, 7
- BOTTOMMARGIN, 63
- END
-
- IDD_FIND, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 288
- TOPMARGIN, 7
- BOTTOMMARGIN, 69
- END
-
- IDD_ABOUTBOX, DIALOG
- BEGIN
- LEFTMARGIN, 6
- RIGHTMARGIN, 259
- TOPMARGIN, 7
- BOTTOMMARGIN, 147
- END
-
- IDD_HOTKEYS, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 219
- TOPMARGIN, 7
- BOTTOMMARGIN, 220
- END
-
- IDD_SETTINGS_WORDS, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 254
- TOPMARGIN, 7
- BOTTOMMARGIN, 220
- END
-
- IDD_PROPPAGE_LARGE, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 228
- TOPMARGIN, 7
- BOTTOMMARGIN, 149
- END
-
- IDD_SPELL_CHECK, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 266
- TOPMARGIN, 7
- BOTTOMMARGIN, 128
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_SETTING_OTHER DIALOGEX 0, 0, 225, 222
-STYLE DS_SETFONT | WS_CHILD | WS_SYSMENU
-FONT 9, "Tahoma", 400, 0, 0xCC
-BEGIN
- GROUPBOX "Save File",IDC_STATIC,7,11,134,39
- LTEXT "Default encoding:",IDC_STATIC,11,23,60,9
- CONTROL "Keep Encoding",IDC_KEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,35,63,10
- COMBOBOX IDC_DEFAULT_ENC,73,21,65,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- GROUPBOX "Open File",IDC_STATIC,145,11,73,39
- CONTROL "Restore Position",IDC_RESTORE_POS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,151,27,62,10
- GROUPBOX "Scripts folder",IDC_STATIC,6,52,212,43
- CONTROL "Default folder",IDC_DEFAULT_SCRIPTS_FOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,63,60,10
- EDITTEXT IDC_SCRIPTS_FOLDER_PATH,11,76,170,13,ES_AUTOHSCROLL
- PUSHBUTTON "...",IDC_SELECT_SCRIPTS_FOLDER_BUTTON,194,76,17,13
- GROUPBOX "Dialogs",IDC_STATIC,7,99,121,27
- CONTROL "Ask for non clear image insertion",IDC_SETTINGS_ASKIMAGE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,110,113,10
- GROUPBOX "Images",IDC_STATIC,133,99,85,27
- CONTROL "Insert clear images",IDC_OPTIONS_CLEARIMGS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,110,69,10
- GROUPBOX "Non-breaking space",IDC_STATIC,7,162,80,46
- LTEXT "Display character:",IDC_STATIC,13,179,35,17
- COMBOBOX IDC_NBSP_CHAR,50,181,29,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- GROUPBOX "Keyboard layout",IDC_STATIC,91,162,128,46
- CONTROL "Change on start",IDC_CHANGE_KEYB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,98,176,87,9
- GROUPBOX "Paste images as",IDC_STATIC,6,128,212,30
- LTEXT "Image format:",IDC_STATIC,14,142,46,8
- COMBOBOX IDC_IMAGETYPE,64,140,40,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- EDITTEXT IDC_JPEGQUALITY,175,139,26,13,ES_AUTOHSCROLL | ES_NUMBER
- CONTROL "",IDC_JPEGSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,200,139,7,14
- LTEXT "JPEG quality:",IDC_STATIC,126,142,42,8
- COMBOBOX IDC_KEYB_LAYOUT,137,190,76,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- LTEXT "Change to:",IDC_STATIC,99,192,36,8
-END
-
-IDD_TOOLS_SETTINGS DIALOGEX 0, 0, 266, 282
-STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-EXSTYLE WS_EX_APPWINDOW
-CAPTION "Settings"
-FONT 8, "Microsoft Sans Serif", 400, 0, 0xCC
-BEGIN
- CONTROL "",IDC_TAB_CTRL,"SysTabControl32",0x0,0,0,265,253
- PUSHBUTTON "OK",IDOK,142,259,55,15
- PUSHBUTTON "Cancel",IDCANCEL,205,259,55,15
-END
-
-IDD_TABLE DIALOGEX 0, 0, 260, 46
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Table properties"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,203,7,50,14
- PUSHBUTTON "Cancel",IDCANCEL,203,24,50,14
- LTEXT "Number of table cells :",IDC_STATIC,7,22,150,8
- CONTROL "Add table header ",IDC_CHECK_TABLE_TITLE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,187,10
- EDITTEXT IDC_EDIT_TABLE_ROWS,157,19,35,14,ES_AUTOHSCROLL | ES_NUMBER
- CONTROL "",IDC_SPIN_TABLE_ROWS,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,192,19,11,14
-END
-
-IDD_WORDS DIALOGEX 0, 0, 366, 323
-STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
-CAPTION "Words"
-FONT 9, "Tahoma", 0, 0, 0x1
-BEGIN
- CONTROL "List1",IDC_WLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_TABSTOP,7,7,354,208,WS_EX_CLIENTEDGE
- DEFPUSHBUTTON "OK",IDOK,301,233,40,14
- PUSHBUTTON "Cancel",IDCANCEL,301,253,40,14
- EDITTEXT IDC_REDIT,242,223,41,12,NOT WS_VISIBLE | NOT WS_TABSTOP
- CONTROL "Show/hide exclusions",IDC_CHECK_SHOWHIDE_EXCLS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,223,80,10
- GROUPBOX "Process",IDC_STATIC,287,220,70,55
- GROUPBOX "Process highlited",IDC_STATIC,14,237,250,37
- PUSHBUTTON "Invert",IDC_BUTTON_DESEL,138,251,50,14
- PUSHBUTTON "Reset replaced",IDC_BUTTON_REMOVEHLREPL,198,251,55,14
- PUSHBUTTON "To exclusions",IDC_BUTTON_ADDHLTOEXCLS,21,251,51,14
- PUSHBUTTON "Highlight all",IDC_BUTTON_SELALL,114,221,51,14
- PUSHBUTTON "Set replaced",IDC_BUTTON_SETHLREPL,80,251,50,14
- PUSHBUTTON "Set replaced all",IDC_BUTTON_SELALLREPL,179,221,58,14
- GROUPBOX "Current word",IDC_WORDS_FR_GBOX_CURWORD,14,282,343,34
- EDITTEXT IDC_WORDS_FR_EDIT_WORD,42,296,67,14,ES_AUTOHSCROLL | ES_READONLY
- EDITTEXT IDC_WORDS_FR_EDIT_REPL,165,296,67,14,ES_AUTOHSCROLL | ES_READONLY
- LTEXT "Word:",IDC_WORDS_FR_TEXT_WORD,20,298,20,8
- LTEXT "Replacement:",IDC_WORDS_FR_TEXT_REPL,117,298,44,8
- PUSHBUTTON "Find",IDC_WORDS_FR_BTN_FIND,245,296,42,14
- PUSHBUTTON "Replace",IDC_WORDS_FR_BTN_REPL,299,296,43,14
-END
-
-IDD_REPLACE DIALOGEX 0, 0, 295, 87
-STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-CAPTION "Replace"
-FONT 9, "Tahoma", 0, 0, 0x0
-BEGIN
- LTEXT "Fi&nd what:",IDC_STATIC,7,9,45,8,NOT WS_GROUP
- LTEXT "Replace with:",IDC_STATIC,7,25,45,8,NOT WS_GROUP
- COMBOBOX IDC_TEXT,53,7,179,62,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- COMBOBOX IDC_REPLACE,53,23,179,62,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- CONTROL "Match &whole words",IDC_WHOLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,41,98,13
- CONTROL "Match &case",IDC_MATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54,98,13
- CONTROL "Regular &expression",IDC_REGEXP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,67,98,13
- GROUPBOX "Direction",IDC_STATIC,171,41,60,38,WS_GROUP
- CONTROL "&Up",IDC_UP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,178,52,44,11
- CONTROL "&Down",IDC_DOWN,"Button",BS_AUTORADIOBUTTON,178,63,44,11
- DEFPUSHBUTTON "&Find Next",ID_FIND_NEXT,238,7,50,14,WS_GROUP
- PUSHBUTTON "&Replace",IDC_REPLACE_ONE,238,25,50,14
- PUSHBUTTON "Replace &All",IDC_REPLACE_ALL,238,43,50,14
- PUSHBUTTON "Cancel",IDCANCEL,238,61,50,14
-END
-
-IDD_OPTIONS DIALOGEX 0, 0, 222, 215
-STYLE DS_SETFONT | WS_CHILD | WS_SYSMENU
-FONT 9, "Tahoma", 0, 0, 0x0
-BEGIN
- LTEXT "Text color:",IDC_STATIC,15,70,38,9
- PUSHBUTTON "",IDC_FG,60,68,22,12
- LTEXT "Background:",IDC_STATIC,89,70,41,9
- PUSHBUTTON "",IDC_BG,134,68,22,12
- LTEXT "Editor font:",IDC_STATIC,15,53,49,9
- COMBOBOX IDC_FONT,60,51,151,70,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- LTEXT "Font size:",IDC_STATIC,137,24,33,9
- COMBOBOX IDC_FONT_SIZE,174,21,36,70,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
- GROUPBOX "Common",IDC_STATIC,7,10,210,31
- GROUPBOX "Body",IDC_STATIC,7,41,210,46
- GROUPBOX "XML source editor",IDC_STATIC,7,89,210,72
- CONTROL "Wrap lines",IDC_WRAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,119,56,11
- CONTROL "Syntax highlighting",IDC_SYNTAXHL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,132,73,11
- CONTROL "Show end of line marks",IDC_SHOWEOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,145,104,11
- CONTROL "Fast Mode",IDC_FAST_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,68,43,11
- LTEXT "Language:",IDC_STATIC,15,23,48,8
- COMBOBOX IDC_LANG,59,21,68,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- GROUPBOX "Spellcheck",IDC_STATIC,7,162,210,45
- CONTROL "Highlight misspelled words",IDC_BACKGROUNDSPELLCHECK,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,117,174,94,10
- CONTROL "Use spellchecker",IDC_USESPELLCHECKER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,174,83,10
- EDITTEXT IDC_CUSTOM_DICT,78,189,122,12,ES_AUTOHSCROLL
- LTEXT "Custom dictionary:",IDS_SPELL_CUSTOM_DICT,15,191,60,9
- PUSHBUTTON "..",IDC_DICTPATH,201,189,12,12
- CONTROL "Show line numbers",IDC_SHOWLINENUMBERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,113,132,95,11
- CONTROL "Highlight matched tags",IDC_TAGHL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,113,145,87,11
- LTEXT "Editor font:",IDC_STATIC,14,105,49,9
- COMBOBOX IDC_SRCFONT,59,103,151,70,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- CONTROL "Show white spaces",IDC_SHOWWHITESPACE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,113,119,71,11
-END
-
-IDD_INPUTBOX DIALOGEX 0, 0, 290, 70
-STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Input"
-FONT 9, "Tahoma", 0, 0, 0x0
-BEGIN
- LTEXT "Text:",IDC_PROMPT,7,7,273,18
- EDITTEXT IDC_INPUT,7,31,273,12,ES_AUTOHSCROLL
- DEFPUSHBUTTON "&Yes",IDYES,155,49,39,14
- PUSHBUTTON "&No",IDNO,198,49,39,14
- PUSHBUTTON "&Cancel",IDCANCEL,241,49,39,14
-END
-
-IDD_FIND DIALOGEX 0, 0, 295, 76
-STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-CAPTION "Find"
-FONT 9, "Tahoma", 0, 0, 0x0
-BEGIN
- LTEXT "Fi&nd what:",IDC_STATIC,7,9,40,8
- COMBOBOX IDC_TEXT,49,7,183,62,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_GROUP | WS_TABSTOP
- DEFPUSHBUTTON "&Find Next",ID_FIND_NEXT,238,7,50,14,WS_GROUP
- CONTROL "Match &whole words",IDC_WHOLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,30,98,13
- CONTROL "Match &case",IDC_MATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,43,98,13
- CONTROL "Regular &expression",IDC_REGEXP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,56,98,13
- GROUPBOX "Direction",IDC_STATIC,172,30,60,38,WS_GROUP
- CONTROL "&Up",IDC_UP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,179,41,44,11
- CONTROL "&Down",IDC_DOWN,"Button",BS_AUTORADIOBUTTON,179,52,44,11
- PUSHBUTTON "Cancel",IDCANCEL,238,24,50,14
-END
-
-IDD_CUSTOMSAVEDLG DIALOGEX 0, 0, 415, 18
-STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
-FONT 8, "Tahoma", 0, 0, 0x0
-BEGIN
- LTEXT "Encoding:",IDC_STATIC,68,2,41,10
- COMBOBOX IDC_ENCODING,130,0,164,104,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
-END
-
-IDD_ABOUTBOX DIALOGEX 0, 0, 266, 151
-STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
-CAPTION "About"
-FONT 9, "Tahoma", 0, 0, 0x0
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,215,133,44,14
- CONTROL 248,IDC_AB_STATIC_BANNER,"Static",SS_BITMAP | SS_NOTIFY | NOT WS_VISIBLE,6,6,56,123,WS_EX_CLIENTEDGE
- CONTROL "",IDC_AB_BANNER,"Static",SS_OWNERDRAW | SS_NOTIFY | NOT WS_VISIBLE,6,6,57,123,WS_EX_CLIENTEDGE
- ICON IDR_MAINFRAME,IDC_STATIC_AB_APPICON,73,8,20,20
- EDITTEXT IDC_STATIC_AB_APPNAMEVER,99,8,157,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
- LTEXT "Build",IDC_STATIC_BUILD,101,20,15,8
- EDITTEXT IDC_BUILDSTAMP,123,20,132,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
- CONTROL "http://code.google.com/p/fictionbookeditor/ ",IDC_SYSLINK_AB_LINKS,
- "SysLink",0x0,101,32,154,8
- EDITTEXT IDC_CONTRIBS,70,51,189,77,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | WS_VSCROLL | NOT WS_TABSTOP,WS_EX_STATICEDGE
- CONTROL "Static",IDC_TEXT_STATUS,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,24,137,180,8
- CONTROL 400,IDC_PIC_UPDATE,"Static",SS_BITMAP,9,136,9,9
- PUSHBUTTON "Update now",IDC_UPDATE,161,133,49,14,NOT WS_VISIBLE
-END
-
-IDD_ADDIMAGE DIALOGEX 0, 0, 147, 66
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
-CAPTION "Choose"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "Yes",IDYES,21,31,49,14
- PUSHBUTTON "No",IDCANCEL,77,31,49,14
- CONTROL "Don't ask again",IDC_ADDIMAGE_ASKAGAIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,41,53,64,10
- LTEXT "Insert clear image?",IDS_ADD_CLEARIMG_TEXT,46,11,65,8
- ICON IDR_MAINFRAME,IDC_ADDIMAGE_ICON,19,6,20,20
-END
-
-IDD_HOTKEYS DIALOGEX 0, 0, 228, 227
-STYLE DS_SETFONT | WS_CHILD | WS_SYSMENU
-FONT 9, "Tahoma", 400, 0, 0xCC
-BEGIN
- LISTBOX IDC_LIST_HOTKEYS_GROUPS,7,21,70,88,LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE
- LISTBOX IDC_LIST_HOTKEYS,83,21,136,88,LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,WS_EX_STATICEDGE
- GROUPBOX "Description",IDC_STATIC_HOTKEY_DESCRIPTION,7,180,211,33,WS_TABSTOP
- EDITTEXT IDC_EDIT_HOTKEY,44,121,100,14,ES_MULTILINE | ES_AUTOHSCROLL
- LTEXT "Groups:",IDC_STATIC_HOTKEYS_GROUPS,9,11,25,8,WS_TABSTOP
- LTEXT "Commands:",IDC_STATIC_HOTKEYS,85,11,37,8,WS_TABSTOP
- LTEXT "Shortcut:",IDC_STATIC,10,124,31,8,WS_TABSTOP
- PUSHBUTTON "Default",IDC_BUTTON_DEFAULT,159,125,50,14
- EDITTEXT IDC_EDIT_HOTKEY_DESCRIPTION,9,189,206,22,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
- PUSHBUTTON "Delete",IDC_BUTTON_HOTKEY_DELETE,159,143,50,14
- GROUPBOX "Actions",IDC_STATIC_HOTKEY_ACTIONS,149,114,69,65
- GROUPBOX "Assigned to",IDC_STATIC_HOTKEY_COLLISION,7,138,137,41
- PUSHBUTTON "Assign",IDC_BUTTON_HOTKEY_ASSIGN,159,161,50,14,WS_DISABLED
- EDITTEXT IDC_EDIT_HOTKEY_COLLISION,14,150,125,24,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
-END
-
-IDD_SETTINGS_WORDS DIALOGEX 0, 0, 262, 227
-STYLE DS_SETFONT | WS_CHILD
-FONT 8, "Tahoma", 400, 0, 0x1
-BEGIN
- EDITTEXT IDC_EDIT_NEW,18,162,165,14,ES_AUTOHSCROLL
- PUSHBUTTON "Add",IDC_BUTTON_ADD,194,162,50,14
- GROUPBOX "Word-exclusion list",IDC_STATIC_WORDS_CHEVRON,7,8,248,177
- CONTROL "",IDC_LIST_WORDS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTDESCENDING | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,17,25,227,106,WS_EX_CLIENTEDGE
- CONTROL "Show exclusions in Words dialog",IDC_CHECK_SHOW_EXCLUSIONS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,198,119,10
- CONTROL "Select All",IDC_CHECK_SELALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,142,45,10
- PUSHBUTTON "Remove selected",IDC_BUTTON_REMOVESEL,67,140,73,14
- EDITTEXT IDC_EDIT_LV,183,7,62,14,ES_AUTOHSCROLL | NOT WS_VISIBLE | NOT WS_TABSTOP,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
-END
-
-IDD_PROPPAGE_LARGE DIALOGEX 0, 0, 235, 156
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
-CAPTION "Property Page"
-FONT 8, "MS Shell Dlg", 400, 0, 0x0
-BEGIN
- LTEXT "TODO: layout property page",IDC_STATIC,73,74,90,8
-END
-
-IDD_SPELL_CHECK DIALOGEX 0, 0, 273, 135
-STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Spelling"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "Cancel",IDCANCEL,216,112,50,14
- LTEXT "Not In Dictionary:",IDC_STATIC,7,14,64,8
- EDITTEXT IDC_SPELL_BEDWORD,72,12,194,12,ES_AUTOHSCROLL
- LTEXT "Change To:",IDC_STATIC,8,30,46,8
- EDITTEXT IDC_SPELL_REPLACEMENT,72,29,194,12,ES_AUTOHSCROLL
- LTEXT "Suggestions:",IDC_STATIC,7,47,46,8
- LISTBOX IDC_SPELL_SUGG_LIST,7,58,145,68,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "Ignore",IDC_SPELL_IGNORE,159,58,50,14
- PUSHBUTTON "Ignore All",IDC_SPELL_IGNOREALL,216,58,50,14
- PUSHBUTTON "Change",IDC_SPELL_CHANGE,159,76,50,14
- PUSHBUTTON "Change All",IDC_SPELL_CHANGEALL,216,76,50,14
- PUSHBUTTON "Add",IDC_SPELL_ADD,159,94,50,14
- PUSHBUTTON "Suggets",IDC_SPELL_SUGGEST,216,94,50,14,WS_DISABLED
- PUSHBUTTON "Undo last",IDC_SPELL_UNDO,159,112,50,14,WS_DISABLED
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDR_MAINFRAME ICON "res\\FBE2.ico"
-IDI_OLDICON ICON "res\\FBE.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Toolbar
-//
-
-IDR_MAINFRAME TOOLBAR 24, 24
-BEGIN
- BUTTON ID_FILE_NEW
- BUTTON ID_FILE_OPEN
- BUTTON ID_FILE_SAVE
- SEPARATOR
- BUTTON ID_FILE_VALIDATE
- SEPARATOR
- BUTTON ID_VIEW_DESC
- BUTTON ID_VIEW_BODY
- BUTTON ID_VIEW_SOURCE
- SEPARATOR
- BUTTON ID_EDIT_ADDBINARY
- BUTTON ID_EDIT_INS_IMAGE
- BUTTON ID_EDIT_INS_INLINEIMAGE
- SEPARATOR
- BUTTON ID_EDIT_FIND
- BUTTON ID_EDIT_FINDNEXT
- SEPARATOR
- BUTTON ID_EDIT_CUT
- BUTTON ID_EDIT_COPY
- BUTTON ID_EDIT_PASTE
- SEPARATOR
- BUTTON ID_EDIT_UNDO
- BUTTON ID_EDIT_REDO
- SEPARATOR
- BUTTON ID_EDIT_BOLD
- BUTTON ID_EDIT_ITALIC
- BUTTON ID_EDIT_SUP
- BUTTON ID_EDIT_SUB
- BUTTON ID_EDIT_STRIK
- BUTTON ID_EDIT_CODE
- SEPARATOR
- BUTTON ID_STYLE_LINK
- BUTTON ID_STYLE_NOTE
- BUTTON ID_STYLE_NOLINK
- BUTTON ID_GOTO_FOOTNOTE
- SEPARATOR
- BUTTON ID_STYLE_NORMAL
- BUTTON ID_STYLE_SUBTITLE
- BUTTON ID_STYLE_TEXTAUTHOR
- SEPARATOR
- BUTTON ID_TOOLS_SPELLCHECK
-END
-
-IDR_MAINFRAME_SMALL TOOLBAR 16, 16
-BEGIN
- BUTTON ID_FILE_NEW
- BUTTON ID_FILE_OPEN
- BUTTON ID_FILE_SAVE
- BUTTON ID_FILE_VALIDATE
- BUTTON ID_VIEW_DESC
- BUTTON ID_VIEW_BODY
- BUTTON ID_VIEW_SOURCE
- BUTTON ID_VIEW_OPTIONS
- BUTTON ID_EDIT_ADDBINARY
- BUTTON ID_EDIT_FIND
- BUTTON ID_EDIT_FINDNEXT
- BUTTON ID_EDIT_REPLACE
- BUTTON ID_EDIT_CUT
- BUTTON ID_EDIT_COPY
- BUTTON ID_EDIT_PASTE
- BUTTON ID_EDIT_UNDO
- BUTTON ID_EDIT_REDO
- BUTTON ID_EDIT_INS_IMAGE
- BUTTON ID_EDIT_INS_INLINEIMAGE
- BUTTON ID_EDIT_ADD_IMAGE
- BUTTON ID_STYLE_LINK
- BUTTON ID_STYLE_NOTE
- BUTTON ID_STYLE_NOLINK
- BUTTON ID_STYLE_NORMAL
- BUTTON ID_STYLE_SUBTITLE
- BUTTON ID_STYLE_TEXTAUTHOR
- BUTTON ID_GOTO_FOOTNOTE
- BUTTON ID_EDIT_ADD_BODY
- BUTTON ID_EDIT_ADD_TITLE
- BUTTON ID_EDIT_ADD_EPIGRAPH
- BUTTON ID_EDIT_ADD_ANN
- BUTTON ID_EDIT_INS_POEM
- BUTTON ID_EDIT_INS_CITE
- BUTTON ID_INSERT_TABLE
- BUTTON ID_TOOLS_SPELLCHECK
-END
-
-IDR_DOCUMENT_TREE TOOLBAR 24, 24
-BEGIN
- BUTTON ID_DT_RIGHT_ONE
- BUTTON ID_DT_RIGHT_SMART
- BUTTON ID_DT_LEFT
- BUTTON ID_DT_MERGE
- BUTTON ID_DT_DELETE
-END
-
-IDR_SCRIPTS TOOLBAR 16, 16
-BEGIN
- BUTTON ID_LAST_SCRIPT
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-IDR_MAINFRAME BITMAP "res\\Toolbar.bmp"
-IDR_MAINFRAME_SMALL BITMAP "res\\Toolbar_small.bmp"
-IDR_SCRIPTS BITMAP "res\\Scripts.bmp"
-IDB_STRUCTURE BITMAP "res\\struct.bmp"
-IDB_WORDSTATES BITMAP "res\\wordstat.bmp"
-IDR_DOCUMENT_TREE BITMAP "res\\document.bmp"
-IDB_AB_BANNER BITMAP "res\\Fb2-shema.bmp"
-IDB_UPD_OK BITMAP "res\\ok.bmp"
-IDB_UPD_ERR BITMAP "res\\error.bmp"
-IDB_UPD_UPDATE BITMAP "res\\update.bmp"
-IDB_UPD_CHECK1 BITMAP "res\\Icon_02.bmp"
-IDB_UPD_CHECK2 BITMAP "res\\Icon_03.bmp"
-IDB_UPD_CHECK3 BITMAP "res\\Icon_04.bmp"
-IDB_UPD_CHECK4 BITMAP "res\\Icon_05.bmp"
-IDB_UPD_CHECK5 BITMAP "res\\Icon_06.bmp"
-IDB_UPD_CHECK6 BITMAP "res\\Icon_07.bmp"
-IDB_UPD_CHECK7 BITMAP "res\\Icon_08.bmp"
-IDB_UPD_CHECK8 BITMAP "res\\Icon_09.bmp"
-IDB_UPD_CHECK9 BITMAP "res\\Icon_10.bmp"
-IDB_UPD_CHECK10 BITMAP "res\\Icon_11.bmp"
-IDB_UPD_CHECK11 BITMAP "res\\Icon_12.bmp"
-IDB_UPD_CHECK12 BITMAP "res\\Icon_13.bmp"
-IDB_UPD_CHECK13 BITMAP "res\\Icon_14.bmp"
-IDB_UPD_CHECK14 BITMAP "res\\Icon_15.bmp"
-IDB_UPD_CHECK15 BITMAP "res\\Icon_16.bmp"
-IDB_UPD_CHECK16 BITMAP "res\\Icon_17.bmp"
-IDB_UPD_CHECK17 BITMAP "res\\Icon_18.bmp"
-IDB_UPD_CHECK18 BITMAP "res\\Icon_19.bmp"
-IDB_UPD_CHECK19 BITMAP "res\\Icon_20.bmp"
-IDB_UPD_CHECK20 BITMAP "res\\Icon_21.bmp"
-IDB_UPD_CHECK21 BITMAP "res\\Icon_22.bmp"
-IDB_UPD_CHECK22 BITMAP "res\\Icon_23.bmp"
-IDB_UPD_CHECK23 BITMAP "res\\Icon_24.bmp"
-IDB_UPD_CHECK24 BITMAP "res\\Icon_25.bmp"
-IDB_CENTER BITMAP "res\\center.bmp"
-IDB_ORANGE BITMAP "res\\orange.bmp"
-IDB_GREEN BITMAP "res\\green.bmp"
-IDB_DOC BITMAP "res\\doc.bmp"
-IDB_XML BITMAP "res\\xml.bmp"
-IDB_OTHER BITMAP "res\\other.bmp"
-IDB_HTML BITMAP "res\\html.bmp"
-IDB_PRC BITMAP "res\\prc.bmp"
-IDB_TEXT BITMAP "res\\text.bmp"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,6,0,0
- PRODUCTVERSION 2,6,0,0
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x21L
-#else
- FILEFLAGS 0x20L
-#endif
- FILEOS 0x40004L
- FILETYPE 0x1L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", "Release"
- VALUE "CompanyName", "FBE Team"
- VALUE "FileDescription", "FictionBook Editor"
- VALUE "FileVersion", "2.6"
- VALUE "InternalName", "FBE"
- VALUE "LegalCopyright", "Copyright 2010 FBE Team, 2008 LitRes, 2003 Mike Matsnev"
- VALUE "OriginalFilename", "FBE.exe"
- VALUE "ProductName", "FictionBook Editor"
- VALUE "ProductVersion", "2"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// RT_MANIFEST
-//
-
-1 RT_MANIFEST "res\\FBE.exe.manifest"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_MAINFRAME MENU
-BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "&New", ID_FILE_NEW
- MENUITEM "&Open...", ID_FILE_OPEN
- MENUITEM "&Save", ID_FILE_SAVE
- MENUITEM "Save &As...", ID_FILE_SAVE_AS
- MENUITEM "&Validate", ID_FILE_VALIDATE
- MENUITEM SEPARATOR
- POPUP "&Import"
- BEGIN
- MENUITEM "No import plugins installed", IDCANCEL
- END
- POPUP "&Export"
- BEGIN
- MENUITEM "No export plugins installed", IDCANCEL
- END
- MENUITEM SEPARATOR
- POPUP "&Recent Files"
- BEGIN
- MENUITEM "No Recent Files", ID_FILE_MRU_FIRST, INACTIVE
- END
- MENUITEM SEPARATOR
- MENUITEM "E&xit", ID_APP_EXIT
- END
- POPUP "&Edit"
- BEGIN
- MENUITEM "&Undo", ID_EDIT_UNDO
- MENUITEM "&Redo", ID_EDIT_REDO
- MENUITEM SEPARATOR
- MENUITEM "Cu&t", ID_EDIT_CUT
- MENUITEM "&Copy", ID_EDIT_COPY
- MENUITEM "&Paste", ID_EDIT_PASTE
- MENUITEM SEPARATOR
- MENUITEM "&Find...", ID_EDIT_FIND
- MENUITEM "Find &Next", ID_EDIT_FINDNEXT
- MENUITEM "R&eplace...", ID_EDIT_REPLACE
- MENUITEM SEPARATOR
- MENUITEM "&Go to footnote or reference", ID_GOTO_FOOTNOTE
- MENUITEM "Go to matching &tag", ID_GOTO_MATCHTAG
- MENUITEM "Go to &wrong tag", ID_GOTO_WRONGTAG
- MENUITEM SEPARATOR
- MENUITEM "C&lone container", ID_EDIT_CLONE
- MENUITEM "Sp&lit container", ID_EDIT_SPLIT
- MENUITEM "&Merge containers", ID_EDIT_MERGE
- MENUITEM "Remove outer container", ID_EDIT_REMOVE_OUTER_SECTION
- END
- POPUP "&View"
- BEGIN
- MENUITEM "&Commands toolbar", 60161
- MENUITEM "Scripts toolbar", 60162
- MENUITEM "&Links Bar", 60163
- MENUITEM "Table Bar", 60164
- MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
- MENUITEM "&Document Tree", ID_VIEW_TREE
- MENUITEM SEPARATOR
- MENUITEM "D&escription", ID_VIEW_DESC
- MENUITEM "&Body", ID_VIEW_BODY
- MENUITEM "So&urce", ID_VIEW_SOURCE
- MENUITEM SEPARATOR
- MENUITEM "Fast Mode", ID_VIEW_FASTMODE
- END
- POPUP "&Add"
- BEGIN
- MENUITEM "&Body", ID_EDIT_ADD_BODY
- MENUITEM "&Title", ID_EDIT_ADD_TITLE
- MENUITEM "&Epigraph", ID_EDIT_ADD_EPIGRAPH
- MENUITEM "A&nnotation", ID_EDIT_ADD_ANN
- MENUITEM SEPARATOR
- MENUITEM "T&ext author", ID_EDIT_ADD_TA
- MENUITEM "&Image", ID_EDIT_INS_IMAGE
- MENUITEM "In&line image", ID_EDIT_INS_INLINEIMAGE
- MENUITEM "&Poem", ID_EDIT_INS_POEM
- MENUITEM "&Cite", ID_EDIT_INS_CITE
- MENUITEM "T&able", ID_INSERT_TABLE
- MENUITEM "&Section image", ID_EDIT_ADD_IMAGE
- MENUITEM SEPARATOR
- MENUITEM "Add &Binary Object...", ID_EDIT_ADDBINARY
- END
- POPUP "&Style"
- BEGIN
- MENUITEM "&Normal", ID_STYLE_NORMAL
- MENUITEM "Text &Author", ID_STYLE_TEXTAUTHOR
- MENUITEM "&Subtitle", ID_STYLE_SUBTITLE
- MENUITEM SEPARATOR
- MENUITEM "&Link...", ID_STYLE_LINK
- MENUITEM "&Footnote...", ID_STYLE_NOTE
- MENUITEM "&Remove link", ID_STYLE_NOLINK
- END
- POPUP "&Tools"
- BEGIN
- MENUITEM "&Words...", ID_TOOLS_WORDS
- MENUITEM "&Settings...", ID_VIEW_OPTIONS
- MENUITEM SEPARATOR
- MENUITEM "Spell &check...", ID_TOOLS_SPELLCHECK
- END
- POPUP "&Scripts"
- BEGIN
- MENUITEM "No scripts found", IDCANCEL, INACTIVE
- END
- POPUP "&Help"
- BEGIN
- MENUITEM "&About FBE...", ID_APP_ABOUT
- END
-END
-
-IDR_DOCUMENT_TREE MENU
-BEGIN
- POPUP "DT"
- BEGIN
- MENUITEM "View", ID_DT_VIEW
- MENUITEM "View Source", ID_DT_VIEWSOURCE
- MENUITEM SEPARATOR
- MENUITEM "Move Right", ID_DT_RIGHT_ONE
- MENUITEM "Move With Children", ID_DT_RIGHT_SMART
- MENUITEM "Move Left", ID_DT_LEFT
- MENUITEM SEPARATOR
- MENUITEM "Delete", ID_DT_DELETE
- END
-END
-
-IDR_TOOLBAR_MENU MENU
-BEGIN
- POPUP "CUSTOMIZE"
- BEGIN
- MENUITEM "Customize toolbar...", ID_TOOLS_CUSTOMIZE
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// ABOUT_FILE
-//
-
-ABOUT_FILE ABOUT_FILE "files\\contributors.txt"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE
-BEGIN
- IDS_HOTKEY_EDIT_ADD_EPIGRAPH "Add epigraph"
- IDS_HOTKEY_EDIT_ADD_IMAGE "Add section image"
- IDS_HOTKEY_EDIT_ADD_TA "Add text author"
- IDS_HOTKEY_EDIT_ADD_TITLE "Add title"
- IDS_HOTKEY_EDIT_BOLD "Bold"
- IDS_HOTKEY_EDIT_CLONE "Clone"
- IDS_HOTKEY_EDIT_COPY "Copy"
- IDS_HOTKEY_EDIT_CUT "Cut"
- IDS_HOTKEY_EDIT_FIND "Find"
- IDS_HOTKEY_EDIT_FIND_NEXT "Find next"
- IDS_HOTKEY_EDIT_INCREMENTAL_SEARCH "Incremental search"
- IDS_HOTKEY_EDIT_INSERT_CITE "Insert cite"
- IDS_HOTKEY_EDIT_INSERT_IMAGE "Insert image"
- IDS_HOTKEY_EDIT_INSERT_POEM "Insert poem"
- IDS_HOTKEY_EDIT_ITALIC "Italic"
- ID_VIEW_SOURCE "Show document source code\nSource"
-END
-
-STRINGTABLE
-BEGIN
- IDS_HOTKEY_PLUGINS_LAST_PLUGIN "Last plugin"
- IDS_HOTKEY_TOOLS_SPELL "Spell check"
- IDC_SPELL_ADD2DICT "Add to dictionary"
- IDS_SPELL_COMPLETED "The spelling check is complete."
- IDC_SPELL_IGNOREALL "Ignore All"
- IDS_SPELL_CONTINUE "Continue"
- IDS_HOTKEY_EDIT_INSERT_INLINEIMAGE "Insert inline image"
- IDS_UPDATE_CANTCONNECT "Can't connect to server"
- IDS_HOTKEY_FASTMODE "Fast mode"
- IDS_HOTKEY_TREEVIEW "Toggle tree view"
- IDS_HOTKEY_TOOLS_SPELLHIGHLIGHT "Toggle highlight"
- IDS_HOTKEY_NAVIGATION_GOTO_FOOTNOTE "Go to footnote or reference"
- IDS_HOTKEY_NAVIGATION_GOTO_MATCHTAG "Go to matchig tag"
- IDS_HOTKEY_NAVIGATION_GOTO_WRONGTAG "Go to wrong tag"
- IDS_UPDATE_DOWNLOADEDFROM "%d Kb from %d Kb downloaded (%d%%)"
- IDS_UPDATE_DOWNLOADED "%d Kb downloaded"
-END
-
-STRINGTABLE
-BEGIN
- ID_INSERT_TABLE "Insert an table at cursor\nInsert table"
- ID_GOTO_FOOTNOTE "Go to footnote or reference\nGo to footnote or reference"
-END
-
-STRINGTABLE
-BEGIN
- ID_LAST_SCRIPT "Execute last called script\nLast script"
- ID_TOOLS_SPELLCHECK "Check document spelling...\nCheck document spelling"
- ID_GOTO_MATCHTAG "Go to matching tag\nGo to matching tag"
- ID_GOTO_WRONGTAG "Go to wrong tag\nGo to wrong tag"
-END
-
-STRINGTABLE
-BEGIN
- ID_DT_LEFT "\nMove to the left"
- ID_DT_DELETE "\nDelete selected node"
- ID_DT_RIGHT_ONE "\nMove node once to the right"
- ID_DT_RIGHT_SMART "\nMove one node to the right with smart mode"
- ID_DT_MERGE "\nMerge containers"
- ID_VIEW_FASTMODE "Toggle fast mode\nToggle fast mode"
-END
-
-STRINGTABLE
-BEGIN
- ID_EDIT_ADD_TA "Add a text author paragraph to the selected container\nAdd text author"
- ID_EDIT_MERGE "Merge selected container with next\nMerge containers"
- ID_EDIT_INS_CITE "Replace selection with a cite container\nInsert cite"
- ID_EDIT_STRIK "Marks the selection """"strikethrough"""" (toggle)\nStrikethrough"
- ID_EDIT_SUB "Marks the selection """"sub"""" (toggle)\nSub"
- ID_EDIT_SUP "Marks the selection """"sup"""" (toggle)\nSup"
- ID_EDIT_CODE "Marks the selection """"code"""" (toggle)\nCode"
-END
-
-STRINGTABLE
-BEGIN
- ID_EDIT_ADD_TITLE "Add a title to the selected object\nAdd title"
- ID_EDIT_ADD_BODY "Add a new body to the document\nAdd body"
- ID_EDIT_CLONE "Clone selected object\nClone"
- ID_EDIT_INS_IMAGE "Insert an image at cursor\nInsert image"
- ID_EDIT_INS_INLINEIMAGE "Insert an inline image at cursor\nInsert inline image"
- ID_FILE_VALIDATE "Validate current document against FictionBook schema\nValidate"
- ID_EDIT_ADD_EPIGRAPH "Add epigraph to selected object\nAdd epigraph"
- ID_EDIT_ADD_IMAGE "Add an image to the selected object\nAdd image"
- ID_EDIT_ADD_ANN "Add annotation to the selected obejct\nAdd annotation"
- ID_EDIT_SPLIT "Split parent container at selection\nSplit container"
- ID_EDIT_INS_POEM "Replace selection with a poem container\nInsert poem"
-END
-
-STRINGTABLE
-BEGIN
- ID_VIEW_TREE "Show or hide the document tree\nToggle document tree"
- IDS_PANE_INS "INS"
- IDS_PANE_OVR "OVR"
- IDS_DOC_TREE_CLEANUP "Clean"
- IDS_HOTKEY_FILE_OPEN "Open"
- IDS_HOTKEY_FILE_SAVE "Save"
- IDS_HOTKEY_FILE_SAVEAS "Save as..."
- IDS_HOTKEY_FILE_VALIDATE "Validate"
- IDS_HOTKEY_GROUP_FILE "File"
- IDS_HOTKEY_EDIT_ADD_ANNOTATION "Add annotation"
- IDS_HOTKEY_EDIT_ADD_BODY "Add body"
-END
-
-STRINGTABLE
-BEGIN
- ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
-END
-
-STRINGTABLE
-BEGIN
- 60161 "Show or hide the command toolbar\nToggle Command ToolBar"
- 60162 "Show or hide the scripts toolbar\nToggle Scripts ToolBar"
- 60163 "Show or hide the links bar\nToggle LinksBar"
- 60164 "Show or hide the table bar\nToggle TableBar"
-END
-
-STRINGTABLE
-BEGIN
- ID_STYLE_NORMAL "Normal paragraph style\nNormal"
- ID_STYLE_TEXTAUTHOR "Text author paragraph style\nText author"
- ID_STYLE_SUBTITLE "Subtitle paragraph style\nSubtitle"
- ID_VIEW_OPTIONS "Display options\nDisplay options"
-END
-
-STRINGTABLE
-BEGIN
- ID_EDIT_BOLD "Marks the selection ""strong"" (toggle)\nStrong"
- ID_EDIT_ITALIC "Marks the selection ""emphasis"" (toggle)\nEmphasis"
-END
-
-STRINGTABLE
-BEGIN
- ID_STYLE_LINK "Add a hyperlink\nHyperlink"
- ID_STYLE_NOTE "Add a footnote\nFootnote"
- ID_EDIT_FINDNEXT "Repeats the last find\nFind next"
- ID_VIEW_DESC "Show document description\nDescription"
- ID_VIEW_BODY "Show document body\nBody"
- ID_STYLE_NOLINK "Remove links from selected text\nRemove links"
- ID_EDIT_ADDBINARY "Add a new binary object to the document\nAdd binary object"
-END
-
-STRINGTABLE
-BEGIN
- ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
- ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
- ID_EDIT_FIND "Find the specified text\nFind"
- ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
- ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
- ID_EDIT_UNDO "Undo the last action\nUndo"
- ID_EDIT_REDO "Redo the previously undone action\nRedo"
-END
-
-STRINGTABLE
-BEGIN
- ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
- ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
-END
-
-STRINGTABLE
-BEGIN
- ID_FILE_NEW "Create a new document\nNew"
- ID_FILE_OPEN "Open an existing document\nOpen"
- ID_FILE_SAVE "Save the active document\nSave"
- ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
-END
-
-STRINGTABLE
-BEGIN
- IDS_CHOOSE_SCRIPTS_FLD "Specify scripts folder"
- IDS_SCRIPT_HOTKEY_CONFLICT
- "Script\n%s\n returned a virtual-key that conflicts with previously loaded script\n %s"
- IDS_HOTKEY_EDIT_MERGE "Merge"
- IDS_HOTKEY_EDIT_PASTE "Paste"
- IDS_HOTKEY_EDIT_REDO "Redo"
- IDS_HOTKEY_EDIT_REPLACE "Replace"
- IDS_HOTKEY_EDIT_SPLIT "Split"
- IDS_HOTKEY_EDIT_UNDO "Undo"
- IDS_HOTKEY_GROUP_EDIT "Edit"
- IDS_HOTKEY_GROUP_NAVIGATION "Navigation"
- IDS_UPDATE_CHECK "Checking for update..."
- IDS_HOTKEY_NAVIGATION_NEXT_ITEM "Next item"
- ID_PANE_INS "OVR"
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE1 "Collapse 1 tree level"
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE2 "Collapse 2 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE3 "Collapse 3 tree levels"
-END
-
-STRINGTABLE
-BEGIN
- ATL_IDS_IDLEMESSAGE "Ready"
-END
-
-STRINGTABLE
-BEGIN
- ATL_IDS_MRU_FILE "Open this document"
- IDS_ENCODINGS "utf-8,utf-16,windows-1251,windows-1252,iso-8859-1,iso-8859-2,iso-8859-5,iso-8859-15,koi8-r"
- IDS_DOCUMENT_TREE_CAPTION "Document structure"
-END
-
-STRINGTABLE
-BEGIN
- IDR_MAINFRAME "FBE"
- IDS_SB_NO_ERR "No errors found."
- IDS_DMS_TI "Title info"
- IDS_LANG_ENGLISH "English"
- IDS_LANG_RUSSIAN "Russian"
- IDS_DMS_GENRE_M "Genre Match"
- IDS_DMS_KW "KeyWords"
- IDS_DMS_AUTHOR "Author NickName"
- IDS_DMS_DI "Document Info"
- IDS_DMS_ID "ID"
- IDS_DMS_STI "Source Title Info"
- IDS_DMS_CI "Custom Info"
- IDS_SETTINGS_VIEW_CAPTION "View"
- IDS_SETTINGS_OTHER_CAPTION "Other"
- IDS_TB_CAPT_ID "ID:"
- IDS_TB_CAPT_HREF "Href:"
-END
-
-STRINGTABLE
-BEGIN
- IDS_MB_OK "OK"
- IDS_MB_CANCEL "Cancel"
- IDS_MB_ABORT "&Abort"
- IDS_MB_RETRY "&Retry"
- IDS_MB_IGNORE "&Ignore"
- IDS_MB_YES "&Yes"
- IDS_MB_NO "&No"
- IDS_MB_CLOSE "Close"
-END
-
-STRINGTABLE
-BEGIN
- IDS_CTXMENU_COPY "Copy"
- IDS_CTXMENU_PASTE "Paste"
- IDS_CTXMENU_SELECT "Select"
- IDS_CTXMENU_IMG_SAVEAS "Save image as..."
- IDS_UPDATE_CONNECTING "Connecting to server..."
- IDS_HOTKEY_WRONG "Wrong shortcut!"
- IDS_HOTKEY_DEFAULT_COLLISION
- "Default hotkey for this command was assigned to ""%s""! Replace?"
- IDS_HOTKEY_ASSIGN_NO_COLLISION "Not assigned to other command"
- IDS_HOTKEY_ASSIGN_COLLISION "Assigned to ""%s"""
- IDS_SETTINGS_NEED_RESTART
- "In order to process changes the program must be restarted.\nRestart now?"
- IDS_DOCTREE_MENU_ELEMENTS "Elements"
- IDS_DOCTREE_MENU_SCRIPTS "Scripts"
- IDS_HOTKEY_EDIT_REMOVE_OUTER_SECTION "Remove outer section"
- IDS_HOTKEY_GROUP_TOOLS "Tools"
- IDS_HOTKEY_TOOLS_WORDS "Words"
- IDS_HOTKEY_GROUP_PLUGINS "Plugins"
-END
-
-STRINGTABLE
-BEGIN
- IDS_UPDATE_DOWNLOADCOMPLETE "Download completed, writing setup file..."
- IDS_UPDATE_DOWNLOADERROR "Download error"
- IDS_UPDATE_404ERROR "404 error : Not Found"
- IDS_UPDATE_403ERROR "403 error : Forbidden"
- IDS_UPDATE_407ERROR "407 error : proxy authentication required"
- IDS_UPDATE_NOTSUPPORTEDRANGE " ( not support range )"
- IDS_UPDATE_DOWNLOADERRORSTATUS "Download error, status code : %d"
- IDS_UPDATE_INCORRECTMD5 "Error, incorrect MD5 checksum"
- IDS_UPDATE_NEWVERSIONAVAILABLE "A new version of FBE is available."
- IDS_UPDATE_HAVELATESTVERSION "You have a latest version of FBE."
- IDS_ABOUT_LOGOCAPTION "FB2 animated logo press ? for help"
- IDS_UPDATE_CLOSE "FBE must be closed to continue installation.\r\n\r\nYou may delete installation file at download location ""%s"" later.\r\n\r\nQuit FBE now and continue installation?"
- IDS_LANG_UKRAINIAN "Ukrainian"
- IDS_UPDATEEXISTS "Update file %s is already exists.\r\nWould you like to execute this file?"
- IDS_UPDATE_DOWNLOADREADY "Update is ready."
- IDS_BAD_XML_MSG "You have opened an invalid XML document.\n\nYou should correct all XML errors (use ""Validate"" and ""Go to wrong tag"" commands) before switching from the SOURCE mode."
-END
-
-STRINGTABLE
-BEGIN
- IDS_TB_CAPT_SECTION_ID "Section ID:"
- IDS_TB_CAPT_IMAGE_TITLE "Image title:"
- IDS_TB_CAPT_TABLE_ID "Table ID:"
- IDS_TB_CAPT_TABLE_STYLE "Table Style:"
- IDS_TB_CAPT_STYLE "style:"
- IDS_TB_CAPT_COLSPAN "colspan:"
- IDS_TB_CAPT_ROWSPAN "rowspan:"
- IDS_TB_CAPT_TR_ALIGN "tr align:"
- IDS_TB_CAPT_TD_ALIGN "th, td align:"
- IDS_TB_CAPT_TD_VALIGN "th, td valign:"
- IDS_SAVE_DLG_MSG "Save changes to %s?"
- IDS_ERRMSGBOX_CAPTION "Error"
- IDS_INVALID_CML_MSG "Invalid command line option: '%c'"
- IDS_CML_ARGS_MSG "Command line option '%c' requires an argument"
- IDS_SEARCH_END_MSG "Finished searching for '%s'."
- IDS_REPL_ALL_CAPT "Replace All"
-END
-
-STRINGTABLE
-BEGIN
- IDS_REPL_DONE_MSG "%d replacement(s) done."
- IDS_SEARCH_FAIL_MSG "Cannot find the string '%s'."
- IDS_SCRIPT_MSG_CPT "FBE Script message"
- IDS_GENRES_LIST_MSG "Can't open genres file %s"
- IDS_VALIDATION_FAIL_MSG "%s\r\nDo you still want to save the file?\r\n\r\nWARNING: Invalid files can be improperly displayed and can cause errors in other applications."
- IDS_VALIDATION_FAIL_CPT "Validation failed"
- IDS_OUT_OF_MEM_MSG "Out of memory"
- IDS_SCINTILLA_LOAD_ERR_MSG "Can't load Scintilla."
- IDS_GOTO_REF_FAIL_MSG "Reference not found."
- IDS_IMPORT_ERR_CPT "Import Error"
- IDS_IMPORT_ERR_MSG "Plugin does not support the required interface"
- IDS_IMPORT_XML_ERR_MSG "Imported object does not support IXMLDOMDocument2 interface"
- IDS_EXPORT_ERR_CPT "Export Error"
- IDS_EXPORT_ERR_MSG "Plugin does not support the required interface"
- IDS_FILE_CHANGED_CPT "File changed"
- IDS_FILE_CHANGED_MSG "%s has been changed by anouther application.\nDo you want to reload it?"
-END
-
-STRINGTABLE
-BEGIN
- IDS_SCRIPT_ERRX_MSG "Script error: %08X at line %d, column %d"
- IDS_SCRIPT_ERRD_MSG "Script error: %s at line %d, column %d"
- IDS_SCRIPT_MSG "Unknown error in script."
- IDS_SCRIPT_LOAD_ERR_MSG "Error loading %s: %s"
- IDS_COM_ERR_CPT "COM Error"
- IDS_XML_PARSE_ERR_CPT "XML Parse Error"
- IDS_XML_PARSE_ERR_MSG "At %s, line %d, column %d: %s"
- IDS_XML_PARSE_ERRQ_MSG "At %s: %s"
- IDS_REPL_WORDS_CPT "Replace words"
- IDS_REPL_WORDS_MSG "%d replacement(s) done"
- IDS_NO_SCRIPTS "No scripts found"
- IDS_SB_SAVED_NO_ERR "Document saved - No errors found."
- IDS_ADD_CLEARIMG_TEXT "Insert clear image?"
- IDS_ADD_CLEARIMG_CAPTION "Add image"
- IDS_ADD_IMAGE_FILEDLG "Choose image to add:"
- IDS_ADD_BINARIES_FILEDLG "Choose binaries to add:"
-END
-
-STRINGTABLE
-BEGIN
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE4 "Collapse 4 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE5 "Collapse 5 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE6 "Collapse 6 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE7 "Collapse 7 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE8 "Collapse 8 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE9 "Collapse 9 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND1 "Expand 1 tree level"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND2 "Expand 2 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND3 "Expand 3 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND4 "Expand 4 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND5 "Expand 5 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND6 "Expand 6 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND7 "Expand 7 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND8 "Expand 8 tree levels"
- IDS_HOTKEY_NAVIGATION_SCI_EXPAND9 "Expand 9 tree levels"
- IDS_HOTKEY_NAVIGATION_SELECT_HREF "Href"
-END
-
-STRINGTABLE
-BEGIN
- IDS_HOTKEY_NAVIGATION_SELECT_ID "ID "
- IDS_HOTKEY_NAVIGATION_SELECT_ID_TABLE "Table ID"
- IDS_HOTKEY_NAVIGATION_SELECT_TEXT "Text"
- IDS_HOTKEY_NAVIGATION_SELECT_TREE "Tree"
- IDS_HOTKEY_GROUP_STYLE "Style"
- IDS_HOTKEY_STYLE_LINK "Link"
- IDS_HOTKEY_STYLE_NO_LINK "No link"
- IDS_HOTKEY_STYLE_NORMAL "Normal"
- IDS_HOTKEY_STYLE_NOTE "Note"
- IDS_HOTKEY_STYLE_SUBTITLE "Subtitle"
- IDS_HOTKEY_STYLE_TEXT_AUTHOR "Text author"
- IDS_HOTKEY_GROUP_VIEW "View"
- IDS_HOTKEY_VIEW_BODY "Body"
- IDS_HOTKEY_VIEW_DESCRIPTION "Description"
- IDS_HOTKEY_VIEW_SOURCE "Source"
- IDS_HOTKEY_EDIT_INSERT_TABLE "Insert table"
-END
-
-STRINGTABLE
-BEGIN
- IDS_HOTKEY_GROUP_SCRIPTS "Scripts"
- IDS_HOTKEY_SCRIPTS_LAST_SCRIPT "Last script"
- IDS_SETTINGS_HOTKEYS_CAPTION "Hotkeys"
- IDS_HOTKEY_GROUP_SYMBOLS "Symbols"
- IDS_SETTINGS_WORDS_CAPTION "Words"
- IDS_SETTINGS_WLIST_COUNTED "Counted"
- IDS_SETTINGS_WLIST_WORD "Word"
- IDS_SETTINGS_WORDS_ADD_ERR_TEXT "This word is already in list!"
- IDS_SETTINGS_WORDS_ADD_ERR_CAP "Error adding word"
- IDS_SETTINGS_WORDS_ADD_ERR_SYM
- "New exclusion word must contain only alpha characters and one '-' between them!"
- IDS_WORDS_WLIST_WORD "Word"
- IDS_WORDS_WLIST_REPLACEMENT "Replacement"
- IDS_WORDS_WLIST_COUNTED "Counted"
- IDS_WORDS_FR_BTN_FIND0 "Find"
- IDS_WORDS_FR_BTN_FIND1 "Next"
- IDS_CTXMENU_CUT "Cut"
-END
-
-STRINGTABLE
-BEGIN
- IDC_SPELL_IGNORE "Ignore"
-END
-
-STRINGTABLE
-BEGIN
- IDC_SPELL_REPLACE "Replace word"
-END
-
-STRINGTABLE
-BEGIN
- IDS_HOTKEY_EDIT_SUB "Subscript"
- IDS_HOTKEY_EDIT_SUP "Superscript"
-END
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-1 TYPELIB "FBE.tlb"
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "atlres.h"
+#include "res1.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian (Russia) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+3 TEXTINCLUDE
+BEGIN
+ "1 TYPELIB ""FBE.tlb""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // Russian (Russia) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""atlres.h""\r\n"
+ "#include ""res1.h""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_SETTING_OTHER, DIALOG
+ BEGIN
+ LEFTMARGIN, 6
+ RIGHTMARGIN, 219
+ TOPMARGIN, 11
+ BOTTOMMARGIN, 209
+ END
+
+ IDD_TOOLS_SETTINGS, DIALOG
+ BEGIN
+ RIGHTMARGIN, 265
+ BOTTOMMARGIN, 275
+ END
+
+ IDD_TABLE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 253
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 39
+ END
+
+ IDD_WORDS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 361
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 316
+ END
+
+ IDD_REPLACE, DIALOG
+ BEGIN
+ END
+
+ IDD_OPTIONS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 217
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 206
+ END
+
+ IDD_INPUTBOX, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 280
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 63
+ END
+
+ IDD_FIND, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 288
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 69
+ END
+
+ IDD_ABOUTBOX, DIALOG
+ BEGIN
+ LEFTMARGIN, 6
+ RIGHTMARGIN, 259
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_HOTKEYS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 220
+ END
+
+ IDD_SETTINGS_WORDS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 254
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 220
+ END
+
+ IDD_PROPPAGE_LARGE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 228
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 149
+ END
+
+ IDD_SPELL_CHECK, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 266
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 128
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_SETTING_OTHER DIALOGEX 0, 0, 225, 222
+STYLE DS_SETFONT | WS_CHILD | WS_SYSMENU
+FONT 9, "Tahoma", 400, 0, 0xCC
+BEGIN
+ GROUPBOX "Save File",IDC_STATIC,7,11,134,39
+ LTEXT "Default encoding:",IDC_STATIC,11,23,60,9
+ CONTROL "Keep Encoding",IDC_KEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,35,63,10
+ COMBOBOX IDC_DEFAULT_ENC,73,21,65,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Open File",IDC_STATIC,145,11,73,39
+ CONTROL "Restore Position",IDC_RESTORE_POS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,151,27,62,10
+ GROUPBOX "Scripts folder",IDC_STATIC,6,52,212,43
+ CONTROL "Default folder",IDC_DEFAULT_SCRIPTS_FOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,63,60,10
+ EDITTEXT IDC_SCRIPTS_FOLDER_PATH,11,76,170,13,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_SELECT_SCRIPTS_FOLDER_BUTTON,194,76,17,13
+ GROUPBOX "Dialogs",IDC_STATIC,7,99,121,27
+ CONTROL "Ask for non clear image insertion",IDC_SETTINGS_ASKIMAGE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,110,113,10
+ GROUPBOX "Images",IDC_STATIC,133,99,85,27
+ CONTROL "Insert clear images",IDC_OPTIONS_CLEARIMGS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,110,69,10
+ GROUPBOX "Non-breaking space",IDC_STATIC,7,162,80,46
+ LTEXT "Display character:",IDC_STATIC,13,179,35,17
+ COMBOBOX IDC_NBSP_CHAR,50,181,29,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Keyboard layout",IDC_STATIC,91,162,128,46
+ CONTROL "Change on start",IDC_CHANGE_KEYB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,98,176,87,9
+ GROUPBOX "Paste images as",IDC_STATIC,6,128,212,30
+ LTEXT "Image format:",IDC_STATIC,14,142,46,8
+ COMBOBOX IDC_IMAGETYPE,64,140,40,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ EDITTEXT IDC_JPEGQUALITY,175,139,26,13,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_JPEGSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,200,139,7,14
+ LTEXT "JPEG quality:",IDC_STATIC,126,142,42,8
+ COMBOBOX IDC_KEYB_LAYOUT,137,190,76,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Change to:",IDC_STATIC,99,192,36,8
+END
+
+IDD_TOOLS_SETTINGS DIALOGEX 0, 0, 266, 282
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "Settings"
+FONT 8, "Microsoft Sans Serif", 400, 0, 0xCC
+BEGIN
+ CONTROL "",IDC_TAB_CTRL,"SysTabControl32",0x0,0,0,265,253
+ PUSHBUTTON "OK",IDOK,142,259,55,15
+ PUSHBUTTON "Cancel",IDCANCEL,205,259,55,15
+END
+
+IDD_TABLE DIALOGEX 0, 0, 260, 46
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Table properties"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,203,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,203,24,50,14
+ LTEXT "Number of table cells :",IDC_STATIC,7,22,150,8
+ CONTROL "Add table header ",IDC_CHECK_TABLE_TITLE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,187,10
+ EDITTEXT IDC_EDIT_TABLE_ROWS,157,19,35,14,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_SPIN_TABLE_ROWS,"msctls_updown32",UDS_WRAP | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,192,19,11,14
+END
+
+IDD_WORDS DIALOGEX 0, 0, 366, 323
+STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+CAPTION "Words"
+FONT 9, "Tahoma", 0, 0, 0x1
+BEGIN
+ CONTROL "List1",IDC_WLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_TABSTOP,7,7,354,208,WS_EX_CLIENTEDGE
+ DEFPUSHBUTTON "OK",IDOK,301,233,40,14
+ PUSHBUTTON "Cancel",IDCANCEL,301,253,40,14
+ EDITTEXT IDC_REDIT,242,223,41,12,NOT WS_VISIBLE | NOT WS_TABSTOP
+ CONTROL "Show/hide exclusions",IDC_CHECK_SHOWHIDE_EXCLS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,223,80,10
+ GROUPBOX "Process",IDC_STATIC,287,220,70,55
+ GROUPBOX "Process highlited",IDC_STATIC,14,237,250,37
+ PUSHBUTTON "Invert",IDC_BUTTON_DESEL,138,251,50,14
+ PUSHBUTTON "Reset replaced",IDC_BUTTON_REMOVEHLREPL,198,251,55,14
+ PUSHBUTTON "To exclusions",IDC_BUTTON_ADDHLTOEXCLS,21,251,51,14
+ PUSHBUTTON "Highlight all",IDC_BUTTON_SELALL,114,221,51,14
+ PUSHBUTTON "Set replaced",IDC_BUTTON_SETHLREPL,80,251,50,14
+ PUSHBUTTON "Set replaced all",IDC_BUTTON_SELALLREPL,179,221,58,14
+ GROUPBOX "Current word",IDC_WORDS_FR_GBOX_CURWORD,14,282,343,34
+ EDITTEXT IDC_WORDS_FR_EDIT_WORD,42,296,67,14,ES_AUTOHSCROLL | ES_READONLY
+ EDITTEXT IDC_WORDS_FR_EDIT_REPL,165,296,67,14,ES_AUTOHSCROLL | ES_READONLY
+ LTEXT "Word:",IDC_WORDS_FR_TEXT_WORD,20,298,20,8
+ LTEXT "Replacement:",IDC_WORDS_FR_TEXT_REPL,117,298,44,8
+ PUSHBUTTON "Find",IDC_WORDS_FR_BTN_FIND,245,296,42,14
+ PUSHBUTTON "Replace",IDC_WORDS_FR_BTN_REPL,299,296,43,14
+END
+
+IDD_REPLACE DIALOGEX 0, 0, 295, 87
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Replace"
+FONT 9, "Tahoma", 0, 0, 0x0
+BEGIN
+ LTEXT "Fi&nd what:",IDC_STATIC,7,9,45,8,NOT WS_GROUP
+ LTEXT "Replace with:",IDC_STATIC,7,25,45,8,NOT WS_GROUP
+ COMBOBOX IDC_TEXT,53,7,179,62,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX IDC_REPLACE,53,23,179,62,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ CONTROL "Match &whole words",IDC_WHOLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,41,98,13
+ CONTROL "Match &case",IDC_MATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54,98,13
+ CONTROL "Regular &expression",IDC_REGEXP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,67,98,13
+ GROUPBOX "Direction",IDC_STATIC,171,41,60,38,WS_GROUP
+ CONTROL "&Up",IDC_UP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,178,52,44,11
+ CONTROL "&Down",IDC_DOWN,"Button",BS_AUTORADIOBUTTON,178,63,44,11
+ DEFPUSHBUTTON "&Find Next",ID_FIND_NEXT,238,7,50,14,WS_GROUP
+ PUSHBUTTON "&Replace",IDC_REPLACE_ONE,238,25,50,14
+ PUSHBUTTON "Replace &All",IDC_REPLACE_ALL,238,43,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,238,61,50,14
+END
+
+IDD_OPTIONS DIALOGEX 0, 0, 222, 215
+STYLE DS_SETFONT | WS_CHILD | WS_SYSMENU
+FONT 9, "Tahoma", 0, 0, 0x0
+BEGIN
+ LTEXT "Text color:",IDC_STATIC,15,70,38,9
+ PUSHBUTTON "",IDC_FG,60,68,22,12
+ LTEXT "Background:",IDC_STATIC,89,70,41,9
+ PUSHBUTTON "",IDC_BG,134,68,22,12
+ LTEXT "Editor font:",IDC_STATIC,15,53,49,9
+ COMBOBOX IDC_FONT,60,51,151,70,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Font size:",IDC_STATIC,137,24,33,9
+ COMBOBOX IDC_FONT_SIZE,174,21,36,70,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Common",IDC_STATIC,7,10,210,31
+ GROUPBOX "Body",IDC_STATIC,7,41,210,46
+ GROUPBOX "XML source editor",IDC_STATIC,7,89,210,72
+ CONTROL "Wrap lines",IDC_WRAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,119,56,11
+ CONTROL "Syntax highlighting",IDC_SYNTAXHL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,132,73,11
+ CONTROL "Show end of line marks",IDC_SHOWEOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,145,104,11
+ CONTROL "Fast Mode",IDC_FAST_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,68,43,11
+ LTEXT "Language:",IDC_STATIC,15,23,48,8
+ COMBOBOX IDC_LANG,59,21,68,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Spellcheck",IDC_STATIC,7,162,210,45
+ CONTROL "Highlight misspelled words",IDC_BACKGROUNDSPELLCHECK,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,117,174,94,10
+ CONTROL "Use spellchecker",IDC_USESPELLCHECKER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,174,83,10
+ EDITTEXT IDC_CUSTOM_DICT,78,189,122,12,ES_AUTOHSCROLL
+ LTEXT "Custom dictionary:",IDS_SPELL_CUSTOM_DICT,15,191,60,9
+ PUSHBUTTON "..",IDC_DICTPATH,201,189,12,12
+ CONTROL "Show line numbers",IDC_SHOWLINENUMBERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,113,132,95,11
+ CONTROL "Highlight matched tags",IDC_TAGHL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,113,145,87,11
+ LTEXT "Editor font:",IDC_STATIC,14,105,49,9
+ COMBOBOX IDC_SRCFONT,59,103,151,70,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ CONTROL "Show white spaces",IDC_SHOWWHITESPACE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,113,119,71,11
+END
+
+IDD_INPUTBOX DIALOGEX 0, 0, 290, 70
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Input"
+FONT 9, "Tahoma", 0, 0, 0x0
+BEGIN
+ LTEXT "Text:",IDC_PROMPT,7,7,273,18
+ EDITTEXT IDC_INPUT,7,31,273,12,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "&Yes",IDYES,155,49,39,14
+ PUSHBUTTON "&No",IDNO,198,49,39,14
+ PUSHBUTTON "&Cancel",IDCANCEL,241,49,39,14
+END
+
+IDD_FIND DIALOGEX 0, 0, 295, 76
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Find"
+FONT 9, "Tahoma", 0, 0, 0x0
+BEGIN
+ LTEXT "Fi&nd what:",IDC_STATIC,7,9,40,8
+ COMBOBOX IDC_TEXT,49,7,183,62,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_GROUP | WS_TABSTOP
+ DEFPUSHBUTTON "&Find Next",ID_FIND_NEXT,238,7,50,14,WS_GROUP
+ CONTROL "Match &whole words",IDC_WHOLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,30,98,13
+ CONTROL "Match &case",IDC_MATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,43,98,13
+ CONTROL "Regular &expression",IDC_REGEXP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,56,98,13
+ GROUPBOX "Direction",IDC_STATIC,172,30,60,38,WS_GROUP
+ CONTROL "&Up",IDC_UP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,179,41,44,11
+ CONTROL "&Down",IDC_DOWN,"Button",BS_AUTORADIOBUTTON,179,52,44,11
+ PUSHBUTTON "Cancel",IDCANCEL,238,24,50,14
+END
+
+IDD_CUSTOMSAVEDLG DIALOGEX 0, 0, 415, 18
+STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
+FONT 8, "Tahoma", 0, 0, 0x0
+BEGIN
+ LTEXT "Encoding:",IDC_STATIC,68,2,41,10
+ COMBOBOX IDC_ENCODING,130,0,164,104,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+END
+
+IDD_ABOUTBOX DIALOGEX 0, 0, 266, 151
+STYLE DS_SETFONT | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+CAPTION "About"
+FONT 9, "Tahoma", 0, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,215,133,44,14
+ CONTROL IDB_BITMAP1,IDC_AB_STATIC_BANNER,"Static",SS_BITMAP | SS_NOTIFY | NOT WS_VISIBLE,6,6,56,123,WS_EX_CLIENTEDGE
+ CONTROL "",IDC_AB_BANNER,"Static",SS_OWNERDRAW | SS_NOTIFY | NOT WS_VISIBLE,6,6,57,123,WS_EX_CLIENTEDGE
+ ICON IDR_MAINFRAME,IDC_STATIC_AB_APPICON,73,8,20,20
+ EDITTEXT IDC_STATIC_AB_APPNAMEVER,99,8,157,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
+ LTEXT "Build",IDC_STATIC_BUILD,101,20,15,8
+ EDITTEXT IDC_BUILDSTAMP,123,20,132,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
+ CONTROL "http://code.google.com/p/fictionbookeditor/ ",IDC_SYSLINK_AB_LINKS,
+ "SysLink",0x0,101,32,154,8
+ EDITTEXT IDC_CONTRIBS,70,51,189,77,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | WS_VSCROLL | NOT WS_TABSTOP,WS_EX_STATICEDGE
+ CONTROL "Static",IDC_TEXT_STATUS,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,24,137,180,8
+ CONTROL IDB_UPD_CHECK1,IDC_PIC_UPDATE,"Static",SS_BITMAP,9,136,9,9
+ PUSHBUTTON "Update now",IDC_UPDATE,161,133,49,14,NOT WS_VISIBLE
+END
+
+IDD_ADDIMAGE DIALOGEX 0, 0, 147, 66
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
+CAPTION "Choose"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Yes",IDYES,21,31,49,14
+ PUSHBUTTON "No",IDCANCEL,77,31,49,14
+ CONTROL "Don't ask again",IDC_ADDIMAGE_ASKAGAIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,41,53,64,10
+ LTEXT "Insert clear image?",IDS_ADD_CLEARIMG_TEXT,46,11,65,8
+ ICON IDR_MAINFRAME,IDC_ADDIMAGE_ICON,19,6,20,20
+END
+
+IDD_HOTKEYS DIALOGEX 0, 0, 228, 227
+STYLE DS_SETFONT | WS_CHILD | WS_SYSMENU
+FONT 9, "Tahoma", 400, 0, 0xCC
+BEGIN
+ LISTBOX IDC_LIST_HOTKEYS_GROUPS,7,21,70,88,LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE
+ LISTBOX IDC_LIST_HOTKEYS,83,21,136,88,LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,WS_EX_STATICEDGE
+ GROUPBOX "Description",IDC_STATIC_HOTKEY_DESCRIPTION,7,180,211,33,WS_TABSTOP
+ EDITTEXT IDC_EDIT_HOTKEY,44,121,100,14,ES_MULTILINE | ES_AUTOHSCROLL
+ LTEXT "Groups:",IDC_STATIC_HOTKEYS_GROUPS,9,11,25,8,WS_TABSTOP
+ LTEXT "Commands:",IDC_STATIC_HOTKEYS,85,11,37,8,WS_TABSTOP
+ LTEXT "Shortcut:",IDC_STATIC,10,124,31,8,WS_TABSTOP
+ PUSHBUTTON "Default",IDC_BUTTON_DEFAULT,159,125,50,14
+ EDITTEXT IDC_EDIT_HOTKEY_DESCRIPTION,9,189,206,22,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
+ PUSHBUTTON "Delete",IDC_BUTTON_HOTKEY_DELETE,159,143,50,14
+ GROUPBOX "Actions",IDC_STATIC_HOTKEY_ACTIONS,149,114,69,65
+ GROUPBOX "Assigned to",IDC_STATIC_HOTKEY_COLLISION,7,138,137,41
+ PUSHBUTTON "Assign",IDC_BUTTON_HOTKEY_ASSIGN,159,161,50,14,WS_DISABLED
+ EDITTEXT IDC_EDIT_HOTKEY_COLLISION,14,150,125,24,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
+END
+
+IDD_SETTINGS_WORDS DIALOGEX 0, 0, 262, 227
+STYLE DS_SETFONT | WS_CHILD
+FONT 8, "Tahoma", 400, 0, 0x1
+BEGIN
+ EDITTEXT IDC_EDIT_NEW,18,162,165,14,ES_AUTOHSCROLL
+ PUSHBUTTON "Add",IDC_BUTTON_ADD,194,162,50,14
+ GROUPBOX "Word-exclusion list",IDC_STATIC_WORDS_CHEVRON,7,8,248,177
+ CONTROL "",IDC_LIST_WORDS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTDESCENDING | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,17,25,227,106,WS_EX_CLIENTEDGE
+ CONTROL "Show exclusions in Words dialog",IDC_CHECK_SHOW_EXCLUSIONS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,198,119,10
+ CONTROL "Select All",IDC_CHECK_SELALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,142,45,10
+ PUSHBUTTON "Remove selected",IDC_BUTTON_REMOVESEL,67,140,73,14
+ EDITTEXT IDC_EDIT_LV,183,7,62,14,ES_AUTOHSCROLL | NOT WS_VISIBLE | NOT WS_TABSTOP,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
+END
+
+IDD_PROPPAGE_LARGE DIALOGEX 0, 0, 235, 156
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Property Page"
+FONT 8, "MS Shell Dlg", 400, 0, 0x0
+BEGIN
+ LTEXT "TODO: layout property page",IDC_STATIC,73,74,90,8
+END
+
+IDD_SPELL_CHECK DIALOGEX 0, 0, 273, 135
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Spelling"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Cancel",IDCANCEL,216,112,50,14
+ LTEXT "Not In Dictionary:",IDC_STATIC,7,14,64,8
+ EDITTEXT IDC_SPELL_BEDWORD,72,12,194,12,ES_AUTOHSCROLL
+ LTEXT "Change To:",IDC_STATIC,8,30,46,8
+ EDITTEXT IDC_SPELL_REPLACEMENT,72,29,194,12,ES_AUTOHSCROLL
+ LTEXT "Suggestions:",IDC_STATIC,7,47,46,8
+ LISTBOX IDC_SPELL_SUGG_LIST,7,58,145,68,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Ignore",IDC_SPELL_IGNORE,159,58,50,14
+ PUSHBUTTON "Ignore All",IDC_SPELL_IGNOREALL,216,58,50,14
+ PUSHBUTTON "Change",IDC_SPELL_CHANGE,159,76,50,14
+ PUSHBUTTON "Change All",IDC_SPELL_CHANGEALL,216,76,50,14
+ PUSHBUTTON "Add",IDC_SPELL_ADD,159,94,50,14
+ PUSHBUTTON "Suggets",IDC_SPELL_SUGGEST,216,94,50,14,WS_DISABLED
+ PUSHBUTTON "Undo last",IDC_SPELL_UNDO,159,112,50,14,WS_DISABLED
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME ICON "res\\FBE2.ico"
+
+IDI_OLDICON ICON "res\\FBE.ico"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Toolbar
+//
+
+IDR_MAINFRAME TOOLBAR 24, 24
+BEGIN
+ BUTTON ID_FILE_NEW
+ BUTTON ID_FILE_OPEN
+ BUTTON ID_FILE_SAVE
+ SEPARATOR
+ BUTTON ID_FILE_VALIDATE
+ SEPARATOR
+ BUTTON ID_VIEW_DESC
+ BUTTON ID_VIEW_BODY
+ BUTTON ID_VIEW_SOURCE
+ SEPARATOR
+ BUTTON ID_EDIT_ADDBINARY
+ BUTTON ID_EDIT_INS_IMAGE
+ BUTTON ID_EDIT_INS_INLINEIMAGE
+ SEPARATOR
+ BUTTON ID_EDIT_FIND
+ BUTTON ID_EDIT_FINDNEXT
+ SEPARATOR
+ BUTTON ID_EDIT_CUT
+ BUTTON ID_EDIT_COPY
+ BUTTON ID_EDIT_PASTE
+ SEPARATOR
+ BUTTON ID_EDIT_UNDO
+ BUTTON ID_EDIT_REDO
+ SEPARATOR
+ BUTTON ID_EDIT_BOLD
+ BUTTON ID_EDIT_ITALIC
+ BUTTON ID_EDIT_SUP
+ BUTTON ID_EDIT_SUB
+ BUTTON ID_EDIT_STRIK
+ BUTTON ID_EDIT_CODE
+ SEPARATOR
+ BUTTON ID_STYLE_LINK
+ BUTTON ID_STYLE_NOTE
+ BUTTON ID_STYLE_NOLINK
+ BUTTON ID_GOTO_FOOTNOTE
+ SEPARATOR
+ BUTTON ID_STYLE_NORMAL
+ BUTTON ID_STYLE_SUBTITLE
+ BUTTON ID_STYLE_TEXTAUTHOR
+ SEPARATOR
+ BUTTON ID_TOOLS_SPELLCHECK
+END
+
+IDR_MAINFRAME_SMALL TOOLBAR 16, 16
+BEGIN
+ BUTTON ID_FILE_NEW
+ BUTTON ID_FILE_OPEN
+ BUTTON ID_FILE_SAVE
+ BUTTON ID_FILE_VALIDATE
+ BUTTON ID_VIEW_DESC
+ BUTTON ID_VIEW_BODY
+ BUTTON ID_VIEW_SOURCE
+ BUTTON ID_VIEW_OPTIONS
+ BUTTON ID_EDIT_ADDBINARY
+ BUTTON ID_EDIT_FIND
+ BUTTON ID_EDIT_FINDNEXT
+ BUTTON ID_EDIT_REPLACE
+ BUTTON ID_EDIT_CUT
+ BUTTON ID_EDIT_COPY
+ BUTTON ID_EDIT_PASTE
+ BUTTON ID_EDIT_UNDO
+ BUTTON ID_EDIT_REDO
+ BUTTON ID_EDIT_INS_IMAGE
+ BUTTON ID_EDIT_INS_INLINEIMAGE
+ BUTTON ID_EDIT_ADD_IMAGE
+ BUTTON ID_STYLE_LINK
+ BUTTON ID_STYLE_NOTE
+ BUTTON ID_STYLE_NOLINK
+ BUTTON ID_STYLE_NORMAL
+ BUTTON ID_STYLE_SUBTITLE
+ BUTTON ID_STYLE_TEXTAUTHOR
+ BUTTON ID_GOTO_FOOTNOTE
+ BUTTON ID_EDIT_ADD_BODY
+ BUTTON ID_EDIT_ADD_TITLE
+ BUTTON ID_EDIT_ADD_EPIGRAPH
+ BUTTON ID_EDIT_ADD_ANN
+ BUTTON ID_EDIT_INS_POEM
+ BUTTON ID_EDIT_INS_CITE
+ BUTTON ID_INSERT_TABLE
+ BUTTON ID_TOOLS_SPELLCHECK
+END
+
+IDR_DOCUMENT_TREE TOOLBAR 24, 24
+BEGIN
+ BUTTON ID_DT_RIGHT_ONE
+ BUTTON ID_DT_RIGHT_SMART
+ BUTTON ID_DT_LEFT
+ BUTTON ID_DT_MERGE
+ BUTTON ID_DT_DELETE
+END
+
+IDR_SCRIPTS TOOLBAR 16, 16
+BEGIN
+ BUTTON ID_LAST_SCRIPT
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDR_MAINFRAME BITMAP "res\\Toolbar.bmp"
+
+IDR_MAINFRAME_SMALL BITMAP "res\\Toolbar_small.bmp"
+
+IDR_SCRIPTS BITMAP "res\\Scripts.bmp"
+
+IDB_STRUCTURE BITMAP "res\\struct.bmp"
+
+IDB_WORDSTATES BITMAP "res\\wordstat.bmp"
+
+IDR_DOCUMENT_TREE BITMAP "res\\document.bmp"
+
+IDB_AB_BANNER BITMAP "res\\Fb2-shema.bmp"
+
+IDB_UPD_OK BITMAP "res\\ok.bmp"
+
+IDB_UPD_ERR BITMAP "res\\error.bmp"
+
+IDB_UPD_UPDATE BITMAP "res\\update.bmp"
+
+IDB_UPD_CHECK1 BITMAP "res\\Icon_02.bmp"
+
+IDB_UPD_CHECK2 BITMAP "res\\Icon_03.bmp"
+
+IDB_UPD_CHECK3 BITMAP "res\\Icon_04.bmp"
+
+IDB_UPD_CHECK4 BITMAP "res\\Icon_05.bmp"
+
+IDB_UPD_CHECK5 BITMAP "res\\Icon_06.bmp"
+
+IDB_UPD_CHECK6 BITMAP "res\\Icon_07.bmp"
+
+IDB_UPD_CHECK7 BITMAP "res\\Icon_08.bmp"
+
+IDB_UPD_CHECK8 BITMAP "res\\Icon_09.bmp"
+
+IDB_UPD_CHECK9 BITMAP "res\\Icon_10.bmp"
+
+IDB_UPD_CHECK10 BITMAP "res\\Icon_11.bmp"
+
+IDB_UPD_CHECK11 BITMAP "res\\Icon_12.bmp"
+
+IDB_UPD_CHECK12 BITMAP "res\\Icon_13.bmp"
+
+IDB_UPD_CHECK13 BITMAP "res\\Icon_14.bmp"
+
+IDB_UPD_CHECK14 BITMAP "res\\Icon_15.bmp"
+
+IDB_UPD_CHECK15 BITMAP "res\\Icon_16.bmp"
+
+IDB_UPD_CHECK16 BITMAP "res\\Icon_17.bmp"
+
+IDB_UPD_CHECK17 BITMAP "res\\Icon_18.bmp"
+
+IDB_UPD_CHECK18 BITMAP "res\\Icon_19.bmp"
+
+IDB_UPD_CHECK19 BITMAP "res\\Icon_20.bmp"
+
+IDB_UPD_CHECK20 BITMAP "res\\Icon_21.bmp"
+
+IDB_UPD_CHECK21 BITMAP "res\\Icon_22.bmp"
+
+IDB_UPD_CHECK22 BITMAP "res\\Icon_23.bmp"
+
+IDB_UPD_CHECK23 BITMAP "res\\Icon_24.bmp"
+
+IDB_UPD_CHECK24 BITMAP "res\\Icon_25.bmp"
+
+IDB_CENTER BITMAP "res\\center.bmp"
+
+IDB_ORANGE BITMAP "res\\orange.bmp"
+
+IDB_GREEN BITMAP "res\\green.bmp"
+
+IDB_DOC BITMAP "res\\doc.bmp"
+
+IDB_XML BITMAP "res\\xml.bmp"
+
+IDB_OTHER BITMAP "res\\other.bmp"
+
+IDB_HTML BITMAP "res\\html.bmp"
+
+IDB_PRC BITMAP "res\\prc.bmp"
+
+IDB_TEXT BITMAP "res\\text.bmp"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 2,6,0,0
+ PRODUCTVERSION 2,6,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x21L
+#else
+ FILEFLAGS 0x20L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "Release"
+ VALUE "CompanyName", "FBE Team"
+ VALUE "FileDescription", "FictionBook Editor"
+ VALUE "FileVersion", "2.6"
+ VALUE "InternalName", "FBE"
+ VALUE "LegalCopyright", "Copyright 2010 FBE Team, 2008 LitRes, 2003 Mike Matsnev"
+ VALUE "OriginalFilename", "FBE.exe"
+ VALUE "ProductName", "FictionBook Editor"
+ VALUE "ProductVersion", "2"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_MAINFRAME MENU
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "&New", ID_FILE_NEW
+ MENUITEM "&Open...", ID_FILE_OPEN
+ MENUITEM "&Save", ID_FILE_SAVE
+ MENUITEM "Save &As...", ID_FILE_SAVE_AS
+ MENUITEM "&Validate", ID_FILE_VALIDATE
+ MENUITEM SEPARATOR
+ POPUP "&Import"
+ BEGIN
+ MENUITEM "No import plugins installed", IDCANCEL
+ END
+ POPUP "&Export"
+ BEGIN
+ MENUITEM "No export plugins installed", IDCANCEL
+ END
+ MENUITEM SEPARATOR
+ POPUP "&Recent Files"
+ BEGIN
+ MENUITEM "No Recent Files", ID_FILE_MRU_FIRST, INACTIVE
+ END
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", ID_APP_EXIT
+ END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "&Undo", ID_EDIT_UNDO
+ MENUITEM "&Redo", ID_EDIT_REDO
+ MENUITEM SEPARATOR
+ MENUITEM "Cu&t", ID_EDIT_CUT
+ MENUITEM "&Copy", ID_EDIT_COPY
+ MENUITEM "&Paste", ID_EDIT_PASTE
+ MENUITEM SEPARATOR
+ MENUITEM "&Find...", ID_EDIT_FIND
+ MENUITEM "Find &Next", ID_EDIT_FINDNEXT
+ MENUITEM "R&eplace...", ID_EDIT_REPLACE
+ MENUITEM SEPARATOR
+ MENUITEM "&Go to footnote or reference", ID_GOTO_FOOTNOTE
+ MENUITEM "Go to matching &tag", ID_GOTO_MATCHTAG
+ MENUITEM "Go to &wrong tag", ID_GOTO_WRONGTAG
+ MENUITEM SEPARATOR
+ MENUITEM "C&lone container", ID_EDIT_CLONE
+ MENUITEM "Sp&lit container", ID_EDIT_SPLIT
+ MENUITEM "&Merge containers", ID_EDIT_MERGE
+ MENUITEM "Remove outer container", ID_EDIT_REMOVE_OUTER_SECTION
+ END
+ POPUP "&View"
+ BEGIN
+ MENUITEM "&Commands toolbar", 60161
+ MENUITEM "Scripts toolbar", 60162
+ MENUITEM "&Links Bar", 60163
+ MENUITEM "Table Bar", 60164
+ MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
+ MENUITEM "&Document Tree", ID_VIEW_TREE
+ MENUITEM SEPARATOR
+ MENUITEM "D&escription", ID_VIEW_DESC
+ MENUITEM "&Body", ID_VIEW_BODY
+ MENUITEM "So&urce", ID_VIEW_SOURCE
+ MENUITEM SEPARATOR
+ MENUITEM "Fast Mode", ID_VIEW_FASTMODE
+ END
+ POPUP "&Add"
+ BEGIN
+ MENUITEM "&Body", ID_EDIT_ADD_BODY
+ MENUITEM "&Title", ID_EDIT_ADD_TITLE
+ MENUITEM "&Epigraph", ID_EDIT_ADD_EPIGRAPH
+ MENUITEM "A&nnotation", ID_EDIT_ADD_ANN
+ MENUITEM SEPARATOR
+ MENUITEM "T&ext author", ID_EDIT_ADD_TA
+ MENUITEM "&Image", ID_EDIT_INS_IMAGE
+ MENUITEM "In&line image", ID_EDIT_INS_INLINEIMAGE
+ MENUITEM "&Poem", ID_EDIT_INS_POEM
+ MENUITEM "&Cite", ID_EDIT_INS_CITE
+ MENUITEM "T&able", ID_INSERT_TABLE
+ MENUITEM "&Section image", ID_EDIT_ADD_IMAGE
+ MENUITEM SEPARATOR
+ MENUITEM "Add &Binary Object...", ID_EDIT_ADDBINARY
+ END
+ POPUP "&Style"
+ BEGIN
+ MENUITEM "&Normal", ID_STYLE_NORMAL
+ MENUITEM "Text &Author", ID_STYLE_TEXTAUTHOR
+ MENUITEM "&Subtitle", ID_STYLE_SUBTITLE
+ MENUITEM SEPARATOR
+ MENUITEM "&Link...", ID_STYLE_LINK
+ MENUITEM "&Footnote...", ID_STYLE_NOTE
+ MENUITEM "&Remove link", ID_STYLE_NOLINK
+ END
+ POPUP "&Tools"
+ BEGIN
+ MENUITEM "&Words...", ID_TOOLS_WORDS
+ MENUITEM "&Settings...", ID_VIEW_OPTIONS
+ MENUITEM SEPARATOR
+ MENUITEM "Spell &check...", ID_TOOLS_SPELLCHECK
+ END
+ POPUP "&Scripts"
+ BEGIN
+ MENUITEM "No scripts found", IDCANCEL, INACTIVE
+ END
+ POPUP "&Help"
+ BEGIN
+ MENUITEM "&About FBE...", ID_APP_ABOUT
+ END
+END
+
+IDR_DOCUMENT_TREE MENU
+BEGIN
+ POPUP "DT"
+ BEGIN
+ MENUITEM "View", ID_DT_VIEW
+ MENUITEM "View Source", ID_DT_VIEWSOURCE
+ MENUITEM SEPARATOR
+ MENUITEM "Move Right", ID_DT_RIGHT_ONE
+ MENUITEM "Move With Children", ID_DT_RIGHT_SMART
+ MENUITEM "Move Left", ID_DT_LEFT
+ MENUITEM SEPARATOR
+ MENUITEM "Delete", ID_DT_DELETE
+ END
+END
+
+IDR_TOOLBAR_MENU MENU
+BEGIN
+ POPUP "CUSTOMIZE"
+ BEGIN
+ MENUITEM "Customize toolbar...", ID_TOOLS_CUSTOMIZE
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// ABOUT_FILE
+//
+
+ABOUT_FILE ABOUT_FILE "files\\contributors.txt"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_HOTKEY_EDIT_ADD_EPIGRAPH "Add epigraph"
+ IDS_HOTKEY_EDIT_ADD_IMAGE "Add section image"
+ IDS_HOTKEY_EDIT_ADD_TA "Add text author"
+ IDS_HOTKEY_EDIT_ADD_TITLE "Add title"
+ IDS_HOTKEY_EDIT_BOLD "Bold"
+ IDS_HOTKEY_EDIT_CLONE "Clone"
+ IDS_HOTKEY_EDIT_COPY "Copy"
+ IDS_HOTKEY_EDIT_CUT "Cut"
+ IDS_HOTKEY_EDIT_FIND "Find"
+ IDS_HOTKEY_EDIT_FIND_NEXT "Find next"
+ IDS_HOTKEY_EDIT_INCREMENTAL_SEARCH "Incremental search"
+ IDS_HOTKEY_EDIT_INSERT_CITE "Insert cite"
+ IDS_HOTKEY_EDIT_INSERT_IMAGE "Insert image"
+ IDS_HOTKEY_EDIT_INSERT_POEM "Insert poem"
+ IDS_HOTKEY_EDIT_ITALIC "Italic"
+ ID_VIEW_SOURCE "Show document source code\nSource"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_HOTKEY_PLUGINS_LAST_PLUGIN "Last plugin"
+ IDS_HOTKEY_TOOLS_SPELL "Spell check"
+ IDC_SPELL_ADD2DICT "Add to dictionary"
+ IDS_SPELL_COMPLETED "The spelling check is complete."
+ IDC_SPELL_IGNOREALL "Ignore All"
+ IDS_SPELL_CONTINUE "Continue"
+ IDS_HOTKEY_EDIT_INSERT_INLINEIMAGE "Insert inline image"
+ IDS_UPDATE_CANTCONNECT "Can't connect to server"
+ IDS_HOTKEY_FASTMODE "Fast mode"
+ IDS_HOTKEY_TREEVIEW "Toggle tree view"
+ IDS_HOTKEY_TOOLS_SPELLHIGHLIGHT "Toggle highlight"
+ IDS_HOTKEY_NAVIGATION_GOTO_FOOTNOTE "Go to footnote or reference"
+ IDS_HOTKEY_NAVIGATION_GOTO_MATCHTAG "Go to matchig tag"
+ IDS_HOTKEY_NAVIGATION_GOTO_WRONGTAG "Go to wrong tag"
+ IDS_UPDATE_DOWNLOADEDFROM "%d Kb from %d Kb downloaded (%d%%)"
+ IDS_UPDATE_DOWNLOADED "%d Kb downloaded"
+END
+
+STRINGTABLE
+BEGIN
+ ID_INSERT_TABLE "Insert an table at cursor\nInsert table"
+ ID_GOTO_FOOTNOTE "Go to footnote or reference\nGo to footnote or reference"
+END
+
+STRINGTABLE
+BEGIN
+ ID_LAST_SCRIPT "Execute last called script\nLast script"
+ ID_TOOLS_SPELLCHECK "Check document spelling...\nCheck document spelling"
+ ID_GOTO_MATCHTAG "Go to matching tag\nGo to matching tag"
+ ID_GOTO_WRONGTAG "Go to wrong tag\nGo to wrong tag"
+END
+
+STRINGTABLE
+BEGIN
+ ID_DT_LEFT "\nMove to the left"
+ ID_DT_DELETE "\nDelete selected node"
+ ID_DT_RIGHT_ONE "\nMove node once to the right"
+ ID_DT_RIGHT_SMART "\nMove one node to the right with smart mode"
+ ID_DT_MERGE "\nMerge containers"
+ ID_VIEW_FASTMODE "Toggle fast mode\nToggle fast mode"
+END
+
+STRINGTABLE
+BEGIN
+ ID_EDIT_ADD_TA "Add a text author paragraph to the selected container\nAdd text author"
+ ID_EDIT_MERGE "Merge selected container with next\nMerge containers"
+ ID_EDIT_INS_CITE "Replace selection with a cite container\nInsert cite"
+ ID_EDIT_STRIK "Marks the selection """"strikethrough"""" (toggle)\nStrikethrough"
+ ID_EDIT_SUB "Marks the selection """"sub"""" (toggle)\nSub"
+ ID_EDIT_SUP "Marks the selection """"sup"""" (toggle)\nSup"
+ ID_EDIT_CODE "Marks the selection """"code"""" (toggle)\nCode"
+END
+
+STRINGTABLE
+BEGIN
+ ID_EDIT_ADD_TITLE "Add a title to the selected object\nAdd title"
+ ID_EDIT_ADD_BODY "Add a new body to the document\nAdd body"
+ ID_EDIT_CLONE "Clone selected object\nClone"
+ ID_EDIT_INS_IMAGE "Insert an image at cursor\nInsert image"
+ ID_EDIT_INS_INLINEIMAGE "Insert an inline image at cursor\nInsert inline image"
+ ID_FILE_VALIDATE "Validate current document against FictionBook schema\nValidate"
+ ID_EDIT_ADD_EPIGRAPH "Add epigraph to selected object\nAdd epigraph"
+ ID_EDIT_ADD_IMAGE "Add an image to the selected object\nAdd image"
+ ID_EDIT_ADD_ANN "Add annotation to the selected obejct\nAdd annotation"
+ ID_EDIT_SPLIT "Split parent container at selection\nSplit container"
+ ID_EDIT_INS_POEM "Replace selection with a poem container\nInsert poem"
+END
+
+STRINGTABLE
+BEGIN
+ ID_VIEW_TREE "Show or hide the document tree\nToggle document tree"
+ IDS_PANE_INS "INS"
+ IDS_PANE_OVR "OVR"
+ IDS_DOC_TREE_CLEANUP "Clean"
+ IDS_HOTKEY_FILE_OPEN "Open"
+ IDS_HOTKEY_FILE_SAVE "Save"
+ IDS_HOTKEY_FILE_SAVEAS "Save as..."
+ IDS_HOTKEY_FILE_VALIDATE "Validate"
+ IDS_HOTKEY_GROUP_FILE "File"
+ IDS_HOTKEY_EDIT_ADD_ANNOTATION "Add annotation"
+ IDS_HOTKEY_EDIT_ADD_BODY "Add body"
+END
+
+STRINGTABLE
+BEGIN
+ ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
+END
+
+STRINGTABLE
+BEGIN
+ 60161 "Show or hide the command toolbar\nToggle Command ToolBar"
+ 60162 "Show or hide the scripts toolbar\nToggle Scripts ToolBar"
+ 60163 "Show or hide the links bar\nToggle LinksBar"
+ 60164 "Show or hide the table bar\nToggle TableBar"
+END
+
+STRINGTABLE
+BEGIN
+ ID_STYLE_NORMAL "Normal paragraph style\nNormal"
+ ID_STYLE_TEXTAUTHOR "Text author paragraph style\nText author"
+ ID_STYLE_SUBTITLE "Subtitle paragraph style\nSubtitle"
+ ID_VIEW_OPTIONS "Display options\nDisplay options"
+END
+
+STRINGTABLE
+BEGIN
+ ID_EDIT_BOLD "Marks the selection ""strong"" (toggle)\nStrong"
+ ID_EDIT_ITALIC "Marks the selection ""emphasis"" (toggle)\nEmphasis"
+END
+
+STRINGTABLE
+BEGIN
+ ID_STYLE_LINK "Add a hyperlink\nHyperlink"
+ ID_STYLE_NOTE "Add a footnote\nFootnote"
+ ID_EDIT_FINDNEXT "Repeats the last find\nFind next"
+ ID_VIEW_DESC "Show document description\nDescription"
+ ID_VIEW_BODY "Show document body\nBody"
+ ID_STYLE_NOLINK "Remove links from selected text\nRemove links"
+ ID_EDIT_ADDBINARY "Add a new binary object to the document\nAdd binary object"
+END
+
+STRINGTABLE
+BEGIN
+ ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
+ ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
+ ID_EDIT_FIND "Find the specified text\nFind"
+ ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
+ ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
+ ID_EDIT_UNDO "Undo the last action\nUndo"
+ ID_EDIT_REDO "Redo the previously undone action\nRedo"
+END
+
+STRINGTABLE
+BEGIN
+ ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
+ ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
+END
+
+STRINGTABLE
+BEGIN
+ ID_FILE_NEW "Create a new document\nNew"
+ ID_FILE_OPEN "Open an existing document\nOpen"
+ ID_FILE_SAVE "Save the active document\nSave"
+ ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_CHOOSE_SCRIPTS_FLD "Specify scripts folder"
+ IDS_SCRIPT_HOTKEY_CONFLICT
+ "Script\n%s\n returned a virtual-key that conflicts with previously loaded script\n %s"
+ IDS_HOTKEY_EDIT_MERGE "Merge"
+ IDS_HOTKEY_EDIT_PASTE "Paste"
+ IDS_HOTKEY_EDIT_REDO "Redo"
+ IDS_HOTKEY_EDIT_REPLACE "Replace"
+ IDS_HOTKEY_EDIT_SPLIT "Split"
+ IDS_HOTKEY_EDIT_UNDO "Undo"
+ IDS_HOTKEY_GROUP_EDIT "Edit"
+ IDS_HOTKEY_GROUP_NAVIGATION "Navigation"
+ IDS_UPDATE_CHECK "Checking for update..."
+ IDS_HOTKEY_NAVIGATION_NEXT_ITEM "Next item"
+ ID_PANE_INS "OVR"
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE1 "Collapse 1 tree level"
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE2 "Collapse 2 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE3 "Collapse 3 tree levels"
+END
+
+STRINGTABLE
+BEGIN
+ ATL_IDS_IDLEMESSAGE "Ready"
+END
+
+STRINGTABLE
+BEGIN
+ ATL_IDS_MRU_FILE "Open this document"
+ IDS_ENCODINGS "utf-8,utf-16,windows-1251,windows-1252,iso-8859-1,iso-8859-2,iso-8859-5,iso-8859-15,koi8-r"
+ IDS_DOCUMENT_TREE_CAPTION "Document structure"
+END
+
+STRINGTABLE
+BEGIN
+ IDR_MAINFRAME "FBE"
+ IDS_SB_NO_ERR "No errors found."
+ IDS_DMS_TI "Title info"
+ IDS_LANG_ENGLISH "English"
+ IDS_LANG_RUSSIAN "Russian"
+ IDS_DMS_GENRE_M "Genre Match"
+ IDS_DMS_KW "KeyWords"
+ IDS_DMS_AUTHOR "Author NickName"
+ IDS_DMS_DI "Document Info"
+ IDS_DMS_ID "ID"
+ IDS_DMS_STI "Source Title Info"
+ IDS_DMS_CI "Custom Info"
+ IDS_SETTINGS_VIEW_CAPTION "View"
+ IDS_SETTINGS_OTHER_CAPTION "Other"
+ IDS_TB_CAPT_ID "ID:"
+ IDS_TB_CAPT_HREF "Href:"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_MB_OK "OK"
+ IDS_MB_CANCEL "Cancel"
+ IDS_MB_ABORT "&Abort"
+ IDS_MB_RETRY "&Retry"
+ IDS_MB_IGNORE "&Ignore"
+ IDS_MB_YES "&Yes"
+ IDS_MB_NO "&No"
+ IDS_MB_CLOSE "Close"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_CTXMENU_COPY "Copy"
+ IDS_CTXMENU_PASTE "Paste"
+ IDS_CTXMENU_SELECT "Select"
+ IDS_CTXMENU_IMG_SAVEAS "Save image as..."
+ IDS_UPDATE_CONNECTING "Connecting to server..."
+ IDS_HOTKEY_WRONG "Wrong shortcut!"
+ IDS_HOTKEY_DEFAULT_COLLISION
+ "Default hotkey for this command was assigned to ""%s""! Replace?"
+ IDS_HOTKEY_ASSIGN_NO_COLLISION "Not assigned to other command"
+ IDS_HOTKEY_ASSIGN_COLLISION "Assigned to ""%s"""
+ IDS_SETTINGS_NEED_RESTART
+ "In order to process changes the program must be restarted.\nRestart now?"
+ IDS_DOCTREE_MENU_ELEMENTS "Elements"
+ IDS_DOCTREE_MENU_SCRIPTS "Scripts"
+ IDS_HOTKEY_EDIT_REMOVE_OUTER_SECTION "Remove outer section"
+ IDS_HOTKEY_GROUP_TOOLS "Tools"
+ IDS_HOTKEY_TOOLS_WORDS "Words"
+ IDS_HOTKEY_GROUP_PLUGINS "Plugins"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_UPDATE_DOWNLOADCOMPLETE "Download completed, writing setup file..."
+ IDS_UPDATE_DOWNLOADERROR "Download error"
+ IDS_UPDATE_404ERROR "404 error : Not Found"
+ IDS_UPDATE_403ERROR "403 error : Forbidden"
+ IDS_UPDATE_407ERROR "407 error : proxy authentication required"
+ IDS_UPDATE_NOTSUPPORTEDRANGE " ( not support range )"
+ IDS_UPDATE_DOWNLOADERRORSTATUS "Download error, status code : %d"
+ IDS_UPDATE_INCORRECTMD5 "Error, incorrect MD5 checksum"
+ IDS_UPDATE_NEWVERSIONAVAILABLE "A new version of FBE is available."
+ IDS_UPDATE_HAVELATESTVERSION "You have a latest version of FBE."
+ IDS_ABOUT_LOGOCAPTION "FB2 animated logo press ? for help"
+ IDS_UPDATE_CLOSE "FBE must be closed to continue installation.\r\n\r\nYou may delete installation file at download location ""%s"" later.\r\n\r\nQuit FBE now and continue installation?"
+ IDS_LANG_UKRAINIAN "Ukrainian"
+ IDS_UPDATEEXISTS "Update file %s is already exists.\r\nWould you like to execute this file?"
+ IDS_UPDATE_DOWNLOADREADY "Update is ready."
+ IDS_BAD_XML_MSG "You have opened an invalid XML document.\n\nYou should correct all XML errors (use ""Validate"" and ""Go to wrong tag"" commands) before switching from the SOURCE mode."
+END
+
+STRINGTABLE
+BEGIN
+ IDS_TB_CAPT_SECTION_ID "Section ID:"
+ IDS_TB_CAPT_IMAGE_TITLE "Image title:"
+ IDS_TB_CAPT_TABLE_ID "Table ID:"
+ IDS_TB_CAPT_TABLE_STYLE "Table Style:"
+ IDS_TB_CAPT_STYLE "style:"
+ IDS_TB_CAPT_COLSPAN "colspan:"
+ IDS_TB_CAPT_ROWSPAN "rowspan:"
+ IDS_TB_CAPT_TR_ALIGN "tr align:"
+ IDS_TB_CAPT_TD_ALIGN "th, td align:"
+ IDS_TB_CAPT_TD_VALIGN "th, td valign:"
+ IDS_SAVE_DLG_MSG "Save changes to %s?"
+ IDS_ERRMSGBOX_CAPTION "Error"
+ IDS_INVALID_CML_MSG "Invalid command line option: '%c'"
+ IDS_CML_ARGS_MSG "Command line option '%c' requires an argument"
+ IDS_SEARCH_END_MSG "Finished searching for '%s'."
+ IDS_REPL_ALL_CAPT "Replace All"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_REPL_DONE_MSG "%d replacement(s) done."
+ IDS_SEARCH_FAIL_MSG "Cannot find the string '%s'."
+ IDS_SCRIPT_MSG_CPT "FBE Script message"
+ IDS_GENRES_LIST_MSG "Can't open genres file %s"
+ IDS_VALIDATION_FAIL_MSG "%s\r\nDo you still want to save the file?\r\n\r\nWARNING: Invalid files can be improperly displayed and can cause errors in other applications."
+ IDS_VALIDATION_FAIL_CPT "Validation failed"
+ IDS_OUT_OF_MEM_MSG "Out of memory"
+ IDS_SCINTILLA_LOAD_ERR_MSG "Can't load Scintilla."
+ IDS_GOTO_REF_FAIL_MSG "Reference not found."
+ IDS_IMPORT_ERR_CPT "Import Error"
+ IDS_IMPORT_ERR_MSG "Plugin does not support the required interface"
+ IDS_IMPORT_XML_ERR_MSG "Imported object does not support IXMLDOMDocument2 interface"
+ IDS_EXPORT_ERR_CPT "Export Error"
+ IDS_EXPORT_ERR_MSG "Plugin does not support the required interface"
+ IDS_FILE_CHANGED_CPT "File changed"
+ IDS_FILE_CHANGED_MSG "%s has been changed by anouther application.\nDo you want to reload it?"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_SCRIPT_ERRX_MSG "Script error: %08X at line %d, column %d"
+ IDS_SCRIPT_ERRD_MSG "Script error: %s at line %d, column %d"
+ IDS_SCRIPT_MSG "Unknown error in script."
+ IDS_SCRIPT_LOAD_ERR_MSG "Error loading %s: %s"
+ IDS_COM_ERR_CPT "COM Error"
+ IDS_XML_PARSE_ERR_CPT "XML Parse Error"
+ IDS_XML_PARSE_ERR_MSG "At %s, line %d, column %d: %s"
+ IDS_XML_PARSE_ERRQ_MSG "At %s: %s"
+ IDS_REPL_WORDS_CPT "Replace words"
+ IDS_REPL_WORDS_MSG "%d replacement(s) done"
+ IDS_NO_SCRIPTS "No scripts found"
+ IDS_SB_SAVED_NO_ERR "Document saved - No errors found."
+ IDS_ADD_CLEARIMG_TEXT "Insert clear image?"
+ IDS_ADD_CLEARIMG_CAPTION "Add image"
+ IDS_ADD_IMAGE_FILEDLG "Choose image to add:"
+ IDS_ADD_BINARIES_FILEDLG "Choose binaries to add:"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE4 "Collapse 4 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE5 "Collapse 5 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE6 "Collapse 6 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE7 "Collapse 7 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE8 "Collapse 8 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE9 "Collapse 9 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND1 "Expand 1 tree level"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND2 "Expand 2 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND3 "Expand 3 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND4 "Expand 4 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND5 "Expand 5 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND6 "Expand 6 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND7 "Expand 7 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND8 "Expand 8 tree levels"
+ IDS_HOTKEY_NAVIGATION_SCI_EXPAND9 "Expand 9 tree levels"
+ IDS_HOTKEY_NAVIGATION_SELECT_HREF "Href"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_HOTKEY_NAVIGATION_SELECT_ID "ID "
+ IDS_HOTKEY_NAVIGATION_SELECT_ID_TABLE "Table ID"
+ IDS_HOTKEY_NAVIGATION_SELECT_TEXT "Text"
+ IDS_HOTKEY_NAVIGATION_SELECT_TREE "Tree"
+ IDS_HOTKEY_GROUP_STYLE "Style"
+ IDS_HOTKEY_STYLE_LINK "Link"
+ IDS_HOTKEY_STYLE_NO_LINK "No link"
+ IDS_HOTKEY_STYLE_NORMAL "Normal"
+ IDS_HOTKEY_STYLE_NOTE "Note"
+ IDS_HOTKEY_STYLE_SUBTITLE "Subtitle"
+ IDS_HOTKEY_STYLE_TEXT_AUTHOR "Text author"
+ IDS_HOTKEY_GROUP_VIEW "View"
+ IDS_HOTKEY_VIEW_BODY "Body"
+ IDS_HOTKEY_VIEW_DESCRIPTION "Description"
+ IDS_HOTKEY_VIEW_SOURCE "Source"
+ IDS_HOTKEY_EDIT_INSERT_TABLE "Insert table"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_HOTKEY_GROUP_SCRIPTS "Scripts"
+ IDS_HOTKEY_SCRIPTS_LAST_SCRIPT "Last script"
+ IDS_SETTINGS_HOTKEYS_CAPTION "Hotkeys"
+ IDS_HOTKEY_GROUP_SYMBOLS "Symbols"
+ IDS_SETTINGS_WORDS_CAPTION "Words"
+ IDS_SETTINGS_WLIST_COUNTED "Counted"
+ IDS_SETTINGS_WLIST_WORD "Word"
+ IDS_SETTINGS_WORDS_ADD_ERR_TEXT "This word is already in list!"
+ IDS_SETTINGS_WORDS_ADD_ERR_CAP "Error adding word"
+ IDS_SETTINGS_WORDS_ADD_ERR_SYM
+ "New exclusion word must contain only alpha characters and one '-' between them!"
+ IDS_WORDS_WLIST_WORD "Word"
+ IDS_WORDS_WLIST_REPLACEMENT "Replacement"
+ IDS_WORDS_WLIST_COUNTED "Counted"
+ IDS_WORDS_FR_BTN_FIND0 "Find"
+ IDS_WORDS_FR_BTN_FIND1 "Next"
+ IDS_CTXMENU_CUT "Cut"
+END
+
+STRINGTABLE
+BEGIN
+ IDC_SPELL_IGNORE "Ignore"
+END
+
+STRINGTABLE
+BEGIN
+ IDC_SPELL_REPLACE "Replace word"
+END
+
+STRINGTABLE
+BEGIN
+ IDS_HOTKEY_EDIT_SUB "Subscript"
+ IDS_HOTKEY_EDIT_SUP "Superscript"
+END
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+1 TYPELIB "FBE.tlb"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/FBE.sln b/FBE.sln
index 16b9d9d..20a69f1 100644
--- a/FBE.sln
+++ b/FBE.sln
@@ -1,53 +1,231 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Localization", "Localization", "{6C7862A8-8BAE-4B07-B1EA-9642D9122354}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FBE", "FBE.vcxproj", "{E1B04471-3393-4970-93ED-FB6A57BCDA8B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Russian", "locales\res_rus\res_rus.vcxproj", "{1BC3F431-9672-4191-9FC5-A8B1C9C08E36}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FBShell", "FBSHell\FBShell.vcxproj", "{856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ukrainian", "locales\res_ukr\res_ukr.vcxproj", "{B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExportHTML", "ExportHTML\ExportHTML.vcxproj", "{07249A4A-8D68-4300-B70F-688FD4F80506}"
-EndProject
-Global
- GlobalSection(SubversionScc) = preSolution
- Svn-Managed = True
- Manager = AnkhSVN - Subversion Support for Visual Studio
- EndGlobalSection
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Debug|Win32.ActiveCfg = Debug|Win32
- {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Debug|Win32.Build.0 = Debug|Win32
- {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Release|Win32.ActiveCfg = Release|Win32
- {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Release|Win32.Build.0 = Release|Win32
- {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Debug|Win32.ActiveCfg = Debug|Win32
- {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Debug|Win32.Build.0 = Debug|Win32
- {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Release|Win32.ActiveCfg = Release|Win32
- {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Release|Win32.Build.0 = Release|Win32
- {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Debug|Win32.ActiveCfg = Debug|Win32
- {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Debug|Win32.Build.0 = Debug|Win32
- {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Release|Win32.ActiveCfg = Release|Win32
- {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Release|Win32.Build.0 = Release|Win32
- {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Debug|Win32.ActiveCfg = Debug|Win32
- {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Debug|Win32.Build.0 = Debug|Win32
- {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Release|Win32.ActiveCfg = Release|Win32
- {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Release|Win32.Build.0 = Release|Win32
- {07249A4A-8D68-4300-B70F-688FD4F80506}.Debug|Win32.ActiveCfg = Debug|Win32
- {07249A4A-8D68-4300-B70F-688FD4F80506}.Debug|Win32.Build.0 = Debug|Win32
- {07249A4A-8D68-4300-B70F-688FD4F80506}.Release|Win32.ActiveCfg = Release|Win32
- {07249A4A-8D68-4300-B70F-688FD4F80506}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {1BC3F431-9672-4191-9FC5-A8B1C9C08E36} = {6C7862A8-8BAE-4B07-B1EA-9642D9122354}
- {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B} = {6C7862A8-8BAE-4B07-B1EA-9642D9122354}
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.24720.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Localization", "Localization", "{6C7862A8-8BAE-4B07-B1EA-9642D9122354}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FBE", "FBE.vcxproj", "{E1B04471-3393-4970-93ED-FB6A57BCDA8B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Russian", "locales\res_rus\res_rus.vcxproj", "{1BC3F431-9672-4191-9FC5-A8B1C9C08E36}"
+ ProjectSection(ProjectDependencies) = postProject
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B} = {E1B04471-3393-4970-93ED-FB6A57BCDA8B}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FBShell", "FBSHell\FBShell.vcxproj", "{856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}"
+ ProjectSection(ProjectDependencies) = postProject
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A} = {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ukrainian", "locales\res_ukr\res_ukr.vcxproj", "{B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}"
+ ProjectSection(ProjectDependencies) = postProject
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B} = {E1B04471-3393-4970-93ED-FB6A57BCDA8B}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhunspell", "hunspell\src\win_api\libhunspell.vcxproj", "{53609BB3-D874-465C-AF7B-DF626DB0D89B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FBV", "FBV\FBV.vcxproj", "{700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExportHTML", "ExportHTML\ExportHTML.vcxproj", "{F15BE191-947B-40DB-934C-507D5011441C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B} = {E1B04471-3393-4970-93ED-FB6A57BCDA8B}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pcre", "pcre\pcre.vcxproj", "{BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug_dll|Win32 = Debug_dll|Win32
+ Debug_dll|x64 = Debug_dll|x64
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ MinSizeRel|Win32 = MinSizeRel|Win32
+ MinSizeRel|x64 = MinSizeRel|x64
+ Release_dll|Win32 = Release_dll|Win32
+ Release_dll|x64 = Release_dll|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ RelWithDebInfo|Win32 = RelWithDebInfo|Win32
+ RelWithDebInfo|x64 = RelWithDebInfo|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Debug_dll|Win32.ActiveCfg = Debug|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Debug_dll|x64.ActiveCfg = Template|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Debug_dll|x64.Build.0 = Template|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Debug|Win32.Build.0 = Debug|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Debug|x64.ActiveCfg = Debug|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.MinSizeRel|Win32.ActiveCfg = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.MinSizeRel|Win32.Build.0 = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.MinSizeRel|x64.ActiveCfg = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.MinSizeRel|x64.Build.0 = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Release_dll|Win32.ActiveCfg = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Release_dll|x64.ActiveCfg = Template|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Release_dll|x64.Build.0 = Template|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Release|Win32.ActiveCfg = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Release|Win32.Build.0 = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.Release|x64.ActiveCfg = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.RelWithDebInfo|Win32.Build.0 = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.RelWithDebInfo|x64.ActiveCfg = Release|Win32
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}.RelWithDebInfo|x64.Build.0 = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Debug_dll|Win32.ActiveCfg = Debug|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Debug_dll|x64.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Debug_dll|x64.Build.0 = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Debug|Win32.Build.0 = Debug|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Debug|x64.ActiveCfg = Debug|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.MinSizeRel|Win32.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.MinSizeRel|Win32.Build.0 = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.MinSizeRel|x64.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.MinSizeRel|x64.Build.0 = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Release_dll|Win32.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Release_dll|x64.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Release_dll|x64.Build.0 = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Release|Win32.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Release|Win32.Build.0 = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.Release|x64.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.RelWithDebInfo|Win32.Build.0 = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.RelWithDebInfo|x64.ActiveCfg = Release|Win32
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36}.RelWithDebInfo|x64.Build.0 = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Debug_dll|Win32.ActiveCfg = Debug|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Debug_dll|x64.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Debug_dll|x64.Build.0 = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Debug|Win32.ActiveCfg = Debug|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Debug|Win32.Build.0 = Debug|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Debug|x64.ActiveCfg = Debug|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.MinSizeRel|Win32.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.MinSizeRel|Win32.Build.0 = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.MinSizeRel|x64.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.MinSizeRel|x64.Build.0 = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Release_dll|Win32.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Release_dll|x64.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Release_dll|x64.Build.0 = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Release|Win32.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Release|Win32.Build.0 = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.Release|x64.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.RelWithDebInfo|Win32.Build.0 = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.RelWithDebInfo|x64.ActiveCfg = Release|Win32
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}.RelWithDebInfo|x64.Build.0 = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Debug_dll|Win32.ActiveCfg = Debug|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Debug_dll|x64.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Debug_dll|x64.Build.0 = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Debug|Win32.Build.0 = Debug|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Debug|x64.ActiveCfg = Debug|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.MinSizeRel|Win32.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.MinSizeRel|Win32.Build.0 = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.MinSizeRel|x64.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.MinSizeRel|x64.Build.0 = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Release_dll|Win32.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Release_dll|x64.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Release_dll|x64.Build.0 = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Release|Win32.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Release|Win32.Build.0 = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.Release|x64.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.RelWithDebInfo|Win32.Build.0 = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.RelWithDebInfo|x64.ActiveCfg = Release|Win32
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B}.RelWithDebInfo|x64.Build.0 = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Debug_dll|Win32.ActiveCfg = Debug_dll|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Debug_dll|Win32.Build.0 = Debug_dll|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Debug_dll|x64.ActiveCfg = Debug_dll|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Debug|Win32.Build.0 = Debug|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Debug|x64.ActiveCfg = Debug|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.MinSizeRel|Win32.ActiveCfg = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.MinSizeRel|Win32.Build.0 = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.MinSizeRel|x64.ActiveCfg = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.MinSizeRel|x64.Build.0 = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release_dll|Win32.ActiveCfg = Release_dll|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release_dll|Win32.Build.0 = Release_dll|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release_dll|x64.ActiveCfg = Release_dll|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release|Win32.ActiveCfg = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release|Win32.Build.0 = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.Release|x64.ActiveCfg = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.RelWithDebInfo|Win32.Build.0 = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.RelWithDebInfo|x64.ActiveCfg = Release|Win32
+ {53609BB3-D874-465C-AF7B-DF626DB0D89B}.RelWithDebInfo|x64.Build.0 = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Debug_dll|Win32.ActiveCfg = Debug|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Debug_dll|Win32.Build.0 = Debug|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Debug_dll|x64.ActiveCfg = Debug|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Debug_dll|x64.Build.0 = Debug|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Debug|Win32.Build.0 = Debug|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Debug|x64.ActiveCfg = Debug|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Debug|x64.Build.0 = Debug|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.MinSizeRel|Win32.ActiveCfg = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.MinSizeRel|Win32.Build.0 = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.MinSizeRel|x64.ActiveCfg = Release|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.MinSizeRel|x64.Build.0 = Release|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Release_dll|Win32.ActiveCfg = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Release_dll|Win32.Build.0 = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Release_dll|x64.ActiveCfg = Release|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Release_dll|x64.Build.0 = Release|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Release|Win32.ActiveCfg = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Release|Win32.Build.0 = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Release|x64.ActiveCfg = Release|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.Release|x64.Build.0 = Release|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.RelWithDebInfo|Win32.Build.0 = Release|Win32
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.RelWithDebInfo|x64.ActiveCfg = Release|x64
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}.RelWithDebInfo|x64.Build.0 = Release|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.Debug_dll|Win32.ActiveCfg = Debug|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.Debug_dll|Win32.Build.0 = Debug|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.Debug_dll|x64.ActiveCfg = Debug|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.Debug_dll|x64.Build.0 = Debug|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.Debug|Win32.Build.0 = Debug|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.Debug|x64.ActiveCfg = Debug|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.Debug|x64.Build.0 = Debug|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.MinSizeRel|Win32.ActiveCfg = Release|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.MinSizeRel|Win32.Build.0 = Release|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.MinSizeRel|x64.ActiveCfg = Release|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.MinSizeRel|x64.Build.0 = Release|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.Release_dll|Win32.ActiveCfg = Release|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.Release_dll|Win32.Build.0 = Release|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.Release_dll|x64.ActiveCfg = Release|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.Release_dll|x64.Build.0 = Release|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.Release|Win32.ActiveCfg = Release|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.Release|Win32.Build.0 = Release|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.Release|x64.ActiveCfg = Release|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.Release|x64.Build.0 = Release|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.RelWithDebInfo|Win32.Build.0 = Release|Win32
+ {F15BE191-947B-40DB-934C-507D5011441C}.RelWithDebInfo|x64.ActiveCfg = Release|x64
+ {F15BE191-947B-40DB-934C-507D5011441C}.RelWithDebInfo|x64.Build.0 = Release|x64
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Debug_dll|Win32.ActiveCfg = Debug|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Debug_dll|Win32.Build.0 = Debug|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Debug_dll|x64.ActiveCfg = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Debug_dll|x64.Build.0 = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Debug|Win32.Build.0 = Debug|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Debug|x64.ActiveCfg = Debug|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.MinSizeRel|x64.ActiveCfg = MinSizeRel|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Release_dll|Win32.ActiveCfg = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Release_dll|Win32.Build.0 = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Release_dll|x64.ActiveCfg = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Release_dll|x64.Build.0 = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Release|Win32.ActiveCfg = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Release|Win32.Build.0 = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.Release|x64.ActiveCfg = Release|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
+ {BFBFBF2D-52FB-44A0-9D44-B3D842A9E057}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {1BC3F431-9672-4191-9FC5-A8B1C9C08E36} = {6C7862A8-8BAE-4B07-B1EA-9642D9122354}
+ {B0D6E5EB-56C0-4DC2-A98F-98EFE5158B8B} = {6C7862A8-8BAE-4B07-B1EA-9642D9122354}
+ EndGlobalSection
+ GlobalSection(SubversionScc) = preSolution
+ Svn-Managed = True
+ Manager = AnkhSVN - Subversion Support for Visual Studio
+ EndGlobalSection
+EndGlobal
diff --git a/FBE.vcxproj b/FBE.vcxproj
index 11203e5..108f4af 100644
--- a/FBE.vcxproj
+++ b/FBE.vcxproj
@@ -1,506 +1,501 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Template
- Win32
-
-
-
- {E1B04471-3393-4970-93ED-FB6A57BCDA8B}
- FBE
- Svn
- Svn
- Svn
- SubversionScc
-
-
-
- Application
- false
- Static
- Unicode
-
-
- Application
- false
- Static
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
-
- true
- .\Debug\
- .\Debug\
- AllRules.ruleset
-
-
- AllRules.ruleset
-
-
- AllRules.ruleset
-
-
-
-
-
- Copying requisite resources...
- rd "$(TargetDir)"\cmd /S /Q
-xcopy "$(ProjectDir)files\*.*" "$(TargetDir)" /E /Q /Y
-
-
-
- NDEBUG;%(PreprocessorDefinitions)
- true
- Win32
- .\Release/FBE.tlb
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- Speed
- false
- extras;utils;wtl;../hunspell/src/hunspell;pcre;%(AdditionalIncludeDirectories)
- NDEBUG;WIN32;_WINDOWS;UNICODE;STRICT;USE_PCRE;_CRT_SECURE_NO_WARNINGS;_WTL_CMDBAR_VISTA_MENUS=0;%(PreprocessorDefinitions)
- MultiThreaded
- false
- Use
- stdafx.h
- .\Release/FBE.pch
- .\Release/
- .\Release/
- .\Release/
- Level3
- true
- Default
-
-
- NDEBUG;%(PreprocessorDefinitions)
- 0x0409
- wtl;extras;%(AdditionalIncludeDirectories)
-
-
- cl /nologo /c /Fo"$(IntDir)buildstamp.obj" buildstamp.c
-
-
- /LTCG %(AdditionalOptions)
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Template
+ Win32
+
+
+
+ {E1B04471-3393-4970-93ED-FB6A57BCDA8B}
+ FBE
+ Svn
+ Svn
+ Svn
+ SubversionScc
+ 8.1
+
+
+
+ Application
+ false
+ Static
+ Unicode
+ v140_xp
+
+
+ Application
+ false
+ Static
+ Unicode
+ v140_xp
+ true
+
+
+ v140_xp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.30319.1
+ $(SolutionDir)$(Configuration)\
+ $(Configuration)\
+
+ true
+ AllRules.ruleset
+
+
+ AllRules.ruleset
+
+
+ AllRules.ruleset
+
+
+
+
+ true
+
+
+
+ Copying requisite resources...
+ rd "$(TargetDir)"cmd /S /Q
+xcopy "$(ProjectDir)files\*.*" "$(TargetDir)" /E /Q /Y
+
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+ true
+ Win32
+
+
+
+
+ MaxSpeed
+ true
+ extras;utils;wtl;./hunspell/src/hunspell;pcre;%(AdditionalIncludeDirectories)
+ HUNSPELL_STATIC;NDEBUG;WIN32;_WINDOWS;UNICODE;STRICT;USE_PCRE;_CRT_SECURE_NO_WARNINGS;_WTL_CMDBAR_VISTA_MENUS=0;%(PreprocessorDefinitions)
+ MultiThreaded
+ false
+ Use
+ stdafx.h
+ Level3
+ true
+ Default
+ true
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+ 0x0409
+ wtl;extras;%(AdditionalIncludeDirectories)
+
+
+
+
+
+
+ /LTCG %(AdditionalOptions)
rpcrt4.lib;
-gdiplus.lib;libhunspell.lib;pcre.lib;opengl32.lib;glu32.lib;$(IntDir)buildstamp.obj;%(AdditionalDependencies)
- true
- ..\hunspell\src\win_api\Release\libhunspell;.\pcre;%(AdditionalLibraryDirectories)
- false
- %(IgnoreSpecificDefaultLibraries)
- %(DelayLoadDLLs)
- .\Release/FBE.pdb
- Windows
- true
- true
-
-
- false
-
-
- MachineX86
-
-
- upx.exe $(OutDir)$(ProjectName).exe
-
-
-
-
- Copying requisite resources...
- rd "$(TargetDir)"\cmd /S /Q
-xcopy "$(ProjectDir)files\*.*" "$(TargetDir)" /E /Q /Y
-
-
-
- _DEBUG;%(PreprocessorDefinitions)
- true
- Win32
- .\Debug/FBE.tlb
-
-
- true
-
-
- Disabled
- extras;utils;wtl;../hunspell/src/hunspell;pcre;%(AdditionalIncludeDirectories)
- _DEBUG;WIN32;_WINDOWS;UNICODE;STRICT;USE_PCRE;_ATL_TRACE_LEVEL=4;_CRT_SECURE_NO_WARNINGS;_ITERATOR_DEBUG_LEVEL=0;_WTL_CMDBAR_VISTA_MENUS=0;%(PreprocessorDefinitions)
- EnableFastChecks
- MultiThreadedDebug
- true
- false
- Use
- stdafx.h
- .\Debug/FBE.pch
- .\Debug/
- .\Debug/
- .\Debug/
- Level2
- true
- ProgramDatabase
- Default
-
-
- _DEBUG;%(PreprocessorDefinitions)
- 0x0409
- wtl;extras;%(AdditionalIncludeDirectories)
-
-
- cl /nologo /c /Fo"$(IntDir)buildstamp.obj" buildstamp.c
-
-
- false
+gdiplus.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)
+ true
+ ..\hunspell\src\win_api\Release\libhunspell;.\pcre;%(AdditionalLibraryDirectories)
+ Windows
+ true
+ true
+ UseFastLinkTimeCodeGeneration
+ MachineX86
+ true
+
+
+
+
+
+
+
+
+ Copying requisite resources...
+ rd "$(TargetDir)" cmd /S /Q
+xcopy "$(ProjectDir)files\*.*" "$(TargetDir)" /E /Q /Y
+
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+ true
+ Win32
+ .\Debug/FBE.tlb
+
+
+ true
+
+
+ Disabled
+ extras;utils;wtl;./hunspell/src/hunspell;pcre;%(AdditionalIncludeDirectories)
+ HUNSPELL_STATIC;_DEBUG;WIN32;_WINDOWS;UNICODE;STRICT;USE_PCRE;_ATL_TRACE_LEVEL=4;_CRT_SECURE_NO_WARNINGS;_WTL_CMDBAR_VISTA_MENUS=0;%(PreprocessorDefinitions)
+ EnableFastChecks
+ MultiThreadedDebug
+ true
+ false
+ Use
+ stdafx.h
+ true
+ EditAndContinue
+ Default
+ Level3
+ true
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+ 0x0409
+ wtl;extras;%(AdditionalIncludeDirectories)
+
+
+
+
+
+
+ false
rpcrt4.lib;
-gdiplus.lib;libhunspell.lib;pcre.lib;opengl32.lib;glu32.lib;$(IntDir)buildstamp.obj;%(AdditionalDependencies)
- true
- ..\hunspell\src\win_api\Release\libhunspell;.\pcre;%(AdditionalLibraryDirectories)
- false
- libcmt.lib;%(IgnoreSpecificDefaultLibraries)
- %(DelayLoadDLLs)
- true
- .\Debug/FBE.pdb
- Windows
- false
-
-
- MachineX86
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
-
-
-
-
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Create
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- Create
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
- Disabled
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
- EnableFastChecks
- Full
- %(AdditionalIncludeDirectories)
- %(PreprocessorDefinitions)
-
-
-
-
- %(PreprocessorDefinitions)
- Win32
- true
- FBE.tlb
- FBE.h
- FBE_i.c
- %(PreprocessorDefinitions)
- Win32
- true
- FBE.tlb
- FBE.h
- FBE_i.c
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- XML
-
-
-
-
-
-
-
-
-
-
-
- _DEBUG
- $(OUTDIR);%(AdditionalIncludeDirectories)
- NDEBUG
- $(OUTDIR);%(AdditionalIncludeDirectories)
-
-
-
-
- true
- true
-
-
- true
- true
-
-
- true
- true
-
-
- true
- true
-
-
-
-
-
-
-
-
-
-
+gdiplus.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)
+ true
+ ..\hunspell\src\win_api\Release\libhunspell;.\pcre;%(AdditionalLibraryDirectories)
+ %(IgnoreSpecificDefaultLibraries)
+ true
+ Windows
+ true
+ true
+ MachineX86
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ HUNSPELL_STATIC;_USING_V110_SDK71_;%(PreprocessorDefinitions)
+
+
+
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+ NotUsing
+ NotUsing
+
+
+
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+
+
+
+
+
+
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Create
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ Create
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+
+
+ Disabled
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+ EnableFastChecks
+ Full
+ %(AdditionalIncludeDirectories)
+ %(PreprocessorDefinitions)
+
+
+
+
+ %(PreprocessorDefinitions)
+ Win32
+ true
+ FBE.tlb
+ FBE.h
+ FBE_i.c
+ %(PreprocessorDefinitions)
+ Win32
+ true
+ FBE.tlb
+ FBE.h
+ FBE_i.c
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ XML
+
+
+
+
+
+
+
+
+
+
+
+ _DEBUG
+ $(OUTDIR);%(AdditionalIncludeDirectories)
+ NDEBUG
+ $(OUTDIR);%(AdditionalIncludeDirectories)
+
+
+
+
+ true
+ true
+
+
+ true
+ true
+
+
+ true
+ true
+
+
+ true
+ true
+
+
+
+
+ {53609bb3-d874-465c-af7b-df626db0d89b}
+
+
+ {bfbfbf2d-52fb-44a0-9d44-b3d842a9e057}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FBE.vcxproj.filters b/FBE.vcxproj.filters
index 73c16c6..d818226 100644
--- a/FBE.vcxproj.filters
+++ b/FBE.vcxproj.filters
@@ -1,508 +1,460 @@
-
-
-
-
- {b46c6a14-cda8-4552-810f-97ed0f17d30d}
- cpp;c;cxx;rc;def;r;odl;idl;hpj;bat
-
-
- {dd80cc0d-c2aa-4363-8853-0be60a1f6747}
- h;hpp;hxx;hm;inl
-
-
- {b1ca92e5-588b-4574-bb31-44c2f60a6c7b}
- cpp;h
-
-
- {0bbc609e-4d9f-4d7f-81d8-e1fbece798f6}
- ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe
-
-
- {f4ba7b2e-b161-4bea-8393-950f5ce075c1}
- cpp;h
-
-
- {ec6d40b1-6c46-4771-8c2d-e3968dadb91c}
-
-
- {b00b3d8d-440c-4ff4-9fd4-7290f74f57ce}
-
-
- {23f8d9b2-47ae-4034-bb33-c3ea42d51d4e}
-
-
- {4824b569-5baa-4847-b66b-a21ffbcc5b93}
-
-
- {ba1b12bd-aa55-4b44-b16c-0235bcd5cb11}
-
-
- {739cf53b-fcad-4838-b088-5b22085673ca}
-
-
- {6e8566fd-3860-480a-9dbc-4c090f1f8515}
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- extras
-
-
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- Header Files\WTL
-
-
- extras
-
-
- extras
-
-
- extras
-
-
- extras
-
-
- extras
-
-
- extras
-
-
- extras
-
-
- extras
-
-
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Dependance Files\XML Stylesheets
-
-
- Dependance Files\XML Stylesheets
-
-
- Dependance Files\XML Stylesheets
-
-
- Dependance Files\XML Stylesheets
-
-
- Dependance Files\Style Sheets
-
-
- Dependance Files\Style Sheets
-
-
- Dependance Files\FictionBook Files
-
-
- Dependance Files\Hypertext Files
-
-
- Dependance Files\Hypertext Files
-
-
- Dependance Files\Script Files
-
-
-
- extras
-
-
- Resource Files
-
-
-
-
- Resource Files
-
-
-
-
- Resource Files
-
-
-
-
- Dependance Files\XML Schemas
-
-
- Dependance Files\XML Schemas
-
-
- Dependance Files\XML Schemas
-
-
- Dependance Files\XML Schemas
-
-
+
+
+
+
+ {b46c6a14-cda8-4552-810f-97ed0f17d30d}
+ cpp;c;cxx;rc;def;r;odl;idl;hpj;bat
+
+
+ {dd80cc0d-c2aa-4363-8853-0be60a1f6747}
+ h;hpp;hxx;hm;inl
+
+
+ {0bbc609e-4d9f-4d7f-81d8-e1fbece798f6}
+ ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe
+
+
+ {f4ba7b2e-b161-4bea-8393-950f5ce075c1}
+ cpp;h
+
+
+ {ec6d40b1-6c46-4771-8c2d-e3968dadb91c}
+
+
+ {b00b3d8d-440c-4ff4-9fd4-7290f74f57ce}
+
+
+ {23f8d9b2-47ae-4034-bb33-c3ea42d51d4e}
+
+
+ {4824b569-5baa-4847-b66b-a21ffbcc5b93}
+
+
+ {ba1b12bd-aa55-4b44-b16c-0235bcd5cb11}
+
+
+ {739cf53b-fcad-4838-b088-5b22085673ca}
+
+
+ {6e8566fd-3860-480a-9dbc-4c090f1f8515}
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ extras
+
+
+ Source Files
+
+
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ extras
+
+
+ extras
+
+
+ extras
+
+
+ extras
+
+
+ extras
+
+
+ extras
+
+
+ extras
+
+
+ extras
+
+
+ Header Files
+
+
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Dependance Files\XML Stylesheets
+
+
+ Dependance Files\XML Stylesheets
+
+
+ Dependance Files\XML Stylesheets
+
+
+ Dependance Files\XML Stylesheets
+
+
+ Dependance Files\Style Sheets
+
+
+ Dependance Files\Style Sheets
+
+
+ Dependance Files\FictionBook Files
+
+
+ Dependance Files\Hypertext Files
+
+
+ Dependance Files\Hypertext Files
+
+
+ Dependance Files\Script Files
+
+
+
+ extras
+
+
+ Resource Files
+
+
+
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
+
+
+ Dependance Files\XML Schemas
+
+
+ Dependance Files\XML Schemas
+
+
+ Dependance Files\XML Schemas
+
+
+ Dependance Files\XML Schemas
+
+
\ No newline at end of file
diff --git a/FBEview.cpp b/FBEview.cpp
index e87f48c..ab86073 100644
--- a/FBEview.cpp
+++ b/FBEview.cpp
@@ -1,4214 +1,4215 @@
-// FBEView.cpp : implementation of the CFBEView class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#include "stdafx.h"
-#include "res1.h"
-
-#include "utils.h"
-#include "apputils.h"
-
-#include "FBEView.h"
-#include "SearchReplace.h"
-#include "Scintilla.h"
-#include "ElementDescMnr.h"
-
-extern CElementDescMnr _EDMnr;
-
-// normalization helpers
-static void PackText(MSHTML::IHTMLElement2Ptr elem,MSHTML::IHTMLDocument2 *doc);
-static void KillDivs(MSHTML::IHTMLElement2Ptr elem);
-static void FixupParagraphs(MSHTML::IHTMLElement2Ptr elem);
-static void RelocateParagraphs(MSHTML::IHTMLDOMNode *node);
-static void KillStyles(MSHTML::IHTMLElement2Ptr elem);
-
-_ATL_FUNC_INFO CFBEView::DocumentCompleteInfo=
- { CC_STDCALL, VT_EMPTY, 2, { VT_DISPATCH, (VT_BYREF | VT_VARIANT) } };
-_ATL_FUNC_INFO CFBEView::BeforeNavigateInfo=
- { CC_STDCALL, VT_EMPTY, 7, {
- VT_DISPATCH,
- (VT_BYREF | VT_VARIANT),
- (VT_BYREF | VT_VARIANT),
- (VT_BYREF | VT_VARIANT),
- (VT_BYREF | VT_VARIANT),
- (VT_BYREF | VT_VARIANT),
- (VT_BYREF | VT_BOOL),
- }
- };
-_ATL_FUNC_INFO CFBEView::VoidInfo=
- { CC_STDCALL, VT_EMPTY, 0 };
-_ATL_FUNC_INFO CFBEView::EventInfo=
- { CC_STDCALL, VT_BOOL, 1, { VT_DISPATCH } };
-_ATL_FUNC_INFO CFBEView::VoidEventInfo=
- { CC_STDCALL, VT_EMPTY, 1, { VT_DISPATCH } };
-
-LRESULT CFBEView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- if (DefWindowProc(uMsg,wParam,lParam))
- return 1;
- if (!SUCCEEDED(QueryControl(&m_browser)))
- return 1;
-
- // register browser events handler
- BrowserEvents::DispEventAdvise(m_browser,&DIID_DWebBrowserEvents2);
-
- return 0;
-}
-
-CFBEView::~CFBEView()
-{
- if(HasDoc())
- {
- DocumentEvents::DispEventUnadvise(Document(), &DIID_HTMLDocumentEvents2);
- TextEvents::DispEventUnadvise(Document()->body, &DIID_HTMLTextContainerEvents2);
- m_mkc->UnRegisterForDirtyRange(m_dirtyRangeCookie);
- }
- if(m_browser)
- BrowserEvents::DispEventUnadvise(m_browser, &DIID_DWebBrowserEvents2);
-
- if(m_find_dlg)
- {
- CloseFindDialog(m_find_dlg);
- delete m_find_dlg;
- }
-}
-
-BOOL CFBEView::PreTranslateMessage(MSG* pMsg)
-{
- return SendMessage(WM_FORWARDMSG,0,(LPARAM)pMsg)!=0;
-}
-
-// editing commands
-LRESULT CFBEView::ExecCommand(int cmd) {
- IOleCommandTargetPtr ct(m_browser);
- if (ct)
- ct->Exec(&CGID_MSHTML,cmd,0,NULL,NULL);
- return 0;
-}
-
-void CFBEView::QueryStatus(OLECMD *cmd,int ncmd) {
- IOleCommandTargetPtr ct(m_browser);
- if (ct)
- ct->QueryStatus(&CGID_MSHTML,ncmd,cmd,NULL);
-}
-
-CString CFBEView::QueryCmdText(int cmd) {
- IOleCommandTargetPtr ct(m_browser);
- if (ct) {
- OLECMD oc={cmd};
- struct {
- OLECMDTEXT oct;
- wchar_t buffer[512];
- } oct={ { OLECMDTEXTF_NAME, 0, 512 } };
- if (SUCCEEDED(ct->QueryStatus(&CGID_MSHTML,1,&oc,&oct.oct)))
- return oct.oct.rgwz;
- }
- return CString();
-}
-
-LRESULT CFBEView::OnStyleLink(WORD, WORD, HWND, BOOL&) {
- try {
- if (Document()->execCommand(L"CreateLink",VARIANT_FALSE,_variant_t(L""))==VARIANT_TRUE)
- {
- ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_SEL_CHANGE),(LPARAM)m_hWnd);
- ::SendMessage(m_frame,WM_COMMAND,MAKELONG(IDC_HREF,IDN_WANTFOCUS),(LPARAM)m_hWnd);
- }
- }
- catch (_com_error&) { }
- return 0;
-}
-
-LRESULT CFBEView::OnStyleFootnote(WORD, WORD, HWND, BOOL&) {
- try {
- m_mk_srv->BeginUndoUnit(L"Create Footnote");
- if (Document()->execCommand(L"CreateLink",VARIANT_FALSE,_variant_t(L""))==VARIANT_TRUE) {
- MSHTML::IHTMLTxtRangePtr r(Document()->selection->createRange());
- MSHTML::IHTMLElementPtr pe(r->parentElement());
- if (U::scmp(pe->tagName,L"A")==0)
- pe->className=L"note";
- }
- m_mk_srv->EndUndoUnit();
- ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_SEL_CHANGE),(LPARAM)m_hWnd);
- ::SendMessage(m_frame,WM_COMMAND,MAKELONG(IDC_HREF,IDN_WANTFOCUS),(LPARAM)m_hWnd);
- }
- catch (_com_error&) { }
- return 0;
-}
-
-bool CFBEView::CheckCommand(WORD wID)
-{
- if (!m_normalize)
- return false;
- switch (wID) {
- case ID_EDIT_ADD_BODY:
- return true;
- case ID_EDIT_ADD_TITLE:
- return bCall(L"AddTitle",SelectionStructCon());
- case ID_EDIT_CLONE:
- return bCall(L"CloneContainer",SelectionStructCon());
- case ID_STYLE_NORMAL:
- return bCall(L"StyleNormal",SelectionStructCon());
- case ID_STYLE_SUBTITLE:
- return bCall(L"StyleSubtitle",SelectionStructCon());
- case ID_STYLE_TEXTAUTHOR:
- return bCall(L"StyleTextAuthor",SelectionStructCon());
- case ID_EDIT_INS_IMAGE:
- return bCall(L"InsImage") && !SelectionStructCode() && !SelectionHasTags(L"SPAN");
- case ID_EDIT_INS_INLINEIMAGE:
- return bCall(L"InsInlineImage");
- case ID_EDIT_ADD_IMAGE:
- return bCall(L"AddImage", SelectionStructCon()) && !SelectionStructCode() && !SelectionHasTags(L"SPAN");
- case ID_EDIT_ADD_EPIGRAPH:
- return bCall(L"AddEpigraph",SelectionStructCon());
- case ID_EDIT_ADD_ANN:
- return bCall(L"AddAnnotation",SelectionStructCon());
- case ID_EDIT_SPLIT:
- return SplitContainer(true);
- case ID_EDIT_INS_POEM:
- return InsertPoem(true);
- case ID_EDIT_INS_CITE:
- return InsertCite(true);
- case ID_EDIT_CODE:
- {
- _variant_t params[3] =
- {
- Document()->selection->createRange().GetInterfacePtr(),
- SelectionStructCon().GetInterfacePtr(),
- true
- };
- return bCall(L"StyleCode", 3, params);
- }
- case ID_INSERT_TABLE:
- return InsertTable(true);
- case ID_GOTO_FOOTNOTE:
- return (GoToFootnote(true) | GoToReference(true));
- case ID_GOTO_REFERENCE:
- return GoToReference(true);
- case ID_EDIT_ADD_TA:
- return bCall(L"AddTA",SelectionStructCon());
- case ID_EDIT_MERGE:
- return bCall(L"MergeContainers",SelectionStructCon());
- case ID_EDIT_REMOVE_OUTER_SECTION:
- return bCall(L"RemoveOuterContainer",SelectionStructCon());
- case ID_STYLE_LINK:
- case ID_STYLE_NOTE:
- try {
- return Document()->queryCommandEnabled(L"CreateLink")==VARIANT_TRUE;
- }
- catch (_com_error) { }
- break;
- }
- return false;
-}
-
-bool CFBEView::CheckSetCommand(WORD wID) {
- if (!m_normalize)
- return false;
-
- switch (wID)
- {
- case ID_EDIT_CODE:
- return bCall(L"IsCode", SelectionStructCode());
- }
-
- return false;
-}
-
-// changes tracking
-MSHTML::IHTMLDOMNodePtr CFBEView::GetChangedNode() {
- MSHTML::IMarkupPointerPtr p1,p2;
- m_mk_srv->CreateMarkupPointer(&p1);
- m_mk_srv->CreateMarkupPointer(&p2);
-
- m_mkc->GetAndClearDirtyRange(m_dirtyRangeCookie,p1,p2);
-
- MSHTML::IHTMLElementPtr e1,e2;
- p1->CurrentScope(&e1);
- p2->CurrentScope(&e2);
- p1.Release();
- p2.Release();
-
- while ((bool)e1 && e1!=e2 && e1->contains(e2)!=VARIANT_TRUE)
- e1=e1->parentElement;
-
- return e1;
-}
-
-static bool IsEmptyNode(MSHTML::IHTMLDOMNode *node) {
- if (node->nodeType!=1)
- return false;
-
- _bstr_t name(node->nodeName);
-
- if (U::scmp(name,L"BR")==0)
- return false;
-
- if (U::scmp(name,L"P")==0) // the editor uses empty Ps to represent empty lines
- return false;
-
- /* if (U::scmp(name,L"EM")==0) // конвертеры иногда обрамляют пробелы тегами и
- return false;
-
- if (U::scmp(name,L"STRONG")==0) // конвертеры иногда обрамляют пробелы тегами и
- return false;*/
-
- // images are always empty
- if (U::scmp(name,L"DIV")==0 && U::scmp(MSHTML::IHTMLElementPtr(node)->className,L"image")==0)
- return false;
- if (U::scmp(name,L"IMG")==0)
- return false;
-
- if (node->hasChildNodes()==VARIANT_FALSE)
- return true;
-
- if (U::scmp(name,L"A")==0) // links can be meaningful even if the contain only ws
- return false;
-
- if ((bool)node->firstChild->nextSibling)
- return false;
-
- if (node->firstChild->nodeType!=3)
- return false;
-
- if (U::is_whitespace(node->firstChild->nodeValue.bstrVal))
- return true;
-
- return false;
-}
-
-// Remove empty leaf nodes
-static void RemoveEmptyNodes(MSHTML::IHTMLDOMNode *node) {
- if (node->nodeType!=1)
- return;
-
- MSHTML::IHTMLDOMNodePtr cur(node->firstChild);
- while (cur)
- {
- MSHTML::IHTMLDOMNodePtr next;
- try { next = cur->nextSibling; } catch(...) { return; }
-
- RemoveEmptyNodes(cur);
- if(IsEmptyNode(cur))
- cur->removeNode(VARIANT_TRUE);
- cur=next;
- }
-}
-
-// Find parent DIV
-static MSHTML::IHTMLElementPtr GetHP(MSHTML::IHTMLElementPtr hp)
-{
- while((bool)hp && U::scmp(hp->tagName,L"DIV"))
- hp = hp->parentElement;
- return hp;
-}
-
-// Splitting
-bool CFBEView::SplitContainer(bool fCheck)
-{
- try
- {
- MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
- if(!(bool)rng)
- return false;
-
- MSHTML::IHTMLElementPtr pe(rng->parentElement());
- while((bool)pe && U::scmp(pe->tagName, L"DIV"))
- pe = pe->parentElement;
-
- if(!(bool)pe || (U::scmp(pe->className, L"section") && U::scmp(pe->className, L"stanza")))
- return false;
-
- MSHTML::IHTMLTxtRangePtr r2(rng->duplicate());
- r2->moveToElementText(pe);
-
- if(rng->compareEndPoints(L"StartToStart", r2) == 0)
- return false;
-
- MSHTML::IHTMLTxtRangePtr r3(rng->duplicate());
- r3->collapse(true);
- MSHTML::IHTMLTxtRangePtr r4(rng->duplicate());
- r4->collapse(false);
-
- if(!(bool)pe || GetHP(r3->parentElement()) != pe || GetHP(r4->parentElement()) != pe)
- return false;
-
- if(fCheck)
- return true;
-
- // At this point we are ready to split
-
- // Create an undo unit
- CString name(L"split ");
- name += (const wchar_t*)pe->className;
- m_mk_srv->BeginUndoUnit((TCHAR*)(const TCHAR*)name);
-
- //// Create a new element
- MSHTML::IHTMLElementPtr ne(Document()->createElement(L"DIV"));
- ne->className = pe->className;
- _bstr_t className = pe->className;
- // SeNS: issue #153
- _bstr_t id = pe->id;
- pe->id = L"";
-
- MSHTML::IHTMLElementPtr peTitle(Document()->createElement(L"DIV"));
- MSHTML::IHTMLElementCollectionPtr peColl = pe->children;
- {
- MSHTML::IHTMLElementPtr peChild = peColl->item(0);
- if(!U::scmp(peChild->tagName, L"DIV") && !U::scmp(peChild->className, L"title"))
- peTitle->innerHTML = peChild->outerHTML;
- else
- peTitle = NULL;
- }
-
- // Create and position markup pointers
- MSHTML::IMarkupPointerPtr selstart, selend, elembeg, elemend;
-
- m_mk_srv->CreateMarkupPointer(&selstart);
- m_mk_srv->CreateMarkupPointer(&selend);
- m_mk_srv->CreateMarkupPointer(&elembeg);
- m_mk_srv->CreateMarkupPointer(&elemend);
-
- MSHTML::IHTMLTxtRangePtr titleRng(rng->duplicate());
- m_mk_srv->MovePointersToRange(titleRng, selstart, selend);
- U::ElTextHTML title(titleRng->htmlText, titleRng->text);
-
- MSHTML::IHTMLTxtRangePtr preRng(rng->duplicate());
- elembeg->MoveAdjacentToElement(pe, MSHTML::ELEM_ADJ_AfterBegin);
- m_mk_srv->MoveRangeToPointers(elembeg, selstart, preRng);
- U::ElTextHTML pre(preRng->htmlText, preRng->text);
-
- MSHTML::IHTMLElementCollectionPtr peChilds = pe->children;
- MSHTML::IHTMLElementPtr elLast = peChilds->item(peChilds->length - 1);
- if(U::scmp(elLast->innerText, L"") == 0)
- elLast->innerText = L"123";
-
- MSHTML::IHTMLTxtRangePtr postRng(rng->duplicate());
- elemend->MoveAdjacentToElement(pe, MSHTML::ELEM_ADJ_BeforeEnd);
- m_mk_srv->MoveRangeToPointers(selend, elemend, postRng);
- U::ElTextHTML post(postRng->htmlText, postRng->text);
-
- // Check if title needs to be created and further text to be copied
- bool fTitle = !title.text.IsEmpty();
- bool fContent = !post.html.IsEmpty();
-
- if(fTitle && title.html.Find(L"") + title.html + CString(L"
");
- if(fContent && post.html.Find(L"") + post.html + CString(L"
");
-
- title.html.Remove(L'\r');
- title.html.Remove(L'\n');
- post.html.Remove(L'\r');
- post.html.Remove(L'\n');
-
- if(post.html.Find(L"
") == 0
- && post.html.GetLength() > 13
- && fTitle
- && title.html.Find(L"
") != title.html.GetLength() -14)
- post.html.Delete(0, 13);
- if(post.html.Find(L"123
") != -1)
- post.html.Replace(L"123
", L"
");
-
- // Insert it after pe
- MSHTML::IHTMLElement2Ptr(pe)->insertAdjacentElement(L"afterEnd", ne);
-
- // Move content or create new
- if(fContent)
- {
- // Create and position destination markup pointer
- if(post.html == L"
")
- post.html += L"
";
- ne->innerHTML = post.html.AllocSysString();
- // SeNS: issue #153
- ne->id = id;
- }
- else
- {
- MSHTML::IHTMLElementPtr para(Document()->createElement(L"P"));
- MSHTML::IHTMLElement3Ptr(para)->inflateBlock = VARIANT_TRUE;
- MSHTML::IHTMLElement2Ptr(ne)->insertAdjacentElement(L"beforeEnd", para);
- }
-
- // Create and move title if needed
- if(fTitle)
- {
- MSHTML::IHTMLElementPtr elTitle(Document()->createElement(L"DIV"));
- elTitle->className = L"title";
- MSHTML::IHTMLElement2Ptr(ne)->insertAdjacentElement(L"afterBegin", elTitle);
-
- // Create and position destination markup pointer
- elTitle->innerHTML = title.html.AllocSysString();
-
- // Delete all containers from title
- KillDivs(elTitle);
- KillStyles(elTitle);
- }
-
- if(pre.html.Find(L"
";
- else
- pre.html = CString(L"") + pre.html + CString(L"
");
- }
- pe->innerHTML = pre.html.AllocSysString();
-
- // Ensure we have good html
- FixupParagraphs(ne);
- PackText(ne, Document());
-
- peColl = pe->children;
- if(peColl->length == 1)
- {
- MSHTML::IHTMLElementPtr peChild = peColl->item(0);
- if(!U::scmp(peChild->tagName, L"DIV") && !U::scmp(peChild->className, className.GetBSTR()))
- m_mk_srv->RemoveElement(peChild);
- }
-
- MSHTML::IHTMLElementCollectionPtr neColl = ne->children;
- if(neColl->length == 1)
- {
- MSHTML::IHTMLElementPtr neChild = neColl->item(0);
- if(!U::scmp(neChild->tagName, L"DIV") && !U::scmp(neChild->className, className.GetBSTR()))
- m_mk_srv->RemoveElement(neChild);
- }
-
- CString peTitSect;
- if(peTitle)
- {
- peTitSect = peTitle->innerHTML.GetBSTR();
- peTitSect += L"
";
- }
-
- CString b = pe->innerText;
- b.Remove(L'\r');
- b.Remove(L'\n');
- CString c = peTitle ? peTitle->innerText : L"";
- c.Remove(L'\r');
- c.Remove(L'\n');
-
- if(peTitle && !U::scmp(b, c))
- pe->innerHTML = peTitSect.AllocSysString();
-
- // Close undo unit
- m_mk_srv->EndUndoUnit();
-
- // Move cursor to newly created item
- GoTo(ne, false);
- }
- catch (_com_error& e)
- {
- U::ReportError(e);
- }
-
- return false;
-}
-
-// cleaning up html
-static void KillDivs(MSHTML::IHTMLElement2Ptr elem) {
- MSHTML::IHTMLElementCollectionPtr divs(elem->getElementsByTagName(L"DIV"));
- while (divs->length>0)
- MSHTML::IHTMLDOMNodePtr(divs->item(0L))->removeNode(VARIANT_FALSE);
-}
-
-static void KillStyles(MSHTML::IHTMLElement2Ptr elem) {
- MSHTML::IHTMLElementCollectionPtr ps(elem->getElementsByTagName(L"P"));
- for (long l=0;llength;++l)
- CheckError(MSHTML::IHTMLElementPtr(ps->item(l))->put_className(NULL));
-}
-
-//////////////////////////////////////////////////////////////////////////////
-/// @fn static bool MergeEqualHTMLElements(MSHTML::IHTMLDOMNode *node)
-///
-/// функция объединяет стоящие рядом одинаковые HTML элементы
-///
-/// @params MSHTML::IHTMLDOMNode *node [in, out] - нода, внутри которой будет производиться преобразование
-///
-/// @note сливаются следующие элементы: EM, STRONG
-/// при этом пробельные символы, располагающиеся между закрывающем и открывающим тегами остаются, т.е.
-/// 'хороший пример ' преобразуется в 'хороший пример '
-///
-/// @author Ильин Иван @date 31.03.08
-//////////////////////////////////////////////////////////////////////////////
-static bool MergeEqualHTMLElements(MSHTML::IHTMLDOMNode *node, MSHTML::IHTMLDocument2 *doc)
-{
- if (node->nodeType != 1) // Element node
- return false;
-
- bool fRet=false;
-
-
- MSHTML::IHTMLDOMNodePtr cur(node->firstChild);
- while ((bool)cur)
- {
- MSHTML::IHTMLDOMNodePtr next;
- try { next = cur->nextSibling; } catch(...) { return false; }
-
- if (MergeEqualHTMLElements(cur,doc))
- {
- cur = node->firstChild;
- continue;
- }
-
- // если нет следующего элемента, то сливать будет несчем
- if(!(bool)next)
- return false;
-
- _bstr_t name(cur->nodeName);
- MSHTML::IHTMLElementPtr curelem(cur);
- MSHTML::IHTMLElementPtr nextElem(next);
-
- if (U::scmp(name,L"EM")==0 || U::scmp(name,L"STRONG")==0)
- {
- // отлавливаем ситуацию с пробелом, обрамленным тегами EM т.д.
- bstr_t curText = curelem->innerText;
- if(curText.length() == 0 || U::is_whitespace(curelem->innerText))
- {
- // удаляем обрамляющие теги
- MSHTML::IHTMLDOMNodePtr prev = cur->previousSibling;
- if((bool)prev)
- {
- if(prev->nodeType == 3)//text
- {
- prev->nodeValue = (bstr_t)prev->nodeValue.bstrVal + curelem->innerText;
- }
- else
- {
- MSHTML::IHTMLElementPtr prevElem(prev);
- prevElem->innerHTML = prevElem->innerHTML + curelem->innerText;
- }
- cur->removeNode(VARIANT_TRUE);
- cur = prev;
- continue;
- }
-
- if((bool)next)
- {
- MSHTML::IHTMLDOMNodePtr parent = cur->parentNode;
- if(next->nodeType == 3)//text
- {
- next->nodeValue = (bstr_t)curelem->innerText + next->nodeValue.bstrVal;
- }
- else
- {
- MSHTML::IHTMLElementPtr nextElem(next);
- nextElem->innerHTML = curelem->innerText + nextElem->innerHTML;
- }
- cur->removeNode(VARIANT_TRUE);
- cur = parent->firstChild;
- continue;
- }
- }
-
- if(next->nodeType == 3) // TextNode
- {
- MSHTML::IHTMLDOMNodePtr afterNext(next->nextSibling);
- if(!(bool)afterNext)
- {
- cur = next;
- continue;
- }
-
- MSHTML::IHTMLElementPtr afterNextElem(afterNext);
-
- bstr_t afterNextName = afterNext->nodeName;
- if(U::scmp(name, afterNextName))// если следующий элемент другого типа
- {
- cur = next;
- continue;
- }
-
- // проверяем между одинаковыми элементами стоят одни пробелы
- if(!U::is_whitespace(next->nodeValue.bstrVal))
- {
- cur = next;
- continue; // 123 45678 абсолютно нормальная ситуация
- }
-
- // объединяем элементы
- MSHTML::IHTMLElementPtr newelem(doc->createElement(name));
- MSHTML::IHTMLDOMNodePtr newnode(newelem);
- newelem->innerHTML = curelem->innerHTML + next->nodeValue.bstrVal + afterNextElem->innerHTML;
- cur->replaceNode(newnode);
- afterNext->removeNode(VARIANT_TRUE);
- next->removeNode(VARIANT_TRUE);
- cur = newnode;
- fRet=true;
- }
- else
- {
- bstr_t nextName(next->nodeName);
- if(U::scmp(name, nextName))// если следующий элемент другого типа
- {
- cur = next;
- continue;
- }
-
- // объединяем элементы
- MSHTML::IHTMLElementPtr newelem(doc->createElement(name));
- MSHTML::IHTMLDOMNodePtr newnode(newelem);
- newelem->innerHTML = curelem->innerHTML + nextElem->innerHTML;
- cur->replaceNode(newnode);
- next->removeNode(VARIANT_TRUE);
- cur = newnode;
- fRet=true;
- continue;
- }
- }
- cur=next;
- }
- return fRet;
-}
-static bool RemoveUnk(MSHTML::IHTMLDOMNode *node, MSHTML::IHTMLDocument2 *doc) {
- if (node->nodeType!=1) // Element node
- return false;
-
- bool fRet=false;
-
-restart:
- MSHTML::IHTMLDOMNodePtr cur(node->firstChild);
- while ((bool)cur)
- {
- MSHTML::IHTMLDOMNodePtr next;
- try { next = cur->nextSibling; } catch(...) { return false; }
-
- if (RemoveUnk(cur,doc))
- goto restart;
-
- _bstr_t name(cur->nodeName);
- MSHTML::IHTMLElementPtr curelem(cur);
-
- if (U::scmp(name,L"B")==0 || U::scmp(name,L"I")==0) {
- const wchar_t *newname=U::scmp(name,L"B")==0 ? L"STRONG" : L"EM";
- MSHTML::IHTMLElementPtr newelem(doc->createElement(newname));
- MSHTML::IHTMLDOMNodePtr newnode(newelem);
- newelem->innerHTML=curelem->innerHTML;
- cur->replaceNode(newnode);
- cur=newnode;
- fRet=true;
- goto restart;
- }
-
- CString text;
- if (curelem != NULL)
- text.SetString(curelem->outerHTML);
-
- if (U::scmp(name,L"P") && U::scmp(name,L"STRONG") &&
- U::scmp(name,L"STRIKE") && U::scmp(name,L"SUP") && U::scmp(name,L"SUB") &&
- U::scmp(name,L"EM") && U::scmp(name,L"A") &&
- (U::scmp(name,L"SPAN") || U::scmp(curelem->className, L"code")) &&
- U::scmp(name,L"#text") && U::scmp(name,L"BR") &&
- (U::scmp(name,L"IMG") || U::scmp(curelem->parentElement->className, L"image") &&
- // Added by SeNS: inline images support
- (U::scmp(name,L"SPAN") || U::scmp(curelem->className, L"image"))))
- {
- if (U::scmp(name,L"DIV")==0) {
- _bstr_t cls(curelem->className);
- _bstr_t id(curelem->id);
- if (!(U::scmp(cls,L"body") && U::scmp(cls,L"section") &&
- U::scmp(cls,L"table") && U::scmp(cls,L"tr") && U::scmp(cls,L"th") && U::scmp(cls,L"td") &&
- U::scmp(cls,L"output") && U::scmp(cls,L"part") && U::scmp(cls,L"output-document-class") &&
- U::scmp(cls,L"annotation") && U::scmp(cls,L"title") && U::scmp(cls,L"epigraph") &&
- U::scmp(cls,L"poem") && U::scmp(cls,L"stanza") && U::scmp(cls,L"cite") &&
- U::scmp(cls,L"date") &&
- U::scmp(cls,L"history") && U::scmp(cls,L"image")&&
- U::scmp(cls,L"code") &&
- U::scmp(id,L"fbw_desc") && U::scmp(id,L"fbw_body") && U::scmp(id,L"fbw_updater")))
- goto ok;
- }
-
- CElementDescriptor* ED;
- if(_EDMnr.GetElementDescriptor(cur, &ED))
- goto ok;
- MSHTML::IHTMLDOMNodePtr ce(cur->previousSibling);
- cur->removeNode(VARIANT_FALSE);
- if (ce)
- next=ce->nextSibling;
- else
- next=node->firstChild;
- }
-ok:
-
- cur=next;
- }
- return fRet;
-}
-
-// move the paragraph up one level
-void MoveUp(bool fCopyFmt,MSHTML::IHTMLDOMNodePtr& node) {
- MSHTML::IHTMLDOMNodePtr parent(node->parentNode);
- MSHTML::IHTMLElement2Ptr elem(parent);
-
- // clone parent (it can be A/EM/STRONG/SPAN)
- if (fCopyFmt) {
- MSHTML::IHTMLDOMNodePtr clone(parent->cloneNode(VARIANT_FALSE));
- while ((bool)node->firstChild)
- clone->appendChild(node->firstChild);
- node->appendChild(clone);
- }
-
- // clone parent once more and move siblings after node to it
- if ((bool)node->nextSibling) {
- MSHTML::IHTMLDOMNodePtr clone(parent->cloneNode(VARIANT_FALSE));
- while ((bool)node->nextSibling)
- clone->appendChild(node->nextSibling);
- elem->insertAdjacentElement(L"afterEnd",MSHTML::IHTMLElementPtr(clone));
- if (U::scmp(parent->nodeName,L"P")==0)
- MSHTML::IHTMLElement3Ptr(clone)->inflateBlock=VARIANT_TRUE;
- }
-
- // now move node to parent level, the tree may be in some weird state
- node->removeNode(VARIANT_TRUE); // delete from tree
- node=elem->insertAdjacentElement(L"afterEnd",MSHTML::IHTMLElementPtr(node));
-}
-
-void BubbleUp(MSHTML::IHTMLDOMNode *node,const wchar_t *name) {
- MSHTML::IHTMLElement2Ptr elem(node);
- MSHTML::IHTMLElementCollectionPtr elements(elem->getElementsByTagName(name));
- long len=elements->length;
- for (long i=0;iitem(i));
- if (!(bool)ce)
- break;
- for (int ll=0;ce->parentNode!=node && ll<30;++ll)
- MoveUp(true,ce);
- MoveUp(false,ce);
- }
-}
-
-#if (1)
-// split paragraphs containing BR elements
-static void SplitBRs(MSHTML::IHTMLElement2Ptr elem)
-{
- CString text = MSHTML::IHTMLElementPtr(elem)->outerHTML;
- if (text.Replace(L" ", L"
") > 0)
- MSHTML::IHTMLElementPtr(elem)->outerHTML = text.AllocSysString();
-}
-#else
-static void SplitBRs(MSHTML::IHTMLElement2Ptr elem) {
- MSHTML::IHTMLElementCollectionPtr BRs(elem->getElementsByTagName(L"BR"));
- while (BRs->length>0) {
- MSHTML::IHTMLDOMNodePtr ce(BRs->item(0L));
- if (!(bool)ce)
- break;
- for (;;) {
- MSHTML::IHTMLDOMNodePtr parent(ce->parentNode);
- if (!(bool)parent) // no parent? huh?
- goto blowit;
- _bstr_t name(parent->nodeName);
- if (U::scmp(name,L"P")==0 || U::scmp(name,L"DIV")==0)
- break;
- if (U::scmp(name,L"BODY")==0)
- goto blowit;
- MoveUp(false,ce);
- }
- MoveUp(false,ce);
-blowit:
- ce->removeNode(VARIANT_TRUE);
- }
-}
-#endif
-
-// this sub should locate any nested paragraphs and bubble them up
-static void RelocateParagraphs(MSHTML::IHTMLDOMNode *node) {
- if (node->nodeType!=1)
- return;
-
- MSHTML::IHTMLDOMNodePtr cur(node->firstChild);
- while (cur) {
- if (cur->nodeType==1) {
- if (!U::scmp(cur->nodeName,L"P")) {
- BubbleUp(cur,L"P");
- BubbleUp(cur,L"DIV");
- } else
- RelocateParagraphs(cur);
- }
- cur=cur->nextSibling;
- }
-}
-
-static bool IsStanza(MSHTML::IHTMLDOMNode *node) {
- MSHTML::IHTMLElementPtr elem(node);
- return U::scmp(elem->className,L"stanza")==0;
-}
-
-// Move text content in DIV items to P elements, so DIVs can
-// contain P and DIV only
-static void PackText(MSHTML::IHTMLElement2Ptr elem, MSHTML::IHTMLDocument2* doc)
-{
- MSHTML::IHTMLElementCollectionPtr elements(elem->getElementsByTagName(L"DIV"));
- for(long i = 0; i < elements->length; ++i)
- {
- MSHTML::IHTMLDOMNodePtr div(elements->item(i));
- if(U::scmp(MSHTML::IHTMLElementPtr(div)->className, L"image") == 0)
- continue;
- MSHTML::IHTMLDOMNodePtr cur(div->firstChild);
- while((bool)cur)
- {
- _bstr_t cur_name(cur->nodeName);
- if (U::scmp(cur_name, L"P") && U::scmp(cur_name, L"DIV"))
- {
- // create a paragraph from a run of !P && !DIV
- MSHTML::IHTMLElementPtr newp(doc->createElement(L"P"));
- MSHTML::IHTMLDOMNodePtr newn(newp);
- cur->replaceNode(newn);
- newn->appendChild(cur);
- while ((bool)newn->nextSibling)
- {
- cur_name = newn->nextSibling->nodeName;
- if (U::scmp(cur_name, L"P") == 0 || U::scmp(cur_name, L"DIV") == 0)
- break;
- newn->appendChild(newn->nextSibling);
- }
- cur = newn->nextSibling;
- }
- else
- cur = cur->nextSibling;
- }
- }
-}
-
-static void FixupLinks(MSHTML::IHTMLDOMNode *dom) {
- MSHTML::IHTMLElement2Ptr elem(dom);
-
- if (!(bool)elem)
- return;
-
- MSHTML::IHTMLElementCollectionPtr coll(elem->getElementsByTagName(L"a"));
- if (!(bool)coll)
- return;
-
- if (coll->length == 0) coll = elem->getElementsByTagName(L"A");
-
- for (long l=0;llength;++l) {
- MSHTML::IHTMLElementPtr a(coll->item(l));
- if (!(bool)a)
- continue;
-
- _variant_t href(a->getAttribute(L"href",2));
- if (V_VT(&href)==VT_BSTR && V_BSTR(&href) &&
- ::SysStringLen(V_BSTR(&href))>11 &&
- memcmp(V_BSTR(&href),L"file://",6*sizeof(wchar_t))==0)
- {
- wchar_t* pos = wcschr((wchar_t*)V_BSTR(&href), L'#');
- if(!pos)
- continue;
- a->setAttribute(L"href",pos,0);
- }
- }
-}
-
-bool CFBEView::InsertPoem(bool fCheck)
-{
- try
- {
- MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
- if(!(bool)rng)
- return false;
-
- MSHTML::IHTMLElementPtr pe(GetHP(rng->parentElement()));
- if(!(bool)pe)
- return false;
-
- // Get parents for start and end ranges and ensure they are the same as pe
- MSHTML::IHTMLTxtRangePtr tr(rng->duplicate());
- tr->collapse(VARIANT_TRUE);
- if (GetHP(tr->parentElement()) != pe)
- return false;
-
- // Check if it possible to insert a poem there
- _bstr_t cls(pe->className);
- if(U::scmp(cls, L"section")
- && U::scmp(cls, L"epigraph")
- && U::scmp(cls, L"annotation")
- && U::scmp(cls, L"history")
- && U::scmp(cls, L"cite"))
- return false;
-
- // Preventing double expanding whether checked or actual executed
- MSHTML::IHTMLElementPtr elBegin, elEnd;
- MSHTML::IHTMLDOMNodePtr begin, end;
- if(!ExpandTxtRangeToParagraphs(rng, elBegin, elEnd))
- return false;
- else
- {
- begin = elBegin;
- end = elEnd;
- }
-
- // All checks passed
- if(fCheck)
- return true;
-
- m_mk_srv->BeginUndoUnit(L"insert poem");
-
- CString rngHTML;
- MSHTML::IHTMLDOMNodePtr sibling = begin;
- do
- {
- rngHTML += MSHTML::IHTMLElementPtr(sibling)->outerHTML.GetBSTR();
- if(sibling == end)
- break;
- }
- while((sibling = sibling->nextSibling));
-
- MSHTML::IHTMLElementPtr ne(Document()->createElement(L""));
-
- if(!U::scmp(rng->text.GetBSTR(), L""))
- {
- MSHTML::IHTMLElementPtr se(Document()->createElement(L"
"));
- se->innerHTML = L"
";
- ne->innerHTML = se->outerHTML;
- }
- else
- {
- MSHTML::IHTMLElementPtr acc(Document()->createElement(L"DIV"));
- acc->innerHTML = rngHTML.AllocSysString();
-
- MSHTML::IHTMLElementCollectionPtr coll = acc->children;
- bool trim = true;
-
- CString stanzaHTML;
- for(int i = 0; i < coll->length; ++i)
- {
- MSHTML::IHTMLElementPtr curr = coll->item(i);
-
- CString line = curr->innerText;
- // changed by SeNS: issue #61
- if (line.Trim().IsEmpty())
- {
- if(trim)
- continue;
- else
- {
- MSHTML::IHTMLElementPtr se(Document()->createElement(L"
"));
- se->innerHTML = stanzaHTML.AllocSysString();
- MSHTML::IHTMLElement2Ptr(ne)->insertAdjacentElement(L"beforeEnd", se);
- stanzaHTML = L"";
- trim = true;
- }
- }
- else
- {
- if(!U::scmp(curr->tagName, L"DIV"))
- {
- if(curr->innerText.GetBSTR())
- {
- stanzaHTML += CString(L"
") + curr->innerText.GetBSTR() + CString(L"
");
- }
- else
- continue;
- }
- else
- {
- stanzaHTML += curr->outerHTML.GetBSTR();
- }
-
- trim = false;
- }
- }
-
- if(stanzaHTML != "")
- {
- MSHTML::IHTMLElementPtr se(Document()->createElement(L"
"));
- se->innerHTML = stanzaHTML.AllocSysString();
- MSHTML::IHTMLElement2Ptr(ne)->insertAdjacentElement(L"beforeEnd", se);
- }
- }
-
-
- MSHTML::IHTMLDOMNodePtr(pe)->insertBefore((MSHTML::IHTMLDOMNodePtr)ne, begin.GetInterfacePtr());
-
- while(begin != end)
- {
- sibling = begin->nextSibling;
- begin->removeNode(VARIANT_TRUE);
- begin = sibling;
- }
- end->removeNode(VARIANT_TRUE);
-
- FixupParagraphs(pe);
- PackText(pe, Document());
-
- rng->moveToElementText(ne);
- rng->collapse(false);
- rng->select();
-
- m_mk_srv->EndUndoUnit();
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
- return true;
-}
-
-bool CFBEView::InsertCite(bool fCheck)
-{
- try
- {
- MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
- if(!(bool)rng)
- return false;
-
- MSHTML::IHTMLElementPtr pe(GetHP(rng->parentElement()));
- if(!(bool)pe)
- return false;
-
- // Get parents for start and end ranges and ensure they are the same as pe
- MSHTML::IHTMLTxtRangePtr tr(rng->duplicate());
- tr->collapse(VARIANT_TRUE);
- if (GetHP(tr->parentElement()) != pe)
- return false;
-
- // Check if it possible to insert a cite there
- _bstr_t cls(pe->className);
- if(U::scmp(cls, L"section")
- && U::scmp(cls, L"epigraph")
- && U::scmp(cls, L"annotation")
- && U::scmp(cls, L"history"))
- return false;
-
- // Preventing double expanding whether checked or actual executed
- MSHTML::IHTMLElementPtr elBegin, elEnd;
- MSHTML::IHTMLDOMNodePtr begin, end;
- if(!ExpandTxtRangeToParagraphs(rng, elBegin, elEnd))
- return false;
- else
- {
- begin = elBegin;
- end = elEnd;
- }
-
- // All checks passed
- if(fCheck)
- return true;
-
- m_mk_srv->BeginUndoUnit(L"insert cite");
-
- CString rngHTML;
- MSHTML::IHTMLDOMNodePtr sibling = begin;
- do
- {
- rngHTML += MSHTML::IHTMLElementPtr(sibling)->outerHTML.GetBSTR();
- if(sibling == end)
- break;
- }
- while((sibling = sibling->nextSibling));
-
- // Create cite
- MSHTML::IHTMLElementPtr ne(Document()->createElement(L"DIV"));
- ne->className = L"cite";
-
- MSHTML::IHTMLElementPtr acc(Document()->createElement(L"DIV"));
- acc->innerHTML = rngHTML.AllocSysString();
-
- MSHTML::IHTMLElementCollectionPtr coll = acc->children;
-
- CString citeHTML;
- for(int i = 0; i < coll->length; ++i)
- {
- MSHTML::IHTMLElementPtr curr = coll->item(i);
- if(!U::scmp(curr->tagName, L"DIV")
- && U::scmp(curr->className, L"table")
- && U::scmp(curr->className, L"poem"))
- {
- if(curr->innerText.GetBSTR())
- {
- citeHTML += CString(L"
") + curr->innerText.GetBSTR() + CString(L"
");
- }
- else
- continue;
- }
- else
- {
- citeHTML += curr->outerHTML.GetBSTR();
- }
- }
-
- ne->innerHTML = citeHTML.AllocSysString();
-
- MSHTML::IHTMLDOMNodePtr(pe)->insertBefore((MSHTML::IHTMLDOMNodePtr)ne, begin.GetInterfacePtr());
-
- while(begin != end)
- {
- sibling = begin->nextSibling;
- begin->removeNode(VARIANT_TRUE);
- begin = sibling;
- }
- end->removeNode(VARIANT_TRUE);
-
- FixupParagraphs(pe);
- PackText(pe, Document());
-
- rng->moveToElementText(ne);
- rng->collapse(false);
- rng->select();
-
- m_mk_srv->EndUndoUnit();
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
- return true;
-}
-
-CString CFBEView::GetClearedRangeText(const MSHTML::IHTMLTxtRangePtr &rng)const
-{
- CString org_text = rng->htmlText;
-
- org_text.Replace(L"\r\n", L"\n");
- org_text.Replace(L" \n", L" ");
- org_text.Replace(L"\n ", L" ");
- org_text.Replace(L"\n", L" ");
-
- while(org_text[org_text.GetLength() - 1] == L' ')
- org_text = org_text.Left(org_text.GetLength() - 1);
- while(org_text[0] == L' ')
- org_text = org_text.Right(org_text.GetLength() - 1);
- org_text.Replace(L"> <", L">\r\n<");
- return org_text;
-}
-
-// searching
-void CFBEView::StartIncSearch() {
- try {
- m_is_start=Document()->selection->createRange();
- m_is_start->collapse(VARIANT_TRUE);
- }
- catch (_com_error&) {
- }
-}
-
-void CFBEView::CancelIncSearch() {
- if (m_is_start) {
- m_is_start->raw_select();
- m_is_start.Release();
- }
-}
-
-// script calls
-void CFBEView::ImgSetURL(IDispatch *elem,const CString& url) {
- try {
- CComDispatchDriver dd(Script());
- _variant_t ve(elem);
- _variant_t vu((const TCHAR *)url);
- dd.Invoke2(L"ImgSetURL",&ve,&vu);
- }
- catch (_com_error&) { }
-}
-
-IDispatchPtr CFBEView::Call(const wchar_t *name) {
- try {
- CComDispatchDriver dd(Script());
- _variant_t ret;
- _variant_t vt2((false));
- dd.Invoke1(name,&vt2,&ret);
- if (V_VT(&ret)==VT_DISPATCH)
- return V_DISPATCH(&ret);
- }
- catch (_com_error&) { }
- return IDispatchPtr();
-}
-IDispatchPtr CFBEView::Call(const wchar_t *name,IDispatch *pDisp) {
- try {
- CComDispatchDriver dd(Script());
- _variant_t vt;
- if (pDisp)
- vt=pDisp;
- _variant_t vt2(false);
- _variant_t ret;
- dd.Invoke2(name,&vt,&vt2,&ret);
- if (V_VT(&ret)==VT_DISPATCH)
- return V_DISPATCH(&ret);
- }
- catch (_com_error&) { }
- return IDispatchPtr();
-}
-static bool vt2bool(const _variant_t& vt) {
- if (V_VT(&vt)==VT_DISPATCH)
- return V_DISPATCH(&vt)!=0;
- if (V_VT(&vt)==VT_BOOL)
- return V_BOOL(&vt)==VARIANT_TRUE;
- if (V_VT(&vt)==VT_I4)
- return V_I4(&vt)!=0;
- if (V_VT(&vt)==VT_UI4)
- return V_UI4(&vt)!=0;
- return false;
-}
-
-bool CFBEView::bCall(const wchar_t *name, int nParams, VARIANT* params)
-{
- try
- {
- CComDispatchDriver dd(Script());
- _variant_t ret;
- dd.InvokeN(name, params, nParams, &ret);
- return vt2bool(ret);
- }
- catch(_com_error& err)
- {
- U::ReportError(err);
- }
-
- return false;
-}
-
-bool CFBEView::bCall(const wchar_t *name,IDispatch *pDisp) {
- try {
- CComDispatchDriver dd(Script());
- _variant_t vt;
- if (pDisp)
- vt=pDisp;
- _variant_t vt2(true);
- _variant_t ret;
- dd.Invoke2(name,&vt,&vt2,&ret);
- return vt2bool(ret);
- }
- catch (_com_error&) { }
- return false;
-}
-
-bool CFBEView::bCall(const wchar_t *name) {
- try {
- CComDispatchDriver dd(Script());
- _variant_t vt2(true);
- _variant_t ret;
- dd.Invoke1(name,&vt2,&ret);
- return vt2bool(ret);
- }
- catch (_com_error&) { }
- return false;
-}
-
-// utilities
-static CString GetPath(MSHTML::IHTMLElementPtr elem) {
- try {
- if (!(bool)elem)
- return CString();
- CString path;
- while (elem) {
- CString cur((const wchar_t *)elem->tagName);
- CString cid((const wchar_t *)elem->id);
- if (cur==_T("BODY"))
- return path;
- if(cid == _T("fbw_body"))
- return path;
- _bstr_t cls(elem->className);
- if (cls.length()>0)
- cur=(const wchar_t *)cls;
- _bstr_t id(elem->id);
- if (id.length()>0) {
- cur+=_T(':');
- cur+=(const wchar_t *)id;
- }
- if (!path.IsEmpty())
- path=_T('/')+path;
- path=cur+path;
- elem=elem->parentElement;
- }
- return path;
- }
- catch (_com_error&) { }
- return CString();
-}
-
-CString CFBEView::SelPath() {
- return GetPath(SelectionContainer());
-}
-
-void CFBEView::GoTo(MSHTML::IHTMLElement *e,bool fScroll) {
- if (!e)
- return;
-
- if (fScroll)
- e->scrollIntoView(VARIANT_TRUE);
-
- MSHTML::IHTMLTxtRangePtr r(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
- r->moveToElementText(e);
- r->collapse(VARIANT_TRUE);
- // all m$ editors like to position the pointer at the end of the preceding element,
- // which sucks. This workaround seems to work most of the time.
- if (e!=r->parentElement() && r->move(L"character",1)==1)
- r->move(L"character",-1);
-
- r->select();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionContainerImp()
-{
- try
- {
- IDispatchPtr selrange(Document()->selection->createRange());
- MSHTML::IHTMLTxtRangePtr range(selrange);
- if(range)
- {
- return range->parentElement();
- }
- MSHTML::IHTMLControlRangePtr coll(selrange);
- if((bool)coll)
- return coll->commonParentElement();
- }
- catch(_com_error& err)
- {
- U::ReportError(err);
- }
-
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionAnchor() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- _bstr_t tn(cur->tagName);
- if (U::scmp(tn,L"A")==0 || (U::scmp(tn,L"DIV")==0 && U::scmp(cur->className,L"image")==0))
- return cur;
- // Added by SeNS - inline images
- if (U::scmp(tn,L"A")==0 || (U::scmp(tn,L"SPAN")==0 && U::scmp(cur->className,L"image")==0))
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) { }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionAnchor(MSHTML::IHTMLElementPtr cur) {
- try {
- while (cur) {
- _bstr_t tn(cur->tagName);
- if (U::scmp(tn,L"A")==0 || (U::scmp(tn,L"DIV")==0 && U::scmp(cur->className,L"image")==0))
- return cur;
- // Added by SeNS - inline images
- if (U::scmp(tn,L"A")==0 || (U::scmp(tn,L"SPAN")==0 && U::scmp(cur->className,L"image")==0))
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) { }
- return MSHTML::IHTMLElementPtr();
-}
-
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionStructCon() {
- try
- {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur)
- {
- if (U::scmp(cur->tagName, L"P") == 0 || U::scmp(cur->tagName, L"DIV") == 0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
-
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionStructNearestCon()
-{
- try
- {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- if(cur)
- {
- return cur;
- }
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
-
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionStructCode() {
- try
- {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while(cur)
- {
- // changed by SeNS: inline images also have a tag SPAN
- if((U::scmp(cur->tagName, L"SPAN") == 0) && (U::scmp(cur->className,L"image")!=0))
- return cur;
- cur = cur->parentElement;
- }
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
-
- return MSHTML::IHTMLElementPtr();
-}
-
-// Modification by Pilgrim
-MSHTML::IHTMLElementPtr CFBEView::SelectionStructSection() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"section")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionStructImage() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- // changed by SeNS: inline images have a tag SPAN, regular tag DIV
- if ((U::scmp(cur->className,L"image")==0) && (U::scmp(cur->tagName,L"SPAN")!=0))
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionStructTable() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"table")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionStructTableCon() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsStyleT() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- _bstr_t style(AU::GetAttrB(cur,L"fbstyle"));
- if (U::scmp(cur->className,L"table")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsStyleTB(_bstr_t& style) {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"table")==0){
- style = AU::GetAttrB(cur,L"fbstyle");
- return cur;
- }
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsStyle() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- _bstr_t style(AU::GetAttrB(cur,L"fbstyle"));
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsStyleB(_bstr_t& style) {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
- style = AU::GetAttrB(cur,L"fbstyle");
- return cur;
- }
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsColspan() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsColspanB(_bstr_t& colspan) {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
- colspan = AU::GetAttrB(cur,L"fbcolspan");
- return cur;
- }
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsRowspan() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsRowspanB(_bstr_t& rowspan) {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
- rowspan = AU::GetAttrB(cur,L"fbrowspan");
- return cur;
- }
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsAlignTR() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"tr")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsAlignTRB(_bstr_t& align) {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"tr")==0){
- align = AU::GetAttrB(cur,L"fbalign");
- return cur;
- }
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsAlign() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"tr")==0 || U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsAlignB(_bstr_t& align) {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"tr")==0 || U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
- align = AU::GetAttrB(cur,L"fbalign");
- return cur;
- }
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsVAlign() {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
- return cur;
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-MSHTML::IHTMLElementPtr CFBEView::SelectionsVAlignB(_bstr_t& valign) {
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- while (cur) {
- if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
- valign = AU::GetAttrB(cur,L"fbvalign");
- return cur;
- }
- cur=cur->parentElement;
- }
- }
- catch (_com_error&) {
- }
- return MSHTML::IHTMLElementPtr();
-}
-
-void CFBEView::Normalize(MSHTML::IHTMLDOMNodePtr dom) {
- try {
- //MSHTML::IHTMLElementCollectionPtr col = dom->childNodes;
- MSHTML::IHTMLDOMNodePtr el = dom->firstChild;
- bool found = false;
-
- // нормализовать нужно только body документа
- while(el)
- {
- MSHTML::IHTMLElementPtr hel(el);
-
- if(U::scmp(hel->id, L"fbw_body") == 0)
- {
- found = true;
- break;
- }
- el = el->nextSibling;
- }
-
- if(!found)
- {
- return;
- }
-
- // wrap in an undo unit
- m_mk_srv->BeginUndoUnit(L"Normalize");
-
- // remove unsupported elements
- RemoveUnk(el,Document());
-
- MergeEqualHTMLElements(el, Document());
- // get rid of nested DIVs and Ps
- RelocateParagraphs(el);
- // delete empty nodes
-
- RemoveEmptyNodes(el);
- // make sure text appears under Ps only
- PackText(el,Document());
- // get rid of nested Ps once more
- RelocateParagraphs(el);
- // convert BRs to separate paragraphs
- SplitBRs(el);
- // delete empty nodes again
- RemoveEmptyNodes(el);
- // fixup links
- FixupLinks(el);
-
- m_mk_srv->EndUndoUnit();
- }
- catch (_com_error& e) {
- U::ReportError(e);
- }
-}
-
-static void FixupParagraphs(MSHTML::IHTMLElement2Ptr elem)
-{
- MSHTML::IHTMLElementCollectionPtr pp(elem->getElementsByTagName(L"P"));
- for(long l = 0; l < pp->length; ++l)
- MSHTML::IHTMLElement3Ptr(pp->item(l))->inflateBlock = VARIANT_TRUE;
-}
-
-LRESULT CFBEView::OnPaste(WORD, WORD, HWND, BOOL&)
-{
- try
- {
- m_mk_srv->BeginUndoUnit(L"Paste");
- ++m_enable_paste;
-
- // added by SeNS: process clipboard and change nbsp
- if (OpenClipboard())
- {
- // process text
- if ( IsClipboardFormatAvailable(CF_TEXT) || IsClipboardFormatAvailable(CF_UNICODETEXT))
- {
- if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
- {
- HANDLE hData = GetClipboardData( CF_UNICODETEXT );
- TCHAR *buffer = (TCHAR*)GlobalLock( hData );
- CString fromClipboard(buffer);
- GlobalUnlock( hData );
-
- fromClipboard.Replace( L"\u00A0", _Settings.GetNBSPChar());
-
- HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, (fromClipboard.GetLength()+1)*sizeof(TCHAR));
- buffer = (TCHAR*)GlobalLock(clipbuffer);
- wcscpy(buffer, fromClipboard);
- GlobalUnlock( clipbuffer );
- SetClipboardData(CF_UNICODETEXT, clipbuffer);
- }
- }
- // process bitmaps from clipboard
- else if ( IsClipboardFormatAvailable(CF_BITMAP))
- {
- HBITMAP hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
- TCHAR szPathName[MAX_PATH] = { 0 };
- TCHAR szFileName[MAX_PATH] = { 0 };
- if (::GetTempPath(sizeof(szPathName)/sizeof(TCHAR), szPathName))
- if (::GetTempFileName(szPathName, L"img", ::GetTickCount(), szFileName))
- {
- int quality = _Settings.GetJpegQuality();
-
- CString fileName(szFileName);
- CImage image;
- image.Attach(hBitmap);
-
- if (_Settings.GetImageType() == 0)
- {
- fileName.Replace(L".tmp", L".png");
- image.Save(fileName, Gdiplus::ImageFormatPNG);
- }
- else
- {
- fileName.Replace(L".tmp", L".jpg");
- // set encoder quality
- Gdiplus::EncoderParameters encoderParameters[1];
- encoderParameters[0].Count = 1;
- encoderParameters[0].Parameter[0].Guid = Gdiplus::EncoderQuality;
- encoderParameters[0].Parameter[0].NumberOfValues = 1;
- encoderParameters[0].Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong;
- encoderParameters[0].Parameter[0].Value = &quality;
- image.Save(fileName, Gdiplus::ImageFormatJPEG, &encoderParameters[0]);
- }
-
- AddImage(fileName, true);
- ::DeleteFile(fileName);
- }
- }
- CloseClipboard();
- }
-
- IOleCommandTargetPtr(m_browser)->Exec(&CGID_MSHTML, IDM_PASTE, 0, NULL, NULL);
- --m_enable_paste;
- if(m_normalize)
- Normalize(Document()->body);
- m_mk_srv->EndUndoUnit();
- }
- catch(_com_error& err)
- {
- U::ReportError(err);
- }
-
- return 0;
-}
-
-// searching
-bool CFBEView::DoSearch(bool fMore)
-{
-#ifndef USE_PCRE
- if(m_fo.match)
- m_fo.match.Release();
-#endif
- if(m_fo.pattern.IsEmpty())
- {
- if(m_is_start)
- m_is_start->raw_select();
- return true;
- }
-
- // added by SeNS
- if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
- m_fo.pattern.Replace( L"\u00A0", _Settings.GetNBSPChar());
-
- return m_fo.fRegexp ? DoSearchRegexp(fMore) : DoSearchStd(fMore);
-}
-
-// Removes HTML tags
-void RemoveTags(CString &src)
-{
- int openTag = 0, closeTag=0;
- while (openTag != -1)
- {
- openTag = src.Find(L"<", 0);
- closeTag = src.Find(L">", openTag+1);
- if (openTag != -1 && closeTag > openTag)
- src.Delete(openTag, closeTag-openTag+1);
- }
-}
-
-// Returns text offset including inline images (treated as a 3 chars each)
-int CFBEView::TextOffset(MSHTML::IHTMLTxtRange *rng, AU::ReMatch rm, CString txt, CString htmlTxt)
-{
- CString text(txt);
- CString match = rm->Value;
- // special fix for "Words" dialog
- match = match.TrimRight(10);
- match = match.TrimRight(13);
- int num = 0, pos = 1;
- if (text.IsEmpty()) text.SetString(rng->text);
- while (num < text.GetLength())
- {
- num = text.Find (match, num);
- if ((num == rm->FirstIndex) || (num == -1)) break;
- num += 1;
- pos++;
- }
- CString html(htmlTxt);
- if (html.IsEmpty()) html.SetString(rng->htmlText);
-
- // change
collapse(VARIANT_TRUE);
- tr->move(L"character",rm->FirstIndex+numImages);
- if (tr->moveStart(L"character",1)==1)
- tr->move(L"character",-1);
- tr->moveEnd(L"character",rm->Length);
- // set focus to editor if selection empty
- if (!rm->Length)
- SetFocus();
- tr->select();
- m_fo.match=rm;
-}
-
-bool CFBEView::DoSearchRegexp(bool fMore)
-{
- try
- {
- // well, try to compile it first
- AU::RegExp re;
-#ifdef USE_PCRE
- re = new AU::IRegExp2();
-#else
- CheckError(re.CreateInstance(L"VBScript.RegExp"));
-#endif
- re->IgnoreCase = m_fo.flags & 4 ? VARIANT_FALSE : VARIANT_TRUE;
- re->Global = VARIANT_TRUE;
- re->Pattern = (const wchar_t*)m_fo.pattern;
-
- // locate starting paragraph
- MSHTML::IHTMLTxtRangePtr sel(Document()->selection->createRange());
- if(!fMore && (bool)m_is_start)
- sel= m_is_start->duplicate();
- if(!(bool)sel)
- return false;
-
- MSHTML::IHTMLElementPtr sc(SelectionStructCon());
- long s_idx = 0;
- long s_off1 = 0;
- long s_off2 = 0;
- if((bool)sc)
- {
- s_idx = sc->sourceIndex;
- if(U::scmp(sc->tagName,L"P") == 0 && (bool)sel)
- {
- s_off2 = sel->text.length();
- MSHTML::IHTMLTxtRangePtr pr(sel->duplicate());
- pr->moveToElementText(sc);
- pr->setEndPoint(L"EndToStart", sel);
- s_off1 = pr->text.length();
- s_off2 += s_off1;
- }
- }
-
- // walk the all collection now, looking for the next P
- MSHTML::IHTMLElementCollectionPtr all(Document()->all);
- long all_len = all->length;
- long incr = m_fo.flags &1 ? -1 : 1;
- bool fWrapped = false;
-
- // * search in starting element
- if ((bool)sc && U::scmp(sc->tagName, L"P") == 0)
- {
- sel->moveToElementText(sc);
- CString selText = sel->text;
-
- AU::ReMatches rm(re->Execute(sel->text));
- // changed by SeNS: fix for issue #62
- if (rm->Count > 0&& !(selText.IsEmpty() && fMore))
- {
- if(incr > 0)
- {
- for(long l = m_startMatch;l < rm->Count; ++l)
- {
- AU::ReMatch crm(rm->Item[l]);
- if(crm->FirstIndex >= s_off2 )
- {
- m_startMatch = l+1;
- SelMatch(sel, crm);
- return true;
- }
- }
- }
- else
- {
- for(long l = m_endMatch; l >= 0; --l)
- {
- AU::ReMatch crm(rm->Item[l]);
- if(crm->FirstIndex < s_off1)
- {
- SelMatch(sel, crm);
- m_endMatch = l-1;
- return true;
- }
- }
- }
- }
- }
-
- // search all others
- for(long cur = s_idx + incr; ; cur += incr)
- {
- // adjust out of bounds indices
- if(cur < 0)
- {
- cur = all_len - 1;
- fWrapped = true;
- }
- else if(cur >= all_len)
- {
- cur = 0;
- fWrapped = true;
- }
-
- // check for wraparound
- if(cur == s_idx)
- break;
-
- // check current element type
- MSHTML::IHTMLElementPtr elem(all->item(cur));
- if(!(bool)elem || U::scmp(elem->tagName,L"P"))
- continue;
-
- // search inside current element
- sel->moveToElementText(elem);
-
- AU::ReMatches rm(re->Execute(sel->text));
- if(rm->Count <= 0)
- continue;
- if(incr > 0)
- {
- SelMatch(sel, rm->Item[0]);
- m_startMatch = 1;
- }
- else
- {
- SelMatch(sel, rm->Item[rm->Count-1]);
- m_endMatch = rm->Count-2;
- }
- if(fWrapped)
- ::MessageBeep(MB_ICONASTERISK);
-
- return true;
- }
-
- // search again in starting element
- if ((bool)sc && U::scmp(sc->tagName, L"P") == 0)
- {
- sel->moveToElementText(sc);
- AU::ReMatches rm(re->Execute(sel->text));
- if(rm->Count > 0)
- {
- if(incr > 0)
- {
- for(long l = 0; l < rm->Count; ++l)
- {
- AU::ReMatch crm(rm->Item[l]);
- if(crm->FirstIndex < s_off1)
- {
- SelMatch(sel, crm);
- if(fWrapped)
- ::MessageBeep(MB_ICONASTERISK);
-
- return true;
- }
- }
- }
- else
- {
- for(long l = rm->Count - 1; l >= 0; --l)
- {
- AU::ReMatch crm(rm->Item[l]);
- if(crm->FirstIndex >= s_off2)
- {
- SelMatch(sel, crm);
- if(fWrapped)
- ::MessageBeep(MB_ICONASTERISK);
- return true;
- }
- }
- }
- }
- }
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
-
- return false;
-}
-
-bool CFBEView::DoSearchStd(bool fMore)
-{
- try
- {
- // fetch selection
- MSHTML::IHTMLTxtRangePtr sel(Document()->selection->createRange());
- if(!fMore && (bool)m_is_start)
- sel = m_is_start->duplicate();
- if(!(bool)sel)
- return false;
-
- MSHTML::IHTMLTxtRangePtr org(sel->duplicate());
- // check if it is collapsed
- if(sel->compareEndPoints(L"StartToEnd", sel) != 0)
- {
- // collapse and advance
- if(m_fo.flags & FRF_REVERSE)
- sel->collapse(VARIANT_TRUE);
- else
- sel->collapse(VARIANT_FALSE);
- }
-
- // search for text
- if(sel->findText((const wchar_t*)m_fo.pattern, 1073741824, m_fo.flags) == VARIANT_TRUE)
- {
- // ok, found
- sel->select();
- return true;
- }
-
- // not found, try searching from start to sel
- sel = MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange();
- sel->collapse(m_fo.flags & 1 ? VARIANT_FALSE : VARIANT_TRUE);
- if(sel->findText((const wchar_t*)m_fo.pattern, 1073741824, m_fo.flags) == VARIANT_TRUE
- && org->compareEndPoints("StartToStart", sel)*(m_fo.flags & 1 ? -1 : 1) > 0)
- {
- // found
- sel->select();
- MessageBeep(MB_ICONASTERISK);
- return true;
- }
- }
- catch (_com_error&)
- {
- //U::ReportError(err);
- }
-
- return false;
-}
-
-static CString GetSM(AU::ReSubMatches sm, int idx)
-{
- if(!sm)
- return CString();
-
- if(idx < 0 || idx >= sm->Count)
- return CString();
-
- _variant_t vt(sm->Item[idx]);
-
- if(V_VT(&vt) == VT_BSTR)
- return V_BSTR(&vt);
-
- return CString();
-}
-
-struct RR
-{
- enum
- {
- STRONG = 1,
- EMPHASIS = 2,
- UPPER = 4,
- LOWER = 8,
- TITLE = 16
- };
-
- int flags;
- int start;
- int len;
-};
-
-typedef CSimpleValArray
RRList;
-
-static CString GetReplStr(const CString& rstr, AU::ReMatch rm, RRList& rl)
-{
- CString rep;
- rep.GetBuffer(rstr.GetLength());
- rep.ReleaseBuffer(0);
-
- AU::ReSubMatches rs(rm->SubMatches);
-
- RR cr;
- memset(&cr, 0, sizeof(cr));
- int flags=0;
-
- CString rv;
- bool emptyParam = false;
-
- for(int i = 0; i < rstr.GetLength(); ++i)
- {
- if ((rstr[i] == L'$' && i < rstr.GetLength() - 1) ||
- (rstr[i] == L'\\' && i < rstr.GetLength() - 1))
- {
- switch(rstr[++i])
- {
- //case L'&': // whole match
- case L'0': // whole match
- rv=(const wchar_t *)rm->Value;
- break;
- case L'+': // last submatch
- rv = GetSM(rs, rs->Count - 1);
- break;
- case L'1':
- case L'2':
- case L'3':
- case L'4':
- case L'5':
- case L'6':
- case L'7':
- case L'8':
- case L'9':
- rv = GetSM(rs, rstr[i] - L'0' - 1);
- if(rv.IsEmpty())
- emptyParam = true;
- break;
- case L'T': // title case
- flags |= RR::TITLE;
- continue;
- case L'U': // uppercase
- flags |= RR::UPPER;
- continue;
- case L'L': // lowercase
- flags |= RR::LOWER;
- continue;
- case L'S': // strong
- flags |= RR::STRONG;
- continue;
- case L'E': // emphasis
- flags |= RR::EMPHASIS;
- continue;
- case L'Q': // turn off flags
- flags = 0;
- continue;
- default: // ignore
- continue;
- }
- }
-
- if(cr.flags != flags && cr.flags && cr.start < rep.GetLength())
- {
- cr.len = rep.GetLength() - cr.start;
- rl.Add(cr);
- cr.flags = 0;
- }
-
- if(flags)
- {
- cr.flags = flags;
- cr.start = rep.GetLength();
- }
-
- // SeNS: fix for issue #142
- if (!emptyParam)
- {
- if(!rv.IsEmpty())
- {
- rep += rv;
- rv.Empty();
- }
- else rep += rstr[i];
- }
- else emptyParam = false;
- }
-
- if(cr.flags && cr.start < rep.GetLength())
- {
- cr.len = rep.GetLength() - cr.start;
- rl.Add(cr);
- }
-
- // process case conversions here
- int tl = rep.GetLength();
- TCHAR* cp = rep.GetBuffer(tl);
- for(int j = 0; j < rl.GetSize();)
- {
- RR rr = rl[j];
- if(rr.flags & RR::UPPER)
- LCMapString(CP_ACP, LCMAP_UPPERCASE, cp + rr.start, rr.len, cp + rr.start, rr.len);
- else if(rr.flags & RR::LOWER)
- LCMapString(CP_ACP, LCMAP_LOWERCASE, cp + rr.start, rr.len, cp + rr.start, rr.len);
- else if(rr.flags & RR::TITLE && rr.len > 0)
- {
- LCMapString(CP_ACP, LCMAP_UPPERCASE, cp + rr.start, 1, cp + rr.start, 1);
- LCMapString(CP_ACP, LCMAP_LOWERCASE, cp + rr.start + 1, rr.len - 1, cp + rr.start + 1, rr.len - 1);
- }
-
- if((rr.flags &~ (RR::UPPER | RR::LOWER | RR::TITLE)) == 0)
- rl.RemoveAt(j);
- else
- ++j;
- }
-
- rep.ReleaseBuffer(tl);
-
- return rep;
-}
-
-void CFBEView::DoReplace() {
- try {
- MSHTML::IHTMLTxtRangePtr sel(Document()->selection->createRange());
- if (!(bool)sel)
- return;
- MSHTML::IHTMLTxtRangePtr x2(sel->duplicate());
- int adv=0;
-
- m_mk_srv->BeginUndoUnit(L"replace");
-
- if (m_fo.match) { // use regexp match
- RRList rl;
- CString rep(GetReplStr(m_fo.replacement,m_fo.match,rl));
-
- // added by SeNS
- if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
- rep.Replace( L"\u00A0", _Settings.GetNBSPChar());
-
- sel->text=(const wchar_t *)rep;
- // change bold/italic where needed
- for (int i=0;iduplicate();
- x2->move(L"character",rr.start-rep.GetLength());
- x2->moveEnd(L"character",rr.len);
- if (rr.flags&RR::STRONG)
- x2->execCommand(L"Bold",VARIANT_FALSE);
- if (rr.flags&RR::EMPHASIS)
- x2->execCommand(L"Italic",VARIANT_FALSE);
- }
- adv=rep.GetLength();
- } else { // plain text
- sel->text=(const wchar_t *)m_fo.replacement;
- adv=m_fo.replacement.GetLength();
- }
- sel->moveStart(L"character",-adv);
- sel->select();
- }
- catch (_com_error& e) {
- U::ReportError(e);
- }
- m_mk_srv->EndUndoUnit();
-}
-
-int CFBEView::GlobalReplace(MSHTML::IHTMLElementPtr elem, CString cntTag)
-{
- if(m_fo.pattern.IsEmpty())
- return 0;
-
- try
- {
- MSHTML::IHTMLTxtRangePtr sel(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
- if(elem)
- sel->moveToElementText(elem);
- if(!(bool)sel)
- return 0;
-
- AU::RegExp re;
-#ifdef USE_PCRE
- re = new AU::IRegExp2();
-#else
- CheckError(re.CreateInstance(L"VBScript.RegExp"));
-#endif
- re->IgnoreCase = m_fo.flags & 4 ? VARIANT_FALSE : VARIANT_TRUE;
- re->Global = VARIANT_TRUE;
-
- // added by SeNS
- if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
- m_fo.pattern.Replace( L"\u00A0", _Settings.GetNBSPChar());
-
- re->Pattern = (const wchar_t*)m_fo.pattern;
-
- m_mk_srv->BeginUndoUnit(L"replace");
-
- sel->collapse(VARIANT_TRUE);
-
- int nRepl = 0;
-
- if(m_fo.fRegexp)
- {
- MSHTML::IHTMLTxtRangePtr s3;
- MSHTML::IHTMLElementCollectionPtr all;
- if(elem)
- all = MSHTML::IHTMLElement2Ptr(elem)->getElementsByTagName(cntTag.AllocSysString());
- else
- all = MSHTML::IHTMLDocument3Ptr(Document())->getElementsByTagName(cntTag.AllocSysString());
- _bstr_t charstr(L"character");
- RRList rl;
- CString repl;
-
- for(long l = 0;l < all->length; ++l)
- {
- MSHTML::IHTMLElementPtr elem(all->item(l));
- sel->moveToElementText(elem);;
- AU::ReMatches rm(re->Execute(sel->text));
- if(rm->Count <= 0)
- continue;
-
- // SeNS: fix for issue #147
- MSHTML::IHTMLTxtRangePtr rng = sel->duplicate();
- CString text = rng->text;
- CString html = rng->htmlText;
-
- // Replace
- sel->collapse(VARIANT_TRUE);
- long last = 0;
- for(long i = 0; i < rm->Count; ++i)
- {
- AU::ReMatch cur(rm->Item[i]);
- long delta = cur->FirstIndex - last;
-
- // SeNS
- delta += TextOffset (rng, cur, text, html);
-
- if(delta)
- {
- sel->move(charstr, delta);
- last += delta;
- }
- if(sel->moveStart(charstr, 1) == 1)
- sel->move(charstr, -1);
- delta = cur->Length;
- last += cur->Length;
- sel->moveEnd(charstr, delta);
- rl.RemoveAll();
- repl = GetReplStr(m_fo.replacement, cur, rl);
-
- // added by SeNS
- if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
- repl.Replace( L"\u00A0", _Settings.GetNBSPChar());
-
- sel->text = (const wchar_t*)repl;
- for(int k = 0; k < rl.GetSize(); ++k)
- {
- RR rr = rl[k];
- s3 = sel->duplicate();
- s3->move(L"character", rr.start - repl.GetLength());
- s3->moveEnd(L"character", rr.len);
- if(rr.flags & RR::STRONG)
- s3->execCommand(L"Bold", VARIANT_FALSE);
- if(rr.flags & RR::EMPHASIS)
- s3->execCommand(L"Italic", VARIANT_FALSE);
- }
- ++nRepl;
- }
- }
- }
- else
- {
- DWORD flags = m_fo.flags & ~FRF_REVERSE;
- _bstr_t pattern((const wchar_t*)m_fo.pattern);
- _bstr_t repl((const wchar_t*)m_fo.replacement);
- while(sel->findText(pattern, 1073741824, flags) == VARIANT_TRUE)
- {
- sel->text = repl;
- ++nRepl;
- }
- }
-
- m_mk_srv->EndUndoUnit();
- return nRepl;
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
-
- return 0;
-}
-
-int CFBEView::ToolWordsGlobalReplace( MSHTML::IHTMLElementPtr fbw_body,
- int* pIndex,
- int* globIndex,
- bool find,
- CString cntTag)
-{
- if(m_fo.pattern.IsEmpty())
- return 0;
-
- int nRepl = 0;
-
- try
- {
- AU::RegExp re;
-#ifdef USE_PCRE
- re = new AU::IRegExp2();
-#else
- CheckError(re.CreateInstance(L"VBScript.RegExp"));
-#endif
- re->IgnoreCase = m_fo.flags & FRF_CASE ? VARIANT_FALSE : VARIANT_TRUE;
- re->Global = m_fo.flags & FRF_WHOLE ? VARIANT_TRUE : VARIANT_FALSE;
- re->Multiline = VARIANT_TRUE;
- re->Pattern = (const wchar_t*)m_fo.pattern;
-
- MSHTML::IHTMLElementCollectionPtr paras = MSHTML::IHTMLElement2Ptr(fbw_body)->getElementsByTagName(cntTag.AllocSysString());
- if(!paras->length)
- return 0;
-
- int iNextElem = pIndex != NULL ? *pIndex : 0;
- CSimpleArray pAdjElems;
-
- while(iNextElem < paras->length)
- {
- pAdjElems.RemoveAll();
-
- MSHTML::IHTMLElementPtr currElem(paras->item(iNextElem));
- CString innerText = currElem->innerText;
- pAdjElems.Add(pElAdjacent(currElem));
-
- if(pIndex != NULL)
- *pIndex = iNextElem;
-
- MSHTML::IHTMLDOMNodePtr currNode(currElem);
- if(MSHTML::IHTMLElementPtr siblElem = currNode->nextSibling)
- {
- int jNextElem = iNextElem + 1;
- for(int i = jNextElem; i < paras->length; ++i)
- {
- MSHTML::IHTMLElementPtr nextElem = paras->item(i);
- if(siblElem == nextElem)
- {
- pAdjElems.Add(pElAdjacent(siblElem));
- innerText += L"\n";
- innerText += siblElem->innerText.GetBSTR();
- iNextElem++;
- siblElem = MSHTML::IHTMLDOMNodePtr(nextElem)->nextSibling;
- }
- else
- {
- break;
- }
- }
- }
- innerText += L"\n";
-
- if(innerText.IsEmpty())
- {
- iNextElem++;
- continue;
- }
-
- // Replace
- #ifdef USE_PCRE
- AU::ReMatches rm(re->Execute(innerText));
- #else
- AU::ReMatches rm(re->Execute(innerText.AllocSysString()));
- #endif
- if(rm->Count <= 0)
- {
- iNextElem++;
- continue;
- }
-
- for(long i = 0; i < rm->Count; ++i)
- {
- AU::ReMatch cur(rm->Item[i]);
-
- long matchIdx = cur->FirstIndex;
- long matchLen = cur->Length - 1;
-
- long pAdjLen = 0;
- bool begin = false, end = false;
- int first = 0, last = 0;
-
- for(int b = 0; b < pAdjElems.GetSize(); ++b)
- {
- int pElemLen = pAdjElems[b].innerText.length() + 1;
-
- if(!pElemLen)
- continue;
-
- pAdjLen += pElemLen;
-
- if(matchIdx < pAdjLen && !begin)
- {
- begin = true;
- first = b;
- }
-
- if(matchIdx + (matchLen - 1) < pAdjLen && !end)
- {
- end = true;
- last = b;
- break;
- }
- }
-
- int skip = 0;
- while(skip < first)
- {
- matchIdx -= (pAdjElems[skip].innerText.length() + 1);
- skip++;
- }
-
- CString newCont;
- int icat = first;
- while(icat <= last)
- {
- newCont += pAdjElems[icat].innerText.GetBSTR();
- icat++;
- }
-
- if(find)
- {
- if(i == rm->Count - 1)
- {
- (*globIndex) = -1;
- (*pIndex) += (pAdjElems.GetSize());
- }
- else
- (*globIndex)++;
-
- if(*globIndex > i)
- {
- (*globIndex)--;
- continue;
- }
-
- MSHTML::IHTMLTxtRangePtr found(Document()->selection->createRange());
- found->moveToElementText(pAdjElems[first].elem);
-
- // SeNS: fix for issue #148
- found->moveStart(L"character", matchIdx+TextOffset (found, cur));
- found->collapse(TRUE);
- int diff = last - first;
- found->moveEnd(L"character", matchLen);
- found->select();
-
- return 0;
- }
- else
- {
- MSHTML::IHTMLTxtRangePtr found(Document()->selection->createRange());
- found->moveToElementText(pAdjElems[first].elem);
-
- // SeNS: fix for issue #148
- found->moveStart(L"character", matchIdx+TextOffset (found, cur));
- found->collapse(TRUE);
- int diff = last - first;
- found->moveEnd(L"character", matchLen);
- found->select();
- CString strRepl;
- GetDlgItem(IDC_WORDS_FR_EDIT_REPL).GetWindowText(strRepl);
-
- found->text = L"";
- found->text = m_fo.replacement.AllocSysString();
-
- newCont.Delete(matchIdx, matchLen - (last - first));
- newCont.Insert(matchIdx, m_fo.replacement);
-
- pAdjElems[first].innerText = newCont.AllocSysString();
- //pAdjElems[first].elem->innerText = pAdjElems[first].innerText;
-
- for(int c = first + 1; c <= last; ++c)
- {
- // MSHTML::IHTMLDOMNodePtr(pAdjElems[c].elem)->removeNode(VARIANT_TRUE);
- iNextElem--;
- }
-
- for(int c = first + 1; c < last; ++c)
- pAdjElems.RemoveAt(c);
-
- if(nRepl >= m_fo.replNum)
- goto stop;
-
- CString again;
- for(int c = 0; c < pAdjElems.GetSize(); ++c)
- {
- //pAdjElems[c].innerText = pAdjElems[c].elem->innerText;
- again += pAdjElems[c].innerText.GetBSTR();
- again += L"\n";
- }
- #ifdef USE_PCRE
- rm = re->Execute(again);
- #else
- rm = re->Execute(again.AllocSysString());
- #endif
- i--;
-
- nRepl++;
- }
- }
-
- iNextElem++;
- }
-
-stop:
-#ifndef USE_PCRE
- re.Release();
-#endif
-
- if(find)
- {
- Document()->selection->empty();
- return -1;
- }
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
-
- return nRepl;
-}
-
-class CViewReplaceDlg : public CReplaceDlgBase {
-public:
- CViewReplaceDlg(CFBEView *view) : CReplaceDlgBase(view) { }
-
- virtual void DoFind() {
- if (!m_view->DoSearch())
- {
- U::MessageBox(MB_OK|MB_ICONEXCLAMATION, IDR_MAINFRAME, IDS_SEARCH_END_MSG, m_view->m_fo.pattern);
- }
- else {
- SaveString();
- SaveHistory();
- m_selvalid=true;
- MakeClose();
- }
- }
- virtual void DoReplace() {
- if (m_selvalid) { // replace
- m_view->DoReplace();
- m_selvalid=false;
- }
- m_view->m_startMatch = m_view->m_endMatch = 0;
- DoFind();
- }
- virtual void DoReplaceAll() {
- int nRepl=m_view->GlobalReplace();
- if (nRepl>0) {
- SaveString();
- SaveHistory();
- U::MessageBox(MB_OK, IDS_REPL_ALL_CAPT, IDS_REPL_DONE_MSG, nRepl);
- MakeClose();
- m_selvalid=false;
- } else
- {
- U::MessageBox(MB_OK|MB_ICONEXCLAMATION, IDR_MAINFRAME, IDS_SEARCH_END_MSG, m_view->m_fo.pattern);
- }
- }
-};
-
-LRESULT CFBEView::OnFind(WORD, WORD, HWND, BOOL&)
-{
- m_fo.pattern = (const wchar_t*)Selection();
- if(!m_find_dlg)
- m_find_dlg = new CViewFindDlg(this);
-
- if(!m_find_dlg->IsValid())
- m_find_dlg->ShowDialog(*this); // show modeless
- else
- m_find_dlg->SetFocus();
- return 0;
-}
-
-LRESULT CFBEView::OnReplace(WORD, WORD, HWND, BOOL&)
-{
- m_fo.pattern = (const wchar_t *)Selection();
- if(!m_replace_dlg)
- m_replace_dlg = new CViewReplaceDlg(this);
-
- if(!m_replace_dlg->IsValid())
- m_replace_dlg->ShowDialog(*this);
- else
- m_replace_dlg->SetFocus();
- return 0;
-}
-
-LRESULT CFBEView::OnFindNext(WORD, WORD, HWND, BOOL&) {
- if (!DoSearch())
- {
- U::MessageBox(MB_OK|MB_ICONEXCLAMATION, IDR_MAINFRAME, IDS_SEARCH_FAIL_MSG, m_fo.pattern);
- }
- return 0;
-}
-
-// binary objects
-_variant_t CFBEView::GetBinary(const wchar_t *id) {
- try {
- CComDispatchDriver dd(Script());
- _variant_t ret;
- _variant_t arg(id);
- if (SUCCEEDED(dd.Invoke1(L"GetBinary",&arg,&ret)))
- return ret;
- }
- catch (_com_error&) { }
- return _variant_t();
-}
-
-// change notifications
-void CFBEView::EditorChanged(int id) {
- switch (id) {
- case FWD_SINK:
- break;
- case BACK_SINK:
- break;
- case RANGE_SINK:
- m_startMatch = m_endMatch = 0;
- if (!m_ignore_changes)
- ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_ED_CHANGED),(LPARAM)m_hWnd);
- break;
- }
-}
-
-// DWebBrowserEvents2
-void CFBEView::OnDocumentComplete(IDispatch *pDisp,VARIANT *vtUrl) {
- m_complete=true;
-}
-
-void CFBEView::Init() {
- // save document pointer
- m_hdoc=m_browser->Document;
-
- m_mk_srv=m_hdoc;
- m_mkc=m_hdoc;
-
- // attach document events handler
- DocumentEvents::DispEventUnadvise(Document(),&DIID_HTMLDocumentEvents2);
- DocumentEvents::DispEventAdvise(Document(),&DIID_HTMLDocumentEvents2);
- TextEvents::DispEventUnadvise(Document()->body,&DIID_HTMLTextContainerEvents2);
- TextEvents::DispEventAdvise(Document()->body,&DIID_HTMLTextContainerEvents2);
-
- // attach editing changed handlers
- m_mkc->RegisterForDirtyRange((RangeSink*)this,&m_dirtyRangeCookie);
-
- // attach external helper
- SetExternalDispatch(CreateHelper());
-
- // fixup all P elements
- FixupParagraphs(Document()->body);
-
- if (m_normalize)
- Normalize(Document()->body);
-
- if (!m_normalize) {
- // check ID and version fields
- MSHTML::IHTMLInputElementPtr ii(Document()->all->item(L"diID"));
- if ((bool)ii && ii->value.length()==0) { // generate new ID
- UUID uuid;
- unsigned char *str;
- if (UuidCreate(&uuid)==RPC_S_OK && UuidToStringA(&uuid,&str)==RPC_S_OK) {
- CString us(str);
- RpcStringFreeA(&str);
- us.MakeUpper();
- ii->value=(const wchar_t *)us;
- }
- }
- ii=Document()->all->item(L"diVersion");
- if ((bool)ii && ii->value.length()==0)
- ii->value=L"1.0";
- ii=Document()->all->item(L"diDate");
- MSHTML::IHTMLInputElementPtr jj(Document()->all->item(L"diDateVal"));
- if ((bool)ii && (bool)jj && ii->value.length()==0 && jj->value.length()==0) {
- time_t tt;
- time(&tt);
- char buffer[128];
- strftime(buffer,sizeof(buffer),"%Y-%m-%d",localtime(&tt));
- ii->value=buffer;
- jj->value=buffer;
- }
- ii=Document()->all->item(L"diProgs");
- if ((bool)ii && ii->value.length()==0)
- ii->value=L"FB Tools";
- }
-
- // added by SeNS
- m_elementsNum = Document()->all->length;
-
- // turn off browser's d&d
- HRESULT hr = m_browser->put_RegisterAsDropTarget(VARIANT_FALSE);
-// m_browser->RegisterAsDropTarget = VARIANT_TRUE;
-
- m_initialized=true;
-}
-
-void CFBEView::OnBeforeNavigate(IDispatch *pDisp,VARIANT *vtUrl,VARIANT *vtFlags,
- VARIANT *vtTargetFrame,VARIANT *vtPostData,
- VARIANT *vtHeaders,VARIANT_BOOL *fCancel)
-{
- if (!m_initialized)
- return;
-
- if (vtUrl && V_VT(vtUrl)==VT_BSTR) {
- m_nav_url=V_BSTR(vtUrl);
-
- if (m_nav_url.Left(13)==_T("fbw-internal:"))
- return;
-
- // changed by SeNS: possible fix for issue #87
- // tested on Windows Vista Ultimate
- ::PostMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_NAVIGATE),(LPARAM)m_hWnd);
- }
-
- // disable navigating away
- *fCancel=VARIANT_TRUE;
-}
-
-// HTMLDocumentEvents
-void CFBEView::OnSelChange(IDispatch *evt) {
- if (!m_ignore_changes)
- ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_SEL_CHANGE),(LPARAM)m_hWnd);
- if (m_cur_sel)
- m_cur_sel.Release();
-}
-
-VARIANT_BOOL CFBEView::OnContextMenu(IDispatch *evt)
-{
- MSHTML::IHTMLEventObjPtr oe(evt);
- oe->cancelBubble = VARIANT_TRUE;
- oe->returnValue = VARIANT_FALSE;
- if(!m_normalize)
- {
- MSHTML::IHTMLElementPtr elem(oe->srcElement);
- if(!(bool)elem)
- return VARIANT_TRUE;
- if(U::scmp(elem->tagName,L"INPUT") && U::scmp(elem->tagName, L"TEXTAREA"))
- return VARIANT_TRUE;
- }
-
- // display custom context menu here
- CMenu menu;
- CString itemName;
-
- menu.CreatePopupMenu();
- menu.AppendMenu(MF_STRING,ID_EDIT_UNDO,_T("&Undo"));
- menu.AppendMenu(MF_SEPARATOR);
-
- itemName.LoadString(IDS_CTXMENU_CUT);
- menu.AppendMenu(MF_STRING, ID_EDIT_CUT, itemName);
-
- itemName.LoadString(IDS_CTXMENU_COPY);
- menu.AppendMenu(MF_STRING, ID_EDIT_COPY, itemName);
-
- itemName.LoadString(IDS_CTXMENU_PASTE);
- menu.AppendMenu(MF_STRING, ID_EDIT_PASTE, itemName);
-
- if(m_normalize)
- {
- menu.AppendMenu(MF_SEPARATOR);
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
- MSHTML::IHTMLElementPtr initial(cur);
- int cmd = ID_SEL_BASE;
- itemName.LoadString(IDS_CTXMENU_SELECT);
-
- while((bool)cur && U::scmp(cur->tagName,L"BODY") && U::scmp(cur->id, L"fbw_body"))
- {
- menu.AppendMenu(MF_STRING, cmd, itemName + L" " + GetPath(cur));
- cur = cur->parentElement;
- ++cmd;
- }
- if(U::scmp(initial->className, L"image") == 0)
- {
- MSHTML::IHTMLImgElementPtr image = MSHTML::IHTMLDOMNodePtr(initial)->firstChild;
- CString src = image->src.GetBSTR();
- src.Delete(src.Find(L"fbw-internal:"), 13);
- if(src != L"#undefined")
- {
- menu.AppendMenu(MF_SEPARATOR);
- itemName.LoadString(IDS_CTXMENU_IMG_SAVEAS);
- menu.AppendMenu(MF_STRING, ID_SAVEIMG_AS, itemName);
- }
- }
- }
-
- AU::TRACKPARAMS tp;
- tp.hMenu = menu;
- tp.uFlags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON;
- tp.x = oe->screenX;
- tp.y = oe->screenY;
- ::SendMessage(m_frame, AU::WM_TRACKPOPUPMENU, 0, (LPARAM)&tp);
-
- return VARIANT_TRUE;
-}
-
-LRESULT CFBEView::OnSelectElement(WORD, WORD wID, HWND, BOOL&) {
- int steps=wID-ID_SEL_BASE;
- try {
- MSHTML::IHTMLElementPtr cur(SelectionContainer());
-
- while ((bool)cur && steps-->0)
- cur=cur->parentElement;
-
- MSHTML::IHTMLTxtRangePtr r(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
-
- r->moveToElementText(cur);
-
- ++m_ignore_changes;
- r->select();
- --m_ignore_changes;
-
- m_cur_sel=cur;
- ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_SEL_CHANGE),(LPARAM)m_hWnd);
- }
- catch (_com_error& e) {
- U::ReportError(e);
- }
-
- return 0;
-}
-
-VARIANT_BOOL CFBEView::OnClick(IDispatch *evt)
-{
- MSHTML::IHTMLEventObjPtr oe(evt);
- MSHTML::IHTMLElementPtr elem(oe->srcElement);
-
- m_startMatch = m_endMatch = 0;
-
- if(!(bool)elem)
- return VARIANT_FALSE;
-
- MSHTML::IHTMLElementPtr parent_element = elem->parentElement;
-
- if(!(bool)parent_element)
- return VARIANT_FALSE;
-
- bstr_t pc = parent_element->className;
-
- if(!U::scmp(pc, L"image"))
- {
- // make image selected
- IHTMLControlRangePtr r(((MSHTML::IHTMLElement2Ptr)(Document()->body))->createControlRange());
- HRESULT hr = r->add((IHTMLControlElementPtr)elem->parentElement);
- hr = r->select();
- //::SendMessage(m_frame, WM_COMMAND, MAKELONG(IDC_HREF, IDN_WANTFOCUS), (LPARAM)m_hWnd);
-
- return VARIANT_TRUE;
- }
-
- if (U::scmp(elem->tagName,L"A"))
- {
- return VARIANT_FALSE;
- }
- /*else
- {
- ::SendMessage(m_frame, WM_COMMAND, MAKELONG(IDC_HREF, IDN_WANTFOCUS), (LPARAM)m_hWnd);
- return VARIANT_FALSE;
- }*/
-
- if(oe->altKey!=VARIANT_TRUE || oe->shiftKey==VARIANT_TRUE || oe->ctrlKey==VARIANT_TRUE)
- return VARIANT_FALSE;
-
- CString sref(AU::GetAttrCS(elem, L"href"));
- if(sref.IsEmpty() || sref[0] != L'#')
- return VARIANT_FALSE;
-
- sref.Delete(0);
-
- MSHTML::IHTMLElementPtr targ(Document()->all->item((const wchar_t*)sref));
-
- if(!(bool)targ)
- return VARIANT_FALSE;
-
- GoTo(targ);
-
- oe->cancelBubble = VARIANT_TRUE;
- oe->returnValue = VARIANT_FALSE;
-
- return VARIANT_TRUE;
-}
-
-VARIANT_BOOL CFBEView::OnKeyDown(IDispatch *evt)
-{
- MSHTML::IHTMLEventObjPtr oe(evt);
- if (oe->keyCode == VK_LEFT || oe->keyCode == VK_UP || oe->keyCode == VK_PRIOR || oe->keyCode == VK_HOME)
- m_startMatch = m_endMatch = 0;
- return VARIANT_TRUE;
-}
-
-VARIANT_BOOL CFBEView::OnRealPaste(IDispatch* evt)
-{
- MSHTML::IHTMLEventObjPtr oe(evt);
- oe->cancelBubble = VARIANT_TRUE;
- if(!m_enable_paste)
- {
- // Blocks first OnRealPaste to stop double-insertion
- SendMessage(WM_COMMAND, MAKELONG(ID_EDIT_PASTE, 0), 0);
- oe->returnValue = VARIANT_FALSE;
- }
- else
- {
- oe->returnValue = VARIANT_TRUE;
- }
-
- return VARIANT_TRUE;
-}
-
-bool CFBEView::IsFormChanged() {
- if (!m_form_changed && (bool)m_cur_input)
- m_form_changed=m_form_changed || m_cur_input->value != m_cur_val;
- return m_form_changed;
-}
-
-bool CFBEView::IsFormCP() {
- if (!m_form_cp && (bool)m_cur_input)
- m_form_cp=m_form_cp || m_cur_input->value != m_cur_val;
- return m_form_cp;
-}
-
-void CFBEView::ResetFormChanged() {
- m_form_changed=false;
- if (m_cur_input)
- m_cur_val=m_cur_input->value;
-}
-
-void CFBEView::ResetFormCP() {
- m_form_cp=false;
- if (m_cur_input)
- m_cur_val=m_cur_input->value;
-}
-
-void CFBEView::OnFocusIn(IDispatch *evt) {
- // check previous value
- if (m_cur_input) {
- bool cv=m_cur_input->value != m_cur_val;
- m_form_changed=m_form_changed || cv;
- m_form_cp=m_form_cp || cv;
- m_cur_input.Release();
- }
-
- MSHTML::IHTMLEventObjPtr oe(evt);
- if (!(bool)oe)
- return;
-
- MSHTML::IHTMLElementPtr te(oe->srcElement);
- if (!(bool)te || U::scmp(te->tagName,L"INPUT"))
- return;
-
- m_cur_input=te;
- if (!(bool)m_cur_input)
- return;
-
- if (U::scmp(m_cur_input->type,L"text")) {
- m_cur_input.Release();
- return;
- }
-
- m_cur_val=m_cur_input->value;
-}
-
-// find/replace support for scintilla
-bool CFBEView::SciFindNext(HWND src,bool fFwdOnly,bool fBarf) {
- if (m_fo.pattern.IsEmpty())
- return true;
-
- int flags=0;
- if (m_fo.flags & FRF_WHOLE)
- flags|=SCFIND_WHOLEWORD;
- if (m_fo.flags & FRF_CASE)
- flags|=SCFIND_MATCHCASE;
- if (m_fo.fRegexp)
- flags|=SCFIND_REGEXP;
- int rev=m_fo.flags & FRF_REVERSE && !fFwdOnly;
-
- // added by SeNS
- if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
- m_fo.pattern.Replace( L"\u00A0", _Settings.GetNBSPChar());
-
- DWORD len=::WideCharToMultiByte(CP_UTF8,0, m_fo.pattern,m_fo.pattern.GetLength(), NULL,0,NULL,NULL);
- char *tmp=(char *)malloc(len+1);
- if (tmp)
- {
- ::WideCharToMultiByte(CP_UTF8,0, m_fo.pattern,m_fo.pattern.GetLength(), tmp,len,NULL,NULL);
- tmp[len]='\0';
- int p1=::SendMessage(src,SCI_GETSELECTIONSTART,0,0);
- int p2=::SendMessage(src,SCI_GETSELECTIONEND,0,0);
- if (p2>p1 && !rev) p1=p2;
-// if (p1!=p2 && !rev) ++p1;
- if (rev) --p1;
- if (p1<0) p1=0;
- p2=rev ? 0 : ::SendMessage(src,SCI_GETLENGTH,0,0);
- int p3=p2==0 ? ::SendMessage(src,SCI_GETLENGTH,0,0) : 0;
- ::SendMessage(src,SCI_SETTARGETSTART,p1,0);
- ::SendMessage(src,SCI_SETTARGETEND,p2,0);
- ::SendMessage(src,SCI_SETSEARCHFLAGS,flags,0);
- // this sometimes hangs in reverse search :)
- int ret=::SendMessage(src,SCI_SEARCHINTARGET,len,(LPARAM)tmp);
- if (ret==-1)
- { // try wrap
- if (p1!=p3)
- {
- ::SendMessage(src,SCI_SETTARGETSTART,p3,0);
- ::SendMessage(src,SCI_SETTARGETEND,p1,0);
- ::SendMessage(src,SCI_SETSEARCHFLAGS,flags,0);
- ret=::SendMessage(src,SCI_SEARCHINTARGET,len,(LPARAM)tmp);
- }
- if (ret==-1)
- {
- free(tmp);
- if (fBarf)
- {
- U::MessageBox(MB_OK|MB_ICONEXCLAMATION, IDR_MAINFRAME, IDS_SEARCH_FAIL_MSG, m_fo.pattern);
- }
- return false;
- }
- ::MessageBeep(MB_ICONASTERISK);
- }
- free(tmp);
- p1=::SendMessage(src,SCI_GETTARGETSTART,0,0);
- p2=::SendMessage(src,SCI_GETTARGETEND,0,0);
- ::SendMessage(src,SCI_SETSELECTIONSTART,p1,0);
- ::SendMessage(src,SCI_SETSELECTIONEND,p2,0);
- ::SendMessage(src,SCI_SCROLLCARET,0,0);
- return true;
- } else
- {
- wchar_t msg[MAX_LOAD_STRING + 1];
- wchar_t cpt[MAX_LOAD_STRING + 1];
- ::LoadString(_Module.GetResourceInstance(), IDS_OUT_OF_MEM_MSG, msg, MAX_LOAD_STRING);
- ::LoadString(_Module.GetResourceInstance(), IDR_MAINFRAME, cpt, MAX_LOAD_STRING);
- ::MessageBox(::GetActiveWindow(), msg, cpt, MB_OK|MB_ICONERROR);
- }
-
- return false;
-}
-
-_bstr_t CFBEView::Selection()
-{
- try
- {
- MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
- if(!(bool)rng)
- return _bstr_t();
-
- MSHTML::IHTMLTxtRangePtr dup(rng->duplicate());
- dup->collapse(VARIANT_TRUE);
-
- MSHTML::IHTMLElementPtr elem(dup->parentElement());
- while ((bool)elem && U::scmp(elem->tagName, L"P") && U::scmp(elem->tagName, L"DIV"))
- elem = elem->parentElement;
-
- if(elem)
- {
- dup->moveToElementText(elem);
- if(rng->compareEndPoints(L"EndToEnd", dup) > 0)
- rng->setEndPoint(L"EndToEnd", dup);
- }
-
- return rng->text;
- }
- catch (_com_error& err)
- {
- U::ReportError(err);
- }
-
- return _bstr_t();
-}
-
-// Modification by Pilgrim
-static bool IsTable(MSHTML::IHTMLDOMNode *node) {
- MSHTML::IHTMLElementPtr elem(node);
- return U::scmp(elem->className,L"table")==0;
-}
-
-static bool IsTR(MSHTML::IHTMLDOMNode *node) {
- MSHTML::IHTMLElementPtr elem(node);
- return U::scmp(elem->className,L"tr")==0;
-}
-
-static bool IsTH(MSHTML::IHTMLDOMNode *node) {
- MSHTML::IHTMLElementPtr elem(node);
- return U::scmp(elem->className,L"th")==0;
-}
-
-static bool IsTD(MSHTML::IHTMLDOMNode *node) {
- MSHTML::IHTMLElementPtr elem(node);
- return U::scmp(elem->className,L"td")==0;
-}
-
-bool CFBEView::GoToFootnote(bool fCheck)
-{
- // * create selection range
- MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
- if (!(bool)rng)
- return false;
-
- MSHTML::IHTMLTxtRangePtr next_rng = rng->duplicate();
- MSHTML::IHTMLTxtRangePtr prev_rng = rng->duplicate();
- next_rng->moveEnd(L"character", +1);
- prev_rng->moveStart(L"character", -1);
-
- CString sref(AU::GetAttrCS(SelectionAnchor(),L"href"));
- if (sref.IsEmpty())
- sref = AU::GetAttrCS(SelectionAnchor(next_rng->parentElement()),L"href");
- if (sref.IsEmpty())
- sref = AU::GetAttrCS(SelectionAnchor(prev_rng->parentElement()),L"href");
-
- if (sref.Find(L"file") == 0)
- sref = sref.Mid(sref.ReverseFind (L'#'),1024);
- if (sref.IsEmpty() || sref[0]!=_T('#'))
- return false;
-
- // * ok, all checks passed
- if (fCheck)
- return true;
-
- sref.Delete(0);
-
- MSHTML::IHTMLElementPtr targ(Document()->all->item((const wchar_t *)sref));
-
- if (!(bool)targ)
- return false;
-
- MSHTML::IHTMLDOMNodePtr childNode;
- MSHTML::IHTMLDOMNodePtr node(targ);
- if (!(bool)node)
- return false;
-
- // added by SeNS: move caret to the foornote text
- if (!U::scmp(node->nodeName,L"DIV") && !U::scmp(targ->className,L"section"))
- {
- if (node->firstChild)
- {
- childNode = node->firstChild;
- while (childNode && !U::scmp(childNode->nodeName,L"DIV") &&
- (!U::scmp(MSHTML::IHTMLElementPtr(childNode)->className,L"image") ||
- !U::scmp(MSHTML::IHTMLElementPtr(childNode)->className,L"title")))
- childNode=childNode->nextSibling;
- }
- }
- if (!childNode) childNode=node;
- if (childNode)
- {
- GoTo(MSHTML::IHTMLElementPtr(childNode));
- targ->scrollIntoView(true);
- }
-
- return true;
-}
-bool CFBEView::GoToReference(bool fCheck)
-{
- // * create selection range
- MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
- if (!(bool)rng)
- return false;
-
- // * get its parent element
- MSHTML::IHTMLElementPtr pe(GetHP(rng->parentElement()));
- if (!(bool)pe)
- return false;
-
- if (rng->compareEndPoints(L"StartToEnd",rng)!=0)
- return false;
-
- while((bool)pe && (U::scmp(pe->tagName,L"DIV")!=0 || U::scmp(pe->className,L"section")!=0))
- pe=pe->parentElement; // Find parent division
- if(!(bool)pe)
- return false;
-
- MSHTML::IHTMLElementPtr body=pe->parentElement;
-
- while((bool)body && (U::scmp(body->tagName,L"DIV")!=0 || U::scmp(body->className,L"body")!=0))
- body=body->parentElement; // Find body
-
- if(!(bool)body)
- return false;
-
- CString id = MSHTML::IHTMLElementPtr(rng->parentElement())->id;
- CString sfbname(AU::GetAttrCS(body,L"fbname"));
- if(id.IsEmpty() && (sfbname.IsEmpty() || !(sfbname.CompareNoCase(L"notes")==0 || sfbname.CompareNoCase(L"comments")==0)))
- return false;
- id = L"#"+id;
-
- // * ok, all checks passed
- if (fCheck)
- return true;
-
- MSHTML::IHTMLElement2Ptr elem(Document()->body);
- MSHTML::IHTMLElementCollectionPtr coll(elem->getElementsByTagName(L"A"));
- if (!(bool)coll || coll->length==0)
- {
- wchar_t cpt[MAX_LOAD_STRING + 1];
- wchar_t msg[MAX_LOAD_STRING + 1];
- ::LoadString(_Module.GetResourceInstance(), IDR_MAINFRAME, cpt, MAX_LOAD_STRING);
- ::LoadString(_Module.GetResourceInstance(), IDS_GOTO_REF_FAIL_MSG, msg, MAX_LOAD_STRING);
- ::MessageBox(::GetActiveWindow(), msg, cpt, MB_OK|MB_ICONINFORMATION);
- return false;
- }
-
- for (long l=0;llength;++l) {
- MSHTML::IHTMLElementPtr a(coll->item(l));
- if (!(bool)a)
- continue;
-
- CString href(AU::GetAttrCS((MSHTML::IHTMLElementPtr)coll->item(l),L"href"));
-
- // changed by SeNS
- if (href.Find(L"file") == 0)
- href = href.Mid(href.ReverseFind (L'#'),1024);
- else if(href.Find(_T("://"),0) !=-1)
- continue;
-
- CString snote = L"#"+pe->id;
-
- if(href==snote || href==id)
- {
- GoTo(a);
- MSHTML::IHTMLTxtRangePtr r(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
- r->moveToElementText(a);
- r->collapse(VARIANT_TRUE);
- // move selection to position after reference
- CString sa = a->innerText;
- r->move(L"character", sa.GetLength());
- r->select();
- // scroll to the center of view
- MSHTML::IHTMLRectPtr rect = MSHTML::IHTMLElement2Ptr(a)->getBoundingClientRect();
- MSHTML::IHTMLWindow2Ptr window(MSHTML::IHTMLDocument2Ptr(Document())->parentWindow);
- if (rect && window)
- {
- if (rect->bottom-rect->top <= _Settings.GetViewHeight())
- window->scrollBy(0,(rect->top+rect->bottom-_Settings.GetViewHeight())/2);
- else
- window->scrollBy(0,rect->top);
- }
- break;
- }
- }
-
- return false;
-}
-
-LRESULT CFBEView::OnEditInsertTable(WORD wNotifyCode, WORD wID, HWND hWndCtl)
-{
- CTableDlg dlg;
- if(dlg.DoModal()==IDOK) {
- int nRows = dlg.m_nRows;
- bool bTitle = dlg.m_bTitle;
- InsertTable(false,bTitle,nRows);
- }
- return 0;
-}
-
-LRESULT CFBEView::OnEditInsImage(WORD, WORD cmdID, HWND, BOOL&)
-{
- // added by SeNS
- bool bInline = (cmdID != ID_EDIT_INS_IMAGE);
-
- if(_Settings.GetInsImageAsking())
- {
- CAddImageDlg imgDialog;
- imgDialog.DoModal(*this);
- }
-
- if(!_Settings.GetIsInsClearImage())
- {
- CFileDialogEx dlg(
- TRUE,
- NULL,
- NULL,
- OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
- L"FBE supported (*.jpg;*.jpeg;*.png)\0*.jpg;*.jpeg;*.png\0JPEG (*.jpg)\0*.jpg\0PNG (*.png)\0*.png\0Bitmap (*.bmp"\
- L")\0*.bmp\0GIF (*.gif)\0*.gif\0TIFF (*.tif)\0*.tif\0\0"
- );
-
- wchar_t dlgTitle[MAX_LOAD_STRING + 1];
- ::LoadString(_Module.GetResourceInstance(), IDS_ADD_IMAGE_FILEDLG, dlgTitle, MAX_LOAD_STRING);
- dlg.m_ofn.lpstrTitle = dlgTitle;
- dlg.m_ofn.nFilterIndex = 1;
-
- if(dlg.DoModal(*this) == IDOK)
- {
- AddImage(dlg.m_szFileName, bInline);
- }
- }
- else
- {
- // added by SeNS
- try {
- if (bInline)
- {
- MSHTML::IHTMLDOMNodePtr node(Call(L"InsInlineImage"));
- }
- else
- {
- MSHTML::IHTMLDOMNodePtr node(Call(L"InsImage"));
- if (node)
- BubbleUp(node,L"DIV");
- }
- }
- catch (_com_error&) { }
- }
-
- return 0;
-}
-
-bool CFBEView::InsertTable(bool fCheck, bool bTitle, int nrows) {
- try {
- // * create selection range
- MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
- if (!(bool)rng)
- return false;
-
- // * get its parent element
- MSHTML::IHTMLElementPtr pe(GetHP(rng->parentElement()));
- if (!(bool)pe)
- return false;
-
- // * get parents for start and end ranges and ensure they are the same as pe
- MSHTML::IHTMLTxtRangePtr tr(rng->duplicate());
- tr->collapse(VARIANT_TRUE);
- if (GetHP(tr->parentElement())!=pe)
- return false;
-#if 0
- tr=rng->duplicate();
- tr->collapse(VARIANT_FALSE);
- if (GetHP(tr->parentElement())!=pe)
- return false;
-#endif
-
- // * check if it possible to insert a table there
- _bstr_t cls(pe->className);
- if (U::scmp(cls,L"section") && U::scmp(cls,L"epigraph") &&
- U::scmp(cls,L"annotation") && U::scmp(cls,L"history") && U::scmp(cls,L"cite"))
- return false;
-
- // * ok, all checks passed
- if (fCheck)
- return true;
-
- // at this point we are ready to create a table
-
- // * create an undo unit
- m_mk_srv->BeginUndoUnit(L"insert table");
-
- MSHTML::IHTMLElementPtr te(Document()->createElement(L"DIV"));
-
- for(int row=nrows; row!=-1; --row){
- // * create tr
- MSHTML::IHTMLElementPtr tre(Document()->createElement(L"DIV"));
- tre->className=L"tr";
- // * create th and td
- MSHTML::IHTMLElementPtr the(Document()->createElement(L"P"));
- if(row==0){
- if(bTitle){//Нужен заголовок таблицы
- the->className=L"th";// * create th - заголовок
- MSHTML::IHTMLElement2Ptr(tre)->insertAdjacentElement(L"afterBegin",the);
- }
- } else {
- the->className=L"td";// * create td - строки
- MSHTML::IHTMLElement2Ptr(tre)->insertAdjacentElement(L"afterBegin",the);
- }
-
- // * create table
- te->className=L"table";
- MSHTML::IHTMLElement2Ptr(te)->insertAdjacentElement(L"afterBegin",tre);
- }
-
- // * paste the results back
- rng->pasteHTML(te->outerHTML);
-
- // * ensure we have good html
- RelocateParagraphs(MSHTML::IHTMLDOMNodePtr(pe));
- FixupParagraphs(pe);
-
- // * close undo unit
- m_mk_srv->EndUndoUnit();
- }
- catch (_com_error& e) {
- U::ReportError(e);
- }
- return false;
-}
-
-long CFBEView::InsertCode()
-{
- if(bCall(L"IsCode", SelectionStructCode()))
- {
- HRESULT hr;
- BeginUndoUnit(L"insert code");
- hr = m_mk_srv->RemoveElement(SelectionStructCode());
- EndUndoUnit();
- return hr == S_OK ? 0 : -1;
- }
- else
- {
- try
- {
- BeginUndoUnit(L"insert code");
-
- int offset = -1;
- MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
- if (!(bool)rng) return -1;
-
- CString rngHTML((wchar_t*)rng->htmlText);
-
- // empty selection case - select current word
- if(rngHTML == L"")
- {
- // select word
- rng->moveStart(L"word",-1);
- CString txt = rng->text;
- offset = txt.GetLength();
- rng->expand(L"word");
- rngHTML.SetString(rng->htmlText);
- }
-
- if (iswspace(rngHTML[rngHTML.GetLength()-1]))
- {
- rng->moveEnd(L"character",-1);
- rngHTML.SetString(rng->htmlText);
- if (offset > rngHTML.GetLength()) offset--;
- }
-
- // save selection
- MSHTML::IMarkupPointerPtr selBegin, selEnd;
- m_mk_srv->CreateMarkupPointer(&selBegin);
- m_mk_srv->CreateMarkupPointer(&selEnd);
- m_mk_srv->MovePointersToRange(rng, selBegin, selEnd);
-
- if(rngHTML.Find(L"createElement(L"");
- MSHTML::IHTMLElementPtr selElem = rng->parentElement();
-
- MSHTML::IHTMLTxtRangePtr rngStart = rng->duplicate();
- MSHTML::IHTMLTxtRangePtr rngEnd = rng->duplicate();
- rngStart->collapse(true);
- rngEnd->collapse(false);
-
- MSHTML::IHTMLElementPtr elBegin = rngStart->parentElement(), elEnd = rngEnd->parentElement();
- while(U::scmp(elBegin->tagName, L"P")) elBegin = elBegin->parentElement;
- while(U::scmp(elEnd->tagName, L"P")) elEnd = elEnd->parentElement;
-
- MSHTML::IHTMLDOMNodePtr bNode = elBegin, eNode = elEnd;
- int last = 0;
- while(bNode)
- {
- CString elBeginHTML = elBegin->innerHTML;
-
- if(U::scmp(elBegin->tagName, L"P") == 0 && elBeginHTML.Find(L"innerHTML = elBegin->innerHTML;
- if(!(elBeginHTML.Find(L"") == 0 &&
- elBeginHTML.Find(L" ") == elBeginHTML.GetLength() - 7))
- {
- elBegin->innerHTML = spanElem->outerHTML;
- }
- }
- // remove code tag
- else
- {
- elBeginHTML.Replace (L"", L" ");
- elBeginHTML.Replace (L" ", L" ");
- elBegin->innerHTML = elBeginHTML.AllocSysString();
- }
-
- if(bNode == eNode)
- break;
-
- bNode = bNode->nextSibling;
- elBegin = bNode;
- }
- // expand selection to the last paragraph
- rng->moveToElementText(elBegin);
- m_mk_srv->MovePointersToRange(rng, NULL, selEnd);
- }
- else if(rngHTML.Find(L"") != -1 && rngHTML.Find(L" ") != -1)
- {
- rngHTML.Replace (L"", L" ");
- rngHTML.Replace (L" ", L" ");
- rng->pasteHTML(rngHTML.AllocSysString());
- }
- else
- {
- if (iswspace(rngHTML[0]))
- {
- rng->moveStart(L"character",1);
- rngHTML.SetString(rng->htmlText);
- }
- if (iswspace(rngHTML[rngHTML.GetLength()-1]))
- {
- rng->moveEnd(L"character",-1);
- rngHTML.SetString(rng->htmlText);
- }
- rngHTML = L"" + rngHTML + L" ";
- rng->pasteHTML(rngHTML.AllocSysString());
- }
-
- // restore selection
- if (offset >= 0)
- {
- rng->move(L"word", -1);
- rng->move(L"character", offset);
- rng->select();
- }
- else
- {
- m_mk_srv->MoveRangeToPointers(selBegin, selEnd, rng);
- rng->select();
- }
-
- EndUndoUnit();
- }
- catch (_com_error& e)
- {
- U::ReportError(e);
- return -1;
- }
-
- return 0;
- }
-}
-
-int CFBEView::GetRangePos(const MSHTML::IHTMLTxtRangePtr range, MSHTML::IHTMLElementPtr &element, int &pos)
-{
- MSHTML::IHTMLTxtRangePtr tr(range->duplicate());
- tr->collapse(VARIANT_TRUE);
-
- // * get its parent element
- element = tr->parentElement();
-
- MSHTML::IHTMLTxtRangePtr btr(range->duplicate());
- btr->moveToElementText(element);
- btr->collapse(VARIANT_TRUE);
-
- pos = 0;
-
- MSHTML::IHTMLDOMNodePtr node(element);
- if(!(bool)node)
- {
- return 0;
- }
-
- int count = 0;
- int cuttedchars = 0;
-
- node = node->firstChild;
- while(node)
- {
- MSHTML::IHTMLDOMTextNodePtr textNode(node);
- if(!(bool)textNode)
- {
- int skip = CountNodeChars(node);
- cuttedchars += skip;
- btr->move(L"character", skip);
- }
- else
- {
- // проверяем не проскочили ли мы искомую позицию
- int skip = count + textNode->length;
- btr->move(L"character", skip);
-
- if(btr->compareEndPoints(L"StartToStart", tr) != -1)
- {
- btr->move(L"character", -skip);
- break;
- }
- pos += skip;
- }
-
- node = node->nextSibling;
- }
-
- // тупая проверка.
- // если курсор стоит сразу после тега, то tr оказывается справа от brt и при этом никогда не бывает равен ему
- int k = btr->compareEndPoints(L"StartToStart", tr);
- if(k == -1)
- {
- int res = btr->move(L"character", 1);
- if (res != 1)
- {
- return 0;
- }
- if(btr->compareEndPoints(L"StartToStart", tr) != 1)
- {
- ++pos;
- }
- }
-
- while(btr->compareEndPoints(L"StartToStart", tr) == -1)
- {
- ++pos;
- int res = btr->move(L"character", 1);
- if (res != 1)
- {
- return 0;
- }
- }
-
- return pos;
-}
-
-bool CFBEView::GetSelectionInfo(MSHTML::IHTMLElementPtr *begin, MSHTML::IHTMLElementPtr *end, int* begin_char, int* end_char, MSHTML::IHTMLTxtRangePtr range)
-{
- *begin_char = 0;
- *end_char = 0;
-
- int b = 0;
- int e = 0;
-
- bool one_elment = false;
- // * create selection range
- MSHTML::IHTMLTxtRangePtr rng;
- if(!(bool)range)
- {
- IDispatchPtr disp(Document()->selection->createRange());
- rng = disp;
- if (!(bool)rng)
- {
- // если не получилось сделать textrange, пробуем сделать control range
- MSHTML::IHTMLControlRangePtr coll(disp);
- if (!(bool)coll)
- {
- return false;
- }
- *begin = coll->item(0);
- *end = coll->item(coll->length - 1);
- return true;
- }
- }
- else
- rng = range;
-
- bstr_t text = rng->text;
-
- MSHTML::IHTMLTxtRangePtr tr(rng->duplicate());
- tr->collapse(VARIANT_TRUE);
-
- // * get its parent element
- *begin = tr->parentElement();
- if (!(bool)(*begin))
- return false;
-
- // ищем позицию относительно начала;
- this->GetRangePos(tr, *begin, b);
-
- tr = rng->duplicate();
- tr->collapse(VARIANT_FALSE);
- *end = tr->parentElement();
- if (*end == *begin)
- {
- one_elment = true;
- }
-
- this->GetRangePos(tr, *end, e);
-
- MSHTML::IHTMLDOMNodePtr nodeb(*begin);
- MSHTML::IHTMLDOMNodePtr nodee(*end);
- if(!(bool)nodeb || !(bool)nodee)
- {
- return false;
- }
-
- /*b = this->GetRelationalCharPos(nodeb, b);
- e = this->GetRelationalCharPos(nodee, e);*/
-
- *begin_char = b;
- *end_char = e;
-
- return true;
-}
-
-MSHTML::IHTMLTxtRangePtr CFBEView::SetSelection(MSHTML::IHTMLElementPtr begin, MSHTML::IHTMLElementPtr end, int begin_pos, int end_pos)
-{
- if(!(bool)begin)
- {
- return 0;
- }
- if(!(bool)end)
- {
- end = begin;
- end_pos = begin_pos;
- }
-
- begin_pos = this->GetRealCharPos(begin, begin_pos);
- end_pos = this->GetRealCharPos(end, end_pos);
-
- MSHTML::IHTMLTxtRangePtr rng(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
- if(!(bool)rng)
- {
- return 0;
- }
-
- // устанавливаем начало выделенной строки
- MSHTML::IHTMLTxtRangePtr rng_begin(rng->duplicate());
- rng_begin->moveToElementText(begin);
- rng_begin->collapse(VARIANT_TRUE);
- rng_begin->moveStart(L"character", begin_pos);
-
- if(begin == end)
- {
- rng_begin->moveEnd(L"character", end_pos - begin_pos);
- HRESULT hr = rng_begin->select();
-
- return rng_begin;
- }
-
- MSHTML::IHTMLTxtRangePtr rng_end(rng->duplicate());
- rng_end->moveToElementText(end);
- rng_end->moveStart(L"character", end_pos);
-
- // раздвигаем регион
- rng_begin->setEndPoint(L"EndToStart", rng_end);
-
- rng_begin->select();
-
-
- return rng_begin;
-}
-
-int CFBEView::GetRelationalCharPos(MSHTML::IHTMLDOMNodePtr node, int pos)
-{
- if(!(bool)node)
- {
- return 0;
- }
-
- int relpos = 0;
- int cuttedchars = 0;
-
- node = node->firstChild;
- while(node)
- {
- MSHTML::IHTMLDOMTextNodePtr textNode(node);
- if(!(bool)textNode)
- {
- cuttedchars += CountNodeChars(node);
- }
- else
- {
- if(relpos + cuttedchars + textNode->length >= pos)
- {
- return pos - cuttedchars;
- }
- relpos += textNode->length;
- }
- node = node->nextSibling;
- }
-
- return 0;
-}
-
-int CFBEView::GetRealCharPos(MSHTML::IHTMLDOMNodePtr node, int pos)
-{
- if(!(bool)node)
- {
- return 0;
- }
-
- int realpos = 0;
- int cuttedchars = 0;
-
- node = node->firstChild;
- while(node)
- {
- MSHTML::IHTMLDOMTextNodePtr textNode(node);
- if(!(bool)textNode)
- {
- cuttedchars += CountNodeChars(node);
- }
- else
- {
- if((realpos + textNode->length) >= pos)
- {
- return pos + cuttedchars;
- }
- realpos += textNode->length;
- }
- node = node->nextSibling;
- }
-
- return 0;
-}
-
-int CFBEView::CountNodeChars(MSHTML::IHTMLDOMNodePtr node)
-{
- if(!(bool)node)
- {
- return 0;
- }
-
- int count = 0;
-
- node = node->firstChild;
- while(node)
- {
- MSHTML::IHTMLDOMTextNodePtr textNode(node);
- if(!(bool)textNode)
- {
- count += CountNodeChars(node);
- }
- else
- {
- count += textNode->length;
- }
- node = node->nextSibling;
- }
-
- return count;
-}
-
-bool CFBEView::CloseFindDialog(CFindDlgBase* dlg)
-{
- if(!dlg || !dlg->IsValid())
- return false;
-
- dlg->DestroyWindow();
- return true;
-}
-
-bool CFBEView::CloseFindDialog(CReplaceDlgBase* dlg)
-{
- if(!dlg || !dlg->IsValid())
- return false;
-
- dlg->DestroyWindow();
- return true;
-}
-
-bool CFBEView::ExpandTxtRangeToParagraphs(MSHTML::IHTMLTxtRangePtr& rng,
- MSHTML::IHTMLElementPtr& begin,
- MSHTML::IHTMLElementPtr& end) const
-{
- MSHTML::IHTMLTxtRangePtr tr1 = rng->duplicate();
- tr1->collapse(true);
-
- MSHTML::IHTMLElementPtr te = GetHP(tr1->parentElement());
-
- if(!(bool)te)
- return false;
-
- MSHTML::IHTMLTxtRangePtr tr2 = rng->duplicate();
- tr2->collapse(false);
-
- begin = tr1->parentElement();
- while((bool)begin && U::scmp(begin->tagName, L"P"))
- begin = begin->parentElement;
-
- if(!(bool)begin)
- return false;
-
- end = tr2->parentElement();
- while((bool)end && U::scmp(end->tagName, L"P"))
- end = end->parentElement;
-
- if(!(bool)end)
- return false;
-
- if(begin == end)
- rng->moveToElementText(begin);
- else
- {
- MSHTML::IMarkupPointerPtr pBegin, pEnd;
- m_mk_srv->CreateMarkupPointer(&pBegin);
- m_mk_srv->CreateMarkupPointer(&pEnd);
- pBegin->MoveAdjacentToElement(begin, MSHTML::ELEM_ADJ_AfterBegin);
- pEnd->MoveAdjacentToElement(end, MSHTML::ELEM_ADJ_BeforeEnd);
- m_mk_srv->MoveRangeToPointers(pBegin, pEnd, rng);
- }
-
- return true;
-}
-
-LRESULT CFBEView::OnCode(WORD wCode, WORD wID, HWND hWnd, BOOL& bHandled)
-{
- return InsertCode();
-}
-
-bool CFBEView::SelectionHasTags(wchar_t* elem)
-{
- try
- {
- MSHTML::IHTMLTxtRangePtr range = Document()->selection->createRange();
- if(range)
- {
- CString html = range->htmlText;
- if(html.Find(CString(L"<") + elem) != -1)
- return true;
- }
- }
- catch(_com_error& err)
- {
- U::ReportError(err);
- return false;
- }
-
- return false;
-}
-
-BSTR CFBEView::PrepareDefaultId(const CString& filename){
-
- CString _filename = U::Transliterate(filename);
- // prepare a default id
- int cp = _filename.ReverseFind(_T('\\'));
- if (cp < 0)
- cp = 0;
- else
- ++cp;
- CString newid;
- TCHAR *ncp=newid.GetBuffer(_filename.GetLength()-cp);
- int newlen=0;
- while (cp<_filename.GetLength()) {
- TCHAR c=_filename[cp];
- if ((c>=_T('0') && c<=_T('9')) ||
- (c>=_T('A') && c<=_T('Z')) ||
- (c>=_T('a') && c<=_T('z')) ||
- c==_T('_') || c==_T('.'))
- ncp[newlen++]=c;
- ++cp;
- }
- newid.ReleaseBuffer(newlen);
- if (!newid.IsEmpty() && !(
- (newid[0]>=_T('A') && newid[0]<=_T('Z')) ||
- (newid[0]>=_T('a') && newid[0]<=_T('z')) ||
- newid[0]==_T('_')))
- newid.Insert(0,_T('_'));
- return newid.AllocSysString();
-}
-
-// images
-void CFBEView::AddImage(const CString& filename, bool bInline)
-{
- _variant_t args[4];
-
- V_BSTR(&args[3]) = filename.AllocSysString();
- V_VT(&args[3]) = VT_BSTR;
-
- HRESULT hr;
- if(FAILED(hr = U::LoadFile(filename, &args[0])))
- {
- U::ReportError(hr);
- return;
- }
-
- // Prepare a default ID
- int cp = filename.ReverseFind(_T('\\'));
- if (cp < 0)
- cp = 0;
- else
- ++cp;
-
- V_BSTR(&args[2]) = PrepareDefaultId(filename);
- V_VT(&args[2]) = VT_BSTR;
-
- // Try to find out mime type
- V_BSTR(&args[1]) = U::GetMimeType(filename).AllocSysString();
- V_VT(&args[1]) = VT_BSTR;
-
- // Stuff the thing into JavaScript
- try
- {
- CComDispatchDriver body(Script());
- _variant_t checkedId;
- hr = body.InvokeN(L"apiAddBinary", args, 4, &checkedId);
-
- if(FAILED(hr))
- U::ReportError(hr);
-
- hr = body.Invoke0(L"FillCoverList");
-
- if(FAILED(hr))
- U::ReportError(hr);
-
- _variant_t check(false);
- if (bInline)
- hr = body.Invoke2(L"InsInlineImage", &check, &checkedId);
- else
- hr = body.Invoke2(L"InsImage", &check, &checkedId);
- if (FAILED(hr))
- U::ReportError(hr);
-
- MSHTML::IHTMLDOMNodePtr node(NULL);
- if(node)
- BubbleUp(node, L"DIV");
- }
- catch (_com_error&) { }
-}
+// FBEView.cpp : implementation of the CFBEView class
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "stdafx.h"
+#include "res1.h"
+
+#include "utils.h"
+#include "apputils.h"
+
+#include "FBEView.h"
+#include "SearchReplace.h"
+#include "Scintilla.h"
+#include "ElementDescMnr.h"
+#include "atlimageex.h"
+
+extern CElementDescMnr _EDMnr;
+
+// normalization helpers
+static void PackText(MSHTML::IHTMLElement2Ptr elem,MSHTML::IHTMLDocument2 *doc);
+static void KillDivs(MSHTML::IHTMLElement2Ptr elem);
+static void FixupParagraphs(MSHTML::IHTMLElement2Ptr elem);
+static void RelocateParagraphs(MSHTML::IHTMLDOMNode *node);
+static void KillStyles(MSHTML::IHTMLElement2Ptr elem);
+
+_ATL_FUNC_INFO CFBEView::DocumentCompleteInfo=
+ { CC_STDCALL, VT_EMPTY, 2, { VT_DISPATCH, (VT_BYREF | VT_VARIANT) } };
+_ATL_FUNC_INFO CFBEView::BeforeNavigateInfo=
+ { CC_STDCALL, VT_EMPTY, 7, {
+ VT_DISPATCH,
+ (VT_BYREF | VT_VARIANT),
+ (VT_BYREF | VT_VARIANT),
+ (VT_BYREF | VT_VARIANT),
+ (VT_BYREF | VT_VARIANT),
+ (VT_BYREF | VT_VARIANT),
+ (VT_BYREF | VT_BOOL),
+ }
+ };
+_ATL_FUNC_INFO CFBEView::VoidInfo=
+ { CC_STDCALL, VT_EMPTY, 0 };
+_ATL_FUNC_INFO CFBEView::EventInfo=
+ { CC_STDCALL, VT_BOOL, 1, { VT_DISPATCH } };
+_ATL_FUNC_INFO CFBEView::VoidEventInfo=
+ { CC_STDCALL, VT_EMPTY, 1, { VT_DISPATCH } };
+
+LRESULT CFBEView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ if (DefWindowProc(uMsg,wParam,lParam))
+ return 1;
+ if (!SUCCEEDED(QueryControl(&m_browser)))
+ return 1;
+
+ // register browser events handler
+ BrowserEvents::DispEventAdvise(m_browser,&DIID_DWebBrowserEvents2);
+
+ return 0;
+}
+
+CFBEView::~CFBEView()
+{
+ if(HasDoc())
+ {
+ DocumentEvents::DispEventUnadvise(Document(), &DIID_HTMLDocumentEvents2);
+ TextEvents::DispEventUnadvise(Document()->body, &DIID_HTMLTextContainerEvents2);
+ m_mkc->UnRegisterForDirtyRange(m_dirtyRangeCookie);
+ }
+ if(m_browser)
+ BrowserEvents::DispEventUnadvise(m_browser, &DIID_DWebBrowserEvents2);
+
+ if(m_find_dlg)
+ {
+ CloseFindDialog(m_find_dlg);
+ delete m_find_dlg;
+ }
+}
+
+BOOL CFBEView::PreTranslateMessage(MSG* pMsg)
+{
+ return SendMessage(WM_FORWARDMSG,0,(LPARAM)pMsg)!=0;
+}
+
+// editing commands
+LRESULT CFBEView::ExecCommand(int cmd) {
+ IOleCommandTargetPtr ct(m_browser);
+ if (ct)
+ ct->Exec(&CGID_MSHTML,cmd,0,NULL,NULL);
+ return 0;
+}
+
+void CFBEView::QueryStatus(OLECMD *cmd,int ncmd) {
+ IOleCommandTargetPtr ct(m_browser);
+ if (ct)
+ ct->QueryStatus(&CGID_MSHTML,ncmd,cmd,NULL);
+}
+
+CString CFBEView::QueryCmdText(int cmd) {
+ IOleCommandTargetPtr ct(m_browser);
+ if (ct) {
+ OLECMD oc={cmd};
+ struct {
+ OLECMDTEXT oct;
+ wchar_t buffer[512];
+ } oct={ { OLECMDTEXTF_NAME, 0, 512 } };
+ if (SUCCEEDED(ct->QueryStatus(&CGID_MSHTML,1,&oc,&oct.oct)))
+ return oct.oct.rgwz;
+ }
+ return CString();
+}
+
+LRESULT CFBEView::OnStyleLink(WORD, WORD, HWND, BOOL&) {
+ try {
+ if (Document()->execCommand(L"CreateLink",VARIANT_FALSE,_variant_t(L""))==VARIANT_TRUE)
+ {
+ ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_SEL_CHANGE),(LPARAM)m_hWnd);
+ ::SendMessage(m_frame,WM_COMMAND,MAKELONG(IDC_HREF,IDN_WANTFOCUS),(LPARAM)m_hWnd);
+ }
+ }
+ catch (_com_error&) { }
+ return 0;
+}
+
+LRESULT CFBEView::OnStyleFootnote(WORD, WORD, HWND, BOOL&) {
+ try {
+ m_mk_srv->BeginUndoUnit(L"Create Footnote");
+ if (Document()->execCommand(L"CreateLink",VARIANT_FALSE,_variant_t(L""))==VARIANT_TRUE) {
+ MSHTML::IHTMLTxtRangePtr r(Document()->selection->createRange());
+ MSHTML::IHTMLElementPtr pe(r->parentElement());
+ if (U::scmp(pe->tagName,L"A")==0)
+ pe->className=L"note";
+ }
+ m_mk_srv->EndUndoUnit();
+ ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_SEL_CHANGE),(LPARAM)m_hWnd);
+ ::SendMessage(m_frame,WM_COMMAND,MAKELONG(IDC_HREF,IDN_WANTFOCUS),(LPARAM)m_hWnd);
+ }
+ catch (_com_error&) { }
+ return 0;
+}
+
+bool CFBEView::CheckCommand(WORD wID)
+{
+ if (!m_normalize)
+ return false;
+ switch (wID) {
+ case ID_EDIT_ADD_BODY:
+ return true;
+ case ID_EDIT_ADD_TITLE:
+ return bCall(L"AddTitle",SelectionStructCon());
+ case ID_EDIT_CLONE:
+ return bCall(L"CloneContainer",SelectionStructCon());
+ case ID_STYLE_NORMAL:
+ return bCall(L"StyleNormal",SelectionStructCon());
+ case ID_STYLE_SUBTITLE:
+ return bCall(L"StyleSubtitle",SelectionStructCon());
+ case ID_STYLE_TEXTAUTHOR:
+ return bCall(L"StyleTextAuthor",SelectionStructCon());
+ case ID_EDIT_INS_IMAGE:
+ return bCall(L"InsImage") && !SelectionStructCode() && !SelectionHasTags(L"SPAN");
+ case ID_EDIT_INS_INLINEIMAGE:
+ return bCall(L"InsInlineImage");
+ case ID_EDIT_ADD_IMAGE:
+ return bCall(L"AddImage", SelectionStructCon()) && !SelectionStructCode() && !SelectionHasTags(L"SPAN");
+ case ID_EDIT_ADD_EPIGRAPH:
+ return bCall(L"AddEpigraph",SelectionStructCon());
+ case ID_EDIT_ADD_ANN:
+ return bCall(L"AddAnnotation",SelectionStructCon());
+ case ID_EDIT_SPLIT:
+ return SplitContainer(true);
+ case ID_EDIT_INS_POEM:
+ return InsertPoem(true);
+ case ID_EDIT_INS_CITE:
+ return InsertCite(true);
+ case ID_EDIT_CODE:
+ {
+ _variant_t params[3] =
+ {
+ Document()->selection->createRange().GetInterfacePtr(),
+ SelectionStructCon().GetInterfacePtr(),
+ true
+ };
+ return bCall(L"StyleCode", 3, params);
+ }
+ case ID_INSERT_TABLE:
+ return InsertTable(true);
+ case ID_GOTO_FOOTNOTE:
+ return (GoToFootnote(true) | GoToReference(true));
+ case ID_GOTO_REFERENCE:
+ return GoToReference(true);
+ case ID_EDIT_ADD_TA:
+ return bCall(L"AddTA",SelectionStructCon());
+ case ID_EDIT_MERGE:
+ return bCall(L"MergeContainers",SelectionStructCon());
+ case ID_EDIT_REMOVE_OUTER_SECTION:
+ return bCall(L"RemoveOuterContainer",SelectionStructCon());
+ case ID_STYLE_LINK:
+ case ID_STYLE_NOTE:
+ try {
+ return Document()->queryCommandEnabled(L"CreateLink")==VARIANT_TRUE;
+ }
+ catch (_com_error) { }
+ break;
+ }
+ return false;
+}
+
+bool CFBEView::CheckSetCommand(WORD wID) {
+ if (!m_normalize)
+ return false;
+
+ switch (wID)
+ {
+ case ID_EDIT_CODE:
+ return bCall(L"IsCode", SelectionStructCode());
+ }
+
+ return false;
+}
+
+// changes tracking
+MSHTML::IHTMLDOMNodePtr CFBEView::GetChangedNode() {
+ MSHTML::IMarkupPointerPtr p1,p2;
+ m_mk_srv->CreateMarkupPointer(&p1);
+ m_mk_srv->CreateMarkupPointer(&p2);
+
+ m_mkc->GetAndClearDirtyRange(m_dirtyRangeCookie,p1,p2);
+
+ MSHTML::IHTMLElementPtr e1,e2;
+ p1->CurrentScope(&e1);
+ p2->CurrentScope(&e2);
+ p1.Release();
+ p2.Release();
+
+ while ((bool)e1 && e1!=e2 && e1->contains(e2)!=VARIANT_TRUE)
+ e1=e1->parentElement;
+
+ return e1;
+}
+
+static bool IsEmptyNode(MSHTML::IHTMLDOMNode *node) {
+ if (node->nodeType!=1)
+ return false;
+
+ _bstr_t name(node->nodeName);
+
+ if (U::scmp(name,L"BR")==0)
+ return false;
+
+ if (U::scmp(name,L"P")==0) // the editor uses empty Ps to represent empty lines
+ return false;
+
+ /* if (U::scmp(name,L"EM")==0) // конвертеры иногда обрамляют пробелы тегами и
+ return false;
+
+ if (U::scmp(name,L"STRONG")==0) // конвертеры иногда обрамляют пробелы тегами и
+ return false;*/
+
+ // images are always empty
+ if (U::scmp(name,L"DIV")==0 && U::scmp(MSHTML::IHTMLElementPtr(node)->className,L"image")==0)
+ return false;
+ if (U::scmp(name,L"IMG")==0)
+ return false;
+
+ if (node->hasChildNodes()==VARIANT_FALSE)
+ return true;
+
+ if (U::scmp(name,L"A")==0) // links can be meaningful even if the contain only ws
+ return false;
+
+ if ((bool)node->firstChild->nextSibling)
+ return false;
+
+ if (node->firstChild->nodeType!=3)
+ return false;
+
+ if (U::is_whitespace(node->firstChild->nodeValue.bstrVal))
+ return true;
+
+ return false;
+}
+
+// Remove empty leaf nodes
+static void RemoveEmptyNodes(MSHTML::IHTMLDOMNode *node) {
+ if (node->nodeType!=1)
+ return;
+
+ MSHTML::IHTMLDOMNodePtr cur(node->firstChild);
+ while (cur)
+ {
+ MSHTML::IHTMLDOMNodePtr next;
+ try { next = cur->nextSibling; } catch(...) { return; }
+
+ RemoveEmptyNodes(cur);
+ if(IsEmptyNode(cur))
+ cur->removeNode(VARIANT_TRUE);
+ cur=next;
+ }
+}
+
+// Find parent DIV
+static MSHTML::IHTMLElementPtr GetHP(MSHTML::IHTMLElementPtr hp)
+{
+ while((bool)hp && U::scmp(hp->tagName,L"DIV"))
+ hp = hp->parentElement;
+ return hp;
+}
+
+// Splitting
+bool CFBEView::SplitContainer(bool fCheck)
+{
+ try
+ {
+ MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
+ if(!(bool)rng)
+ return false;
+
+ MSHTML::IHTMLElementPtr pe(rng->parentElement());
+ while((bool)pe && U::scmp(pe->tagName, L"DIV"))
+ pe = pe->parentElement;
+
+ if(!(bool)pe || (U::scmp(pe->className, L"section") && U::scmp(pe->className, L"stanza")))
+ return false;
+
+ MSHTML::IHTMLTxtRangePtr r2(rng->duplicate());
+ r2->moveToElementText(pe);
+
+ if(rng->compareEndPoints(L"StartToStart", r2) == 0)
+ return false;
+
+ MSHTML::IHTMLTxtRangePtr r3(rng->duplicate());
+ r3->collapse(true);
+ MSHTML::IHTMLTxtRangePtr r4(rng->duplicate());
+ r4->collapse(false);
+
+ if(!(bool)pe || GetHP(r3->parentElement()) != pe || GetHP(r4->parentElement()) != pe)
+ return false;
+
+ if(fCheck)
+ return true;
+
+ // At this point we are ready to split
+
+ // Create an undo unit
+ CString name(L"split ");
+ name += (const wchar_t*)pe->className;
+ m_mk_srv->BeginUndoUnit((TCHAR*)(const TCHAR*)name);
+
+ //// Create a new element
+ MSHTML::IHTMLElementPtr ne(Document()->createElement(L"DIV"));
+ ne->className = pe->className;
+ _bstr_t className = pe->className;
+ // SeNS: issue #153
+ _bstr_t id = pe->id;
+ pe->id = L"";
+
+ MSHTML::IHTMLElementPtr peTitle(Document()->createElement(L"DIV"));
+ MSHTML::IHTMLElementCollectionPtr peColl = pe->children;
+ {
+ MSHTML::IHTMLElementPtr peChild = peColl->item(0);
+ if(!U::scmp(peChild->tagName, L"DIV") && !U::scmp(peChild->className, L"title"))
+ peTitle->innerHTML = peChild->outerHTML;
+ else
+ peTitle = NULL;
+ }
+
+ // Create and position markup pointers
+ MSHTML::IMarkupPointerPtr selstart, selend, elembeg, elemend;
+
+ m_mk_srv->CreateMarkupPointer(&selstart);
+ m_mk_srv->CreateMarkupPointer(&selend);
+ m_mk_srv->CreateMarkupPointer(&elembeg);
+ m_mk_srv->CreateMarkupPointer(&elemend);
+
+ MSHTML::IHTMLTxtRangePtr titleRng(rng->duplicate());
+ m_mk_srv->MovePointersToRange(titleRng, selstart, selend);
+ U::ElTextHTML title(titleRng->htmlText, titleRng->text);
+
+ MSHTML::IHTMLTxtRangePtr preRng(rng->duplicate());
+ elembeg->MoveAdjacentToElement(pe, MSHTML::ELEM_ADJ_AfterBegin);
+ m_mk_srv->MoveRangeToPointers(elembeg, selstart, preRng);
+ U::ElTextHTML pre(preRng->htmlText, preRng->text);
+
+ MSHTML::IHTMLElementCollectionPtr peChilds = pe->children;
+ MSHTML::IHTMLElementPtr elLast = peChilds->item(peChilds->length - 1);
+ if(U::scmp(elLast->innerText, L"") == 0)
+ elLast->innerText = L"123";
+
+ MSHTML::IHTMLTxtRangePtr postRng(rng->duplicate());
+ elemend->MoveAdjacentToElement(pe, MSHTML::ELEM_ADJ_BeforeEnd);
+ m_mk_srv->MoveRangeToPointers(selend, elemend, postRng);
+ U::ElTextHTML post(postRng->htmlText, postRng->text);
+
+ // Check if title needs to be created and further text to be copied
+ bool fTitle = !title.text.IsEmpty();
+ bool fContent = !post.html.IsEmpty();
+
+ if(fTitle && title.html.Find(L"") + title.html + CString(L"
");
+ if(fContent && post.html.Find(L"") + post.html + CString(L"
");
+
+ title.html.Remove(L'\r');
+ title.html.Remove(L'\n');
+ post.html.Remove(L'\r');
+ post.html.Remove(L'\n');
+
+ if(post.html.Find(L"
") == 0
+ && post.html.GetLength() > 13
+ && fTitle
+ && title.html.Find(L"
") != title.html.GetLength() -14)
+ post.html.Delete(0, 13);
+ if(post.html.Find(L"123
") != -1)
+ post.html.Replace(L"123
", L"
");
+
+ // Insert it after pe
+ MSHTML::IHTMLElement2Ptr(pe)->insertAdjacentElement(L"afterEnd", ne);
+
+ // Move content or create new
+ if(fContent)
+ {
+ // Create and position destination markup pointer
+ if(post.html == L"
")
+ post.html += L"
";
+ ne->innerHTML = post.html.AllocSysString();
+ // SeNS: issue #153
+ ne->id = id;
+ }
+ else
+ {
+ MSHTML::IHTMLElementPtr para(Document()->createElement(L"P"));
+ MSHTML::IHTMLElement3Ptr(para)->inflateBlock = VARIANT_TRUE;
+ MSHTML::IHTMLElement2Ptr(ne)->insertAdjacentElement(L"beforeEnd", para);
+ }
+
+ // Create and move title if needed
+ if(fTitle)
+ {
+ MSHTML::IHTMLElementPtr elTitle(Document()->createElement(L"DIV"));
+ elTitle->className = L"title";
+ MSHTML::IHTMLElement2Ptr(ne)->insertAdjacentElement(L"afterBegin", elTitle);
+
+ // Create and position destination markup pointer
+ elTitle->innerHTML = title.html.AllocSysString();
+
+ // Delete all containers from title
+ KillDivs(elTitle);
+ KillStyles(elTitle);
+ }
+
+ if(pre.html.Find(L"
";
+ else
+ pre.html = CString(L"") + pre.html + CString(L"
");
+ }
+ pe->innerHTML = pre.html.AllocSysString();
+
+ // Ensure we have good html
+ FixupParagraphs(ne);
+ PackText(ne, Document());
+
+ peColl = pe->children;
+ if(peColl->length == 1)
+ {
+ MSHTML::IHTMLElementPtr peChild = peColl->item(0);
+ if(!U::scmp(peChild->tagName, L"DIV") && !U::scmp(peChild->className, className.GetBSTR()))
+ m_mk_srv->RemoveElement(peChild);
+ }
+
+ MSHTML::IHTMLElementCollectionPtr neColl = ne->children;
+ if(neColl->length == 1)
+ {
+ MSHTML::IHTMLElementPtr neChild = neColl->item(0);
+ if(!U::scmp(neChild->tagName, L"DIV") && !U::scmp(neChild->className, className.GetBSTR()))
+ m_mk_srv->RemoveElement(neChild);
+ }
+
+ CString peTitSect;
+ if(peTitle)
+ {
+ peTitSect = peTitle->innerHTML.GetBSTR();
+ peTitSect += L"
";
+ }
+
+ CString b = pe->innerText;
+ b.Remove(L'\r');
+ b.Remove(L'\n');
+ CString c = peTitle ? peTitle->innerText : L"";
+ c.Remove(L'\r');
+ c.Remove(L'\n');
+
+ if(peTitle && !U::scmp(b, c))
+ pe->innerHTML = peTitSect.AllocSysString();
+
+ // Close undo unit
+ m_mk_srv->EndUndoUnit();
+
+ // Move cursor to newly created item
+ GoTo(ne, false);
+ }
+ catch (_com_error& e)
+ {
+ U::ReportError(e);
+ }
+
+ return false;
+}
+
+// cleaning up html
+static void KillDivs(MSHTML::IHTMLElement2Ptr elem) {
+ MSHTML::IHTMLElementCollectionPtr divs(elem->getElementsByTagName(L"DIV"));
+ while (divs->length>0)
+ MSHTML::IHTMLDOMNodePtr(divs->item(0L))->removeNode(VARIANT_FALSE);
+}
+
+static void KillStyles(MSHTML::IHTMLElement2Ptr elem) {
+ MSHTML::IHTMLElementCollectionPtr ps(elem->getElementsByTagName(L"P"));
+ for (long l=0;llength;++l)
+ CheckError(MSHTML::IHTMLElementPtr(ps->item(l))->put_className(NULL));
+}
+
+//////////////////////////////////////////////////////////////////////////////
+/// @fn static bool MergeEqualHTMLElements(MSHTML::IHTMLDOMNode *node)
+///
+/// функция объединяет стоящие рядом одинаковые HTML элементы
+///
+/// @params MSHTML::IHTMLDOMNode *node [in, out] - нода, внутри которой будет производиться преобразование
+///
+/// @note сливаются следующие элементы: EM, STRONG
+/// при этом пробельные символы, располагающиеся между закрывающем и открывающим тегами остаются, т.е.
+/// 'хороший пример ' преобразуется в 'хороший пример '
+///
+/// @author Ильин Иван @date 31.03.08
+//////////////////////////////////////////////////////////////////////////////
+static bool MergeEqualHTMLElements(MSHTML::IHTMLDOMNode *node, MSHTML::IHTMLDocument2 *doc)
+{
+ if (node->nodeType != 1) // Element node
+ return false;
+
+ bool fRet=false;
+
+
+ MSHTML::IHTMLDOMNodePtr cur(node->firstChild);
+ while ((bool)cur)
+ {
+ MSHTML::IHTMLDOMNodePtr next;
+ try { next = cur->nextSibling; } catch(...) { return false; }
+
+ if (MergeEqualHTMLElements(cur,doc))
+ {
+ cur = node->firstChild;
+ continue;
+ }
+
+ // если нет следующего элемента, то сливать будет несчем
+ if(!(bool)next)
+ return false;
+
+ _bstr_t name(cur->nodeName);
+ MSHTML::IHTMLElementPtr curelem(cur);
+ MSHTML::IHTMLElementPtr nextElem(next);
+
+ if (U::scmp(name,L"EM")==0 || U::scmp(name,L"STRONG")==0)
+ {
+ // отлавливаем ситуацию с пробелом, обрамленным тегами EM т.д.
+ bstr_t curText = curelem->innerText;
+ if(curText.length() == 0 || U::is_whitespace(curelem->innerText))
+ {
+ // удаляем обрамляющие теги
+ MSHTML::IHTMLDOMNodePtr prev = cur->previousSibling;
+ if((bool)prev)
+ {
+ if(prev->nodeType == 3)//text
+ {
+ prev->nodeValue = (bstr_t)prev->nodeValue.bstrVal + curelem->innerText;
+ }
+ else
+ {
+ MSHTML::IHTMLElementPtr prevElem(prev);
+ prevElem->innerHTML = prevElem->innerHTML + curelem->innerText;
+ }
+ cur->removeNode(VARIANT_TRUE);
+ cur = prev;
+ continue;
+ }
+
+ if((bool)next)
+ {
+ MSHTML::IHTMLDOMNodePtr parent = cur->parentNode;
+ if(next->nodeType == 3)//text
+ {
+ next->nodeValue = (bstr_t)curelem->innerText + next->nodeValue.bstrVal;
+ }
+ else
+ {
+ MSHTML::IHTMLElementPtr nextElem(next);
+ nextElem->innerHTML = curelem->innerText + nextElem->innerHTML;
+ }
+ cur->removeNode(VARIANT_TRUE);
+ cur = parent->firstChild;
+ continue;
+ }
+ }
+
+ if(next->nodeType == 3) // TextNode
+ {
+ MSHTML::IHTMLDOMNodePtr afterNext(next->nextSibling);
+ if(!(bool)afterNext)
+ {
+ cur = next;
+ continue;
+ }
+
+ MSHTML::IHTMLElementPtr afterNextElem(afterNext);
+
+ bstr_t afterNextName = afterNext->nodeName;
+ if(U::scmp(name, afterNextName))// если следующий элемент другого типа
+ {
+ cur = next;
+ continue;
+ }
+
+ // проверяем между одинаковыми элементами стоят одни пробелы
+ if(!U::is_whitespace(next->nodeValue.bstrVal))
+ {
+ cur = next;
+ continue; // 123 45678 абсолютно нормальная ситуация
+ }
+
+ // объединяем элементы
+ MSHTML::IHTMLElementPtr newelem(doc->createElement(name));
+ MSHTML::IHTMLDOMNodePtr newnode(newelem);
+ newelem->innerHTML = curelem->innerHTML + next->nodeValue.bstrVal + afterNextElem->innerHTML;
+ cur->replaceNode(newnode);
+ afterNext->removeNode(VARIANT_TRUE);
+ next->removeNode(VARIANT_TRUE);
+ cur = newnode;
+ fRet=true;
+ }
+ else
+ {
+ bstr_t nextName(next->nodeName);
+ if(U::scmp(name, nextName))// если следующий элемент другого типа
+ {
+ cur = next;
+ continue;
+ }
+
+ // объединяем элементы
+ MSHTML::IHTMLElementPtr newelem(doc->createElement(name));
+ MSHTML::IHTMLDOMNodePtr newnode(newelem);
+ newelem->innerHTML = curelem->innerHTML + nextElem->innerHTML;
+ cur->replaceNode(newnode);
+ next->removeNode(VARIANT_TRUE);
+ cur = newnode;
+ fRet=true;
+ continue;
+ }
+ }
+ cur=next;
+ }
+ return fRet;
+}
+static bool RemoveUnk(MSHTML::IHTMLDOMNode *node, MSHTML::IHTMLDocument2 *doc) {
+ if (node->nodeType!=1) // Element node
+ return false;
+
+ bool fRet=false;
+
+restart:
+ MSHTML::IHTMLDOMNodePtr cur(node->firstChild);
+ while ((bool)cur)
+ {
+ MSHTML::IHTMLDOMNodePtr next;
+ try { next = cur->nextSibling; } catch(...) { return false; }
+
+ if (RemoveUnk(cur,doc))
+ goto restart;
+
+ _bstr_t name(cur->nodeName);
+ MSHTML::IHTMLElementPtr curelem(cur);
+
+ if (U::scmp(name,L"B")==0 || U::scmp(name,L"I")==0) {
+ const wchar_t *newname=U::scmp(name,L"B")==0 ? L"STRONG" : L"EM";
+ MSHTML::IHTMLElementPtr newelem(doc->createElement(newname));
+ MSHTML::IHTMLDOMNodePtr newnode(newelem);
+ newelem->innerHTML=curelem->innerHTML;
+ cur->replaceNode(newnode);
+ cur=newnode;
+ fRet=true;
+ goto restart;
+ }
+
+ CString text;
+ if (curelem != NULL)
+ text.SetString(curelem->outerHTML);
+
+ if (U::scmp(name,L"P") && U::scmp(name,L"STRONG") &&
+ U::scmp(name,L"STRIKE") && U::scmp(name,L"SUP") && U::scmp(name,L"SUB") &&
+ U::scmp(name,L"EM") && U::scmp(name,L"A") &&
+ (U::scmp(name,L"SPAN") || U::scmp(curelem->className, L"code")) &&
+ U::scmp(name,L"#text") && U::scmp(name,L"BR") &&
+ (U::scmp(name,L"IMG") || U::scmp(curelem->parentElement->className, L"image") &&
+ // Added by SeNS: inline images support
+ (U::scmp(name,L"SPAN") || U::scmp(curelem->className, L"image"))))
+ {
+ if (U::scmp(name,L"DIV")==0) {
+ _bstr_t cls(curelem->className);
+ _bstr_t id(curelem->id);
+ if (!(U::scmp(cls,L"body") && U::scmp(cls,L"section") &&
+ U::scmp(cls,L"table") && U::scmp(cls,L"tr") && U::scmp(cls,L"th") && U::scmp(cls,L"td") &&
+ U::scmp(cls,L"output") && U::scmp(cls,L"part") && U::scmp(cls,L"output-document-class") &&
+ U::scmp(cls,L"annotation") && U::scmp(cls,L"title") && U::scmp(cls,L"epigraph") &&
+ U::scmp(cls,L"poem") && U::scmp(cls,L"stanza") && U::scmp(cls,L"cite") &&
+ U::scmp(cls,L"date") &&
+ U::scmp(cls,L"history") && U::scmp(cls,L"image")&&
+ U::scmp(cls,L"code") &&
+ U::scmp(id,L"fbw_desc") && U::scmp(id,L"fbw_body") && U::scmp(id,L"fbw_updater")))
+ goto ok;
+ }
+
+ CElementDescriptor* ED;
+ if(_EDMnr.GetElementDescriptor(cur, &ED))
+ goto ok;
+ MSHTML::IHTMLDOMNodePtr ce(cur->previousSibling);
+ cur->removeNode(VARIANT_FALSE);
+ if (ce)
+ next=ce->nextSibling;
+ else
+ next=node->firstChild;
+ }
+ok:
+
+ cur=next;
+ }
+ return fRet;
+}
+
+// move the paragraph up one level
+void MoveUp(bool fCopyFmt,MSHTML::IHTMLDOMNodePtr& node) {
+ MSHTML::IHTMLDOMNodePtr parent(node->parentNode);
+ MSHTML::IHTMLElement2Ptr elem(parent);
+
+ // clone parent (it can be A/EM/STRONG/SPAN)
+ if (fCopyFmt) {
+ MSHTML::IHTMLDOMNodePtr clone(parent->cloneNode(VARIANT_FALSE));
+ while ((bool)node->firstChild)
+ clone->appendChild(node->firstChild);
+ node->appendChild(clone);
+ }
+
+ // clone parent once more and move siblings after node to it
+ if ((bool)node->nextSibling) {
+ MSHTML::IHTMLDOMNodePtr clone(parent->cloneNode(VARIANT_FALSE));
+ while ((bool)node->nextSibling)
+ clone->appendChild(node->nextSibling);
+ elem->insertAdjacentElement(L"afterEnd",MSHTML::IHTMLElementPtr(clone));
+ if (U::scmp(parent->nodeName,L"P")==0)
+ MSHTML::IHTMLElement3Ptr(clone)->inflateBlock=VARIANT_TRUE;
+ }
+
+ // now move node to parent level, the tree may be in some weird state
+ node->removeNode(VARIANT_TRUE); // delete from tree
+ node=elem->insertAdjacentElement(L"afterEnd",MSHTML::IHTMLElementPtr(node));
+}
+
+void BubbleUp(MSHTML::IHTMLDOMNode *node,const wchar_t *name) {
+ MSHTML::IHTMLElement2Ptr elem(node);
+ MSHTML::IHTMLElementCollectionPtr elements(elem->getElementsByTagName(name));
+ long len=elements->length;
+ for (long i=0;iitem(i));
+ if (!(bool)ce)
+ break;
+ for (int ll=0;ce->parentNode!=node && ll<30;++ll)
+ MoveUp(true,ce);
+ MoveUp(false,ce);
+ }
+}
+
+#if (1)
+// split paragraphs containing BR elements
+static void SplitBRs(MSHTML::IHTMLElement2Ptr elem)
+{
+ CString text = MSHTML::IHTMLElementPtr(elem)->outerHTML;
+ if (text.Replace(L" ", L"
") > 0)
+ MSHTML::IHTMLElementPtr(elem)->outerHTML = text.AllocSysString();
+}
+#else
+static void SplitBRs(MSHTML::IHTMLElement2Ptr elem) {
+ MSHTML::IHTMLElementCollectionPtr BRs(elem->getElementsByTagName(L"BR"));
+ while (BRs->length>0) {
+ MSHTML::IHTMLDOMNodePtr ce(BRs->item(0L));
+ if (!(bool)ce)
+ break;
+ for (;;) {
+ MSHTML::IHTMLDOMNodePtr parent(ce->parentNode);
+ if (!(bool)parent) // no parent? huh?
+ goto blowit;
+ _bstr_t name(parent->nodeName);
+ if (U::scmp(name,L"P")==0 || U::scmp(name,L"DIV")==0)
+ break;
+ if (U::scmp(name,L"BODY")==0)
+ goto blowit;
+ MoveUp(false,ce);
+ }
+ MoveUp(false,ce);
+blowit:
+ ce->removeNode(VARIANT_TRUE);
+ }
+}
+#endif
+
+// this sub should locate any nested paragraphs and bubble them up
+static void RelocateParagraphs(MSHTML::IHTMLDOMNode *node) {
+ if (node->nodeType!=1)
+ return;
+
+ MSHTML::IHTMLDOMNodePtr cur(node->firstChild);
+ while (cur) {
+ if (cur->nodeType==1) {
+ if (!U::scmp(cur->nodeName,L"P")) {
+ BubbleUp(cur,L"P");
+ BubbleUp(cur,L"DIV");
+ } else
+ RelocateParagraphs(cur);
+ }
+ cur=cur->nextSibling;
+ }
+}
+
+static bool IsStanza(MSHTML::IHTMLDOMNode *node) {
+ MSHTML::IHTMLElementPtr elem(node);
+ return U::scmp(elem->className,L"stanza")==0;
+}
+
+// Move text content in DIV items to P elements, so DIVs can
+// contain P and DIV only
+static void PackText(MSHTML::IHTMLElement2Ptr elem, MSHTML::IHTMLDocument2* doc)
+{
+ MSHTML::IHTMLElementCollectionPtr elements(elem->getElementsByTagName(L"DIV"));
+ for(long i = 0; i < elements->length; ++i)
+ {
+ MSHTML::IHTMLDOMNodePtr div(elements->item(i));
+ if(U::scmp(MSHTML::IHTMLElementPtr(div)->className, L"image") == 0)
+ continue;
+ MSHTML::IHTMLDOMNodePtr cur(div->firstChild);
+ while((bool)cur)
+ {
+ _bstr_t cur_name(cur->nodeName);
+ if (U::scmp(cur_name, L"P") && U::scmp(cur_name, L"DIV"))
+ {
+ // create a paragraph from a run of !P && !DIV
+ MSHTML::IHTMLElementPtr newp(doc->createElement(L"P"));
+ MSHTML::IHTMLDOMNodePtr newn(newp);
+ cur->replaceNode(newn);
+ newn->appendChild(cur);
+ while ((bool)newn->nextSibling)
+ {
+ cur_name = newn->nextSibling->nodeName;
+ if (U::scmp(cur_name, L"P") == 0 || U::scmp(cur_name, L"DIV") == 0)
+ break;
+ newn->appendChild(newn->nextSibling);
+ }
+ cur = newn->nextSibling;
+ }
+ else
+ cur = cur->nextSibling;
+ }
+ }
+}
+
+static void FixupLinks(MSHTML::IHTMLDOMNode *dom) {
+ MSHTML::IHTMLElement2Ptr elem(dom);
+
+ if (!(bool)elem)
+ return;
+
+ MSHTML::IHTMLElementCollectionPtr coll(elem->getElementsByTagName(L"a"));
+ if (!(bool)coll)
+ return;
+
+ if (coll->length == 0) coll = elem->getElementsByTagName(L"A");
+
+ for (long l=0;llength;++l) {
+ MSHTML::IHTMLElementPtr a(coll->item(l));
+ if (!(bool)a)
+ continue;
+
+ _variant_t href(a->getAttribute(L"href",2));
+ if (V_VT(&href)==VT_BSTR && V_BSTR(&href) &&
+ ::SysStringLen(V_BSTR(&href))>11 &&
+ memcmp(V_BSTR(&href),L"file://",6*sizeof(wchar_t))==0)
+ {
+ wchar_t* pos = wcschr((wchar_t*)V_BSTR(&href), L'#');
+ if(!pos)
+ continue;
+ a->setAttribute(L"href",pos,0);
+ }
+ }
+}
+
+bool CFBEView::InsertPoem(bool fCheck)
+{
+ try
+ {
+ MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
+ if(!(bool)rng)
+ return false;
+
+ MSHTML::IHTMLElementPtr pe(GetHP(rng->parentElement()));
+ if(!(bool)pe)
+ return false;
+
+ // Get parents for start and end ranges and ensure they are the same as pe
+ MSHTML::IHTMLTxtRangePtr tr(rng->duplicate());
+ tr->collapse(VARIANT_TRUE);
+ if (GetHP(tr->parentElement()) != pe)
+ return false;
+
+ // Check if it possible to insert a poem there
+ _bstr_t cls(pe->className);
+ if(U::scmp(cls, L"section")
+ && U::scmp(cls, L"epigraph")
+ && U::scmp(cls, L"annotation")
+ && U::scmp(cls, L"history")
+ && U::scmp(cls, L"cite"))
+ return false;
+
+ // Preventing double expanding whether checked or actual executed
+ MSHTML::IHTMLElementPtr elBegin, elEnd;
+ MSHTML::IHTMLDOMNodePtr begin, end;
+ if(!ExpandTxtRangeToParagraphs(rng, elBegin, elEnd))
+ return false;
+ else
+ {
+ begin = elBegin;
+ end = elEnd;
+ }
+
+ // All checks passed
+ if(fCheck)
+ return true;
+
+ m_mk_srv->BeginUndoUnit(L"insert poem");
+
+ CString rngHTML;
+ MSHTML::IHTMLDOMNodePtr sibling = begin;
+ do
+ {
+ rngHTML += MSHTML::IHTMLElementPtr(sibling)->outerHTML.GetBSTR();
+ if(sibling == end)
+ break;
+ }
+ while((sibling = sibling->nextSibling));
+
+ MSHTML::IHTMLElementPtr ne(Document()->createElement(L""));
+
+ if(!U::scmp(rng->text.GetBSTR(), L""))
+ {
+ MSHTML::IHTMLElementPtr se(Document()->createElement(L"
"));
+ se->innerHTML = L"
";
+ ne->innerHTML = se->outerHTML;
+ }
+ else
+ {
+ MSHTML::IHTMLElementPtr acc(Document()->createElement(L"DIV"));
+ acc->innerHTML = rngHTML.AllocSysString();
+
+ MSHTML::IHTMLElementCollectionPtr coll = acc->children;
+ bool trim = true;
+
+ CString stanzaHTML;
+ for(int i = 0; i < coll->length; ++i)
+ {
+ MSHTML::IHTMLElementPtr curr = coll->item(i);
+
+ CString line = curr->innerText;
+ // changed by SeNS: issue #61
+ if (line.Trim().IsEmpty())
+ {
+ if(trim)
+ continue;
+ else
+ {
+ MSHTML::IHTMLElementPtr se(Document()->createElement(L"
"));
+ se->innerHTML = stanzaHTML.AllocSysString();
+ MSHTML::IHTMLElement2Ptr(ne)->insertAdjacentElement(L"beforeEnd", se);
+ stanzaHTML = L"";
+ trim = true;
+ }
+ }
+ else
+ {
+ if(!U::scmp(curr->tagName, L"DIV"))
+ {
+ if(curr->innerText.GetBSTR())
+ {
+ stanzaHTML += CString(L"
") + curr->innerText.GetBSTR() + CString(L"
");
+ }
+ else
+ continue;
+ }
+ else
+ {
+ stanzaHTML += curr->outerHTML.GetBSTR();
+ }
+
+ trim = false;
+ }
+ }
+
+ if(stanzaHTML != "")
+ {
+ MSHTML::IHTMLElementPtr se(Document()->createElement(L"
"));
+ se->innerHTML = stanzaHTML.AllocSysString();
+ MSHTML::IHTMLElement2Ptr(ne)->insertAdjacentElement(L"beforeEnd", se);
+ }
+ }
+
+
+ MSHTML::IHTMLDOMNodePtr(pe)->insertBefore((MSHTML::IHTMLDOMNodePtr)ne, begin.GetInterfacePtr());
+
+ while(begin != end)
+ {
+ sibling = begin->nextSibling;
+ begin->removeNode(VARIANT_TRUE);
+ begin = sibling;
+ }
+ end->removeNode(VARIANT_TRUE);
+
+ FixupParagraphs(pe);
+ PackText(pe, Document());
+
+ rng->moveToElementText(ne);
+ rng->collapse(false);
+ rng->select();
+
+ m_mk_srv->EndUndoUnit();
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+ return true;
+}
+
+bool CFBEView::InsertCite(bool fCheck)
+{
+ try
+ {
+ MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
+ if(!(bool)rng)
+ return false;
+
+ MSHTML::IHTMLElementPtr pe(GetHP(rng->parentElement()));
+ if(!(bool)pe)
+ return false;
+
+ // Get parents for start and end ranges and ensure they are the same as pe
+ MSHTML::IHTMLTxtRangePtr tr(rng->duplicate());
+ tr->collapse(VARIANT_TRUE);
+ if (GetHP(tr->parentElement()) != pe)
+ return false;
+
+ // Check if it possible to insert a cite there
+ _bstr_t cls(pe->className);
+ if(U::scmp(cls, L"section")
+ && U::scmp(cls, L"epigraph")
+ && U::scmp(cls, L"annotation")
+ && U::scmp(cls, L"history"))
+ return false;
+
+ // Preventing double expanding whether checked or actual executed
+ MSHTML::IHTMLElementPtr elBegin, elEnd;
+ MSHTML::IHTMLDOMNodePtr begin, end;
+ if(!ExpandTxtRangeToParagraphs(rng, elBegin, elEnd))
+ return false;
+ else
+ {
+ begin = elBegin;
+ end = elEnd;
+ }
+
+ // All checks passed
+ if(fCheck)
+ return true;
+
+ m_mk_srv->BeginUndoUnit(L"insert cite");
+
+ CString rngHTML;
+ MSHTML::IHTMLDOMNodePtr sibling = begin;
+ do
+ {
+ rngHTML += MSHTML::IHTMLElementPtr(sibling)->outerHTML.GetBSTR();
+ if(sibling == end)
+ break;
+ }
+ while((sibling = sibling->nextSibling));
+
+ // Create cite
+ MSHTML::IHTMLElementPtr ne(Document()->createElement(L"DIV"));
+ ne->className = L"cite";
+
+ MSHTML::IHTMLElementPtr acc(Document()->createElement(L"DIV"));
+ acc->innerHTML = rngHTML.AllocSysString();
+
+ MSHTML::IHTMLElementCollectionPtr coll = acc->children;
+
+ CString citeHTML;
+ for(int i = 0; i < coll->length; ++i)
+ {
+ MSHTML::IHTMLElementPtr curr = coll->item(i);
+ if(!U::scmp(curr->tagName, L"DIV")
+ && U::scmp(curr->className, L"table")
+ && U::scmp(curr->className, L"poem"))
+ {
+ if(curr->innerText.GetBSTR())
+ {
+ citeHTML += CString(L"
") + curr->innerText.GetBSTR() + CString(L"
");
+ }
+ else
+ continue;
+ }
+ else
+ {
+ citeHTML += curr->outerHTML.GetBSTR();
+ }
+ }
+
+ ne->innerHTML = citeHTML.AllocSysString();
+
+ MSHTML::IHTMLDOMNodePtr(pe)->insertBefore((MSHTML::IHTMLDOMNodePtr)ne, begin.GetInterfacePtr());
+
+ while(begin != end)
+ {
+ sibling = begin->nextSibling;
+ begin->removeNode(VARIANT_TRUE);
+ begin = sibling;
+ }
+ end->removeNode(VARIANT_TRUE);
+
+ FixupParagraphs(pe);
+ PackText(pe, Document());
+
+ rng->moveToElementText(ne);
+ rng->collapse(false);
+ rng->select();
+
+ m_mk_srv->EndUndoUnit();
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+ return true;
+}
+
+CString CFBEView::GetClearedRangeText(const MSHTML::IHTMLTxtRangePtr &rng)const
+{
+ CString org_text = rng->htmlText;
+
+ org_text.Replace(L"\r\n", L"\n");
+ org_text.Replace(L" \n", L" ");
+ org_text.Replace(L"\n ", L" ");
+ org_text.Replace(L"\n", L" ");
+
+ while(org_text[org_text.GetLength() - 1] == L' ')
+ org_text = org_text.Left(org_text.GetLength() - 1);
+ while(org_text[0] == L' ')
+ org_text = org_text.Right(org_text.GetLength() - 1);
+ org_text.Replace(L"> <", L">\r\n<");
+ return org_text;
+}
+
+// searching
+void CFBEView::StartIncSearch() {
+ try {
+ m_is_start=Document()->selection->createRange();
+ m_is_start->collapse(VARIANT_TRUE);
+ }
+ catch (_com_error&) {
+ }
+}
+
+void CFBEView::CancelIncSearch() {
+ if (m_is_start) {
+ m_is_start->raw_select();
+ m_is_start.Release();
+ }
+}
+
+// script calls
+void CFBEView::ImgSetURL(IDispatch *elem,const CString& url) {
+ try {
+ CComDispatchDriver dd(Script());
+ _variant_t ve(elem);
+ _variant_t vu((const TCHAR *)url);
+ dd.Invoke2(L"ImgSetURL",&ve,&vu);
+ }
+ catch (_com_error&) { }
+}
+
+IDispatchPtr CFBEView::Call(const wchar_t *name) {
+ try {
+ CComDispatchDriver dd(Script());
+ _variant_t ret;
+ _variant_t vt2((false));
+ dd.Invoke1(name,&vt2,&ret);
+ if (V_VT(&ret)==VT_DISPATCH)
+ return V_DISPATCH(&ret);
+ }
+ catch (_com_error&) { }
+ return IDispatchPtr();
+}
+IDispatchPtr CFBEView::Call(const wchar_t *name,IDispatch *pDisp) {
+ try {
+ CComDispatchDriver dd(Script());
+ _variant_t vt;
+ if (pDisp)
+ vt=pDisp;
+ _variant_t vt2(false);
+ _variant_t ret;
+ dd.Invoke2(name,&vt,&vt2,&ret);
+ if (V_VT(&ret)==VT_DISPATCH)
+ return V_DISPATCH(&ret);
+ }
+ catch (_com_error&) { }
+ return IDispatchPtr();
+}
+static bool vt2bool(const _variant_t& vt) {
+ if (V_VT(&vt)==VT_DISPATCH)
+ return V_DISPATCH(&vt)!=0;
+ if (V_VT(&vt)==VT_BOOL)
+ return V_BOOL(&vt)==VARIANT_TRUE;
+ if (V_VT(&vt)==VT_I4)
+ return V_I4(&vt)!=0;
+ if (V_VT(&vt)==VT_UI4)
+ return V_UI4(&vt)!=0;
+ return false;
+}
+
+bool CFBEView::bCall(const wchar_t *name, int nParams, VARIANT* params)
+{
+ try
+ {
+ CComDispatchDriver dd(Script());
+ _variant_t ret;
+ dd.InvokeN(name, params, nParams, &ret);
+ return vt2bool(ret);
+ }
+ catch(_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return false;
+}
+
+bool CFBEView::bCall(const wchar_t *name,IDispatch *pDisp) {
+ try {
+ CComDispatchDriver dd(Script());
+ _variant_t vt;
+ if (pDisp)
+ vt=pDisp;
+ _variant_t vt2(true);
+ _variant_t ret;
+ dd.Invoke2(name,&vt,&vt2,&ret);
+ return vt2bool(ret);
+ }
+ catch (_com_error&) { }
+ return false;
+}
+
+bool CFBEView::bCall(const wchar_t *name) {
+ try {
+ CComDispatchDriver dd(Script());
+ _variant_t vt2(true);
+ _variant_t ret;
+ dd.Invoke1(name,&vt2,&ret);
+ return vt2bool(ret);
+ }
+ catch (_com_error&) { }
+ return false;
+}
+
+// utilities
+static CString GetPath(MSHTML::IHTMLElementPtr elem) {
+ try {
+ if (!(bool)elem)
+ return CString();
+ CString path;
+ while (elem) {
+ CString cur((const wchar_t *)elem->tagName);
+ CString cid((const wchar_t *)elem->id);
+ if (cur==_T("BODY"))
+ return path;
+ if(cid == _T("fbw_body"))
+ return path;
+ _bstr_t cls(elem->className);
+ if (cls.length()>0)
+ cur=(const wchar_t *)cls;
+ _bstr_t id(elem->id);
+ if (id.length()>0) {
+ cur+=_T(':');
+ cur+=(const wchar_t *)id;
+ }
+ if (!path.IsEmpty())
+ path=_T('/')+path;
+ path=cur+path;
+ elem=elem->parentElement;
+ }
+ return path;
+ }
+ catch (_com_error&) { }
+ return CString();
+}
+
+CString CFBEView::SelPath() {
+ return GetPath(SelectionContainer());
+}
+
+void CFBEView::GoTo(MSHTML::IHTMLElement *e,bool fScroll) {
+ if (!e)
+ return;
+
+ if (fScroll)
+ e->scrollIntoView(VARIANT_TRUE);
+
+ MSHTML::IHTMLTxtRangePtr r(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
+ r->moveToElementText(e);
+ r->collapse(VARIANT_TRUE);
+ // all m$ editors like to position the pointer at the end of the preceding element,
+ // which sucks. This workaround seems to work most of the time.
+ if (e!=r->parentElement() && r->move(L"character",1)==1)
+ r->move(L"character",-1);
+
+ r->select();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionContainerImp()
+{
+ try
+ {
+ IDispatchPtr selrange(Document()->selection->createRange());
+ MSHTML::IHTMLTxtRangePtr range(selrange);
+ if(range)
+ {
+ return range->parentElement();
+ }
+ MSHTML::IHTMLControlRangePtr coll(selrange);
+ if((bool)coll)
+ return coll->commonParentElement();
+ }
+ catch(_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionAnchor() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ _bstr_t tn(cur->tagName);
+ if (U::scmp(tn,L"A")==0 || (U::scmp(tn,L"DIV")==0 && U::scmp(cur->className,L"image")==0))
+ return cur;
+ // Added by SeNS - inline images
+ if (U::scmp(tn,L"A")==0 || (U::scmp(tn,L"SPAN")==0 && U::scmp(cur->className,L"image")==0))
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) { }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionAnchor(MSHTML::IHTMLElementPtr cur) {
+ try {
+ while (cur) {
+ _bstr_t tn(cur->tagName);
+ if (U::scmp(tn,L"A")==0 || (U::scmp(tn,L"DIV")==0 && U::scmp(cur->className,L"image")==0))
+ return cur;
+ // Added by SeNS - inline images
+ if (U::scmp(tn,L"A")==0 || (U::scmp(tn,L"SPAN")==0 && U::scmp(cur->className,L"image")==0))
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) { }
+ return MSHTML::IHTMLElementPtr();
+}
+
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionStructCon() {
+ try
+ {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur)
+ {
+ if (U::scmp(cur->tagName, L"P") == 0 || U::scmp(cur->tagName, L"DIV") == 0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionStructNearestCon()
+{
+ try
+ {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ if(cur)
+ {
+ return cur;
+ }
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionStructCode() {
+ try
+ {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while(cur)
+ {
+ // changed by SeNS: inline images also have a tag SPAN
+ if((U::scmp(cur->tagName, L"SPAN") == 0) && (U::scmp(cur->className,L"image")!=0))
+ return cur;
+ cur = cur->parentElement;
+ }
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return MSHTML::IHTMLElementPtr();
+}
+
+// Modification by Pilgrim
+MSHTML::IHTMLElementPtr CFBEView::SelectionStructSection() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"section")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionStructImage() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ // changed by SeNS: inline images have a tag SPAN, regular tag DIV
+ if ((U::scmp(cur->className,L"image")==0) && (U::scmp(cur->tagName,L"SPAN")!=0))
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionStructTable() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"table")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionStructTableCon() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsStyleT() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ _bstr_t style(AU::GetAttrB(cur,L"fbstyle"));
+ if (U::scmp(cur->className,L"table")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsStyleTB(_bstr_t& style) {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"table")==0){
+ style = AU::GetAttrB(cur,L"fbstyle");
+ return cur;
+ }
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsStyle() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ _bstr_t style(AU::GetAttrB(cur,L"fbstyle"));
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsStyleB(_bstr_t& style) {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
+ style = AU::GetAttrB(cur,L"fbstyle");
+ return cur;
+ }
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsColspan() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsColspanB(_bstr_t& colspan) {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
+ colspan = AU::GetAttrB(cur,L"fbcolspan");
+ return cur;
+ }
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsRowspan() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsRowspanB(_bstr_t& rowspan) {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
+ rowspan = AU::GetAttrB(cur,L"fbrowspan");
+ return cur;
+ }
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsAlignTR() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"tr")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsAlignTRB(_bstr_t& align) {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"tr")==0){
+ align = AU::GetAttrB(cur,L"fbalign");
+ return cur;
+ }
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsAlign() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"tr")==0 || U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsAlignB(_bstr_t& align) {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"tr")==0 || U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
+ align = AU::GetAttrB(cur,L"fbalign");
+ return cur;
+ }
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsVAlign() {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0)
+ return cur;
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+MSHTML::IHTMLElementPtr CFBEView::SelectionsVAlignB(_bstr_t& valign) {
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ while (cur) {
+ if (U::scmp(cur->className,L"th")==0 || U::scmp(cur->className,L"td")==0){
+ valign = AU::GetAttrB(cur,L"fbvalign");
+ return cur;
+ }
+ cur=cur->parentElement;
+ }
+ }
+ catch (_com_error&) {
+ }
+ return MSHTML::IHTMLElementPtr();
+}
+
+void CFBEView::Normalize(MSHTML::IHTMLDOMNodePtr dom) {
+ try {
+ //MSHTML::IHTMLElementCollectionPtr col = dom->childNodes;
+ MSHTML::IHTMLDOMNodePtr el = dom->firstChild;
+ bool found = false;
+
+ // нормализовать нужно только body документа
+ while(el)
+ {
+ MSHTML::IHTMLElementPtr hel(el);
+
+ if(U::scmp(hel->id, L"fbw_body") == 0)
+ {
+ found = true;
+ break;
+ }
+ el = el->nextSibling;
+ }
+
+ if(!found)
+ {
+ return;
+ }
+
+ // wrap in an undo unit
+ m_mk_srv->BeginUndoUnit(L"Normalize");
+
+ // remove unsupported elements
+ RemoveUnk(el,Document());
+
+ MergeEqualHTMLElements(el, Document());
+ // get rid of nested DIVs and Ps
+ RelocateParagraphs(el);
+ // delete empty nodes
+
+ RemoveEmptyNodes(el);
+ // make sure text appears under Ps only
+ PackText(el,Document());
+ // get rid of nested Ps once more
+ RelocateParagraphs(el);
+ // convert BRs to separate paragraphs
+ SplitBRs(el);
+ // delete empty nodes again
+ RemoveEmptyNodes(el);
+ // fixup links
+ FixupLinks(el);
+
+ m_mk_srv->EndUndoUnit();
+ }
+ catch (_com_error& e) {
+ U::ReportError(e);
+ }
+}
+
+static void FixupParagraphs(MSHTML::IHTMLElement2Ptr elem)
+{
+ MSHTML::IHTMLElementCollectionPtr pp(elem->getElementsByTagName(L"P"));
+ for(long l = 0; l < pp->length; ++l)
+ MSHTML::IHTMLElement3Ptr(pp->item(l))->inflateBlock = VARIANT_TRUE;
+}
+
+LRESULT CFBEView::OnPaste(WORD, WORD, HWND, BOOL&)
+{
+ try
+ {
+ m_mk_srv->BeginUndoUnit(L"Paste");
+ ++m_enable_paste;
+
+ // added by SeNS: process clipboard and change nbsp
+ if (OpenClipboard())
+ {
+ // process text
+ if ( IsClipboardFormatAvailable(CF_TEXT) || IsClipboardFormatAvailable(CF_UNICODETEXT))
+ {
+ if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
+ {
+ HANDLE hData = GetClipboardData( CF_UNICODETEXT );
+ TCHAR *buffer = (TCHAR*)GlobalLock( hData );
+ CString fromClipboard(buffer);
+ GlobalUnlock( hData );
+
+ fromClipboard.Replace( L"\u00A0", _Settings.GetNBSPChar());
+
+ HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, (fromClipboard.GetLength()+1)*sizeof(TCHAR));
+ buffer = (TCHAR*)GlobalLock(clipbuffer);
+ wcscpy(buffer, fromClipboard);
+ GlobalUnlock( clipbuffer );
+ SetClipboardData(CF_UNICODETEXT, clipbuffer);
+ }
+ }
+ // process bitmaps from clipboard
+ else if ( IsClipboardFormatAvailable(CF_BITMAP))
+ {
+ HBITMAP hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
+ TCHAR szPathName[MAX_PATH] = { 0 };
+ TCHAR szFileName[MAX_PATH] = { 0 };
+ if (::GetTempPath(sizeof(szPathName)/sizeof(TCHAR), szPathName))
+ if (::GetTempFileName(szPathName, L"img", ::GetTickCount(), szFileName))
+ {
+ int quality = _Settings.GetJpegQuality();
+
+ CString fileName(szFileName);
+ FBE::CImageEx image;
+ image.Attach(hBitmap);
+
+ if (_Settings.GetImageType() == 0)
+ {
+ fileName.Replace(L".tmp", L".png");
+ image.Save(fileName, Gdiplus::ImageFormatPNG);
+ }
+ else
+ {
+ fileName.Replace(L".tmp", L".jpg");
+ // set encoder quality
+ Gdiplus::EncoderParameters encoderParameters[1];
+ encoderParameters[0].Count = 1;
+ encoderParameters[0].Parameter[0].Guid = Gdiplus::EncoderQuality;
+ encoderParameters[0].Parameter[0].NumberOfValues = 1;
+ encoderParameters[0].Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong;
+ encoderParameters[0].Parameter[0].Value = &quality;
+ image.Save(fileName, Gdiplus::ImageFormatJPEG, &encoderParameters[0]);
+ }
+
+ AddImage(fileName, true);
+ ::DeleteFile(fileName);
+ }
+ }
+ CloseClipboard();
+ }
+
+ IOleCommandTargetPtr(m_browser)->Exec(&CGID_MSHTML, IDM_PASTE, 0, NULL, NULL);
+ --m_enable_paste;
+ if(m_normalize)
+ Normalize(Document()->body);
+ m_mk_srv->EndUndoUnit();
+ }
+ catch(_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return 0;
+}
+
+// searching
+bool CFBEView::DoSearch(bool fMore)
+{
+#ifndef USE_PCRE
+ if(m_fo.match)
+ m_fo.match.Release();
+#endif
+ if(m_fo.pattern.IsEmpty())
+ {
+ if(m_is_start)
+ m_is_start->raw_select();
+ return true;
+ }
+
+ // added by SeNS
+ if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
+ m_fo.pattern.Replace( L"\u00A0", _Settings.GetNBSPChar());
+
+ return m_fo.fRegexp ? DoSearchRegexp(fMore) : DoSearchStd(fMore);
+}
+
+// Removes HTML tags
+void RemoveTags(CString &src)
+{
+ int openTag = 0, closeTag=0;
+ while (openTag != -1)
+ {
+ openTag = src.Find(L"<", 0);
+ closeTag = src.Find(L">", openTag+1);
+ if (openTag != -1 && closeTag > openTag)
+ src.Delete(openTag, closeTag-openTag+1);
+ }
+}
+
+// Returns text offset including inline images (treated as a 3 chars each)
+int CFBEView::TextOffset(MSHTML::IHTMLTxtRange *rng, AU::ReMatch rm, CString txt, CString htmlTxt)
+{
+ CString text(txt);
+ CString match = rm->Value;
+ // special fix for "Words" dialog
+ match = match.TrimRight(10);
+ match = match.TrimRight(13);
+ int num = 0, pos = 1;
+ if (text.IsEmpty()) text.SetString(rng->text);
+ while (num < text.GetLength())
+ {
+ num = text.Find (match, num);
+ if ((num == rm->FirstIndex) || (num == -1)) break;
+ num += 1;
+ pos++;
+ }
+ CString html(htmlTxt);
+ if (html.IsEmpty()) html.SetString(rng->htmlText);
+
+ // change
collapse(VARIANT_TRUE);
+ tr->move(L"character",rm->FirstIndex+numImages);
+ if (tr->moveStart(L"character",1)==1)
+ tr->move(L"character",-1);
+ tr->moveEnd(L"character",rm->Length);
+ // set focus to editor if selection empty
+ if (!rm->Length)
+ SetFocus();
+ tr->select();
+ m_fo.match=rm;
+}
+
+bool CFBEView::DoSearchRegexp(bool fMore)
+{
+ try
+ {
+ // well, try to compile it first
+ AU::RegExp re;
+#ifdef USE_PCRE
+ re = new AU::IRegExp2();
+#else
+ CheckError(re.CreateInstance(L"VBScript.RegExp"));
+#endif
+ re->IgnoreCase = m_fo.flags & 4 ? VARIANT_FALSE : VARIANT_TRUE;
+ re->Global = VARIANT_TRUE;
+ re->Pattern = (const wchar_t*)m_fo.pattern;
+
+ // locate starting paragraph
+ MSHTML::IHTMLTxtRangePtr sel(Document()->selection->createRange());
+ if(!fMore && (bool)m_is_start)
+ sel= m_is_start->duplicate();
+ if(!(bool)sel)
+ return false;
+
+ MSHTML::IHTMLElementPtr sc(SelectionStructCon());
+ long s_idx = 0;
+ long s_off1 = 0;
+ long s_off2 = 0;
+ if((bool)sc)
+ {
+ s_idx = sc->sourceIndex;
+ if(U::scmp(sc->tagName,L"P") == 0 && (bool)sel)
+ {
+ s_off2 = sel->text.length();
+ MSHTML::IHTMLTxtRangePtr pr(sel->duplicate());
+ pr->moveToElementText(sc);
+ pr->setEndPoint(L"EndToStart", sel);
+ s_off1 = pr->text.length();
+ s_off2 += s_off1;
+ }
+ }
+
+ // walk the all collection now, looking for the next P
+ MSHTML::IHTMLElementCollectionPtr all(Document()->all);
+ long all_len = all->length;
+ long incr = m_fo.flags &1 ? -1 : 1;
+ bool fWrapped = false;
+
+ // * search in starting element
+ if ((bool)sc && U::scmp(sc->tagName, L"P") == 0)
+ {
+ sel->moveToElementText(sc);
+ CString selText = sel->text;
+
+ AU::ReMatches rm(re->Execute(sel->text));
+ // changed by SeNS: fix for issue #62
+ if (rm->Count > 0&& !(selText.IsEmpty() && fMore))
+ {
+ if(incr > 0)
+ {
+ for(long l = m_startMatch;l < rm->Count; ++l)
+ {
+ AU::ReMatch crm(rm->Item[l]);
+ if(crm->FirstIndex >= s_off2 )
+ {
+ m_startMatch = l+1;
+ SelMatch(sel, crm);
+ return true;
+ }
+ }
+ }
+ else
+ {
+ for(long l = m_endMatch; l >= 0; --l)
+ {
+ AU::ReMatch crm(rm->Item[l]);
+ if(crm->FirstIndex < s_off1)
+ {
+ SelMatch(sel, crm);
+ m_endMatch = l-1;
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ // search all others
+ for(long cur = s_idx + incr; ; cur += incr)
+ {
+ // adjust out of bounds indices
+ if(cur < 0)
+ {
+ cur = all_len - 1;
+ fWrapped = true;
+ }
+ else if(cur >= all_len)
+ {
+ cur = 0;
+ fWrapped = true;
+ }
+
+ // check for wraparound
+ if(cur == s_idx)
+ break;
+
+ // check current element type
+ MSHTML::IHTMLElementPtr elem(all->item(cur));
+ if(!(bool)elem || U::scmp(elem->tagName,L"P"))
+ continue;
+
+ // search inside current element
+ sel->moveToElementText(elem);
+
+ AU::ReMatches rm(re->Execute(sel->text));
+ if(rm->Count <= 0)
+ continue;
+ if(incr > 0)
+ {
+ SelMatch(sel, rm->Item[0]);
+ m_startMatch = 1;
+ }
+ else
+ {
+ SelMatch(sel, rm->Item[rm->Count-1]);
+ m_endMatch = rm->Count-2;
+ }
+ if(fWrapped)
+ ::MessageBeep(MB_ICONASTERISK);
+
+ return true;
+ }
+
+ // search again in starting element
+ if ((bool)sc && U::scmp(sc->tagName, L"P") == 0)
+ {
+ sel->moveToElementText(sc);
+ AU::ReMatches rm(re->Execute(sel->text));
+ if(rm->Count > 0)
+ {
+ if(incr > 0)
+ {
+ for(long l = 0; l < rm->Count; ++l)
+ {
+ AU::ReMatch crm(rm->Item[l]);
+ if(crm->FirstIndex < s_off1)
+ {
+ SelMatch(sel, crm);
+ if(fWrapped)
+ ::MessageBeep(MB_ICONASTERISK);
+
+ return true;
+ }
+ }
+ }
+ else
+ {
+ for(long l = rm->Count - 1; l >= 0; --l)
+ {
+ AU::ReMatch crm(rm->Item[l]);
+ if(crm->FirstIndex >= s_off2)
+ {
+ SelMatch(sel, crm);
+ if(fWrapped)
+ ::MessageBeep(MB_ICONASTERISK);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return false;
+}
+
+bool CFBEView::DoSearchStd(bool fMore)
+{
+ try
+ {
+ // fetch selection
+ MSHTML::IHTMLTxtRangePtr sel(Document()->selection->createRange());
+ if(!fMore && (bool)m_is_start)
+ sel = m_is_start->duplicate();
+ if(!(bool)sel)
+ return false;
+
+ MSHTML::IHTMLTxtRangePtr org(sel->duplicate());
+ // check if it is collapsed
+ if(sel->compareEndPoints(L"StartToEnd", sel) != 0)
+ {
+ // collapse and advance
+ if(m_fo.flags & FRF_REVERSE)
+ sel->collapse(VARIANT_TRUE);
+ else
+ sel->collapse(VARIANT_FALSE);
+ }
+
+ // search for text
+ if(sel->findText((const wchar_t*)m_fo.pattern, 1073741824, m_fo.flags) == VARIANT_TRUE)
+ {
+ // ok, found
+ sel->select();
+ return true;
+ }
+
+ // not found, try searching from start to sel
+ sel = MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange();
+ sel->collapse(m_fo.flags & 1 ? VARIANT_FALSE : VARIANT_TRUE);
+ if(sel->findText((const wchar_t*)m_fo.pattern, 1073741824, m_fo.flags) == VARIANT_TRUE
+ && org->compareEndPoints("StartToStart", sel)*(m_fo.flags & 1 ? -1 : 1) > 0)
+ {
+ // found
+ sel->select();
+ MessageBeep(MB_ICONASTERISK);
+ return true;
+ }
+ }
+ catch (_com_error&)
+ {
+ //U::ReportError(err);
+ }
+
+ return false;
+}
+
+static CString GetSM(AU::ReSubMatches sm, int idx)
+{
+ if(!sm)
+ return CString();
+
+ if(idx < 0 || idx >= sm->Count)
+ return CString();
+
+ _variant_t vt(sm->Item[idx]);
+
+ if(V_VT(&vt) == VT_BSTR)
+ return V_BSTR(&vt);
+
+ return CString();
+}
+
+struct RR
+{
+ enum
+ {
+ STRONG = 1,
+ EMPHASIS = 2,
+ UPPER = 4,
+ LOWER = 8,
+ TITLE = 16
+ };
+
+ int flags;
+ int start;
+ int len;
+};
+
+typedef CSimpleValArray
RRList;
+
+static CString GetReplStr(const CString& rstr, AU::ReMatch rm, RRList& rl)
+{
+ CString rep;
+ rep.GetBuffer(rstr.GetLength());
+ rep.ReleaseBuffer(0);
+
+ AU::ReSubMatches rs(rm->SubMatches);
+
+ RR cr;
+ memset(&cr, 0, sizeof(cr));
+ int flags=0;
+
+ CString rv;
+ bool emptyParam = false;
+
+ for(int i = 0; i < rstr.GetLength(); ++i)
+ {
+ if ((rstr[i] == L'$' && i < rstr.GetLength() - 1) ||
+ (rstr[i] == L'\\' && i < rstr.GetLength() - 1))
+ {
+ switch(rstr[++i])
+ {
+ //case L'&': // whole match
+ case L'0': // whole match
+ rv=(const wchar_t *)rm->Value;
+ break;
+ case L'+': // last submatch
+ rv = GetSM(rs, rs->Count - 1);
+ break;
+ case L'1':
+ case L'2':
+ case L'3':
+ case L'4':
+ case L'5':
+ case L'6':
+ case L'7':
+ case L'8':
+ case L'9':
+ rv = GetSM(rs, rstr[i] - L'0' - 1);
+ if(rv.IsEmpty())
+ emptyParam = true;
+ break;
+ case L'T': // title case
+ flags |= RR::TITLE;
+ continue;
+ case L'U': // uppercase
+ flags |= RR::UPPER;
+ continue;
+ case L'L': // lowercase
+ flags |= RR::LOWER;
+ continue;
+ case L'S': // strong
+ flags |= RR::STRONG;
+ continue;
+ case L'E': // emphasis
+ flags |= RR::EMPHASIS;
+ continue;
+ case L'Q': // turn off flags
+ flags = 0;
+ continue;
+ default: // ignore
+ continue;
+ }
+ }
+
+ if(cr.flags != flags && cr.flags && cr.start < rep.GetLength())
+ {
+ cr.len = rep.GetLength() - cr.start;
+ rl.Add(cr);
+ cr.flags = 0;
+ }
+
+ if(flags)
+ {
+ cr.flags = flags;
+ cr.start = rep.GetLength();
+ }
+
+ // SeNS: fix for issue #142
+ if (!emptyParam)
+ {
+ if(!rv.IsEmpty())
+ {
+ rep += rv;
+ rv.Empty();
+ }
+ else rep += rstr[i];
+ }
+ else emptyParam = false;
+ }
+
+ if(cr.flags && cr.start < rep.GetLength())
+ {
+ cr.len = rep.GetLength() - cr.start;
+ rl.Add(cr);
+ }
+
+ // process case conversions here
+ int tl = rep.GetLength();
+ TCHAR* cp = rep.GetBuffer(tl);
+ for(int j = 0; j < rl.GetSize();)
+ {
+ RR rr = rl[j];
+ if(rr.flags & RR::UPPER)
+ LCMapString(CP_ACP, LCMAP_UPPERCASE, cp + rr.start, rr.len, cp + rr.start, rr.len);
+ else if(rr.flags & RR::LOWER)
+ LCMapString(CP_ACP, LCMAP_LOWERCASE, cp + rr.start, rr.len, cp + rr.start, rr.len);
+ else if(rr.flags & RR::TITLE && rr.len > 0)
+ {
+ LCMapString(CP_ACP, LCMAP_UPPERCASE, cp + rr.start, 1, cp + rr.start, 1);
+ LCMapString(CP_ACP, LCMAP_LOWERCASE, cp + rr.start + 1, rr.len - 1, cp + rr.start + 1, rr.len - 1);
+ }
+
+ if((rr.flags &~ (RR::UPPER | RR::LOWER | RR::TITLE)) == 0)
+ rl.RemoveAt(j);
+ else
+ ++j;
+ }
+
+ rep.ReleaseBuffer(tl);
+
+ return rep;
+}
+
+void CFBEView::DoReplace() {
+ try {
+ MSHTML::IHTMLTxtRangePtr sel(Document()->selection->createRange());
+ if (!(bool)sel)
+ return;
+ MSHTML::IHTMLTxtRangePtr x2(sel->duplicate());
+ int adv=0;
+
+ m_mk_srv->BeginUndoUnit(L"replace");
+
+ if (m_fo.match) { // use regexp match
+ RRList rl;
+ CString rep(GetReplStr(m_fo.replacement,m_fo.match,rl));
+
+ // added by SeNS
+ if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
+ rep.Replace( L"\u00A0", _Settings.GetNBSPChar());
+
+ sel->text=(const wchar_t *)rep;
+ // change bold/italic where needed
+ for (int i=0;iduplicate();
+ x2->move(L"character",rr.start-rep.GetLength());
+ x2->moveEnd(L"character",rr.len);
+ if (rr.flags&RR::STRONG)
+ x2->execCommand(L"Bold",VARIANT_FALSE);
+ if (rr.flags&RR::EMPHASIS)
+ x2->execCommand(L"Italic",VARIANT_FALSE);
+ }
+ adv=rep.GetLength();
+ } else { // plain text
+ sel->text=(const wchar_t *)m_fo.replacement;
+ adv=m_fo.replacement.GetLength();
+ }
+ sel->moveStart(L"character",-adv);
+ sel->select();
+ }
+ catch (_com_error& e) {
+ U::ReportError(e);
+ }
+ m_mk_srv->EndUndoUnit();
+}
+
+int CFBEView::GlobalReplace(MSHTML::IHTMLElementPtr elem, CString cntTag)
+{
+ if(m_fo.pattern.IsEmpty())
+ return 0;
+
+ try
+ {
+ MSHTML::IHTMLTxtRangePtr sel(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
+ if(elem)
+ sel->moveToElementText(elem);
+ if(!(bool)sel)
+ return 0;
+
+ AU::RegExp re;
+#ifdef USE_PCRE
+ re = new AU::IRegExp2();
+#else
+ CheckError(re.CreateInstance(L"VBScript.RegExp"));
+#endif
+ re->IgnoreCase = m_fo.flags & 4 ? VARIANT_FALSE : VARIANT_TRUE;
+ re->Global = VARIANT_TRUE;
+
+ // added by SeNS
+ if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
+ m_fo.pattern.Replace( L"\u00A0", _Settings.GetNBSPChar());
+
+ re->Pattern = (const wchar_t*)m_fo.pattern;
+
+ m_mk_srv->BeginUndoUnit(L"replace");
+
+ sel->collapse(VARIANT_TRUE);
+
+ int nRepl = 0;
+
+ if(m_fo.fRegexp)
+ {
+ MSHTML::IHTMLTxtRangePtr s3;
+ MSHTML::IHTMLElementCollectionPtr all;
+ if(elem)
+ all = MSHTML::IHTMLElement2Ptr(elem)->getElementsByTagName(cntTag.AllocSysString());
+ else
+ all = MSHTML::IHTMLDocument3Ptr(Document())->getElementsByTagName(cntTag.AllocSysString());
+ _bstr_t charstr(L"character");
+ RRList rl;
+ CString repl;
+
+ for(long l = 0;l < all->length; ++l)
+ {
+ MSHTML::IHTMLElementPtr elem(all->item(l));
+ sel->moveToElementText(elem);;
+ AU::ReMatches rm(re->Execute(sel->text));
+ if(rm->Count <= 0)
+ continue;
+
+ // SeNS: fix for issue #147
+ MSHTML::IHTMLTxtRangePtr rng = sel->duplicate();
+ CString text = rng->text;
+ CString html = rng->htmlText;
+
+ // Replace
+ sel->collapse(VARIANT_TRUE);
+ long last = 0;
+ for(long i = 0; i < rm->Count; ++i)
+ {
+ AU::ReMatch cur(rm->Item[i]);
+ long delta = cur->FirstIndex - last;
+
+ // SeNS
+ delta += TextOffset (rng, cur, text, html);
+
+ if(delta)
+ {
+ sel->move(charstr, delta);
+ last += delta;
+ }
+ if(sel->moveStart(charstr, 1) == 1)
+ sel->move(charstr, -1);
+ delta = cur->Length;
+ last += cur->Length;
+ sel->moveEnd(charstr, delta);
+ rl.RemoveAll();
+ repl = GetReplStr(m_fo.replacement, cur, rl);
+
+ // added by SeNS
+ if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
+ repl.Replace( L"\u00A0", _Settings.GetNBSPChar());
+
+ sel->text = (const wchar_t*)repl;
+ for(int k = 0; k < rl.GetSize(); ++k)
+ {
+ RR rr = rl[k];
+ s3 = sel->duplicate();
+ s3->move(L"character", rr.start - repl.GetLength());
+ s3->moveEnd(L"character", rr.len);
+ if(rr.flags & RR::STRONG)
+ s3->execCommand(L"Bold", VARIANT_FALSE);
+ if(rr.flags & RR::EMPHASIS)
+ s3->execCommand(L"Italic", VARIANT_FALSE);
+ }
+ ++nRepl;
+ }
+ }
+ }
+ else
+ {
+ DWORD flags = m_fo.flags & ~FRF_REVERSE;
+ _bstr_t pattern((const wchar_t*)m_fo.pattern);
+ _bstr_t repl((const wchar_t*)m_fo.replacement);
+ while(sel->findText(pattern, 1073741824, flags) == VARIANT_TRUE)
+ {
+ sel->text = repl;
+ ++nRepl;
+ }
+ }
+
+ m_mk_srv->EndUndoUnit();
+ return nRepl;
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return 0;
+}
+
+int CFBEView::ToolWordsGlobalReplace( MSHTML::IHTMLElementPtr fbw_body,
+ int* pIndex,
+ int* globIndex,
+ bool find,
+ CString cntTag)
+{
+ if(m_fo.pattern.IsEmpty())
+ return 0;
+
+ int nRepl = 0;
+
+ try
+ {
+ AU::RegExp re;
+#ifdef USE_PCRE
+ re = new AU::IRegExp2();
+#else
+ CheckError(re.CreateInstance(L"VBScript.RegExp"));
+#endif
+ re->IgnoreCase = m_fo.flags & FRF_CASE ? VARIANT_FALSE : VARIANT_TRUE;
+ re->Global = m_fo.flags & FRF_WHOLE ? VARIANT_TRUE : VARIANT_FALSE;
+ re->Multiline = VARIANT_TRUE;
+ re->Pattern = (const wchar_t*)m_fo.pattern;
+
+ MSHTML::IHTMLElementCollectionPtr paras = MSHTML::IHTMLElement2Ptr(fbw_body)->getElementsByTagName(cntTag.AllocSysString());
+ if(!paras->length)
+ return 0;
+
+ int iNextElem = pIndex != NULL ? *pIndex : 0;
+ CSimpleArray pAdjElems;
+
+ while(iNextElem < paras->length)
+ {
+ pAdjElems.RemoveAll();
+
+ MSHTML::IHTMLElementPtr currElem(paras->item(iNextElem));
+ CString innerText = currElem->innerText;
+ pAdjElems.Add(pElAdjacent(currElem));
+
+ if(pIndex != NULL)
+ *pIndex = iNextElem;
+
+ MSHTML::IHTMLDOMNodePtr currNode(currElem);
+ if(MSHTML::IHTMLElementPtr siblElem = currNode->nextSibling)
+ {
+ int jNextElem = iNextElem + 1;
+ for(int i = jNextElem; i < paras->length; ++i)
+ {
+ MSHTML::IHTMLElementPtr nextElem = paras->item(i);
+ if(siblElem == nextElem)
+ {
+ pAdjElems.Add(pElAdjacent(siblElem));
+ innerText += L"\n";
+ innerText += siblElem->innerText.GetBSTR();
+ iNextElem++;
+ siblElem = MSHTML::IHTMLDOMNodePtr(nextElem)->nextSibling;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ innerText += L"\n";
+
+ if(innerText.IsEmpty())
+ {
+ iNextElem++;
+ continue;
+ }
+
+ // Replace
+ #ifdef USE_PCRE
+ AU::ReMatches rm(re->Execute(innerText));
+ #else
+ AU::ReMatches rm(re->Execute(innerText.AllocSysString()));
+ #endif
+ if(rm->Count <= 0)
+ {
+ iNextElem++;
+ continue;
+ }
+
+ for(long i = 0; i < rm->Count; ++i)
+ {
+ AU::ReMatch cur(rm->Item[i]);
+
+ long matchIdx = cur->FirstIndex;
+ long matchLen = cur->Length - 1;
+
+ long pAdjLen = 0;
+ bool begin = false, end = false;
+ int first = 0, last = 0;
+
+ for(int b = 0; b < pAdjElems.GetSize(); ++b)
+ {
+ int pElemLen = pAdjElems[b].innerText.length() + 1;
+
+ if(!pElemLen)
+ continue;
+
+ pAdjLen += pElemLen;
+
+ if(matchIdx < pAdjLen && !begin)
+ {
+ begin = true;
+ first = b;
+ }
+
+ if(matchIdx + (matchLen - 1) < pAdjLen && !end)
+ {
+ end = true;
+ last = b;
+ break;
+ }
+ }
+
+ int skip = 0;
+ while(skip < first)
+ {
+ matchIdx -= (pAdjElems[skip].innerText.length() + 1);
+ skip++;
+ }
+
+ CString newCont;
+ int icat = first;
+ while(icat <= last)
+ {
+ newCont += pAdjElems[icat].innerText.GetBSTR();
+ icat++;
+ }
+
+ if(find)
+ {
+ if(i == rm->Count - 1)
+ {
+ (*globIndex) = -1;
+ (*pIndex) += (pAdjElems.GetSize());
+ }
+ else
+ (*globIndex)++;
+
+ if(*globIndex > i)
+ {
+ (*globIndex)--;
+ continue;
+ }
+
+ MSHTML::IHTMLTxtRangePtr found(Document()->selection->createRange());
+ found->moveToElementText(pAdjElems[first].elem);
+
+ // SeNS: fix for issue #148
+ found->moveStart(L"character", matchIdx+TextOffset (found, cur));
+ found->collapse(TRUE);
+ int diff = last - first;
+ found->moveEnd(L"character", matchLen);
+ found->select();
+
+ return 0;
+ }
+ else
+ {
+ MSHTML::IHTMLTxtRangePtr found(Document()->selection->createRange());
+ found->moveToElementText(pAdjElems[first].elem);
+
+ // SeNS: fix for issue #148
+ found->moveStart(L"character", matchIdx+TextOffset (found, cur));
+ found->collapse(TRUE);
+ int diff = last - first;
+ found->moveEnd(L"character", matchLen);
+ found->select();
+ CString strRepl;
+ GetDlgItem(IDC_WORDS_FR_EDIT_REPL).GetWindowText(strRepl);
+
+ found->text = L"";
+ found->text = m_fo.replacement.AllocSysString();
+
+ newCont.Delete(matchIdx, matchLen - (last - first));
+ newCont.Insert(matchIdx, m_fo.replacement);
+
+ pAdjElems[first].innerText = newCont.AllocSysString();
+ //pAdjElems[first].elem->innerText = pAdjElems[first].innerText;
+
+ for(int c = first + 1; c <= last; ++c)
+ {
+ // MSHTML::IHTMLDOMNodePtr(pAdjElems[c].elem)->removeNode(VARIANT_TRUE);
+ iNextElem--;
+ }
+
+ for(int c = first + 1; c < last; ++c)
+ pAdjElems.RemoveAt(c);
+
+ if(nRepl >= m_fo.replNum)
+ goto stop;
+
+ CString again;
+ for(int c = 0; c < pAdjElems.GetSize(); ++c)
+ {
+ //pAdjElems[c].innerText = pAdjElems[c].elem->innerText;
+ again += pAdjElems[c].innerText.GetBSTR();
+ again += L"\n";
+ }
+ #ifdef USE_PCRE
+ rm = re->Execute(again);
+ #else
+ rm = re->Execute(again.AllocSysString());
+ #endif
+ i--;
+
+ nRepl++;
+ }
+ }
+
+ iNextElem++;
+ }
+
+stop:
+#ifndef USE_PCRE
+ re.Release();
+#endif
+
+ if(find)
+ {
+ Document()->selection->empty();
+ return -1;
+ }
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return nRepl;
+}
+
+class CViewReplaceDlg : public CReplaceDlgBase {
+public:
+ CViewReplaceDlg(CFBEView *view) : CReplaceDlgBase(view) { }
+
+ virtual void DoFind() {
+ if (!m_view->DoSearch())
+ {
+ U::MessageBox(MB_OK|MB_ICONEXCLAMATION, IDR_MAINFRAME, IDS_SEARCH_END_MSG, m_view->m_fo.pattern);
+ }
+ else {
+ SaveString();
+ SaveHistory();
+ m_selvalid=true;
+ MakeClose();
+ }
+ }
+ virtual void DoReplace() {
+ if (m_selvalid) { // replace
+ m_view->DoReplace();
+ m_selvalid=false;
+ }
+ m_view->m_startMatch = m_view->m_endMatch = 0;
+ DoFind();
+ }
+ virtual void DoReplaceAll() {
+ int nRepl=m_view->GlobalReplace();
+ if (nRepl>0) {
+ SaveString();
+ SaveHistory();
+ U::MessageBox(MB_OK, IDS_REPL_ALL_CAPT, IDS_REPL_DONE_MSG, nRepl);
+ MakeClose();
+ m_selvalid=false;
+ } else
+ {
+ U::MessageBox(MB_OK|MB_ICONEXCLAMATION, IDR_MAINFRAME, IDS_SEARCH_END_MSG, m_view->m_fo.pattern);
+ }
+ }
+};
+
+LRESULT CFBEView::OnFind(WORD, WORD, HWND, BOOL&)
+{
+ m_fo.pattern = (const wchar_t*)Selection();
+ if(!m_find_dlg)
+ m_find_dlg = new CViewFindDlg(this);
+
+ if(!m_find_dlg->IsValid())
+ m_find_dlg->ShowDialog(*this); // show modeless
+ else
+ m_find_dlg->SetFocus();
+ return 0;
+}
+
+LRESULT CFBEView::OnReplace(WORD, WORD, HWND, BOOL&)
+{
+ m_fo.pattern = (const wchar_t *)Selection();
+ if(!m_replace_dlg)
+ m_replace_dlg = new CViewReplaceDlg(this);
+
+ if(!m_replace_dlg->IsValid())
+ m_replace_dlg->ShowDialog(*this);
+ else
+ m_replace_dlg->SetFocus();
+ return 0;
+}
+
+LRESULT CFBEView::OnFindNext(WORD, WORD, HWND, BOOL&) {
+ if (!DoSearch())
+ {
+ U::MessageBox(MB_OK|MB_ICONEXCLAMATION, IDR_MAINFRAME, IDS_SEARCH_FAIL_MSG, m_fo.pattern);
+ }
+ return 0;
+}
+
+// binary objects
+_variant_t CFBEView::GetBinary(const wchar_t *id) {
+ try {
+ CComDispatchDriver dd(Script());
+ _variant_t ret;
+ _variant_t arg(id);
+ if (SUCCEEDED(dd.Invoke1(L"GetBinary",&arg,&ret)))
+ return ret;
+ }
+ catch (_com_error&) { }
+ return _variant_t();
+}
+
+// change notifications
+void CFBEView::EditorChanged(int id) {
+ switch (id) {
+ case FWD_SINK:
+ break;
+ case BACK_SINK:
+ break;
+ case RANGE_SINK:
+ m_startMatch = m_endMatch = 0;
+ if (!m_ignore_changes)
+ ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_ED_CHANGED),(LPARAM)m_hWnd);
+ break;
+ }
+}
+
+// DWebBrowserEvents2
+void CFBEView::OnDocumentComplete(IDispatch *pDisp,VARIANT *vtUrl) {
+ m_complete=true;
+}
+
+void CFBEView::Init() {
+ // save document pointer
+ m_hdoc=m_browser->Document;
+
+ m_mk_srv=m_hdoc;
+ m_mkc=m_hdoc;
+
+ // attach document events handler
+ DocumentEvents::DispEventUnadvise(Document(),&DIID_HTMLDocumentEvents2);
+ DocumentEvents::DispEventAdvise(Document(),&DIID_HTMLDocumentEvents2);
+ TextEvents::DispEventUnadvise(Document()->body,&DIID_HTMLTextContainerEvents2);
+ TextEvents::DispEventAdvise(Document()->body,&DIID_HTMLTextContainerEvents2);
+
+ // attach editing changed handlers
+ m_mkc->RegisterForDirtyRange((RangeSink*)this,&m_dirtyRangeCookie);
+
+ // attach external helper
+ SetExternalDispatch(CreateHelper());
+
+ // fixup all P elements
+ FixupParagraphs(Document()->body);
+
+ if (m_normalize)
+ Normalize(Document()->body);
+
+ if (!m_normalize) {
+ // check ID and version fields
+ MSHTML::IHTMLInputElementPtr ii(Document()->all->item(L"diID"));
+ if ((bool)ii && ii->value.length()==0) { // generate new ID
+ UUID uuid;
+ unsigned char *str;
+ if (UuidCreate(&uuid)==RPC_S_OK && UuidToStringA(&uuid,&str)==RPC_S_OK) {
+ CString us(str);
+ RpcStringFreeA(&str);
+ us.MakeUpper();
+ ii->value=(const wchar_t *)us;
+ }
+ }
+ ii=Document()->all->item(L"diVersion");
+ if ((bool)ii && ii->value.length()==0)
+ ii->value=L"1.0";
+ ii=Document()->all->item(L"diDate");
+ MSHTML::IHTMLInputElementPtr jj(Document()->all->item(L"diDateVal"));
+ if ((bool)ii && (bool)jj && ii->value.length()==0 && jj->value.length()==0) {
+ time_t tt;
+ time(&tt);
+ char buffer[128];
+ strftime(buffer,sizeof(buffer),"%Y-%m-%d",localtime(&tt));
+ ii->value=buffer;
+ jj->value=buffer;
+ }
+ ii=Document()->all->item(L"diProgs");
+ if ((bool)ii && ii->value.length()==0)
+ ii->value=L"FB Tools";
+ }
+
+ // added by SeNS
+ m_elementsNum = Document()->all->length;
+
+ // turn off browser's d&d
+ HRESULT hr = m_browser->put_RegisterAsDropTarget(VARIANT_FALSE);
+// m_browser->RegisterAsDropTarget = VARIANT_TRUE;
+
+ m_initialized=true;
+}
+
+void CFBEView::OnBeforeNavigate(IDispatch *pDisp,VARIANT *vtUrl,VARIANT *vtFlags,
+ VARIANT *vtTargetFrame,VARIANT *vtPostData,
+ VARIANT *vtHeaders,VARIANT_BOOL *fCancel)
+{
+ if (!m_initialized)
+ return;
+
+ if (vtUrl && V_VT(vtUrl)==VT_BSTR) {
+ m_nav_url=V_BSTR(vtUrl);
+
+ if (m_nav_url.Left(13)==_T("fbw-internal:"))
+ return;
+
+ // changed by SeNS: possible fix for issue #87
+ // tested on Windows Vista Ultimate
+ ::PostMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_NAVIGATE),(LPARAM)m_hWnd);
+ }
+
+ // disable navigating away
+ *fCancel=VARIANT_TRUE;
+}
+
+// HTMLDocumentEvents
+void CFBEView::OnSelChange(IDispatch *evt) {
+ if (!m_ignore_changes)
+ ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_SEL_CHANGE),(LPARAM)m_hWnd);
+ if (m_cur_sel)
+ m_cur_sel.Release();
+}
+
+VARIANT_BOOL CFBEView::OnContextMenu(IDispatch *evt)
+{
+ MSHTML::IHTMLEventObjPtr oe(evt);
+ oe->cancelBubble = VARIANT_TRUE;
+ oe->returnValue = VARIANT_FALSE;
+ if(!m_normalize)
+ {
+ MSHTML::IHTMLElementPtr elem(oe->srcElement);
+ if(!(bool)elem)
+ return VARIANT_TRUE;
+ if(U::scmp(elem->tagName,L"INPUT") && U::scmp(elem->tagName, L"TEXTAREA"))
+ return VARIANT_TRUE;
+ }
+
+ // display custom context menu here
+ CMenu menu;
+ CString itemName;
+
+ menu.CreatePopupMenu();
+ menu.AppendMenu(MF_STRING,ID_EDIT_UNDO,_T("&Undo"));
+ menu.AppendMenu(MF_SEPARATOR);
+
+ itemName.LoadString(IDS_CTXMENU_CUT);
+ menu.AppendMenu(MF_STRING, ID_EDIT_CUT, itemName);
+
+ itemName.LoadString(IDS_CTXMENU_COPY);
+ menu.AppendMenu(MF_STRING, ID_EDIT_COPY, itemName);
+
+ itemName.LoadString(IDS_CTXMENU_PASTE);
+ menu.AppendMenu(MF_STRING, ID_EDIT_PASTE, itemName);
+
+ if(m_normalize)
+ {
+ menu.AppendMenu(MF_SEPARATOR);
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+ MSHTML::IHTMLElementPtr initial(cur);
+ int cmd = ID_SEL_BASE;
+ itemName.LoadString(IDS_CTXMENU_SELECT);
+
+ while((bool)cur && U::scmp(cur->tagName,L"BODY") && U::scmp(cur->id, L"fbw_body"))
+ {
+ menu.AppendMenu(MF_STRING, cmd, itemName + L" " + GetPath(cur));
+ cur = cur->parentElement;
+ ++cmd;
+ }
+ if(U::scmp(initial->className, L"image") == 0)
+ {
+ MSHTML::IHTMLImgElementPtr image = MSHTML::IHTMLDOMNodePtr(initial)->firstChild;
+ CString src = image->src.GetBSTR();
+ src.Delete(src.Find(L"fbw-internal:"), 13);
+ if(src != L"#undefined")
+ {
+ menu.AppendMenu(MF_SEPARATOR);
+ itemName.LoadString(IDS_CTXMENU_IMG_SAVEAS);
+ menu.AppendMenu(MF_STRING, ID_SAVEIMG_AS, itemName);
+ }
+ }
+ }
+
+ AU::TRACKPARAMS tp;
+ tp.hMenu = menu;
+ tp.uFlags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON;
+ tp.x = oe->screenX;
+ tp.y = oe->screenY;
+ ::SendMessage(m_frame, AU::WM_TRACKPOPUPMENU, 0, (LPARAM)&tp);
+
+ return VARIANT_TRUE;
+}
+
+LRESULT CFBEView::OnSelectElement(WORD, WORD wID, HWND, BOOL&) {
+ int steps=wID-ID_SEL_BASE;
+ try {
+ MSHTML::IHTMLElementPtr cur(SelectionContainer());
+
+ while ((bool)cur && steps-->0)
+ cur=cur->parentElement;
+
+ MSHTML::IHTMLTxtRangePtr r(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
+
+ r->moveToElementText(cur);
+
+ ++m_ignore_changes;
+ r->select();
+ --m_ignore_changes;
+
+ m_cur_sel=cur;
+ ::SendMessage(m_frame,WM_COMMAND,MAKELONG(0,IDN_SEL_CHANGE),(LPARAM)m_hWnd);
+ }
+ catch (_com_error& e) {
+ U::ReportError(e);
+ }
+
+ return 0;
+}
+
+VARIANT_BOOL CFBEView::OnClick(IDispatch *evt)
+{
+ MSHTML::IHTMLEventObjPtr oe(evt);
+ MSHTML::IHTMLElementPtr elem(oe->srcElement);
+
+ m_startMatch = m_endMatch = 0;
+
+ if(!(bool)elem)
+ return VARIANT_FALSE;
+
+ MSHTML::IHTMLElementPtr parent_element = elem->parentElement;
+
+ if(!(bool)parent_element)
+ return VARIANT_FALSE;
+
+ bstr_t pc = parent_element->className;
+
+ if(!U::scmp(pc, L"image"))
+ {
+ // make image selected
+ IHTMLControlRangePtr r(((MSHTML::IHTMLElement2Ptr)(Document()->body))->createControlRange());
+ HRESULT hr = r->add((IHTMLControlElementPtr)elem->parentElement);
+ hr = r->select();
+ //::SendMessage(m_frame, WM_COMMAND, MAKELONG(IDC_HREF, IDN_WANTFOCUS), (LPARAM)m_hWnd);
+
+ return VARIANT_TRUE;
+ }
+
+ if (U::scmp(elem->tagName,L"A"))
+ {
+ return VARIANT_FALSE;
+ }
+ /*else
+ {
+ ::SendMessage(m_frame, WM_COMMAND, MAKELONG(IDC_HREF, IDN_WANTFOCUS), (LPARAM)m_hWnd);
+ return VARIANT_FALSE;
+ }*/
+
+ if(oe->altKey!=VARIANT_TRUE || oe->shiftKey==VARIANT_TRUE || oe->ctrlKey==VARIANT_TRUE)
+ return VARIANT_FALSE;
+
+ CString sref(AU::GetAttrCS(elem, L"href"));
+ if(sref.IsEmpty() || sref[0] != L'#')
+ return VARIANT_FALSE;
+
+ sref.Delete(0);
+
+ MSHTML::IHTMLElementPtr targ(Document()->all->item((const wchar_t*)sref));
+
+ if(!(bool)targ)
+ return VARIANT_FALSE;
+
+ GoTo(targ);
+
+ oe->cancelBubble = VARIANT_TRUE;
+ oe->returnValue = VARIANT_FALSE;
+
+ return VARIANT_TRUE;
+}
+
+VARIANT_BOOL CFBEView::OnKeyDown(IDispatch *evt)
+{
+ MSHTML::IHTMLEventObjPtr oe(evt);
+ if (oe->keyCode == VK_LEFT || oe->keyCode == VK_UP || oe->keyCode == VK_PRIOR || oe->keyCode == VK_HOME)
+ m_startMatch = m_endMatch = 0;
+ return VARIANT_TRUE;
+}
+
+VARIANT_BOOL CFBEView::OnRealPaste(IDispatch* evt)
+{
+ MSHTML::IHTMLEventObjPtr oe(evt);
+ oe->cancelBubble = VARIANT_TRUE;
+ if(!m_enable_paste)
+ {
+ // Blocks first OnRealPaste to stop double-insertion
+ SendMessage(WM_COMMAND, MAKELONG(ID_EDIT_PASTE, 0), 0);
+ oe->returnValue = VARIANT_FALSE;
+ }
+ else
+ {
+ oe->returnValue = VARIANT_TRUE;
+ }
+
+ return VARIANT_TRUE;
+}
+
+bool CFBEView::IsFormChanged() {
+ if (!m_form_changed && (bool)m_cur_input)
+ m_form_changed=m_form_changed || m_cur_input->value != m_cur_val;
+ return m_form_changed;
+}
+
+bool CFBEView::IsFormCP() {
+ if (!m_form_cp && (bool)m_cur_input)
+ m_form_cp=m_form_cp || m_cur_input->value != m_cur_val;
+ return m_form_cp;
+}
+
+void CFBEView::ResetFormChanged() {
+ m_form_changed=false;
+ if (m_cur_input)
+ m_cur_val=m_cur_input->value;
+}
+
+void CFBEView::ResetFormCP() {
+ m_form_cp=false;
+ if (m_cur_input)
+ m_cur_val=m_cur_input->value;
+}
+
+void CFBEView::OnFocusIn(IDispatch *evt) {
+ // check previous value
+ if (m_cur_input) {
+ bool cv=m_cur_input->value != m_cur_val;
+ m_form_changed=m_form_changed || cv;
+ m_form_cp=m_form_cp || cv;
+ m_cur_input.Release();
+ }
+
+ MSHTML::IHTMLEventObjPtr oe(evt);
+ if (!(bool)oe)
+ return;
+
+ MSHTML::IHTMLElementPtr te(oe->srcElement);
+ if (!(bool)te || U::scmp(te->tagName,L"INPUT"))
+ return;
+
+ m_cur_input=te;
+ if (!(bool)m_cur_input)
+ return;
+
+ if (U::scmp(m_cur_input->type,L"text")) {
+ m_cur_input.Release();
+ return;
+ }
+
+ m_cur_val=m_cur_input->value;
+}
+
+// find/replace support for scintilla
+bool CFBEView::SciFindNext(HWND src,bool fFwdOnly,bool fBarf) {
+ if (m_fo.pattern.IsEmpty())
+ return true;
+
+ int flags=0;
+ if (m_fo.flags & FRF_WHOLE)
+ flags|=SCFIND_WHOLEWORD;
+ if (m_fo.flags & FRF_CASE)
+ flags|=SCFIND_MATCHCASE;
+ if (m_fo.fRegexp)
+ flags|=SCFIND_REGEXP;
+ int rev=m_fo.flags & FRF_REVERSE && !fFwdOnly;
+
+ // added by SeNS
+ if (_Settings.GetNBSPChar().Compare(L"\u00A0") != 0)
+ m_fo.pattern.Replace( L"\u00A0", _Settings.GetNBSPChar());
+
+ DWORD len=::WideCharToMultiByte(CP_UTF8,0, m_fo.pattern,m_fo.pattern.GetLength(), NULL,0,NULL,NULL);
+ char *tmp=(char *)malloc(len+1);
+ if (tmp)
+ {
+ ::WideCharToMultiByte(CP_UTF8,0, m_fo.pattern,m_fo.pattern.GetLength(), tmp,len,NULL,NULL);
+ tmp[len]='\0';
+ int p1=::SendMessage(src,SCI_GETSELECTIONSTART,0,0);
+ int p2=::SendMessage(src,SCI_GETSELECTIONEND,0,0);
+ if (p2>p1 && !rev) p1=p2;
+// if (p1!=p2 && !rev) ++p1;
+ if (rev) --p1;
+ if (p1<0) p1=0;
+ p2=rev ? 0 : ::SendMessage(src,SCI_GETLENGTH,0,0);
+ int p3=p2==0 ? ::SendMessage(src,SCI_GETLENGTH,0,0) : 0;
+ ::SendMessage(src,SCI_SETTARGETSTART,p1,0);
+ ::SendMessage(src,SCI_SETTARGETEND,p2,0);
+ ::SendMessage(src,SCI_SETSEARCHFLAGS,flags,0);
+ // this sometimes hangs in reverse search :)
+ int ret=::SendMessage(src,SCI_SEARCHINTARGET,len,(LPARAM)tmp);
+ if (ret==-1)
+ { // try wrap
+ if (p1!=p3)
+ {
+ ::SendMessage(src,SCI_SETTARGETSTART,p3,0);
+ ::SendMessage(src,SCI_SETTARGETEND,p1,0);
+ ::SendMessage(src,SCI_SETSEARCHFLAGS,flags,0);
+ ret=::SendMessage(src,SCI_SEARCHINTARGET,len,(LPARAM)tmp);
+ }
+ if (ret==-1)
+ {
+ free(tmp);
+ if (fBarf)
+ {
+ U::MessageBox(MB_OK|MB_ICONEXCLAMATION, IDR_MAINFRAME, IDS_SEARCH_FAIL_MSG, m_fo.pattern);
+ }
+ return false;
+ }
+ ::MessageBeep(MB_ICONASTERISK);
+ }
+ free(tmp);
+ p1=::SendMessage(src,SCI_GETTARGETSTART,0,0);
+ p2=::SendMessage(src,SCI_GETTARGETEND,0,0);
+ ::SendMessage(src,SCI_SETSELECTIONSTART,p1,0);
+ ::SendMessage(src,SCI_SETSELECTIONEND,p2,0);
+ ::SendMessage(src,SCI_SCROLLCARET,0,0);
+ return true;
+ } else
+ {
+ wchar_t msg[MAX_LOAD_STRING + 1];
+ wchar_t cpt[MAX_LOAD_STRING + 1];
+ ::LoadString(_Module.GetResourceInstance(), IDS_OUT_OF_MEM_MSG, msg, MAX_LOAD_STRING);
+ ::LoadString(_Module.GetResourceInstance(), IDR_MAINFRAME, cpt, MAX_LOAD_STRING);
+ ::MessageBox(::GetActiveWindow(), msg, cpt, MB_OK|MB_ICONERROR);
+ }
+
+ return false;
+}
+
+_bstr_t CFBEView::Selection()
+{
+ try
+ {
+ MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
+ if(!(bool)rng)
+ return _bstr_t();
+
+ MSHTML::IHTMLTxtRangePtr dup(rng->duplicate());
+ dup->collapse(VARIANT_TRUE);
+
+ MSHTML::IHTMLElementPtr elem(dup->parentElement());
+ while ((bool)elem && U::scmp(elem->tagName, L"P") && U::scmp(elem->tagName, L"DIV"))
+ elem = elem->parentElement;
+
+ if(elem)
+ {
+ dup->moveToElementText(elem);
+ if(rng->compareEndPoints(L"EndToEnd", dup) > 0)
+ rng->setEndPoint(L"EndToEnd", dup);
+ }
+
+ return rng->text;
+ }
+ catch (_com_error& err)
+ {
+ U::ReportError(err);
+ }
+
+ return _bstr_t();
+}
+
+// Modification by Pilgrim
+static bool IsTable(MSHTML::IHTMLDOMNode *node) {
+ MSHTML::IHTMLElementPtr elem(node);
+ return U::scmp(elem->className,L"table")==0;
+}
+
+static bool IsTR(MSHTML::IHTMLDOMNode *node) {
+ MSHTML::IHTMLElementPtr elem(node);
+ return U::scmp(elem->className,L"tr")==0;
+}
+
+static bool IsTH(MSHTML::IHTMLDOMNode *node) {
+ MSHTML::IHTMLElementPtr elem(node);
+ return U::scmp(elem->className,L"th")==0;
+}
+
+static bool IsTD(MSHTML::IHTMLDOMNode *node) {
+ MSHTML::IHTMLElementPtr elem(node);
+ return U::scmp(elem->className,L"td")==0;
+}
+
+bool CFBEView::GoToFootnote(bool fCheck)
+{
+ // * create selection range
+ MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
+ if (!(bool)rng)
+ return false;
+
+ MSHTML::IHTMLTxtRangePtr next_rng = rng->duplicate();
+ MSHTML::IHTMLTxtRangePtr prev_rng = rng->duplicate();
+ next_rng->moveEnd(L"character", +1);
+ prev_rng->moveStart(L"character", -1);
+
+ CString sref(AU::GetAttrCS(SelectionAnchor(),L"href"));
+ if (sref.IsEmpty())
+ sref = AU::GetAttrCS(SelectionAnchor(next_rng->parentElement()),L"href");
+ if (sref.IsEmpty())
+ sref = AU::GetAttrCS(SelectionAnchor(prev_rng->parentElement()),L"href");
+
+ if (sref.Find(L"file") == 0)
+ sref = sref.Mid(sref.ReverseFind (L'#'),1024);
+ if (sref.IsEmpty() || sref[0]!=_T('#'))
+ return false;
+
+ // * ok, all checks passed
+ if (fCheck)
+ return true;
+
+ sref.Delete(0);
+
+ MSHTML::IHTMLElementPtr targ(Document()->all->item((const wchar_t *)sref));
+
+ if (!(bool)targ)
+ return false;
+
+ MSHTML::IHTMLDOMNodePtr childNode;
+ MSHTML::IHTMLDOMNodePtr node(targ);
+ if (!(bool)node)
+ return false;
+
+ // added by SeNS: move caret to the foornote text
+ if (!U::scmp(node->nodeName,L"DIV") && !U::scmp(targ->className,L"section"))
+ {
+ if (node->firstChild)
+ {
+ childNode = node->firstChild;
+ while (childNode && !U::scmp(childNode->nodeName,L"DIV") &&
+ (!U::scmp(MSHTML::IHTMLElementPtr(childNode)->className,L"image") ||
+ !U::scmp(MSHTML::IHTMLElementPtr(childNode)->className,L"title")))
+ childNode=childNode->nextSibling;
+ }
+ }
+ if (!childNode) childNode=node;
+ if (childNode)
+ {
+ GoTo(MSHTML::IHTMLElementPtr(childNode));
+ targ->scrollIntoView(true);
+ }
+
+ return true;
+}
+bool CFBEView::GoToReference(bool fCheck)
+{
+ // * create selection range
+ MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
+ if (!(bool)rng)
+ return false;
+
+ // * get its parent element
+ MSHTML::IHTMLElementPtr pe(GetHP(rng->parentElement()));
+ if (!(bool)pe)
+ return false;
+
+ if (rng->compareEndPoints(L"StartToEnd",rng)!=0)
+ return false;
+
+ while((bool)pe && (U::scmp(pe->tagName,L"DIV")!=0 || U::scmp(pe->className,L"section")!=0))
+ pe=pe->parentElement; // Find parent division
+ if(!(bool)pe)
+ return false;
+
+ MSHTML::IHTMLElementPtr body=pe->parentElement;
+
+ while((bool)body && (U::scmp(body->tagName,L"DIV")!=0 || U::scmp(body->className,L"body")!=0))
+ body=body->parentElement; // Find body
+
+ if(!(bool)body)
+ return false;
+
+ CString id = MSHTML::IHTMLElementPtr(rng->parentElement())->id;
+ CString sfbname(AU::GetAttrCS(body,L"fbname"));
+ if(id.IsEmpty() && (sfbname.IsEmpty() || !(sfbname.CompareNoCase(L"notes")==0 || sfbname.CompareNoCase(L"comments")==0)))
+ return false;
+ id = L"#"+id;
+
+ // * ok, all checks passed
+ if (fCheck)
+ return true;
+
+ MSHTML::IHTMLElement2Ptr elem(Document()->body);
+ MSHTML::IHTMLElementCollectionPtr coll(elem->getElementsByTagName(L"A"));
+ if (!(bool)coll || coll->length==0)
+ {
+ wchar_t cpt[MAX_LOAD_STRING + 1];
+ wchar_t msg[MAX_LOAD_STRING + 1];
+ ::LoadString(_Module.GetResourceInstance(), IDR_MAINFRAME, cpt, MAX_LOAD_STRING);
+ ::LoadString(_Module.GetResourceInstance(), IDS_GOTO_REF_FAIL_MSG, msg, MAX_LOAD_STRING);
+ ::MessageBox(::GetActiveWindow(), msg, cpt, MB_OK|MB_ICONINFORMATION);
+ return false;
+ }
+
+ for (long l=0;llength;++l) {
+ MSHTML::IHTMLElementPtr a(coll->item(l));
+ if (!(bool)a)
+ continue;
+
+ CString href(AU::GetAttrCS((MSHTML::IHTMLElementPtr)coll->item(l),L"href"));
+
+ // changed by SeNS
+ if (href.Find(L"file") == 0)
+ href = href.Mid(href.ReverseFind (L'#'),1024);
+ else if(href.Find(_T("://"),0) !=-1)
+ continue;
+
+ CString snote = L"#"+pe->id;
+
+ if(href==snote || href==id)
+ {
+ GoTo(a);
+ MSHTML::IHTMLTxtRangePtr r(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
+ r->moveToElementText(a);
+ r->collapse(VARIANT_TRUE);
+ // move selection to position after reference
+ CString sa = a->innerText;
+ r->move(L"character", sa.GetLength());
+ r->select();
+ // scroll to the center of view
+ MSHTML::IHTMLRectPtr rect = MSHTML::IHTMLElement2Ptr(a)->getBoundingClientRect();
+ MSHTML::IHTMLWindow2Ptr window(MSHTML::IHTMLDocument2Ptr(Document())->parentWindow);
+ if (rect && window)
+ {
+ if (rect->bottom-rect->top <= _Settings.GetViewHeight())
+ window->scrollBy(0,(rect->top+rect->bottom-_Settings.GetViewHeight())/2);
+ else
+ window->scrollBy(0,rect->top);
+ }
+ break;
+ }
+ }
+
+ return false;
+}
+
+LRESULT CFBEView::OnEditInsertTable(WORD wNotifyCode, WORD wID, HWND hWndCtl)
+{
+ CTableDlg dlg;
+ if(dlg.DoModal()==IDOK) {
+ int nRows = dlg.m_nRows;
+ bool bTitle = dlg.m_bTitle;
+ InsertTable(false,bTitle,nRows);
+ }
+ return 0;
+}
+
+LRESULT CFBEView::OnEditInsImage(WORD, WORD cmdID, HWND, BOOL&)
+{
+ // added by SeNS
+ bool bInline = (cmdID != ID_EDIT_INS_IMAGE);
+
+ if(_Settings.GetInsImageAsking())
+ {
+ CAddImageDlg imgDialog;
+ imgDialog.DoModal(*this);
+ }
+
+ if(!_Settings.GetIsInsClearImage())
+ {
+ CFileDialogEx dlg(
+ TRUE,
+ NULL,
+ NULL,
+ OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR,
+ L"FBE supported (*.jpg;*.jpeg;*.png)\0*.jpg;*.jpeg;*.png\0JPEG (*.jpg)\0*.jpg\0PNG (*.png)\0*.png\0Bitmap (*.bmp"\
+ L")\0*.bmp\0GIF (*.gif)\0*.gif\0TIFF (*.tif)\0*.tif\0\0"
+ );
+
+ wchar_t dlgTitle[MAX_LOAD_STRING + 1];
+ ::LoadString(_Module.GetResourceInstance(), IDS_ADD_IMAGE_FILEDLG, dlgTitle, MAX_LOAD_STRING);
+ dlg.m_ofn.lpstrTitle = dlgTitle;
+ dlg.m_ofn.nFilterIndex = 1;
+
+ if(dlg.DoModal(*this) == IDOK)
+ {
+ AddImage(dlg.m_szFileName, bInline);
+ }
+ }
+ else
+ {
+ // added by SeNS
+ try {
+ if (bInline)
+ {
+ MSHTML::IHTMLDOMNodePtr node(Call(L"InsInlineImage"));
+ }
+ else
+ {
+ MSHTML::IHTMLDOMNodePtr node(Call(L"InsImage"));
+ if (node)
+ BubbleUp(node,L"DIV");
+ }
+ }
+ catch (_com_error&) { }
+ }
+
+ return 0;
+}
+
+bool CFBEView::InsertTable(bool fCheck, bool bTitle, int nrows) {
+ try {
+ // * create selection range
+ MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
+ if (!(bool)rng)
+ return false;
+
+ // * get its parent element
+ MSHTML::IHTMLElementPtr pe(GetHP(rng->parentElement()));
+ if (!(bool)pe)
+ return false;
+
+ // * get parents for start and end ranges and ensure they are the same as pe
+ MSHTML::IHTMLTxtRangePtr tr(rng->duplicate());
+ tr->collapse(VARIANT_TRUE);
+ if (GetHP(tr->parentElement())!=pe)
+ return false;
+#if 0
+ tr=rng->duplicate();
+ tr->collapse(VARIANT_FALSE);
+ if (GetHP(tr->parentElement())!=pe)
+ return false;
+#endif
+
+ // * check if it possible to insert a table there
+ _bstr_t cls(pe->className);
+ if (U::scmp(cls,L"section") && U::scmp(cls,L"epigraph") &&
+ U::scmp(cls,L"annotation") && U::scmp(cls,L"history") && U::scmp(cls,L"cite"))
+ return false;
+
+ // * ok, all checks passed
+ if (fCheck)
+ return true;
+
+ // at this point we are ready to create a table
+
+ // * create an undo unit
+ m_mk_srv->BeginUndoUnit(L"insert table");
+
+ MSHTML::IHTMLElementPtr te(Document()->createElement(L"DIV"));
+
+ for(int row=nrows; row!=-1; --row){
+ // * create tr
+ MSHTML::IHTMLElementPtr tre(Document()->createElement(L"DIV"));
+ tre->className=L"tr";
+ // * create th and td
+ MSHTML::IHTMLElementPtr the(Document()->createElement(L"P"));
+ if(row==0){
+ if(bTitle){//Нужен заголовок таблицы
+ the->className=L"th";// * create th - заголовок
+ MSHTML::IHTMLElement2Ptr(tre)->insertAdjacentElement(L"afterBegin",the);
+ }
+ } else {
+ the->className=L"td";// * create td - строки
+ MSHTML::IHTMLElement2Ptr(tre)->insertAdjacentElement(L"afterBegin",the);
+ }
+
+ // * create table
+ te->className=L"table";
+ MSHTML::IHTMLElement2Ptr(te)->insertAdjacentElement(L"afterBegin",tre);
+ }
+
+ // * paste the results back
+ rng->pasteHTML(te->outerHTML);
+
+ // * ensure we have good html
+ RelocateParagraphs(MSHTML::IHTMLDOMNodePtr(pe));
+ FixupParagraphs(pe);
+
+ // * close undo unit
+ m_mk_srv->EndUndoUnit();
+ }
+ catch (_com_error& e) {
+ U::ReportError(e);
+ }
+ return false;
+}
+
+long CFBEView::InsertCode()
+{
+ if(bCall(L"IsCode", SelectionStructCode()))
+ {
+ HRESULT hr;
+ BeginUndoUnit(L"insert code");
+ hr = m_mk_srv->RemoveElement(SelectionStructCode());
+ EndUndoUnit();
+ return hr == S_OK ? 0 : -1;
+ }
+ else
+ {
+ try
+ {
+ BeginUndoUnit(L"insert code");
+
+ int offset = -1;
+ MSHTML::IHTMLTxtRangePtr rng(Document()->selection->createRange());
+ if (!(bool)rng) return -1;
+
+ CString rngHTML((wchar_t*)rng->htmlText);
+
+ // empty selection case - select current word
+ if(rngHTML == L"")
+ {
+ // select word
+ rng->moveStart(L"word",-1);
+ CString txt = rng->text;
+ offset = txt.GetLength();
+ rng->expand(L"word");
+ rngHTML.SetString(rng->htmlText);
+ }
+
+ if (iswspace(rngHTML[rngHTML.GetLength()-1]))
+ {
+ rng->moveEnd(L"character",-1);
+ rngHTML.SetString(rng->htmlText);
+ if (offset > rngHTML.GetLength()) offset--;
+ }
+
+ // save selection
+ MSHTML::IMarkupPointerPtr selBegin, selEnd;
+ m_mk_srv->CreateMarkupPointer(&selBegin);
+ m_mk_srv->CreateMarkupPointer(&selEnd);
+ m_mk_srv->MovePointersToRange(rng, selBegin, selEnd);
+
+ if(rngHTML.Find(L"createElement(L"");
+ MSHTML::IHTMLElementPtr selElem = rng->parentElement();
+
+ MSHTML::IHTMLTxtRangePtr rngStart = rng->duplicate();
+ MSHTML::IHTMLTxtRangePtr rngEnd = rng->duplicate();
+ rngStart->collapse(true);
+ rngEnd->collapse(false);
+
+ MSHTML::IHTMLElementPtr elBegin = rngStart->parentElement(), elEnd = rngEnd->parentElement();
+ while(U::scmp(elBegin->tagName, L"P")) elBegin = elBegin->parentElement;
+ while(U::scmp(elEnd->tagName, L"P")) elEnd = elEnd->parentElement;
+
+ MSHTML::IHTMLDOMNodePtr bNode = elBegin, eNode = elEnd;
+ int last = 0;
+ while(bNode)
+ {
+ CString elBeginHTML = elBegin->innerHTML;
+
+ if(U::scmp(elBegin->tagName, L"P") == 0 && elBeginHTML.Find(L"innerHTML = elBegin->innerHTML;
+ if(!(elBeginHTML.Find(L"") == 0 &&
+ elBeginHTML.Find(L" ") == elBeginHTML.GetLength() - 7))
+ {
+ elBegin->innerHTML = spanElem->outerHTML;
+ }
+ }
+ // remove code tag
+ else
+ {
+ elBeginHTML.Replace (L"", L" ");
+ elBeginHTML.Replace (L" ", L" ");
+ elBegin->innerHTML = elBeginHTML.AllocSysString();
+ }
+
+ if(bNode == eNode)
+ break;
+
+ bNode = bNode->nextSibling;
+ elBegin = bNode;
+ }
+ // expand selection to the last paragraph
+ rng->moveToElementText(elBegin);
+ m_mk_srv->MovePointersToRange(rng, NULL, selEnd);
+ }
+ else if(rngHTML.Find(L"") != -1 && rngHTML.Find(L" ") != -1)
+ {
+ rngHTML.Replace (L"", L" ");
+ rngHTML.Replace (L" ", L" ");
+ rng->pasteHTML(rngHTML.AllocSysString());
+ }
+ else
+ {
+ if (iswspace(rngHTML[0]))
+ {
+ rng->moveStart(L"character",1);
+ rngHTML.SetString(rng->htmlText);
+ }
+ if (iswspace(rngHTML[rngHTML.GetLength()-1]))
+ {
+ rng->moveEnd(L"character",-1);
+ rngHTML.SetString(rng->htmlText);
+ }
+ rngHTML = L"" + rngHTML + L" ";
+ rng->pasteHTML(rngHTML.AllocSysString());
+ }
+
+ // restore selection
+ if (offset >= 0)
+ {
+ rng->move(L"word", -1);
+ rng->move(L"character", offset);
+ rng->select();
+ }
+ else
+ {
+ m_mk_srv->MoveRangeToPointers(selBegin, selEnd, rng);
+ rng->select();
+ }
+
+ EndUndoUnit();
+ }
+ catch (_com_error& e)
+ {
+ U::ReportError(e);
+ return -1;
+ }
+
+ return 0;
+ }
+}
+
+int CFBEView::GetRangePos(const MSHTML::IHTMLTxtRangePtr range, MSHTML::IHTMLElementPtr &element, int &pos)
+{
+ MSHTML::IHTMLTxtRangePtr tr(range->duplicate());
+ tr->collapse(VARIANT_TRUE);
+
+ // * get its parent element
+ element = tr->parentElement();
+
+ MSHTML::IHTMLTxtRangePtr btr(range->duplicate());
+ btr->moveToElementText(element);
+ btr->collapse(VARIANT_TRUE);
+
+ pos = 0;
+
+ MSHTML::IHTMLDOMNodePtr node(element);
+ if(!(bool)node)
+ {
+ return 0;
+ }
+
+ int count = 0;
+ int cuttedchars = 0;
+
+ node = node->firstChild;
+ while(node)
+ {
+ MSHTML::IHTMLDOMTextNodePtr textNode(node);
+ if(!(bool)textNode)
+ {
+ int skip = CountNodeChars(node);
+ cuttedchars += skip;
+ btr->move(L"character", skip);
+ }
+ else
+ {
+ // проверяем не проскочили ли мы искомую позицию
+ int skip = count + textNode->length;
+ btr->move(L"character", skip);
+
+ if(btr->compareEndPoints(L"StartToStart", tr) != -1)
+ {
+ btr->move(L"character", -skip);
+ break;
+ }
+ pos += skip;
+ }
+
+ node = node->nextSibling;
+ }
+
+ // тупая проверка.
+ // если курсор стоит сразу после тега, то tr оказывается справа от brt и при этом никогда не бывает равен ему
+ int k = btr->compareEndPoints(L"StartToStart", tr);
+ if(k == -1)
+ {
+ int res = btr->move(L"character", 1);
+ if (res != 1)
+ {
+ return 0;
+ }
+ if(btr->compareEndPoints(L"StartToStart", tr) != 1)
+ {
+ ++pos;
+ }
+ }
+
+ while(btr->compareEndPoints(L"StartToStart", tr) == -1)
+ {
+ ++pos;
+ int res = btr->move(L"character", 1);
+ if (res != 1)
+ {
+ return 0;
+ }
+ }
+
+ return pos;
+}
+
+bool CFBEView::GetSelectionInfo(MSHTML::IHTMLElementPtr *begin, MSHTML::IHTMLElementPtr *end, int* begin_char, int* end_char, MSHTML::IHTMLTxtRangePtr range)
+{
+ *begin_char = 0;
+ *end_char = 0;
+
+ int b = 0;
+ int e = 0;
+
+ bool one_elment = false;
+ // * create selection range
+ MSHTML::IHTMLTxtRangePtr rng;
+ if(!(bool)range)
+ {
+ IDispatchPtr disp(Document()->selection->createRange());
+ rng = disp;
+ if (!(bool)rng)
+ {
+ // если не получилось сделать textrange, пробуем сделать control range
+ MSHTML::IHTMLControlRangePtr coll(disp);
+ if (!(bool)coll)
+ {
+ return false;
+ }
+ *begin = coll->item(0);
+ *end = coll->item(coll->length - 1);
+ return true;
+ }
+ }
+ else
+ rng = range;
+
+ bstr_t text = rng->text;
+
+ MSHTML::IHTMLTxtRangePtr tr(rng->duplicate());
+ tr->collapse(VARIANT_TRUE);
+
+ // * get its parent element
+ *begin = tr->parentElement();
+ if (!(bool)(*begin))
+ return false;
+
+ // ищем позицию относительно начала;
+ this->GetRangePos(tr, *begin, b);
+
+ tr = rng->duplicate();
+ tr->collapse(VARIANT_FALSE);
+ *end = tr->parentElement();
+ if (*end == *begin)
+ {
+ one_elment = true;
+ }
+
+ this->GetRangePos(tr, *end, e);
+
+ MSHTML::IHTMLDOMNodePtr nodeb(*begin);
+ MSHTML::IHTMLDOMNodePtr nodee(*end);
+ if(!(bool)nodeb || !(bool)nodee)
+ {
+ return false;
+ }
+
+ /*b = this->GetRelationalCharPos(nodeb, b);
+ e = this->GetRelationalCharPos(nodee, e);*/
+
+ *begin_char = b;
+ *end_char = e;
+
+ return true;
+}
+
+MSHTML::IHTMLTxtRangePtr CFBEView::SetSelection(MSHTML::IHTMLElementPtr begin, MSHTML::IHTMLElementPtr end, int begin_pos, int end_pos)
+{
+ if(!(bool)begin)
+ {
+ return 0;
+ }
+ if(!(bool)end)
+ {
+ end = begin;
+ end_pos = begin_pos;
+ }
+
+ begin_pos = this->GetRealCharPos(begin, begin_pos);
+ end_pos = this->GetRealCharPos(end, end_pos);
+
+ MSHTML::IHTMLTxtRangePtr rng(MSHTML::IHTMLBodyElementPtr(Document()->body)->createTextRange());
+ if(!(bool)rng)
+ {
+ return 0;
+ }
+
+ // устанавливаем начало выделенной строки
+ MSHTML::IHTMLTxtRangePtr rng_begin(rng->duplicate());
+ rng_begin->moveToElementText(begin);
+ rng_begin->collapse(VARIANT_TRUE);
+ rng_begin->moveStart(L"character", begin_pos);
+
+ if(begin == end)
+ {
+ rng_begin->moveEnd(L"character", end_pos - begin_pos);
+ HRESULT hr = rng_begin->select();
+
+ return rng_begin;
+ }
+
+ MSHTML::IHTMLTxtRangePtr rng_end(rng->duplicate());
+ rng_end->moveToElementText(end);
+ rng_end->moveStart(L"character", end_pos);
+
+ // раздвигаем регион
+ rng_begin->setEndPoint(L"EndToStart", rng_end);
+
+ rng_begin->select();
+
+
+ return rng_begin;
+}
+
+int CFBEView::GetRelationalCharPos(MSHTML::IHTMLDOMNodePtr node, int pos)
+{
+ if(!(bool)node)
+ {
+ return 0;
+ }
+
+ int relpos = 0;
+ int cuttedchars = 0;
+
+ node = node->firstChild;
+ while(node)
+ {
+ MSHTML::IHTMLDOMTextNodePtr textNode(node);
+ if(!(bool)textNode)
+ {
+ cuttedchars += CountNodeChars(node);
+ }
+ else
+ {
+ if(relpos + cuttedchars + textNode->length >= pos)
+ {
+ return pos - cuttedchars;
+ }
+ relpos += textNode->length;
+ }
+ node = node->nextSibling;
+ }
+
+ return 0;
+}
+
+int CFBEView::GetRealCharPos(MSHTML::IHTMLDOMNodePtr node, int pos)
+{
+ if(!(bool)node)
+ {
+ return 0;
+ }
+
+ int realpos = 0;
+ int cuttedchars = 0;
+
+ node = node->firstChild;
+ while(node)
+ {
+ MSHTML::IHTMLDOMTextNodePtr textNode(node);
+ if(!(bool)textNode)
+ {
+ cuttedchars += CountNodeChars(node);
+ }
+ else
+ {
+ if((realpos + textNode->length) >= pos)
+ {
+ return pos + cuttedchars;
+ }
+ realpos += textNode->length;
+ }
+ node = node->nextSibling;
+ }
+
+ return 0;
+}
+
+int CFBEView::CountNodeChars(MSHTML::IHTMLDOMNodePtr node)
+{
+ if(!(bool)node)
+ {
+ return 0;
+ }
+
+ int count = 0;
+
+ node = node->firstChild;
+ while(node)
+ {
+ MSHTML::IHTMLDOMTextNodePtr textNode(node);
+ if(!(bool)textNode)
+ {
+ count += CountNodeChars(node);
+ }
+ else
+ {
+ count += textNode->length;
+ }
+ node = node->nextSibling;
+ }
+
+ return count;
+}
+
+bool CFBEView::CloseFindDialog(CFindDlgBase* dlg)
+{
+ if(!dlg || !dlg->IsValid())
+ return false;
+
+ dlg->DestroyWindow();
+ return true;
+}
+
+bool CFBEView::CloseFindDialog(CReplaceDlgBase* dlg)
+{
+ if(!dlg || !dlg->IsValid())
+ return false;
+
+ dlg->DestroyWindow();
+ return true;
+}
+
+bool CFBEView::ExpandTxtRangeToParagraphs(MSHTML::IHTMLTxtRangePtr& rng,
+ MSHTML::IHTMLElementPtr& begin,
+ MSHTML::IHTMLElementPtr& end) const
+{
+ MSHTML::IHTMLTxtRangePtr tr1 = rng->duplicate();
+ tr1->collapse(true);
+
+ MSHTML::IHTMLElementPtr te = GetHP(tr1->parentElement());
+
+ if(!(bool)te)
+ return false;
+
+ MSHTML::IHTMLTxtRangePtr tr2 = rng->duplicate();
+ tr2->collapse(false);
+
+ begin = tr1->parentElement();
+ while((bool)begin && U::scmp(begin->tagName, L"P"))
+ begin = begin->parentElement;
+
+ if(!(bool)begin)
+ return false;
+
+ end = tr2->parentElement();
+ while((bool)end && U::scmp(end->tagName, L"P"))
+ end = end->parentElement;
+
+ if(!(bool)end)
+ return false;
+
+ if(begin == end)
+ rng->moveToElementText(begin);
+ else
+ {
+ MSHTML::IMarkupPointerPtr pBegin, pEnd;
+ m_mk_srv->CreateMarkupPointer(&pBegin);
+ m_mk_srv->CreateMarkupPointer(&pEnd);
+ pBegin->MoveAdjacentToElement(begin, MSHTML::ELEM_ADJ_AfterBegin);
+ pEnd->MoveAdjacentToElement(end, MSHTML::ELEM_ADJ_BeforeEnd);
+ m_mk_srv->MoveRangeToPointers(pBegin, pEnd, rng);
+ }
+
+ return true;
+}
+
+LRESULT CFBEView::OnCode(WORD wCode, WORD wID, HWND hWnd, BOOL& bHandled)
+{
+ return InsertCode();
+}
+
+bool CFBEView::SelectionHasTags(wchar_t* elem)
+{
+ try
+ {
+ MSHTML::IHTMLTxtRangePtr range = Document()->selection->createRange();
+ if(range)
+ {
+ CString html = range->htmlText;
+ if(html.Find(CString(L"<") + elem) != -1)
+ return true;
+ }
+ }
+ catch(_com_error& err)
+ {
+ U::ReportError(err);
+ return false;
+ }
+
+ return false;
+}
+
+BSTR CFBEView::PrepareDefaultId(const CString& filename){
+
+ CString _filename = U::Transliterate(filename);
+ // prepare a default id
+ int cp = _filename.ReverseFind(_T('\\'));
+ if (cp < 0)
+ cp = 0;
+ else
+ ++cp;
+ CString newid;
+ TCHAR *ncp=newid.GetBuffer(_filename.GetLength()-cp);
+ int newlen=0;
+ while (cp<_filename.GetLength()) {
+ TCHAR c=_filename[cp];
+ if ((c>=_T('0') && c<=_T('9')) ||
+ (c>=_T('A') && c<=_T('Z')) ||
+ (c>=_T('a') && c<=_T('z')) ||
+ c==_T('_') || c==_T('.'))
+ ncp[newlen++]=c;
+ ++cp;
+ }
+ newid.ReleaseBuffer(newlen);
+ if (!newid.IsEmpty() && !(
+ (newid[0]>=_T('A') && newid[0]<=_T('Z')) ||
+ (newid[0]>=_T('a') && newid[0]<=_T('z')) ||
+ newid[0]==_T('_')))
+ newid.Insert(0,_T('_'));
+ return newid.AllocSysString();
+}
+
+// images
+void CFBEView::AddImage(const CString& filename, bool bInline)
+{
+ _variant_t args[4];
+
+ V_BSTR(&args[3]) = filename.AllocSysString();
+ V_VT(&args[3]) = VT_BSTR;
+
+ HRESULT hr;
+ if(FAILED(hr = U::LoadFile(filename, &args[0])))
+ {
+ U::ReportError(hr);
+ return;
+ }
+
+ // Prepare a default ID
+ int cp = filename.ReverseFind(_T('\\'));
+ if (cp < 0)
+ cp = 0;
+ else
+ ++cp;
+
+ V_BSTR(&args[2]) = PrepareDefaultId(filename);
+ V_VT(&args[2]) = VT_BSTR;
+
+ // Try to find out mime type
+ V_BSTR(&args[1]) = U::GetMimeType(filename).AllocSysString();
+ V_VT(&args[1]) = VT_BSTR;
+
+ // Stuff the thing into JavaScript
+ try
+ {
+ CComDispatchDriver body(Script());
+ _variant_t checkedId;
+ hr = body.InvokeN(L"apiAddBinary", args, 4, &checkedId);
+
+ if(FAILED(hr))
+ U::ReportError(hr);
+
+ hr = body.Invoke0(L"FillCoverList");
+
+ if(FAILED(hr))
+ U::ReportError(hr);
+
+ _variant_t check(false);
+ if (bInline)
+ hr = body.Invoke2(L"InsInlineImage", &check, &checkedId);
+ else
+ hr = body.Invoke2(L"InsImage", &check, &checkedId);
+ if (FAILED(hr))
+ U::ReportError(hr);
+
+ MSHTML::IHTMLDOMNodePtr node(NULL);
+ if(node)
+ BubbleUp(node, L"DIV");
+ }
+ catch (_com_error&) { }
+}
diff --git a/FBSHell/FBShell.vcxproj b/FBSHell/FBShell.vcxproj
index 44b80a4..d236a49 100644
--- a/FBSHell/FBShell.vcxproj
+++ b/FBSHell/FBShell.vcxproj
@@ -1,453 +1,462 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}
- FBShell
- Svn
- Svn
- Svn
- SubversionScc
-
-
-
- DynamicLibrary
- Unicode
- false
- false
- v100
-
-
- DynamicLibrary
- false
- Unicode
- Static
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- AllRules.ruleset
-
-
- AllRules.ruleset
-
-
-
-
-
- Disabled
- $(SolutionDir)WTL;libjpeg;libpng;zlib;%(AdditionalIncludeDirectories)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
- false
- Use
- Level3
- EditAndContinue
-
-
- true
- FBSHell.def
- /nologo /mktyplib203 /win32
- true
- MachineX86
-
-
-
-
- MinSpace
- true
- Size
- $(SolutionDir)WTL;libjpeg;libpng;zlib;%(AdditionalIncludeDirectories)
- MultiThreaded
- true
- false
- Use
- Level3
- ProgramDatabase
- NDEBUG;WIN32;_WINDOWS;UNICODE;STRICT;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
- AsInvoker
- FBSHell.def
- /nologo /mktyplib203 /win32
- true
- true
- true
- MachineX86
-
-
-
-
-
-
-
-
- upx.exe $(OutDir)FBShell.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Create
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {856C10BA-254C-4FA0-B45B-00F4B5A6DEB2}
+ FBShell
+ Svn
+ Svn
+ Svn
+ SubversionScc
+ 8.1
+
+
+
+ DynamicLibrary
+ Unicode
+ false
+ false
+ v140_xp
+ true
+
+
+ DynamicLibrary
+ false
+ Unicode
+ v140_xp
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.30319.1
+ $(SolutionDir)$(Configuration)\
+ $(Configuration)\
+ $(SolutionDir)$(Configuration)\
+ $(Configuration)\
+ AllRules.ruleset
+
+
+ AllRules.ruleset
+
+
+
+
+ true
+
+
+
+ Disabled
+ $(SolutionDir)WTL;libjpeg;libpng;zlib;%(AdditionalIncludeDirectories)
+ true
+ EnableFastChecks
+ MultiThreadedDebugDLL
+ false
+ Use
+ Level3
+ EditAndContinue
+ /Zc:threadSafeInit-
+
+
+ true
+ FBSHell.def
+ /nologo /mktyplib203 /win32
+ true
+ MachineX86
+ Windows
+ false
+
+
+
+
+ $(SolutionDir)WTL;libjpeg;libpng;zlib;%(AdditionalIncludeDirectories)
+ MultiThreaded
+ true
+ false
+ Use
+ Level3
+ ProgramDatabase
+ NDEBUG;WIN32;_WINDOWS;UNICODE;STRICT;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ /Zc:threadSafeInit-
+
+
+ AsInvoker
+ FBSHell.def
+ /nologo /mktyplib203 /win32
+ true
+ true
+ true
+ MachineX86
+
+
+
+
+ Windows
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FBSHell/FBShell.vcxproj.filters b/FBSHell/FBShell.vcxproj.filters
index 25e7bbb..2faa78d 100644
--- a/FBSHell/FBShell.vcxproj.filters
+++ b/FBSHell/FBShell.vcxproj.filters
@@ -1,289 +1,290 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Source Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
- Resource Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
-
- Resource Files
-
-
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Source Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Resource Files
+
+
\ No newline at end of file
diff --git a/FBSHell/StdAfx.h b/FBSHell/StdAfx.h
index 7b69b82..3d957fd 100644
--- a/FBSHell/StdAfx.h
+++ b/FBSHell/StdAfx.h
@@ -1,67 +1,67 @@
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#if !defined(AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_)
-#define AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-// check for unicode
-#ifndef UNICODE
-#error This program requires unicode support to run
-#endif
-
-#define WINVER 0x0410 // W2K/98
-#define _WIN32_WINNT 0x0500 // W2K
-#define _WIN32_IE 0x0600 // IE 6+
-
-// we are MT by default
-#define _ATL_MULTI_THREADED
-
-// Insert your headers here
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-
-#include
-
-extern CComModule _Module;
-
-#include
-#include
-
-#include
-
-#include
-#include
-
-#import
-
-#include
-#include
-#include
-
-#include
-
-#include
-
-#include
-#include
-#include
-#include
-
-#include "resource.h"
-#include "ptr.h"
-#include "Image.h"
-#include "FBShell.h"
-
-#include
-
-using namespace _com_util;
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_)
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_)
+#define AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+// check for unicode
+#ifndef UNICODE
+#error This program requires unicode support to run
+#endif
+
+#define WINVER 0x0501 // WinXP
+#define _WIN32_WINNT 0x0501 // WinXP
+#define _WIN32_IE 0x0600 // IE 6+
+
+// we are MT by default
+#define _ATL_MULTI_THREADED
+
+// Insert your headers here
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#include
+
+extern CComModule _Module;
+
+#include
+#include
+
+#include
+
+#include
+#include
+
+#import
+
+#include
+#include
+#include
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "resource.h"
+#include "ptr.h"
+#include "Image.h"
+#include "FBShell.h"
+
+#include
+
+using namespace _com_util;
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__AA787312_D02C_4332_A4DD_1B1AA8B9E8BF__INCLUDED_)
diff --git a/FBSHell/packages.config b/FBSHell/packages.config
new file mode 100644
index 0000000..7df3378
--- /dev/null
+++ b/FBSHell/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/FBV/FBV.cpp b/FBV/FBV.cpp
new file mode 100644
index 0000000..ef5fb08
--- /dev/null
+++ b/FBV/FBV.cpp
@@ -0,0 +1,681 @@
+#include
+#include
+#include
+#include
+
+#include "resource.h"
+
+#import
+
+using namespace _com_util;
+
+#if defined _M_IX86
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_IA64
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
+#if defined _M_IX86
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_IA64
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
+
+enum {
+ INIT_TIMER=1
+};
+
+static HWND g_dialog;
+static HINSTANCE g_instance;
+static UINT_PTR g_timer;
+static bool g_stop;
+static bool g_validating;
+static TCHAR g_schema_file[MAX_PATH];
+static const wchar_t *FBNS=L"http://www.gribuser.ru/xml/fictionbook/2.0";
+static int FBNS_len;
+static const wchar_t *XLINKNS=L"http://www.w3.org/1999/xlink";
+static int XLINKNS_len;
+
+static void DoEvents() {
+ MSG msg;
+
+ while (::PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
+ if (!::IsDialogMessage(g_dialog,&msg)) {
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ }
+ }
+}
+
+enum VState {
+ UNCHECKED, VALID, INVALID
+};
+
+struct FileInfo {
+ BSTR filename;
+ BSTR errmsg;
+ FILETIME timestamp;
+ ULARGE_INTEGER size;
+ VState state;
+};
+
+static struct FileInfo *g_file_list;
+static int g_list_items,g_list_max;
+
+static void ScanDirectory(const wchar_t *filename);
+static void ValidateFiles();
+
+static void AddFileInfo(const wchar_t *filename,DWORD attr,FILETIME ft,
+ DWORD szLow,DWORD szHigh)
+{
+ if (g_list_items>=g_list_max) {
+ int nsize=g_list_max ? g_list_max<<1 : 128;
+ void *nmem=::realloc(g_file_list, nsize*sizeof(g_file_list[0]));
+ if (!nmem)
+ return;
+ g_file_list=(FileInfo*)nmem;
+ g_list_max=nsize;
+ }
+
+ FileInfo *fi=&g_file_list[g_list_items++];
+
+ fi->filename=::SysAllocString(filename);
+
+ if (!fi->filename)
+ return;
+
+ fi->timestamp=ft;
+ fi->size.LowPart=szLow;
+ fi->size.HighPart=szHigh;
+ fi->state=UNCHECKED;
+ fi->errmsg=NULL;
+
+ // add to list control
+ LVITEM lvi;
+ memset(&lvi,0,sizeof(lvi));
+ lvi.mask=LVIF_IMAGE|LVIF_PARAM|LVIF_TEXT;
+ lvi.iItem=g_list_items-1;
+ lvi.pszText=LPSTR_TEXTCALLBACK;
+ lvi.lParam=g_list_items-1;
+
+ ::SendDlgItemMessage(g_dialog,IDC_FILELIST,LVM_INSERTITEM,0,(LPARAM)&lvi);
+}
+
+static void AddFile(const wchar_t *filename) {
+ DWORD attr=::GetFileAttributes(filename);
+
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ return;
+
+ if (attr & FILE_ATTRIBUTE_DIRECTORY) {
+ ScanDirectory(filename);
+ return;
+ }
+
+ HANDLE hFile=::CreateFile(filename,FILE_READ_ATTRIBUTES,0,NULL,OPEN_EXISTING,0,NULL);
+ if (hFile==INVALID_HANDLE_VALUE)
+ return;
+
+ FILETIME ft;
+ ULARGE_INTEGER fs;
+
+ ::GetFileTime(hFile,NULL,NULL,&ft);
+ fs.LowPart=::GetFileSize(hFile,&fs.HighPart);
+
+ ::CloseHandle(hFile);
+
+ AddFileInfo(filename,attr,ft,fs.LowPart,fs.HighPart);
+}
+
+static void ScanDirectory(const wchar_t *filename) {
+ ::SendDlgItemMessage(g_dialog,IDC_STATUS,SB_SETTEXT,0,(LPARAM)filename);
+ DoEvents(); // pump messages
+
+ int namelen=lstrlen(filename);
+ if (namelen<=0 || namelen>MAX_PATH-5)
+ return;
+
+ TCHAR buffer[MAX_PATH];
+ lstrcpy(buffer,filename);
+
+ if (buffer[namelen-1]!=_T('\\'))
+ buffer[namelen++]=_T('\\');
+ buffer[namelen]=_T('*');
+ buffer[namelen+1]=0;
+
+ HANDLE hFind;
+ BOOL fNext=TRUE;
+ WIN32_FIND_DATA fd;
+
+ for (hFind=::FindFirstFile(buffer,&fd);
+ hFind!=INVALID_HANDLE_VALUE && fNext && !g_stop;
+ fNext=::FindNextFile(hFind,&fd))
+ {
+ if (lstrcmp(fd.cFileName,_T("."))==0 || lstrcmp(fd.cFileName,_T(".."))==0)
+ continue;
+
+ int curlen=lstrlen(fd.cFileName);
+ if (curlen+namelen>=MAX_PATH)
+ continue;
+
+ lstrcpy(buffer+namelen,fd.cFileName);
+
+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ ScanDirectory(buffer);
+ continue;
+ }
+
+ if (curlen>4 && lstrcmpi(fd.cFileName+curlen-4,_T(".fb2"))==0)
+ AddFileInfo(buffer,fd.dwFileAttributes,fd.ftLastWriteTime,
+ fd.nFileSizeLow,fd.nFileSizeHigh);
+ }
+
+ if (hFind!=INVALID_HANDLE_VALUE)
+ ::FindClose(hFind);
+}
+
+static void ProcessCommandLine() {
+ int argc;
+ wchar_t **argv=::CommandLineToArgvW(::GetCommandLineW(),&argc);
+
+ int base=0;
+ if (argc>0) {
+ int len=lstrlen(argv[0]);
+ if (len>4 && lstrcmpiW(argv[0]+len-4,L".exe")==0)
+ ++base;
+ }
+
+ for (int i=base;iid),&rc);
+ ::ScreenToClient(hDlg,rc);
+
+ // left
+ switch (ii->borders[0]) {
+ case BL: ii->rc.left=rc.left-cli.left; break;
+ case BR: ii->rc.left=cli.right-rc.left; break;
+ default: assert(0); break;
+ }
+
+ // top
+ switch (ii->borders[1]) {
+ case BT: ii->rc.top=rc.top-cli.top; break;
+ case BB: ii->rc.top=cli.bottom-rc.top; break;
+ default: assert(0); break;
+ }
+
+ // right
+ switch (ii->borders[2]) {
+ case BL: ii->rc.right=rc.right-cli.left; break;
+ case BR: ii->rc.right=cli.right-rc.right; break;
+ case BS: ii->rc.right=rc.right-rc.left; break;
+ }
+
+ // bottom
+ switch (ii->borders[3]) {
+ case BT: ii->rc.bottom=rc.bottom-cli.top; break;
+ case BB: ii->rc.bottom=cli.bottom-rc.bottom; break;
+ case BS: ii->rc.bottom=rc.bottom-rc.top; break;
+ }
+ }
+}
+
+static void SizeDialog(HWND hDlg, ControlInfo *ii,int nitems) {
+ RECT cli;
+ ::GetClientRect(hDlg,&cli);
+
+ for (;nitems;--nitems,++ii) {
+ RECT rc;
+ ::GetWindowRect(::GetDlgItem(hDlg,ii->id),&rc);
+ int oldw=rc.right-rc.left;
+
+ // left
+ switch (ii->borders[0]) {
+ case BL: rc.left=cli.left+ii->rc.left; break;
+ case BR: rc.left=cli.right-ii->rc.left; break;
+ case BS: assert(0); break;
+ }
+
+ // top
+ switch (ii->borders[1]) {
+ case BT: rc.top=cli.top+ii->rc.top; break;
+ case BB: rc.top=cli.bottom-ii->rc.top; break;
+ case BS: assert(0);
+ }
+
+ // right
+ switch (ii->borders[2]) {
+ case BL: rc.right=cli.left+ii->rc.right; break;
+ case BR: rc.right=cli.right-ii->rc.right; break;
+ case BS: rc.right=rc.left+ii->rc.right; break;
+ }
+
+ // bottom
+ switch (ii->borders[3]) {
+ case BT: rc.bottom=cli.top+ii->rc.bottom; break;
+ case BB: rc.bottom=cli.bottom-ii->rc.bottom; break;
+ case BS: rc.bottom=rc.top+ii->rc.bottom; break;
+ }
+
+ int neww=rc.right-rc.left;
+
+ if (!ii->flags && newwid,LVM_SETCOLUMNWIDTH,0,
+ MAKELPARAM(neww-::GetSystemMetrics(SM_CXVSCROLL)-4,0));
+
+ ::MoveWindow(::GetDlgItem(hDlg,ii->id),
+ rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,
+ TRUE);
+
+ if (!ii->flags && neww>oldw)
+ ::SendDlgItemMessage(hDlg,ii->id,LVM_SETCOLUMNWIDTH,0,
+ MAKELPARAM(neww-::GetSystemMetrics(SM_CXVSCROLL)-4,0));
+
+ if (ii->flags)
+ ::RedrawWindow(::GetDlgItem(hDlg,ii->id),NULL,NULL,
+ RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
+ }
+}
+
+static INT_PTR CALLBACK DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
+{
+ NMHDR *nmh;
+
+ switch (uMsg) {
+ case WM_INITDIALOG: {
+ RECT rcmsg,rcstatus;
+
+ g_dialog=hDlg;
+ // adjust the edit control height to avoid overlapping the status line
+ ::GetWindowRect(::GetDlgItem(hDlg,IDC_STATUS),&rcstatus);
+ ::GetWindowRect(::GetDlgItem(hDlg,IDC_MSG),&rcmsg);
+ rcmsg.bottom=rcstatus.top;
+ ScreenToClient(hDlg,rcmsg);
+ ::MoveWindow(::GetDlgItem(hDlg,IDC_MSG),rcmsg.left,rcmsg.top,
+ rcmsg.right-rcmsg.left,rcmsg.bottom-rcmsg.top,FALSE);
+ // initialize resizing structures
+ SizeInit(hDlg,g_controls,NCONTROLS);
+ ::SendMessage(hDlg,WM_SETICON,ICON_BIG,
+ (LPARAM)::LoadIcon(g_instance,MAKEINTRESOURCE(IDI_MAIN)));
+ // set list view imagelist
+ ::SendDlgItemMessage(hDlg,IDC_FILELIST,LVM_SETIMAGELIST,LVSIL_SMALL,
+ (LPARAM)::ImageList_LoadBitmap(g_instance,MAKEINTRESOURCE(IDB_VICONS),
+ 16,0,RGB(255,0,255)));
+ // add one column to list view
+ ::GetClientRect(::GetDlgItem(hDlg,IDC_FILELIST),&rcmsg);
+ LVCOLUMN lvc;
+ memset(&lvc,0,sizeof(lvc));
+ lvc.mask=LVCF_FMT|LVCF_WIDTH;
+ lvc.fmt=LVCFMT_LEFT;
+ lvc.cx=rcmsg.right-rcmsg.left-::GetSystemMetrics(SM_CXVSCROLL)-4;
+ lvc.pszText=_T("File name");
+ ::SendDlgItemMessage(hDlg,IDC_FILELIST,LVM_INSERTCOLUMN,0,(LPARAM)&lvc);
+ // set startup timer
+ g_timer=::SetTimer(hDlg,INIT_TIMER,100,NULL);
+ return TRUE; }
+
+ case WM_COMMAND:
+ if (HIWORD(wParam)==0 || HIWORD(wParam)==1) {
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ g_stop=true;
+ ::EndDialog(hDlg,IDCANCEL);
+ break;
+ case IDC_VALIDATE:
+ if (g_validating)
+ g_stop=true;
+ else
+ ValidateFiles();
+ break;
+ }
+ }
+ break;
+
+ case WM_SIZE:
+ SizeDialog(hDlg,g_controls,NCONTROLS);
+ break;
+
+ case WM_TIMER:
+ if (wParam==g_timer) {
+ ::KillTimer(hDlg,g_timer);
+ ProcessCommandLine();
+ if (g_list_items==0)
+ ::EndDialog(hDlg,IDCANCEL);
+ else
+ ValidateFiles();
+ } else
+ return FALSE;
+ break;
+
+ case WM_NOTIFY:
+ nmh=(NMHDR *)lParam;
+ if (nmh->idFrom==IDC_FILELIST && nmh->code==LVN_GETDISPINFO) {
+ NMLVDISPINFO *lvi=(NMLVDISPINFO*)lParam;
+
+ if (lvi->item.mask & LVIF_TEXT && lvi->item.lParam>=0 && lvi->item.lParamitem.lParam].filename;
+ const wchar_t *slash=wcsrchr(name,_T('\\'));
+ if (slash)
+ name=slash+1;
+
+ int len=lstrlenW(name);
+ if (len>4 && lstrcmpiW(name+len-4,L".fb2")==0)
+ len-=4;
+
+ // copy filename
+ if (len>lvi->item.cchTextMax-1)
+ len=lvi->item.cchTextMax-1;
+ memcpy(lvi->item.pszText,name,len*sizeof(wchar_t));
+ lvi->item.pszText[len]=0;
+ }
+ } else if (nmh->idFrom==IDC_FILELIST && nmh->code==LVN_ITEMCHANGED) {
+ NMLISTVIEW *lvi=(NMLISTVIEW *)lParam;
+
+ if (lvi->iItem>=0 && lvi->lParam>=0 && lvi->lParamuNewState & LVIS_SELECTED)
+ {
+ FileInfo *fi=&g_file_list[lvi->lParam];
+
+ if (fi->errmsg && fi->errmsg[0])
+ ::SetDlgItemText(hDlg,IDC_MSG,fi->errmsg);
+ else
+ ::SetDlgItemText(hDlg,IDC_MSG,_T("No errors."));
+
+ ::SendDlgItemMessage(g_dialog,IDC_STATUS,SB_SETTEXT,0,(LPARAM)fi->filename);
+ }
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+// SAX error handler
+class SAXEH : public MSXML2::ISAXErrorHandler {
+public:
+ SAXEH() : m_error_msg(0) { }
+ ~SAXEH() { ::SysFreeString(m_error_msg); }
+
+ // dummy IUnknown
+ STDMETHOD(QueryInterface)(REFIID iid,void **ppvObject) {
+ if (iid==IID_IUnknown || iid==__uuidof(MSXML2::ISAXErrorHandler)) {
+ *ppvObject=this;
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+ }
+ STDMETHOD_(ULONG,AddRef)() { return 1; }
+ STDMETHOD_(ULONG,Release)() { return 1; }
+
+ // ISAXErrorHandler
+ STDMETHOD(raw_error)(MSXML2::ISAXLocator *loc, USHORT *msg, HRESULT hr) {
+ SetMsg(loc,msg,hr);
+ return E_FAIL;
+ }
+ STDMETHOD(raw_fatalError)(MSXML2::ISAXLocator *loc, USHORT *msg, HRESULT hr) {
+ SetMsg(loc,msg,hr);
+ return E_FAIL;
+ }
+ STDMETHOD(raw_ignorableWarning)(MSXML2::ISAXLocator *loc, USHORT *msg, HRESULT hr) {
+ SetMsg(loc,msg,hr);
+ return E_FAIL;
+ }
+
+ BSTR m_error_msg;
+
+ void SetMsg(MSXML2::ISAXLocator *loc,const USHORT *msg,HRESULT hr) {
+ if (m_error_msg)
+ return;
+
+ int line=loc->getLineNumber();
+ int col=loc->getColumnNumber();
+
+ if (line>0 && col>0) {
+ wchar_t buffer[2048];
+
+ _snwprintf(buffer,sizeof(buffer)/sizeof(buffer[0]),L"At line %d, column %d:\r\n%s",
+ line,col,msg);
+
+ // delete namespace references
+ for (wchar_t *cp=buffer;*cp;++cp)
+ if (*cp==L'{') {
+ if (wcsncmp(cp+1,FBNS,FBNS_len)==0 && cp[1+FBNS_len]==L'}') {
+ int len=lstrlen(cp+FBNS_len+2);
+ memmove(cp,cp+FBNS_len+2,len*sizeof(wchar_t));
+ cp[len]=0;
+ --cp; // restart from copied char
+ } else if (wcsncmp(cp+1,XLINKNS,XLINKNS_len)==0 && cp[1+XLINKNS_len]==L'}') {
+ int len=lstrlen(cp+XLINKNS_len+2);
+ memmove(cp,cp+XLINKNS_len+2,len*sizeof(wchar_t));
+ cp[len]=0;
+ --cp; // restart from copied char
+ }
+ }
+
+ m_error_msg=::SysAllocString(buffer);
+ } else
+ m_error_msg=::SysAllocString((const OLECHAR *)msg);
+ }
+};
+
+static void SetItemState(int idx,FileInfo *fi,VState state) {
+ if (fi->state==state)
+ return;
+
+ fi->state=state;
+
+ LVITEM lvi;
+ memset(&lvi,0,sizeof(lvi));
+
+ lvi.iItem=idx; // XXX assumes index==param, should really use LVM_FINDITEM
+ lvi.mask=LVIF_IMAGE;
+ lvi.iImage=fi->state;
+
+ ::SendDlgItemMessage(g_dialog,IDC_FILELIST,LVM_SETITEM,0,(LPARAM)&lvi);
+}
+
+static void SetCOMError(int idx,FileInfo *fi,_com_error& e) {
+ wchar_t buffer[1024];
+
+ _snwprintf(buffer,sizeof(buffer)/sizeof(buffer[0]),L"COM Error: %x [%s]",
+ e.Error(),(const wchar_t *)e.Description());
+
+ fi->errmsg=::SysAllocString(buffer);
+ SetItemState(idx,fi,INVALID);
+}
+
+static void ValidateFiles() {
+ g_validating=true;
+ g_stop=false;
+ ::SetDlgItemText(g_dialog,IDC_VALIDATE,_T("&Stop"));
+
+ // create an error handler
+ SAXEH eh;
+
+ try {
+ MSXML2::IXMLDOMSchemaCollection2Ptr scol;
+ CheckError(scol.CreateInstance(L"Msxml2.XMLSchemaCache.4.0"));
+
+ // load fictionbook schema
+ scol->add(FBNS,g_schema_file);
+
+ // create a SAX reader
+ MSXML2::ISAXXMLReaderPtr rdr;
+ CheckError(rdr.CreateInstance(L"Msxml2.SAXXMLReader.4.0"));
+
+ // attach a schema
+ rdr->putFeature((USHORT*)L"schema-validation",VARIANT_TRUE);
+ rdr->putProperty((USHORT*)L"schemas",scol.GetInterfacePtr());
+ rdr->putFeature((USHORT*)L"exhaustive-errors",VARIANT_TRUE);
+
+ rdr->putErrorHandler(&eh);
+
+ for (int i=0;!g_stop && istate==UNCHECKED;
+
+ if (!fDV) {
+ HANDLE hFile=::CreateFile(fi->filename,FILE_READ_ATTRIBUTES,0,NULL,OPEN_EXISTING,0,NULL);
+ if (hFile!=INVALID_HANDLE_VALUE) {
+ FILETIME tm;
+ ULARGE_INTEGER sz;
+ ::GetFileTime(hFile,NULL,NULL,&tm);
+ sz.LowPart=::GetFileSize(hFile,&sz.HighPart);
+ ::CloseHandle(hFile);
+
+ fDV=tm.dwHighDateTime!=fi->timestamp.dwHighDateTime ||
+ tm.dwLowDateTime!=fi->timestamp.dwLowDateTime ||
+ sz.QuadPart!=fi->size.QuadPart;
+
+ fi->timestamp=tm;
+ fi->size=sz;
+ }
+ }
+
+ if (fDV) {
+ ::SendDlgItemMessage(g_dialog,IDC_STATUS,SB_SETTEXT,0,(LPARAM)fi->filename);
+ try {
+ rdr->parseURL((USHORT*)fi->filename);
+ SetItemState(i,fi,VALID);
+ }
+ catch (_com_error& e) {
+ if (eh.m_error_msg) {
+ fi->errmsg=eh.m_error_msg;
+ eh.m_error_msg=0;
+ SetItemState(i,fi,INVALID);
+ } else
+ SetCOMError(i,fi,e);
+ }
+ DoEvents();
+ }
+ }
+ }
+ catch (_com_error& e) {
+ wchar_t buffer[1024];
+ _snwprintf(buffer,sizeof(buffer)/sizeof(buffer[0]),L"COM Error: %x [%s]",
+ e.Error(),(const wchar_t *)e.Description());
+ ::MessageBox(g_dialog,buffer,_T("Error"),MB_OK|MB_ICONERROR);
+ }
+
+ ::SendDlgItemMessage(g_dialog,IDC_STATUS,SB_SETTEXT,0,(LPARAM)_T("Done."));
+ ::SetDlgItemText(g_dialog,IDC_VALIDATE,_T("Re&validate"));
+ g_validating=false;
+}
\ No newline at end of file
diff --git a/FBV/FBV.rc b/FBV/FBV.rc
new file mode 100644
index 0000000..b3f1bae
--- /dev/null
+++ b/FBV/FBV.rc
@@ -0,0 +1,116 @@
+//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
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+#ifdef _WIN32
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+#endif //_WIN32
+
+#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
+
+#endif // Russian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// 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
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_MAIN DIALOGEX 0, 0, 346, 201
+STYLE DS_NOIDLEMSG | DS_CENTERMOUSE | WS_MINIMIZEBOX | WS_MAXIMIZEBOX |
+ WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU |
+ WS_THICKFRAME
+CAPTION "FictionBook Validator"
+FONT 10, "Tahoma"
+BEGIN
+ CONTROL "List1",IDC_FILELIST,"SysListView32",LVS_REPORT |
+ LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_TABSTOP,0,0,346,
+ 144,WS_EX_STATICEDGE
+ EDITTEXT IDC_MSG,0,144,288,47,ES_MULTILINE | ES_AUTOVSCROLL |
+ ES_READONLY | NOT WS_BORDER | WS_VSCROLL,
+ WS_EX_STATICEDGE
+ PUSHBUTTON "Re&validate",IDC_VALIDATE,294,150,48,14,NOT WS_VISIBLE
+ PUSHBUTTON "E&xit",IDCANCEL,294,171,48,14
+ CONTROL "Scanning...",IDC_STATUS,"msctls_statusbar32",0x0,0,191,
+ 346,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_MAIN ICON DISCARDABLE "..\\res\\FBE.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_VICONS BITMAP DISCARDABLE "vicons.bmp"
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/FBV/FBV.vcxproj b/FBV/FBV.vcxproj
new file mode 100644
index 0000000..0125b1c
--- /dev/null
+++ b/FBV/FBV.vcxproj
@@ -0,0 +1,150 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {700EF473-7FF9-4CD4-93FB-9C3ABF5D5C4A}
+ Win32Proj
+ 8.1
+
+
+
+ Application
+ true
+ v140_xp
+ Static
+ Unicode
+
+
+ Application
+ false
+ v140_xp
+ Static
+ Unicode
+ false
+ true
+
+
+ Application
+ true
+ v140_xp
+ Unicode
+
+
+ Application
+ false
+ v140_xp
+ Unicode
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ MultiThreadedDebug
+ Level3
+ ProgramDatabase
+ Disabled
+
+
+ MachineX86
+ true
+ Windows
+ comctl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+
+
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ MultiThreaded
+ Level3
+ ProgramDatabase
+ true
+
+
+ MachineX86
+ true
+ Windows
+ true
+ true
+ comctl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ UseFastLinkTimeCodeGeneration
+
+
+
+
+ comctl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+
+
+ MultiThreadedDebug
+
+
+
+
+ comctl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
+ UseFastLinkTimeCodeGeneration
+
+
+ MultiThreaded
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FBV/FBV.vcxproj.filters b/FBV/FBV.vcxproj.filters
new file mode 100644
index 0000000..d5ca969
--- /dev/null
+++ b/FBV/FBV.vcxproj.filters
@@ -0,0 +1,37 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
+
+
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
+
\ No newline at end of file
diff --git a/FBV/resource.h b/FBV/resource.h
new file mode 100644
index 0000000..350c319
--- /dev/null
+++ b/FBV/resource.h
@@ -0,0 +1,22 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by FBV.rc
+//
+#define IDD_MAIN 101
+#define IDI_MAIN 102
+#define IDB_VICONS 103
+#define IDC_FILELIST 1000
+#define IDC_MSG 1001
+#define IDC_VALIDATE 1002
+#define IDC_STATUS 1004
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1005
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/FBV/vicons.bmp b/FBV/vicons.bmp
new file mode 100644
index 0000000..324037c
Binary files /dev/null and b/FBV/vicons.bmp differ
diff --git a/Installer/MakeInstaller.bat b/Installer/MakeInstaller.bat
index 464bad0..000d047 100644
--- a/Installer/MakeInstaller.bat
+++ b/Installer/MakeInstaller.bat
@@ -1,18 +1,19 @@
-@ECHO OFF
-
-rd .\Input /S /Q
-
-devenv ..\FBE.sln /clean Release
-devenv ..\FBE.sln /build Release
-
-md .\Input
-
-copy ..\Release\FBE.exe .\Input\
-copy ..\Release\res_rus.dll .\Input\
-copy ..\Release\res_ukr.dll .\Input\
-copy ..\Release\FBSHell.dll .\Input\
-copy ..\Release\ExportHTML.dll .\Input\
-
-xcopy ..\files\*.* .\Input\ /E /Y
-
+@ECHO OFF
+
+rd .\Input /S /Q
+
+devenv ..\FBE.sln /clean Release
+devenv ..\FBE.sln /build Release
+
+md .\Input
+
+copy ..\Release\FBE.exe .\Input\
+copy ..\Release\pcre.dll .\Input\
+copy ..\Release\res_rus.dll .\Input\
+copy ..\Release\res_ukr.dll .\Input\
+copy ..\Release\FBSHell.dll .\Input\
+copy ..\Release\ExportHTML.dll .\Input\
+
+xcopy ..\files\*.* .\Input\ /E /Y
+
"C:\Program Files\NSIS\Unicode\makensis" MakeInstaller.nsi
\ No newline at end of file
diff --git a/Installer/MakeInstaller.nsi b/Installer/MakeInstaller.nsi
index 1d0c9f2..3354556 100644
Binary files a/Installer/MakeInstaller.nsi and b/Installer/MakeInstaller.nsi differ
diff --git a/NOWTO.md b/NOWTO.md
new file mode 100644
index 0000000..c2e2177
--- /dev/null
+++ b/NOWTO.md
@@ -0,0 +1,11 @@
+# FictionBook Editor HowTo
+
+## How to build
+
+To build FBE you need Visual Studio 2015, Community Edition is suitable. You can try previous versions, but it's untested. Nothing else is required.
+
+Don't forget to install [MSXML 4.0](https://www.microsoft.com/en-us/download/details.aspx?id=15697), this component is required to run FictionBook Editor.
+
+## How to make installer
+
+To make installer you need to install [NSIS Unicode](http://www.scratchpaper.com/). Build Release configuration of FBE, then go to Installer folder. Fist run MakeInstaller.bat to copy required files to Installer folder, and after this load MakeInstaller.nsi to NSIS and compile.
\ No newline at end of file
diff --git a/ReadMe.md b/ReadMe.md
new file mode 100644
index 0000000..a8ad42a
--- /dev/null
+++ b/ReadMe.md
@@ -0,0 +1,18 @@
+# FictionBook Editor
+
+## About FBE
+
+Fiction Book Editor (FBE) is a famous (standard de facto) fb2 documents editor, initially created by Mike Matsnev (http://haali.su), supported for years by many various developers on the closed source code principles; last contributor was a Russian company "LitRes" (http://litres.ru). FBE source code was released at January, 2010.
+In 2016 development was continued by evpobr (evpobr@gmail.com).
+
+FBE consists of the following components:
+* FictionBook Editor;
+* FBShell, shell extension for Explorer;
+* ExportHTML, plugin for FictionBook Editor to export FB2 to HTML format;
+* FBV, FictionBook Validator.
+
+## System requirements
+
+You need at least Windows XP SP3 to run FictionBook Editor, Windows Vista and higher are supported as well. 64-bit OSes are supported, except FBShell, which will not work under 64-bit Explorer.
+
+To run FictionBook Editor [MSXML 4.0](https://www.microsoft.com/en-us/download/details.aspx?id=15697) is required.
diff --git a/Speller.cpp b/Speller.cpp
index 0f5402b..038c7be 100644
--- a/Speller.cpp
+++ b/Speller.cpp
@@ -1,955 +1,957 @@
-#include "stdafx.h"
-#include "resource.h"
-#include "res1.h"
-#include
-#include
-#include "FBE.h"
-#include "Speller.h"
-
-// spell check dialog initialisation
-LRESULT CSpellDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-{
- m_BadWord = GetDlgItem(IDC_SPELL_BEDWORD);
- m_Replacement = GetDlgItem(IDC_SPELL_REPLACEMENT);
- m_Suggestions = GetDlgItem(IDC_SPELL_SUGG_LIST);
- m_IgnoreContinue = GetDlgItem(IDC_SPELL_IGNORE);
- m_WasSuspended = false;
-
- UpdateData();
- CenterWindow();
- return 1;
-}
-
-LRESULT CSpellDialog::OnActivate(UINT, WPARAM wParam, LPARAM, BOOL&)
-{
- if (wParam == WA_INACTIVE)
- {
- CString txt;
- txt.LoadString(IDS_SPELL_CONTINUE);
- m_IgnoreContinue.SetWindowText (txt);
-
- GetDlgItem(IDC_SPELL_IGNOREALL).EnableWindow(FALSE);
- GetDlgItem(IDC_SPELL_CHANGE).EnableWindow(FALSE);
- GetDlgItem(IDC_SPELL_CHANGEALL).EnableWindow(FALSE);
- GetDlgItem(IDC_SPELL_ADD).EnableWindow(FALSE);
- m_Replacement.EnableWindow(FALSE);
- m_Suggestions.EnableWindow(FALSE);
- m_WasSuspended = true;
-
- UpdateWindow();
- }
- return 0;
-}
-
-LRESULT CSpellDialog::UpdateData()
-{
- m_BadWord.SetWindowText (m_sBadWord);
- m_Suggestions.ResetContent();
- if (m_strSuggestions)
- for (int i=0; iGetSize(); i++)
- {
- m_Suggestions.AddString((*m_strSuggestions)[i]);
- if (!i) m_Replacement.SetWindowText ((*m_strSuggestions)[i]);
- }
-
- if(m_Speller->GetUndoState())
- GetDlgItem(IDC_SPELL_UNDO).EnableWindow(TRUE);
- else
- GetDlgItem(IDC_SPELL_UNDO).EnableWindow(FALSE);
-
- return 1;
-}
-
-LRESULT CSpellDialog::OnSelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- CString strText;
- if (m_Suggestions.GetText(m_Suggestions.GetCurSel(),strText))
- m_Replacement.SetWindowText(strText);
- return 0;
-}
-
-// change text to suggested word on doubleclick
-LRESULT CSpellDialog::OnSelDblClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- CString strText;
- if (m_Suggestions.GetText(m_Suggestions.GetCurSel(),strText))
- {
- m_Replacement.SetWindowText(strText);
- OnChange(0, 0, 0, bHandled);
- }
- return 0;
-}
-
-LRESULT CSpellDialog::OnEditChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- m_Replacement.GetWindowText(m_sReplacement);
- return 0;
-}
-
-LRESULT CSpellDialog::OnCancel(WORD, WORD wID, HWND, BOOL&)
-{
- ATLASSERT(m_Speller!=NULL);
- m_Speller->EndDocumentCheck();
- return 0;
-}
-
-LRESULT CSpellDialog::OnIgnore(WORD, WORD wID, HWND, BOOL&)
-{
- ATLASSERT(m_Speller!=NULL);
- if (m_WasSuspended)
- {
- CString txt;
- txt.LoadString(IDC_SPELL_IGNORE);
- m_IgnoreContinue.SetWindowText (txt);
-
- GetDlgItem(IDC_SPELL_IGNOREALL).EnableWindow(TRUE);
- GetDlgItem(IDC_SPELL_CHANGE).EnableWindow(TRUE);
- GetDlgItem(IDC_SPELL_CHANGEALL).EnableWindow(TRUE);
- GetDlgItem(IDC_SPELL_ADD).EnableWindow(TRUE);
- m_Replacement.EnableWindow(TRUE);
- m_Suggestions.EnableWindow(TRUE);
- m_WasSuspended = false;
-
- UpdateWindow();
- m_Speller->StartDocumentCheck();
- }
- else
- m_Speller->ContinueDocumentCheck();
-
- return 0;
-}
-
-LRESULT CSpellDialog::OnIgnoreAll(WORD, WORD wID, HWND, BOOL&)
-{
- ATLASSERT(m_Speller!=NULL);
- m_Speller->IgnoreAll(m_sBadWord);
- m_Speller->ContinueDocumentCheck();
- return 0;
-}
-
-LRESULT CSpellDialog::OnChange(WORD, WORD wID, HWND, BOOL&)
-{
- ATLASSERT(m_Speller!=NULL);
- m_Speller->BeginUndoUnit(L"replace word");
- m_Speller->Replace(m_sReplacement);
- m_Speller->EndUndoUnit();
- m_Speller->ContinueDocumentCheck();
- return 0;
-}
-
-LRESULT CSpellDialog::OnChangeAll(WORD, WORD wID, HWND, BOOL&)
-{
- ATLASSERT(m_Speller!=NULL);
- m_Speller->AddReplacement(m_sBadWord,m_sReplacement);
- m_Speller->BeginUndoUnit(L"replace word");
- m_Speller->Replace(m_sReplacement);
- m_Speller->EndUndoUnit();
- m_Speller->ContinueDocumentCheck();
- return 0;
-}
-
-LRESULT CSpellDialog::OnAdd(WORD, WORD wID, HWND, BOOL&)
-{
- ATLASSERT(m_Speller!=NULL);
- m_Speller->AddToDictionary(m_sBadWord);
- m_Speller->ContinueDocumentCheck();
- return 0;
-}
-
-LRESULT CSpellDialog::OnUndo(WORD, WORD wID, HWND, BOOL&)
-{
- ATLASSERT(m_Speller!=NULL);
- m_Speller->Undo();
- UpdateData();
- return 0;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////
-//
-// CSpeller methods
-//
-////////////////////////////////////////////////////////////////////////////////////////////
-
-Hunhandle* CSpeller::LoadDictionary(CString dictPath, CString dictName)
-{
- USES_CONVERSION;
- Hunhandle* dict = NULL;
-
- if ( ATLPath::FileExists(dictPath+dictName+L".aff") && ATLPath::FileExists(dictPath+dictName+L".dic"))
- {
- // create dictionary from file
- dict = Hunspell_create(T2A(dictPath+dictName+".aff"), T2A(dictPath+dictName+".dic"));
- }
- return dict;
-}
-
-//
-// CSpeller constructor
-//
-CSpeller::CSpeller(CString dictPath):
- m_prevY(0), m_Lang(LANG_EN), m_Enabled(true), m_spell_dlg(0), m_prevSelRange(0)
-{
- m_DictPath = dictPath;
-
- // initialize all dictionaries
- for (int i=LANG_EN; i<=LANG_NONE; i++)
- m_Dictionaries.Add(dicts[i]);
-
- // but load only English and Russian dictionaries
- m_Dictionaries[LANG_EN].handle = LoadDictionary(dictPath, dicts[LANG_EN].name);
- m_Dictionaries[LANG_RU].handle = LoadDictionary(dictPath, dicts[LANG_RU].name);
-
- // don't split on apostrophes
- splitter = new CSplitter(L"'\u0301");
-}
-
-//
-// CSpeller destructor
-//
-CSpeller::~CSpeller()
-{
- EndDocumentCheck();
- // unload dictionaries
- for (int i=0; iparentWindow);
- IServiceProviderPtr pISP(pWin);
- pISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2,(void **)&m_browser);
-
- m_doc3 = MSHTML::IHTMLDocument3Ptr(doc);
- m_doc4 = MSHTML::IHTMLDocument4Ptr(doc);
- m_fbw_body = m_doc3->getElementById(L"fbw_body");
- m_scrollElement = m_doc3->documentElement;
- m_mkc = MSHTML::IMarkupContainer2Ptr(m_doc4);
- m_ims = MSHTML::IMarkupServicesPtr(m_doc4);
- m_ihrs = MSHTML::IHighlightRenderingServicesPtr(m_doc4);
- m_ids = MSHTML::IDisplayServicesPtr(m_doc4);
-
- // create a render style (wavy red line)
- _bstr_t b;
- m_irs = m_doc4->createRenderStyle(b);
- m_irs->defaultTextSelection = "false";
- m_irs->textBackgroundColor = "transparent";
- m_irs->textColor = "transparent";
- m_irs->textDecoration = "underline";
- m_irs->textDecorationColor = "red";
- m_irs->textUnderlineStyle = "wave";
-
- // detect document language
- SetDocumentLanguage();
-}
-
-void CSpeller::SetDocumentLanguage()
-{
- m_Lang = LANG_NONE;
- MSHTML::IHTMLSelectElementPtr elem = MSHTML::IHTMLDocument3Ptr(m_doc4)->getElementById(L"tiLang");
- if (elem)
- {
- CString lang = elem->value;
- for (int i=LANG_EN; iselection->createRange());
- if (selRange) rng = selRange->duplicate();
- if (rng)
- {
- CString s = rng->text;
- if (!s.IsEmpty()) rng->collapse(true);
- rng->expand(L"word");
- return rng;
- }
- else return 0;
-}
-
-//
-// Return word under caret
-//
-CString CSpeller::GetSelWord()
-{
- CString word(L"");
- MSHTML::IHTMLTxtRangePtr range = GetSelWordRange();
- if (range) word.SetString(range->text);
- return word.Trim();
-}
-
-//
-// Do a spell-check and append popup menu (if nessasary)
-//
-void CSpeller::AppendSpellMenu (HMENU menu)
-{
- CString word = GetSelWord();
- if (word.IsEmpty()) return;
-
- if (SpellCheck(word) != SPELL_OK)
- {
- m_menuSuggestions = GetSuggestions(word);
- int numSuggestions = m_menuSuggestions->GetSize();
- // limit up to 8 suggestion
- if (numSuggestions > 8) numSuggestions = 8;
-
- ::AppendMenu(menu, MF_SEPARATOR, 0, NULL);
- for (int i=0; i 0)
- ::AppendMenu(menu, MF_SEPARATOR, 0, NULL);
-
- CString itemName;
- itemName.LoadString(IDC_SPELL_IGNOREALL);
- ::AppendMenu(menu, MF_STRING, IDC_SPELL_IGNOREALL, itemName);
-
- itemName.LoadString(IDC_SPELL_ADD2DICT);
- ::AppendMenu(menu, MF_STRING, IDC_SPELL_ADD2DICT, itemName);
- }
-}
-
-//
-// Replace misspelled word from the correct variant (from popup menu)
-//
-void CSpeller::Replace(int nIndex)
-{
- MSHTML::IHTMLTxtRangePtr range = GetSelWordRange();
- CString addSpace = range->text;
- if (addSpace.Right(1) == L" ") addSpace.SetString(L" "); else addSpace.SetString(L"");
- try
- {
- CString replace = (*m_menuSuggestions)[nIndex];
- if (m_numAphChanged) replace.Replace(L"'", L"");
- replace = replace + addSpace;
- _bstr_t b = replace.AllocSysString();
- range->put_text(b);
- }
- catch(...){}
-}
-
-//
-// Replace misspelled word from the correct variant (from dialog)
-//
-void CSpeller::Replace(CString word)
-{
- if (m_selRange)
- {
- if (m_numAphChanged) word.Replace(L"'", L"");
- _bstr_t b = word.AllocSysString();
- m_selRange->put_text(b);
- }
-}
-
-void CSpeller::IgnoreAll(CString word)
-{
- if (word.IsEmpty()) word = GetSelWord();
- if (SpellCheck(word) != SPELL_OK)
- {
- m_IgnoreWords.Add(word);
- // recheck page
- ClearAllMarks();
- HighlightMisspells();
- }
-}
-
-void CSpeller::AddToDictionary()
-{
- CString word = GetSelWord();
- if (SpellCheck(word) != SPELL_OK)
- {
- Hunhandle* currDict = GetDictionary(word);
- // add to Hunspell's runtime dictionary
- CT2A str (word, m_codePage);
- Hunspell_add(currDict, str);
- // add to custom dictionary
- m_CustomDict.Add(word);
- SaveCustomDict();
- // recheck page
- ClearAllMarks();
- HighlightMisspells();
- }
-}
-
-void CSpeller::AddToDictionary(CString word)
-{
- Hunhandle* currDict = GetDictionary(word);
- // add to Hunspell's runtime dictionary
- CT2A str (word, m_codePage);
- Hunspell_add(currDict, str);
- // add to custom dictionary
- m_CustomDict.Add(word);
- SaveCustomDict();
- // recheck page
- ClearAllMarks();
- HighlightMisspells();
-}
-
-//
-// Return dictionary based on word (bi-lingual hack)
-//
-Hunhandle* CSpeller::GetDictionary(CString word)
-{
- // select document dictionary (based on FB2 document settings)
- m_codePage = m_Dictionaries[m_Lang].codepage;
- Hunhandle* currDict = m_Dictionaries[m_Lang].handle;
-
- // special fix for Russian words at non-Russian document
- if (m_Lang != LANG_RU && m_Lang != LANG_UA && m_Lang != LANG_BY)
- {
- // try to detect Russian language: too dirty but simple
- // 0x0 - English or other latin, 0x4 - Russian
- unsigned char* sData = (unsigned char*)word.GetString();
- if (sData[1] == 0x4)
- {
- // Russian language detected
- currDict = m_Dictionaries[LANG_RU].handle;
- m_codePage = m_Dictionaries[LANG_RU].codepage;
- }
- }
- return currDict;
-}
-
-//
-// Return suggestions for misspell word
-//
-CStrings* CSpeller::GetSuggestions(CString word)
-{
- // remove all soft hyphens
- word.Replace(L"\u00AD", L"");
-
- Hunhandle* currDict = GetDictionary(word);
- // encode string to the dictionary encoding
- CT2A str (word, m_codePage);
- char **list;
- int listLength = Hunspell_suggest(currDict, &list, str);
- CStrings* suggestions;
- suggestions = new CStrings();
-
- char** p = list;
- for (int i=0; iAdd(s);
- p++;
- }
- Hunspell_free_list(currDict, &list, listLength);
- return suggestions;
-}
-
-//
-// Spell check the word
-// CString "word" in UTF encoding
-// if no "range" assigned, spellcheck is non-interactive
-// "suggestions" (if assigned) will be filled by a replacement variants
-//
-SPELL_RESULT CSpeller::SpellCheck(CString word)
-{
- SPELL_RESULT spellResult(SPELL_OK);
- if (word.IsEmpty()) return SPELL_OK;
- Hunhandle* currDict = GetDictionary(word);
-
- // do spell check
- if (currDict)
- {
- CString checkWord(word);
-
- if (splitter->AlphaExceptions().Find(word[word.GetLength()-1]) > -1)
- checkWord.Delete(word.GetLength()-1);
-
- // replace aphostrophes (dictionaries understand only regular ' aphostrophe
- m_numAphChanged = checkWord.Replace(L"", L"'");
- // remove all soft hyphens
- checkWord.Replace(L"\u00AD", L"");
- // remove accent
- checkWord.Replace(L"\u0301", L"");
- // special case for Russian letter ""
- if (currDict == m_Dictionaries[LANG_RU].handle) checkWord.Replace(L"", L"");
-
- // encode string to the dictionary encoding
- CT2A str (checkWord, m_codePage);
-
- try { spellResult = (SPELL_RESULT) Hunspell_spell(currDict, str); }
- catch(...) { spellResult = SPELL_OK; }
-
- if (spellResult != SPELL_OK)
- {
- // check ignore_all list first
- int nIdx = m_IgnoreWords.Find(word);
- if (nIdx > -1)
- {
- spellResult = SPELL_OK;
- }
- else
- {
- // check auto-replacement list
- nIdx = m_ChangeWords.Find(word);
- if (nIdx > -1)
- {
- spellResult = SPELL_CHANGEALL;
- }
- else
- {
- // check in custom dictionary
- nIdx = m_CustomDict.Find(word);
- if (nIdx > -1) spellResult = SPELL_OK;
- }
- }
- }
- }
- return spellResult;
-}
-
-//
-// Highlight word at the pos in the element
-//
-void CSpeller::MarkElement(MSHTML::IHTMLElementPtr elem, long uniqID, CString word, int pos)
-{
- MSHTML::IMarkupPointerPtr impStart;
- MSHTML::IMarkupPointerPtr impEnd;
-
- // Create start markup pointer
- m_ims->CreateMarkupPointer(&impStart);
- impStart->MoveAdjacentToElement(elem, MSHTML::ELEM_ADJ_AfterBegin);
- for (int i=0; iMoveUnit (MSHTML::MOVEUNIT_NEXTCHAR);
-
- // Create end markup pointer
- m_ims->CreateMarkupPointer(&impEnd);
- impEnd->MoveAdjacentToElement(elem, MSHTML::ELEM_ADJ_BeforeEnd);
-
- // Locate the misspelled word
- _bstr_t w = word.AllocSysString();
- // First: exact match
-// if (impStart->findText (w, FINDTEXT_WHOLEWORD | FINDTEXT_MATCHCASE, impEnd, NULL) == S_FALSE)
- // Second: partial match
- if (impStart->findText (w, FINDTEXT_MATCHCASE, impEnd, NULL) == S_FALSE)
- return;
-
- // Create a display pointers from the markup pointers
- MSHTML::IDisplayPointerPtr idpStart;
- m_ids->CreateDisplayPointer(&idpStart);
- idpStart->MoveToMarkupPointer(impStart, NULL);
-
- MSHTML::IDisplayPointerPtr idpEnd;
- m_ids->CreateDisplayPointer(&idpEnd);
- idpEnd->MoveToMarkupPointer(impEnd, NULL);
-
- // Add or remove the segment
- MSHTML::IHighlightSegmentPtr ihs;
- m_ihrs->AddSegment(idpStart, idpEnd, m_irs, &ihs);
-
- m_ElementHighlights.insert(HIGHLIGHT(uniqID, ihs));
-}
-
-//
-// Removes all highlights in the document and clear saved highlights
-//
-void CSpeller::ClearAllMarks()
-{
- for each (HIGHLIGHT itr in m_ElementHighlights)
- {
- m_ihrs->RemoveSegment(itr.second);
- }
- m_ElementHighlights.clear();
-}
-
-//
-// Removes highlights for the unique element
-//
-void CSpeller::ClearMarks (int elemID)
-{
- HIGHLIGHTS::iterator itr, lastElement;
-
- itr = m_ElementHighlights.find(elemID);
- if (itr != m_ElementHighlights.end())
- {
- lastElement = m_ElementHighlights.upper_bound(elemID);
- for ( ; itr != lastElement; ++itr)
- if (itr->second)
- m_ihrs->RemoveSegment(itr->second);
-
- m_ElementHighlights.erase(elemID);
- }
-}
-
-//
-// Spellcheck selected element
-//
-void CSpeller::CheckElement(MSHTML::IHTMLElementPtr elem, long uniqID, bool HTMLChanged)
-{
- CWords words;
- // skip whole document checking
- CString html = elem->innerHTML;
- if (html.Find(L"= 0) return;
-
- CString innerText = elem->innerText;
-
- if (!innerText.Trim().IsEmpty())
- {
- if (uniqID < 0) uniqID = MSHTML::IHTMLUniqueNamePtr(elem)->uniqueNumber;
-
- if (HTMLChanged)
- ClearAllMarks();
- else
- ClearMarks(uniqID);
-
- // tokenize and spellcheck
- splitter->Split(&innerText, &words);
- for (int i=0; i
scrollTop;
- if (Y != m_prevY)
- {
- HighlightMisspells();
- m_prevY = Y;
- }
- }
-}
-
-inline void CSpeller::HighlightMisspells()
-{
- if (m_HighlightMisspells && m_Enabled)
- CheckCurrentPage();
-}
-
-
-void CSpeller::CheckCurrentPage()
-{
- CWords words;
- CString tagName;
- std::pair< std::set::iterator, bool > pr;
- int currNum, numChanges = 0, nStartElem, nEndElem;
- MSHTML::IHTMLElementPtr elem, endElem;
-
- // lookup first element on page
- for (int y=10; yclientHeight; y+=10)
- {
- elem = m_doc2->elementFromPoint(63, y);
- tagName.SetString(elem->tagName);
- if (tagName.CompareNoCase(L"P")==0) break;
- }
- // lookup last element on page
- for (int y=m_scrollElement->clientHeight; y>10; y-=10)
- {
- endElem = m_doc2->elementFromPoint(63, y);
- tagName.SetString(endElem->tagName);
- if (tagName.CompareNoCase(L"P")==0) break;
- }
-
- // get all document paragraphs
- MSHTML::IHTMLElementPtr fbw_body = m_doc3->getElementById(L"fbw_body");
- MSHTML::IHTMLElementCollectionPtr paras = MSHTML::IHTMLElement2Ptr(fbw_body)->getElementsByTagName(L"P");
-
- nStartElem = nEndElem = -1;
- for (int i=0; ilength; i++)
- {
- if ((nStartElem == -1) && paras->item(i) == elem) nStartElem = i;
- else if (paras->item(i) == endElem)
- {
- nEndElem = i;
- break;
- }
- }
-
- if (nStartElem == -1) nStartElem = 0;
-
- if (nEndElem == -1) nEndElem = nStartElem+20;
- else if (nEndElem+1 < paras->length) nEndElem++;
-
- for (int i=nStartElem; iitem(i);
- // get element unique number
- if (elem)
- {
- currNum = MSHTML::IHTMLUniqueNamePtr(elem)->uniqueNumber;
-
- // Getting uniqueNumber from IHTMLUniqueName interface changes
- // the internal HTML document version. We need to correct this
- // issue, because document not really changed
- pr = m_uniqIDs.insert(currNum);
- if (pr.second) numChanges++;
-
- CString innerText = elem->innerText;
- if(!innerText.IsEmpty())
- {
- // remove underline
- ClearMarks(currNum);
- splitter->Split(&innerText, &words);
- for (int i=0; iShowDialog();
- m_undoSrv = undoSrv;
- }
-
- // save current selection
- if (!m_prevSelRange)
- {
- m_ims->CreateMarkupPointer(&m_impStart);
- m_ims->CreateMarkupPointer(&m_impEnd);
-
- m_prevSelRange = m_doc2->selection->createRange();
- m_ims->MovePointersToRange(m_prevSelRange, m_impStart, m_impEnd);
- }
-
- // fetch selection
- CString selType = m_doc2->selection->type;
- m_selRange = m_doc2->selection->createRange();
-
- MSHTML::IHTMLElementPtr elem(m_selRange->parentElement());
- CString tag = elem->tagName;
-
- // if no caret (no focus) and no text selected, start from the beginning of displayed text
- if (tag.Compare (L"P") && selType.CompareNoCase(L"text"))
- {
- m_selRange->moveToElementText(m_doc2->elementFromPoint(65, 15));
- m_selRange->collapse(VARIANT_TRUE);
- }
- m_selRange->moveStart(L"word", -1);
-// m_selRange->moveEnd(L"word", 1);
-
- ContinueDocumentCheck();
-}
-
-//
-// Spellcheck whole document from beginning
-// Returns true if some changes was made, or false if no changes
-//
-void CSpeller::ContinueDocumentCheck()
-{
- HRESULT compareEnd;
- SPELL_RESULT result;
- CString word;
- _bstr_t b;
- bool bHyphen = false;
-
- // find next misspell word from the beginning or current position
- do
- {
- // shift to the next word
- m_selRange->move(L"word", 1);
- m_selRange->moveEnd(L"word", 1);
-
- result = SPELL_OK;
- word.SetString (m_selRange->text);
- word.Trim();
- // special check for hyphen
- if (word.Compare(L"-")==0)
- {
- m_selRange->moveStart(L"word", -1);
- m_selRange->moveEnd(L"word", 1);
- word.SetString (m_selRange->text);
- word.Trim();
- bHyphen = true;
- }
-
- // if word != words delimiter
- if (word.FindOneOf(Tokens)==-1)
- result = SpellCheck(word);
-
- // select exact word
- if ((result == SPELL_CHANGE) || (result == SPELL_CHANGEALL) || (result == SPELL_MISSPELL))
- {
- b = word.AllocSysString();
- m_selRange->findText(b, 1073741824, 2);
- m_selRange->select();
- }
-
- switch (result)
- {
- case SPELL_CHANGEALL:
- {
- CString replaceStr = m_ChangeWordsTo[m_ChangeWords.Find(word)];
- // replace aphostrophes back
- if (m_numAphChanged) replaceStr.Replace(L"'", L"");
- BeginUndoUnit(L"replace word");
- b = replaceStr.AllocSysString();
- m_selRange->put_text(b);
- EndUndoUnit();
- break;
- }
- case SPELL_MISSPELL:
- {
- m_spell_dlg->m_sBadWord = word;
- if (m_spell_dlg->m_strSuggestions)
- delete m_spell_dlg->m_strSuggestions;
- m_spell_dlg->m_strSuggestions = GetSuggestions(word);
- m_spell_dlg->UpdateData();
- break;
- }
- }
-
- // check for end of selection
- if (bHyphen)
- {
- m_selRange->moveStart(L"word", 2);
- m_selRange->moveEnd(L"word", 1);
- bHyphen = false;
- }
- compareEnd = m_selRange->compareEndPoints(L"StartToEnd", m_selRange);
- if (compareEnd == 0)
- {
- m_selRange->move(L"word", 1);
- m_selRange->moveEnd(L"word", 1);
- compareEnd = m_selRange->compareEndPoints(L"StartToEnd", m_selRange);
- }
-
- } while (result != SPELL_MISSPELL && compareEnd != 0);
-
- if (!compareEnd)
- EndDocumentCheck(false);
-}
-
-void CSpeller::EndDocumentCheck(bool bCancel)
-{
- if (m_spell_dlg)
- {
- m_spell_dlg->DestroyWindow();
- m_spell_dlg = 0;
- }
- // display message box
- if (!bCancel)
- {
- U::MessageBox(MB_OK | MB_ICONINFORMATION, IDR_MAINFRAME, IDS_SPELL_CHECK_COMPLETED);
- }
- // restore previous selection
- if (m_prevSelRange)
- {
- m_ims->MoveRangeToPointers(m_impStart, m_impEnd, m_prevSelRange);
- m_prevSelRange->select();
-
- // delete objects
- m_prevSelRange = 0;
- }
- // delete spell-check selection range
- if (m_selRange)
- {
- m_selRange = 0;
- }
-}
+#include "stdafx.h"
+#include "resource.h"
+#include "res1.h"
+#include
+#include
+#include "FBE.h"
+#include "Speller.h"
+
+// spell check dialog initialisation
+LRESULT CSpellDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ m_BadWord = GetDlgItem(IDC_SPELL_BEDWORD);
+ m_Replacement = GetDlgItem(IDC_SPELL_REPLACEMENT);
+ m_Suggestions = GetDlgItem(IDC_SPELL_SUGG_LIST);
+ m_IgnoreContinue = GetDlgItem(IDC_SPELL_IGNORE);
+ m_WasSuspended = false;
+
+ UpdateData();
+ CenterWindow();
+ return 1;
+}
+
+LRESULT CSpellDialog::OnActivate(UINT, WPARAM wParam, LPARAM, BOOL&)
+{
+ if (wParam == WA_INACTIVE)
+ {
+ CString txt;
+ txt.LoadString(IDS_SPELL_CONTINUE);
+ m_IgnoreContinue.SetWindowText (txt);
+
+ GetDlgItem(IDC_SPELL_IGNOREALL).EnableWindow(FALSE);
+ GetDlgItem(IDC_SPELL_CHANGE).EnableWindow(FALSE);
+ GetDlgItem(IDC_SPELL_CHANGEALL).EnableWindow(FALSE);
+ GetDlgItem(IDC_SPELL_ADD).EnableWindow(FALSE);
+ m_Replacement.EnableWindow(FALSE);
+ m_Suggestions.EnableWindow(FALSE);
+ m_WasSuspended = true;
+
+ UpdateWindow();
+ }
+ return 0;
+}
+
+LRESULT CSpellDialog::UpdateData()
+{
+ m_BadWord.SetWindowText (m_sBadWord);
+ m_Suggestions.ResetContent();
+ if (m_strSuggestions)
+ for (int i=0; iGetSize(); i++)
+ {
+ m_Suggestions.AddString((*m_strSuggestions)[i]);
+ if (!i) m_Replacement.SetWindowText ((*m_strSuggestions)[i]);
+ }
+
+ if(m_Speller->GetUndoState())
+ GetDlgItem(IDC_SPELL_UNDO).EnableWindow(TRUE);
+ else
+ GetDlgItem(IDC_SPELL_UNDO).EnableWindow(FALSE);
+
+ return 1;
+}
+
+LRESULT CSpellDialog::OnSelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ CString strText;
+ if (m_Suggestions.GetText(m_Suggestions.GetCurSel(),strText))
+ m_Replacement.SetWindowText(strText);
+ return 0;
+}
+
+// change text to suggested word on doubleclick
+LRESULT CSpellDialog::OnSelDblClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ CString strText;
+ if (m_Suggestions.GetText(m_Suggestions.GetCurSel(),strText))
+ {
+ m_Replacement.SetWindowText(strText);
+ OnChange(0, 0, 0, bHandled);
+ }
+ return 0;
+}
+
+LRESULT CSpellDialog::OnEditChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_Replacement.GetWindowText(m_sReplacement);
+ return 0;
+}
+
+LRESULT CSpellDialog::OnCancel(WORD, WORD wID, HWND, BOOL&)
+{
+ ATLASSERT(m_Speller!=NULL);
+ m_Speller->EndDocumentCheck();
+ return 0;
+}
+
+LRESULT CSpellDialog::OnIgnore(WORD, WORD wID, HWND, BOOL&)
+{
+ ATLASSERT(m_Speller!=NULL);
+ if (m_WasSuspended)
+ {
+ CString txt;
+ txt.LoadString(IDC_SPELL_IGNORE);
+ m_IgnoreContinue.SetWindowText (txt);
+
+ GetDlgItem(IDC_SPELL_IGNOREALL).EnableWindow(TRUE);
+ GetDlgItem(IDC_SPELL_CHANGE).EnableWindow(TRUE);
+ GetDlgItem(IDC_SPELL_CHANGEALL).EnableWindow(TRUE);
+ GetDlgItem(IDC_SPELL_ADD).EnableWindow(TRUE);
+ m_Replacement.EnableWindow(TRUE);
+ m_Suggestions.EnableWindow(TRUE);
+ m_WasSuspended = false;
+
+ UpdateWindow();
+ m_Speller->StartDocumentCheck();
+ }
+ else
+ m_Speller->ContinueDocumentCheck();
+
+ return 0;
+}
+
+LRESULT CSpellDialog::OnIgnoreAll(WORD, WORD wID, HWND, BOOL&)
+{
+ ATLASSERT(m_Speller!=NULL);
+ m_Speller->IgnoreAll(m_sBadWord);
+ m_Speller->ContinueDocumentCheck();
+ return 0;
+}
+
+LRESULT CSpellDialog::OnChange(WORD, WORD wID, HWND, BOOL&)
+{
+ ATLASSERT(m_Speller!=NULL);
+ m_Speller->BeginUndoUnit(L"replace word");
+ m_Speller->Replace(m_sReplacement);
+ m_Speller->EndUndoUnit();
+ m_Speller->ContinueDocumentCheck();
+ return 0;
+}
+
+LRESULT CSpellDialog::OnChangeAll(WORD, WORD wID, HWND, BOOL&)
+{
+ ATLASSERT(m_Speller!=NULL);
+ m_Speller->AddReplacement(m_sBadWord,m_sReplacement);
+ m_Speller->BeginUndoUnit(L"replace word");
+ m_Speller->Replace(m_sReplacement);
+ m_Speller->EndUndoUnit();
+ m_Speller->ContinueDocumentCheck();
+ return 0;
+}
+
+LRESULT CSpellDialog::OnAdd(WORD, WORD wID, HWND, BOOL&)
+{
+ ATLASSERT(m_Speller!=NULL);
+ m_Speller->AddToDictionary(m_sBadWord);
+ m_Speller->ContinueDocumentCheck();
+ return 0;
+}
+
+LRESULT CSpellDialog::OnUndo(WORD, WORD wID, HWND, BOOL&)
+{
+ ATLASSERT(m_Speller!=NULL);
+ m_Speller->Undo();
+ UpdateData();
+ return 0;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+//
+// CSpeller methods
+//
+////////////////////////////////////////////////////////////////////////////////////////////
+
+Hunhandle* CSpeller::LoadDictionary(CString dictPath, CString dictName)
+{
+ USES_CONVERSION;
+ Hunhandle* dict = NULL;
+
+ if ( ATLPath::FileExists(dictPath+dictName+L".aff") && ATLPath::FileExists(dictPath+dictName+L".dic"))
+ {
+ // create dictionary from file
+ CW2A affpath(dictPath + dictName + L".aff", CP_UTF8);
+ CW2A dpath(dictPath + dictName + L".dic", CP_UTF8);
+ dict = Hunspell_create(affpath, dpath);
+ }
+ return dict;
+}
+
+//
+// CSpeller constructor
+//
+CSpeller::CSpeller(CString dictPath):
+ m_prevY(0), m_Lang(LANG_EN), m_Enabled(true), m_spell_dlg(0), m_prevSelRange(0)
+{
+ m_DictPath = dictPath;
+
+ // initialize all dictionaries
+ for (int i=LANG_EN; i<=LANG_NONE; i++)
+ m_Dictionaries.Add(dicts[i]);
+
+ // but load only English and Russian dictionaries
+ m_Dictionaries[LANG_EN].handle = LoadDictionary(dictPath, dicts[LANG_EN].name);
+ m_Dictionaries[LANG_RU].handle = LoadDictionary(dictPath, dicts[LANG_RU].name);
+
+ // don't split on apostrophes
+ splitter = new CSplitter(L"'\u0301");
+}
+
+//
+// CSpeller destructor
+//
+CSpeller::~CSpeller()
+{
+ EndDocumentCheck();
+ // unload dictionaries
+ for (int i=0; iparentWindow);
+ IServiceProviderPtr pISP(pWin);
+ pISP->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2,(void **)&m_browser);
+
+ m_doc3 = MSHTML::IHTMLDocument3Ptr(doc);
+ m_doc4 = MSHTML::IHTMLDocument4Ptr(doc);
+ m_fbw_body = m_doc3->getElementById(L"fbw_body");
+ m_scrollElement = m_doc3->documentElement;
+ m_mkc = MSHTML::IMarkupContainer2Ptr(m_doc4);
+ m_ims = MSHTML::IMarkupServicesPtr(m_doc4);
+ m_ihrs = MSHTML::IHighlightRenderingServicesPtr(m_doc4);
+ m_ids = MSHTML::IDisplayServicesPtr(m_doc4);
+
+ // create a render style (wavy red line)
+ _bstr_t b;
+ m_irs = m_doc4->createRenderStyle(b);
+ m_irs->defaultTextSelection = "false";
+ m_irs->textBackgroundColor = "transparent";
+ m_irs->textColor = "transparent";
+ m_irs->textDecoration = "underline";
+ m_irs->textDecorationColor = "red";
+ m_irs->textUnderlineStyle = "wave";
+
+ // detect document language
+ SetDocumentLanguage();
+}
+
+void CSpeller::SetDocumentLanguage()
+{
+ m_Lang = LANG_NONE;
+ MSHTML::IHTMLSelectElementPtr elem = MSHTML::IHTMLDocument3Ptr(m_doc4)->getElementById(L"tiLang");
+ if (elem)
+ {
+ CString lang = elem->value;
+ for (int i=LANG_EN; iselection->createRange());
+ if (selRange) rng = selRange->duplicate();
+ if (rng)
+ {
+ CString s = rng->text;
+ if (!s.IsEmpty()) rng->collapse(true);
+ rng->expand(L"word");
+ return rng;
+ }
+ else return 0;
+}
+
+//
+// Return word under caret
+//
+CString CSpeller::GetSelWord()
+{
+ CString word(L"");
+ MSHTML::IHTMLTxtRangePtr range = GetSelWordRange();
+ if (range) word.SetString(range->text);
+ return word.Trim();
+}
+
+//
+// Do a spell-check and append popup menu (if nessasary)
+//
+void CSpeller::AppendSpellMenu (HMENU menu)
+{
+ CString word = GetSelWord();
+ if (word.IsEmpty()) return;
+
+ if (SpellCheck(word) != SPELL_OK)
+ {
+ m_menuSuggestions = GetSuggestions(word);
+ int numSuggestions = m_menuSuggestions->GetSize();
+ // limit up to 8 suggestion
+ if (numSuggestions > 8) numSuggestions = 8;
+
+ ::AppendMenu(menu, MF_SEPARATOR, 0, NULL);
+ for (int i=0; i 0)
+ ::AppendMenu(menu, MF_SEPARATOR, 0, NULL);
+
+ CString itemName;
+ itemName.LoadString(IDC_SPELL_IGNOREALL);
+ ::AppendMenu(menu, MF_STRING, IDC_SPELL_IGNOREALL, itemName);
+
+ itemName.LoadString(IDC_SPELL_ADD2DICT);
+ ::AppendMenu(menu, MF_STRING, IDC_SPELL_ADD2DICT, itemName);
+ }
+}
+
+//
+// Replace misspelled word from the correct variant (from popup menu)
+//
+void CSpeller::Replace(int nIndex)
+{
+ MSHTML::IHTMLTxtRangePtr range = GetSelWordRange();
+ CString addSpace = range->text;
+ if (addSpace.Right(1) == L" ") addSpace.SetString(L" "); else addSpace.SetString(L"");
+ try
+ {
+ CString replace = (*m_menuSuggestions)[nIndex];
+ if (m_numAphChanged) replace.Replace(L"'", L"");
+ replace = replace + addSpace;
+ _bstr_t b = replace.AllocSysString();
+ range->put_text(b);
+ }
+ catch(...){}
+}
+
+//
+// Replace misspelled word from the correct variant (from dialog)
+//
+void CSpeller::Replace(CString word)
+{
+ if (m_selRange)
+ {
+ if (m_numAphChanged) word.Replace(L"'", L"");
+ _bstr_t b = word.AllocSysString();
+ m_selRange->put_text(b);
+ }
+}
+
+void CSpeller::IgnoreAll(CString word)
+{
+ if (word.IsEmpty()) word = GetSelWord();
+ if (SpellCheck(word) != SPELL_OK)
+ {
+ m_IgnoreWords.Add(word);
+ // recheck page
+ ClearAllMarks();
+ HighlightMisspells();
+ }
+}
+
+void CSpeller::AddToDictionary()
+{
+ CString word = GetSelWord();
+ if (SpellCheck(word) != SPELL_OK)
+ {
+ Hunhandle* currDict = GetDictionary(word);
+ // add to Hunspell's runtime dictionary
+ CW2A str (word, CP_UTF8);
+ Hunspell_add(currDict, str);
+ // add to custom dictionary
+ m_CustomDict.Add(word);
+ SaveCustomDict();
+ // recheck page
+ ClearAllMarks();
+ HighlightMisspells();
+ }
+}
+
+void CSpeller::AddToDictionary(CString word)
+{
+ Hunhandle* currDict = GetDictionary(word);
+ // add to Hunspell's runtime dictionary
+ CT2A str (word, CP_UTF8);
+ Hunspell_add(currDict, str);
+ // add to custom dictionary
+ m_CustomDict.Add(word);
+ SaveCustomDict();
+ // recheck page
+ ClearAllMarks();
+ HighlightMisspells();
+}
+
+//
+// Return dictionary based on word (bi-lingual hack)
+//
+Hunhandle* CSpeller::GetDictionary(CString word)
+{
+ // select document dictionary (based on FB2 document settings)
+ m_codePage = m_Dictionaries[m_Lang].codepage;
+ Hunhandle* currDict = m_Dictionaries[m_Lang].handle;
+
+ // special fix for Russian words at non-Russian document
+ if (m_Lang != LANG_RU && m_Lang != LANG_UA && m_Lang != LANG_BY)
+ {
+ // try to detect Russian language: too dirty but simple
+ // 0x0 - English or other latin, 0x4 - Russian
+ unsigned char* sData = (unsigned char*)word.GetString();
+ if (sData[1] == 0x4)
+ {
+ // Russian language detected
+ currDict = m_Dictionaries[LANG_RU].handle;
+ m_codePage = m_Dictionaries[LANG_RU].codepage;
+ }
+ }
+ return currDict;
+}
+
+//
+// Return suggestions for misspell word
+//
+CStrings* CSpeller::GetSuggestions(CString word)
+{
+ // remove all soft hyphens
+ word.Replace(L"\u00AD", L"");
+
+ Hunhandle* currDict = GetDictionary(word);
+ // encode string to the dictionary encoding
+ CW2A str (word, CP_UTF8);
+ char **list;
+ int listLength = Hunspell_suggest(currDict, &list, str);
+ CStrings* suggestions;
+ suggestions = new CStrings();
+
+ char** p = list;
+ for (int i=0; iAdd(s);
+ p++;
+ }
+ Hunspell_free_list(currDict, &list, listLength);
+ return suggestions;
+}
+
+//
+// Spell check the word
+// CString "word" in UTF encoding
+// if no "range" assigned, spellcheck is non-interactive
+// "suggestions" (if assigned) will be filled by a replacement variants
+//
+SPELL_RESULT CSpeller::SpellCheck(CString word)
+{
+ SPELL_RESULT spellResult(SPELL_OK);
+ if (word.IsEmpty()) return SPELL_OK;
+ Hunhandle* currDict = GetDictionary(word);
+
+ // do spell check
+ if (currDict)
+ {
+ CString checkWord(word);
+
+ if (splitter->AlphaExceptions().Find(word[word.GetLength()-1]) > -1)
+ checkWord.Delete(word.GetLength()-1);
+
+ // replace aphostrophes (dictionaries understand only regular ' aphostrophe
+ m_numAphChanged = checkWord.Replace(L"", L"'");
+ // remove all soft hyphens
+ checkWord.Replace(L"\u00AD", L"");
+ // remove accent
+ checkWord.Replace(L"\u0301", L"");
+ // special case for Russian letter ""
+ if (currDict == m_Dictionaries[LANG_RU].handle) checkWord.Replace(L"", L"");
+
+ // encode string to the dictionary encoding
+ CW2A str (checkWord, CP_UTF8);
+
+ try { spellResult = (SPELL_RESULT) Hunspell_spell(currDict, str); }
+ catch(...) { spellResult = SPELL_OK; }
+
+ if (spellResult != SPELL_OK)
+ {
+ // check ignore_all list first
+ int nIdx = m_IgnoreWords.Find(word);
+ if (nIdx > -1)
+ {
+ spellResult = SPELL_OK;
+ }
+ else
+ {
+ // check auto-replacement list
+ nIdx = m_ChangeWords.Find(word);
+ if (nIdx > -1)
+ {
+ spellResult = SPELL_CHANGEALL;
+ }
+ else
+ {
+ // check in custom dictionary
+ nIdx = m_CustomDict.Find(word);
+ if (nIdx > -1) spellResult = SPELL_OK;
+ }
+ }
+ }
+ }
+ return spellResult;
+}
+
+//
+// Highlight word at the pos in the element
+//
+void CSpeller::MarkElement(MSHTML::IHTMLElementPtr elem, long uniqID, CString word, int pos)
+{
+ MSHTML::IMarkupPointerPtr impStart;
+ MSHTML::IMarkupPointerPtr impEnd;
+
+ // Create start markup pointer
+ m_ims->CreateMarkupPointer(&impStart);
+ impStart->MoveAdjacentToElement(elem, MSHTML::ELEM_ADJ_AfterBegin);
+ for (int i=0; iMoveUnit (MSHTML::MOVEUNIT_NEXTCHAR);
+
+ // Create end markup pointer
+ m_ims->CreateMarkupPointer(&impEnd);
+ impEnd->MoveAdjacentToElement(elem, MSHTML::ELEM_ADJ_BeforeEnd);
+
+ // Locate the misspelled word
+ _bstr_t w = word.AllocSysString();
+ // First: exact match
+// if (impStart->findText (w, FINDTEXT_WHOLEWORD | FINDTEXT_MATCHCASE, impEnd, NULL) == S_FALSE)
+ // Second: partial match
+ if (impStart->findText (w, FINDTEXT_MATCHCASE, impEnd, NULL) == S_FALSE)
+ return;
+
+ // Create a display pointers from the markup pointers
+ MSHTML::IDisplayPointerPtr idpStart;
+ m_ids->CreateDisplayPointer(&idpStart);
+ idpStart->MoveToMarkupPointer(impStart, NULL);
+
+ MSHTML::IDisplayPointerPtr idpEnd;
+ m_ids->CreateDisplayPointer(&idpEnd);
+ idpEnd->MoveToMarkupPointer(impEnd, NULL);
+
+ // Add or remove the segment
+ MSHTML::IHighlightSegmentPtr ihs;
+ m_ihrs->AddSegment(idpStart, idpEnd, m_irs, &ihs);
+
+ m_ElementHighlights.insert(HIGHLIGHT(uniqID, ihs));
+}
+
+//
+// Removes all highlights in the document and clear saved highlights
+//
+void CSpeller::ClearAllMarks()
+{
+ for each (HIGHLIGHT itr in m_ElementHighlights)
+ {
+ m_ihrs->RemoveSegment(itr.second);
+ }
+ m_ElementHighlights.clear();
+}
+
+//
+// Removes highlights for the unique element
+//
+void CSpeller::ClearMarks (int elemID)
+{
+ HIGHLIGHTS::iterator itr, lastElement;
+
+ itr = m_ElementHighlights.find(elemID);
+ if (itr != m_ElementHighlights.end())
+ {
+ lastElement = m_ElementHighlights.upper_bound(elemID);
+ for ( ; itr != lastElement; ++itr)
+ if (itr->second)
+ m_ihrs->RemoveSegment(itr->second);
+
+ m_ElementHighlights.erase(elemID);
+ }
+}
+
+//
+// Spellcheck selected element
+//
+void CSpeller::CheckElement(MSHTML::IHTMLElementPtr elem, long uniqID, bool HTMLChanged)
+{
+ CWords words;
+ // skip whole document checking
+ CString html = elem->innerHTML;
+ if (html.Find(L"= 0) return;
+
+ CString innerText = elem->innerText;
+
+ if (!innerText.Trim().IsEmpty())
+ {
+ if (uniqID < 0) uniqID = MSHTML::IHTMLUniqueNamePtr(elem)->uniqueNumber;
+
+ if (HTMLChanged)
+ ClearAllMarks();
+ else
+ ClearMarks(uniqID);
+
+ // tokenize and spellcheck
+ splitter->Split(&innerText, &words);
+ for (int i=0; i
scrollTop;
+ if (Y != m_prevY)
+ {
+ HighlightMisspells();
+ m_prevY = Y;
+ }
+ }
+}
+
+void CSpeller::HighlightMisspells()
+{
+ if (m_HighlightMisspells && m_Enabled)
+ CheckCurrentPage();
+}
+
+
+void CSpeller::CheckCurrentPage()
+{
+ CWords words;
+ CString tagName;
+ std::pair< std::set::iterator, bool > pr;
+ int currNum, numChanges = 0, nStartElem, nEndElem;
+ MSHTML::IHTMLElementPtr elem, endElem;
+
+ // lookup first element on page
+ for (int y=10; yclientHeight; y+=10)
+ {
+ elem = m_doc2->elementFromPoint(63, y);
+ tagName.SetString(elem->tagName);
+ if (tagName.CompareNoCase(L"P")==0) break;
+ }
+ // lookup last element on page
+ for (int y=m_scrollElement->clientHeight; y>10; y-=10)
+ {
+ endElem = m_doc2->elementFromPoint(63, y);
+ tagName.SetString(endElem->tagName);
+ if (tagName.CompareNoCase(L"P")==0) break;
+ }
+
+ // get all document paragraphs
+ MSHTML::IHTMLElementPtr fbw_body = m_doc3->getElementById(L"fbw_body");
+ MSHTML::IHTMLElementCollectionPtr paras = MSHTML::IHTMLElement2Ptr(fbw_body)->getElementsByTagName(L"P");
+
+ nStartElem = nEndElem = -1;
+ for (int i=0; ilength; i++)
+ {
+ if ((nStartElem == -1) && paras->item(i) == elem) nStartElem = i;
+ else if (paras->item(i) == endElem)
+ {
+ nEndElem = i;
+ break;
+ }
+ }
+
+ if (nStartElem == -1) nStartElem = 0;
+
+ if (nEndElem == -1) nEndElem = nStartElem+20;
+ else if (nEndElem+1 < paras->length) nEndElem++;
+
+ for (int i=nStartElem; iitem(i);
+ // get element unique number
+ if (elem)
+ {
+ currNum = MSHTML::IHTMLUniqueNamePtr(elem)->uniqueNumber;
+
+ // Getting uniqueNumber from IHTMLUniqueName interface changes
+ // the internal HTML document version. We need to correct this
+ // issue, because document not really changed
+ pr = m_uniqIDs.insert(currNum);
+ if (pr.second) numChanges++;
+
+ CString innerText = elem->innerText;
+ if(!innerText.IsEmpty())
+ {
+ // remove underline
+ ClearMarks(currNum);
+ splitter->Split(&innerText, &words);
+ for (int i=0; iShowDialog();
+ m_undoSrv = undoSrv;
+ }
+
+ // save current selection
+ if (!m_prevSelRange)
+ {
+ m_ims->CreateMarkupPointer(&m_impStart);
+ m_ims->CreateMarkupPointer(&m_impEnd);
+
+ m_prevSelRange = m_doc2->selection->createRange();
+ m_ims->MovePointersToRange(m_prevSelRange, m_impStart, m_impEnd);
+ }
+
+ // fetch selection
+ CString selType = m_doc2->selection->type;
+ m_selRange = m_doc2->selection->createRange();
+
+ MSHTML::IHTMLElementPtr elem(m_selRange->parentElement());
+ CString tag = elem->tagName;
+
+ // if no caret (no focus) and no text selected, start from the beginning of displayed text
+ if (tag.Compare (L"P") && selType.CompareNoCase(L"text"))
+ {
+ m_selRange->moveToElementText(m_doc2->elementFromPoint(65, 15));
+ m_selRange->collapse(VARIANT_TRUE);
+ }
+ m_selRange->moveStart(L"word", -1);
+// m_selRange->moveEnd(L"word", 1);
+
+ ContinueDocumentCheck();
+}
+
+//
+// Spellcheck whole document from beginning
+// Returns true if some changes was made, or false if no changes
+//
+void CSpeller::ContinueDocumentCheck()
+{
+ HRESULT compareEnd;
+ SPELL_RESULT result;
+ CString word;
+ _bstr_t b;
+ bool bHyphen = false;
+
+ // find next misspell word from the beginning or current position
+ do
+ {
+ // shift to the next word
+ m_selRange->move(L"word", 1);
+ m_selRange->moveEnd(L"word", 1);
+
+ result = SPELL_OK;
+ word.SetString (m_selRange->text);
+ word.Trim();
+ // special check for hyphen
+ if (word.Compare(L"-")==0)
+ {
+ m_selRange->moveStart(L"word", -1);
+ m_selRange->moveEnd(L"word", 1);
+ word.SetString (m_selRange->text);
+ word.Trim();
+ bHyphen = true;
+ }
+
+ // if word != words delimiter
+ if (word.FindOneOf(Tokens)==-1)
+ result = SpellCheck(word);
+
+ // select exact word
+ if ((result == SPELL_CHANGE) || (result == SPELL_CHANGEALL) || (result == SPELL_MISSPELL))
+ {
+ b = word.AllocSysString();
+ m_selRange->findText(b, 1073741824, 2);
+ m_selRange->select();
+ }
+
+ switch (result)
+ {
+ case SPELL_CHANGEALL:
+ {
+ CString replaceStr = m_ChangeWordsTo[m_ChangeWords.Find(word)];
+ // replace aphostrophes back
+ if (m_numAphChanged) replaceStr.Replace(L"'", L"");
+ BeginUndoUnit(L"replace word");
+ b = replaceStr.AllocSysString();
+ m_selRange->put_text(b);
+ EndUndoUnit();
+ break;
+ }
+ case SPELL_MISSPELL:
+ {
+ m_spell_dlg->m_sBadWord = word;
+ if (m_spell_dlg->m_strSuggestions)
+ delete m_spell_dlg->m_strSuggestions;
+ m_spell_dlg->m_strSuggestions = GetSuggestions(word);
+ m_spell_dlg->UpdateData();
+ break;
+ }
+ }
+
+ // check for end of selection
+ if (bHyphen)
+ {
+ m_selRange->moveStart(L"word", 2);
+ m_selRange->moveEnd(L"word", 1);
+ bHyphen = false;
+ }
+ compareEnd = m_selRange->compareEndPoints(L"StartToEnd", m_selRange);
+ if (compareEnd == 0)
+ {
+ m_selRange->move(L"word", 1);
+ m_selRange->moveEnd(L"word", 1);
+ compareEnd = m_selRange->compareEndPoints(L"StartToEnd", m_selRange);
+ }
+
+ } while (result != SPELL_MISSPELL && compareEnd != 0);
+
+ if (!compareEnd)
+ EndDocumentCheck(false);
+}
+
+void CSpeller::EndDocumentCheck(bool bCancel)
+{
+ if (m_spell_dlg)
+ {
+ m_spell_dlg->DestroyWindow();
+ m_spell_dlg = 0;
+ }
+ // display message box
+ if (!bCancel)
+ {
+ U::MessageBox(MB_OK | MB_ICONINFORMATION, IDR_MAINFRAME, IDS_SPELL_CHECK_COMPLETED);
+ }
+ // restore previous selection
+ if (m_prevSelRange)
+ {
+ m_ims->MoveRangeToPointers(m_impStart, m_impEnd, m_prevSelRange);
+ m_prevSelRange->select();
+
+ // delete objects
+ m_prevSelRange = 0;
+ }
+ // delete spell-check selection range
+ if (m_selRange)
+ {
+ m_selRange = 0;
+ }
+}
diff --git a/README.txt b/ToDo.md
similarity index 95%
rename from README.txt
rename to ToDo.md
index 4c0fc6b..a869355 100644
--- a/README.txt
+++ b/ToDo.md
@@ -1,4 +1,5 @@
-TODO:
+# FictionBook TODO:
+
+ coverpage, sequences
+ binaries
+ saving bodies and annotations/histories
diff --git a/WTL/atlapp.h b/WTL/atlapp.h
deleted file mode 100644
index e47bcd6..0000000
--- a/WTL/atlapp.h
+++ /dev/null
@@ -1,2035 +0,0 @@
-// Windows Template Library - WTL version 8.1
-// Copyright (C) Microsoft Corporation. All rights reserved.
-//
-// This file is a part of the Windows Template Library.
-// The use and distribution terms for this software are covered by the
-// Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
-// which can be found in the file CPL.TXT at the root of this distribution.
-// By using this software in any fashion, you are agreeing to be bound by
-// the terms of this license. You must not remove this notice, or
-// any other, from this software.
-
-#ifndef __ATLAPP_H__
-#define __ATLAPP_H__
-
-#pragma once
-
-#ifndef __cplusplus
- #error WTL requires C++ compilation (use a .cpp suffix)
-#endif
-
-#ifndef __ATLBASE_H__
- #error atlapp.h requires atlbase.h to be included first
-#endif
-
-#ifndef _WIN32_WCE
- #if (WINVER < 0x0400)
- #error WTL requires Windows version 4.0 or higher
- #endif
-
- #if (_WIN32_IE < 0x0300)
- #error WTL requires IE version 3.0 or higher
- #endif
-#endif
-
-#ifdef _ATL_NO_COMMODULE
- #error WTL requires that _ATL_NO_COMMODULE is not defined
-#endif
-
-#if (_ATL_VER >= 0x0900) && defined(_ATL_MIN_CRT)
- #error _ATL_MIN_CRT is not supported with ATL 9.0 and higher
-#endif
-
-#if defined(_WIN32_WCE) && defined(_ATL_MIN_CRT)
- #pragma message("Warning: WTL for Windows CE doesn't use _ATL_MIN_CRT")
-#endif
-
-#include
-#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE)
- #include // for _beginthreadex
-#endif
-
-#if (_ATL_VER < 0x0800) && !defined(_DEBUG)
- #include
-#endif
-
-#include
-#ifndef _WIN32_WCE
- #pragma comment(lib, "comctl32.lib")
-#endif
-
-#ifndef _WIN32_WCE
- #include "atlres.h"
-#else // CE specific
- #include "atlresce.h"
-#endif // _WIN32_WCE
-
-// We need to disable this warning because of template class arguments
-#pragma warning(disable: 4127)
-
-#if (_ATL_VER >= 0x0900) && !defined(_SECURE_ATL)
- #define _SECURE_ATL 1
-#endif
-
-
-///////////////////////////////////////////////////////////////////////////////
-// WTL version number
-
-#define _WTL_VER 0x0810
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Classes in this file:
-//
-// CMessageFilter
-// CIdleHandler
-// CMessageLoop
-//
-// CAppModule
-// CServerAppModule
-//
-// CRegKeyEx
-//
-// Global functions:
-// AtlGetDefaultGuiFont()
-// AtlCreateControlFont()
-// AtlCreateBoldFont()
-// AtlInitCommonControls()
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Global support for Windows CE
-
-#ifdef _WIN32_WCE
-
-#ifndef SW_SHOWDEFAULT
- #define SW_SHOWDEFAULT SW_SHOWNORMAL
-#endif // !SW_SHOWDEFAULT
-
-// These get's OR-ed in a constant and will have no effect.
-// Defining them reduces the number of #ifdefs required for CE.
-#define LR_DEFAULTSIZE 0
-#define LR_LOADFROMFILE 0
-
-#ifndef SM_CXCURSOR
- #define SM_CXCURSOR 13
-#endif
-#ifndef SM_CYCURSOR
- #define SM_CYCURSOR 14
-#endif
-
-inline BOOL IsMenu(HMENU hMenu)
-{
- MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
- ::SetLastError(0);
- BOOL bRet = ::GetMenuItemInfo(hMenu, 0, TRUE, &mii);
- if(!bRet)
- bRet = (::GetLastError() != ERROR_INVALID_MENU_HANDLE) ? TRUE : FALSE;
- return bRet;
-}
-
-#if (_WIN32_WCE >= 410)
-extern "C" void WINAPI ListView_SetItemSpacing(HWND hwndLV, int iHeight);
-#endif // (_WIN32_WCE >= 410)
-
-inline int MulDiv(IN int nNumber, IN int nNumerator, IN int nDenominator)
-{
- __int64 multiple = nNumber * nNumerator;
- return static_cast(multiple / nDenominator);
-}
-
-#if (_ATL_VER >= 0x0800)
-
-#ifndef _WTL_KEEP_WS_OVERLAPPEDWINDOW
- #ifdef WS_OVERLAPPEDWINDOW
- #undef WS_OVERLAPPEDWINDOW
- #define WS_OVERLAPPEDWINDOW 0
- #endif // WS_OVERLAPPEDWINDOW
-#endif // !_WTL_KEEP_WS_OVERLAPPEDWINDOW
-
-#ifndef RDW_FRAME
- #define RDW_FRAME 0
-#endif // !RDW_FRAME
-
-#ifndef WM_WINDOWPOSCHANGING
- #define WM_WINDOWPOSCHANGING 0
-#endif // !WM_WINDOWPOSCHANGING
-
-#define FreeResource(x)
-#define UnlockResource(x)
-
-namespace ATL
-{
- inline HRESULT CComModule::RegisterClassObjects(DWORD /*dwClsContext*/, DWORD /*dwFlags*/) throw()
- { return E_NOTIMPL; }
- inline HRESULT CComModule::RevokeClassObjects() throw()
- { return E_NOTIMPL; }
-}; // namespace ATL
-
-#ifndef lstrlenW
- #define lstrlenW (int)ATL::lstrlenW
-#endif // lstrlenW
-
-inline int WINAPI lstrlenA(LPCSTR lpszString)
-{ return ATL::lstrlenA(lpszString); }
-
-#ifdef lstrcpyn
- #undef lstrcpyn
- #define lstrcpyn ATL::lstrcpynW
-#endif // lstrcpyn
-
-#ifndef SetWindowLongPtrW
- inline LONG_PTR tmp_SetWindowLongPtrW( HWND hWnd, int nIndex, LONG_PTR dwNewLong )
- {
- return( ::SetWindowLongW( hWnd, nIndex, LONG( dwNewLong ) ) );
- }
- #define SetWindowLongPtrW tmp_SetWindowLongPtrW
-#endif
-
-#ifndef GetWindowLongPtrW
- inline LONG_PTR tmp_GetWindowLongPtrW( HWND hWnd, int nIndex )
- {
- return( ::GetWindowLongW( hWnd, nIndex ) );
- }
- #define GetWindowLongPtrW tmp_GetWindowLongPtrW
-#endif
-
-#ifndef LongToPtr
- #define LongToPtr(x) ((void*)x)
-#endif
-
-#ifndef PtrToInt
- #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
-#endif
-
-#else // !(_ATL_VER >= 0x0800)
-
-#ifdef lstrlenW
- #undef lstrlenW
- #define lstrlenW (int)::wcslen
-#endif // lstrlenW
-
-#define lstrlenA (int)strlen
-
-#ifndef lstrcpyn
- inline LPTSTR lstrcpyn(LPTSTR lpstrDest, LPCTSTR lpstrSrc, int nLength)
- {
- if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0)
- return NULL;
- int nLen = min(lstrlen(lpstrSrc), nLength - 1);
- LPTSTR lpstrRet = (LPTSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(TCHAR));
- lpstrDest[nLen] = 0;
- return lpstrRet;
- }
-#endif // !lstrcpyn
-
-#ifndef lstrcpynW
- inline LPWSTR lstrcpynW(LPWSTR lpstrDest, LPCWSTR lpstrSrc, int nLength)
- {
- return lstrcpyn(lpstrDest, lpstrSrc, nLength); // WinCE is Unicode only
- }
-#endif // !lstrcpynW
-
-#ifndef lstrcpynA
- inline LPSTR lstrcpynA(LPSTR lpstrDest, LPCSTR lpstrSrc, int nLength)
- {
- if(lpstrDest == NULL || lpstrSrc == NULL || nLength <= 0)
- return NULL;
- int nLen = min(lstrlenA(lpstrSrc), nLength - 1);
- LPSTR lpstrRet = (LPSTR)memcpy(lpstrDest, lpstrSrc, nLen * sizeof(char));
- lpstrDest[nLen] = 0;
- return lpstrRet;
- }
-#endif // !lstrcpyn
-
-#ifdef TrackPopupMenu
- #undef TrackPopupMenu
-#endif // TrackPopupMenu
-
-#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \
-static CWndClassInfo& GetWndClassInfo() \
-{ \
- static CWndClassInfo wc = \
- { \
- { style, StartWindowProc, \
- 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName }, \
- NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \
- }; \
- return wc; \
-}
-
-#ifndef _MAX_FNAME
- #define _MAX_FNAME _MAX_PATH
-#endif // _MAX_FNAME
-
-#if (_WIN32_WCE < 400)
- #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i)))
-#endif // (_WIN32_WCE < 400)
-
-#if (_WIN32_WCE < 410)
- #define WHEEL_PAGESCROLL (UINT_MAX)
- #define WHEEL_DELTA 120
-#endif // (_WIN32_WCE < 410)
-
-#ifdef DrawIcon
- #undef DrawIcon
-#endif
-
-#ifndef VARCMP_LT
- #define VARCMP_LT 0
-#endif
-#ifndef VARCMP_EQ
- #define VARCMP_EQ 1
-#endif
-#ifndef VARCMP_GT
- #define VARCMP_GT 2
-#endif
-#ifndef VARCMP_NULL
- #define VARCMP_NULL 3
-#endif
-
-#ifndef RDW_ALLCHILDREN
- #define RDW_ALLCHILDREN 0
-#endif
-
-#endif // !(_ATL_VER >= 0x0800)
-
-#endif // _WIN32_WCE
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Global support for using original VC++ 6.0 headers with WTL
-
-#ifndef _ATL_NO_OLD_HEADERS_WIN64
-#if !defined(_WIN64) && (_ATL_VER < 0x0700)
-
- #ifndef PSM_INSERTPAGE
- #define PSM_INSERTPAGE (WM_USER + 119)
- #endif // !PSM_INSERTPAGE
-
- #ifndef GetClassLongPtr
- #define GetClassLongPtrA GetClassLongA
- #define GetClassLongPtrW GetClassLongW
- #ifdef UNICODE
- #define GetClassLongPtr GetClassLongPtrW
- #else
- #define GetClassLongPtr GetClassLongPtrA
- #endif // !UNICODE
- #endif // !GetClassLongPtr
-
- #ifndef GCLP_HICONSM
- #define GCLP_HICONSM (-34)
- #endif // !GCLP_HICONSM
-
- #ifndef GetWindowLongPtr
- #define GetWindowLongPtrA GetWindowLongA
- #define GetWindowLongPtrW GetWindowLongW
- #ifdef UNICODE
- #define GetWindowLongPtr GetWindowLongPtrW
- #else
- #define GetWindowLongPtr GetWindowLongPtrA
- #endif // !UNICODE
- #endif // !GetWindowLongPtr
-
- #ifndef SetWindowLongPtr
- #define SetWindowLongPtrA SetWindowLongA
- #define SetWindowLongPtrW SetWindowLongW
- #ifdef UNICODE
- #define SetWindowLongPtr SetWindowLongPtrW
- #else
- #define SetWindowLongPtr SetWindowLongPtrA
- #endif // !UNICODE
- #endif // !SetWindowLongPtr
-
- #ifndef GWLP_WNDPROC
- #define GWLP_WNDPROC (-4)
- #endif
- #ifndef GWLP_HINSTANCE
- #define GWLP_HINSTANCE (-6)
- #endif
- #ifndef GWLP_HWNDPARENT
- #define GWLP_HWNDPARENT (-8)
- #endif
- #ifndef GWLP_USERDATA
- #define GWLP_USERDATA (-21)
- #endif
- #ifndef GWLP_ID
- #define GWLP_ID (-12)
- #endif
-
- #ifndef DWLP_MSGRESULT
- #define DWLP_MSGRESULT 0
- #endif
-
- typedef long LONG_PTR;
- typedef unsigned long ULONG_PTR;
- typedef ULONG_PTR DWORD_PTR;
-
- #ifndef HandleToUlong
- #define HandleToUlong( h ) ((ULONG)(ULONG_PTR)(h) )
- #endif
- #ifndef HandleToLong
- #define HandleToLong( h ) ((LONG)(LONG_PTR) (h) )
- #endif
- #ifndef LongToHandle
- #define LongToHandle( h) ((HANDLE)(LONG_PTR) (h))
- #endif
- #ifndef PtrToUlong
- #define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) )
- #endif
- #ifndef PtrToLong
- #define PtrToLong( p ) ((LONG)(LONG_PTR) (p) )
- #endif
- #ifndef PtrToUint
- #define PtrToUint( p ) ((UINT)(UINT_PTR) (p) )
- #endif
- #ifndef PtrToInt
- #define PtrToInt( p ) ((INT)(INT_PTR) (p) )
- #endif
- #ifndef PtrToUshort
- #define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
- #endif
- #ifndef PtrToShort
- #define PtrToShort( p ) ((short)(LONG_PTR)(p) )
- #endif
- #ifndef IntToPtr
- #define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i))
- #endif
- #ifndef UIntToPtr
- #define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui))
- #endif
- #ifndef LongToPtr
- #define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l))
- #endif
- #ifndef ULongToPtr
- #define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul))
- #endif
-
-#endif // !defined(_WIN64) && (_ATL_VER < 0x0700)
-#endif // !_ATL_NO_OLD_HEADERS_WIN64
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Global support for SecureHelper functions
-
-#ifndef _TRUNCATE
- #define _TRUNCATE ((size_t)-1)
-#endif
-
-#ifndef _ERRCODE_DEFINED
- #define _ERRCODE_DEFINED
- typedef int errno_t;
-#endif
-
-#ifndef _SECURECRT_ERRCODE_VALUES_DEFINED
- #define _SECURECRT_ERRCODE_VALUES_DEFINED
- #define EINVAL 22
- #define STRUNCATE 80
-#endif
-
-#ifndef _countof
- #define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
-#endif
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Miscellaneous global support
-
-// define useful macros from winuser.h
-#ifndef IS_INTRESOURCE
- #define IS_INTRESOURCE(_r) (((ULONG_PTR)(_r) >> 16) == 0)
-#endif // IS_INTRESOURCE
-
-// protect template members from windowsx.h macros
-#ifdef _INC_WINDOWSX
- #undef SubclassWindow
-#endif // _INC_WINDOWSX
-
-// define useful macros from windowsx.h
-#ifndef GET_X_LPARAM
- #define GET_X_LPARAM(lParam) ((int)(short)LOWORD(lParam))
-#endif
-#ifndef GET_Y_LPARAM
- #define GET_Y_LPARAM(lParam) ((int)(short)HIWORD(lParam))
-#endif
-
-// Dummy structs for compiling with /CLR
-#if (_MSC_VER >= 1300) && defined(_MANAGED)
- __if_not_exists(_IMAGELIST::_IMAGELIST) { struct _IMAGELIST { }; }
- __if_not_exists(_TREEITEM::_TREEITEM) { struct _TREEITEM { }; }
- __if_not_exists(_PSP::_PSP) { struct _PSP { }; }
-#endif
-
-// Define ATLVERIFY macro for ATL3
-#if (_ATL_VER < 0x0700)
- #ifndef ATLVERIFY
- #ifdef _DEBUG
- #define ATLVERIFY(expr) ATLASSERT(expr)
- #else
- #define ATLVERIFY(expr) (expr)
- #endif // DEBUG
- #endif // ATLVERIFY
-#endif // (_ATL_VER < 0x0700)
-
-// Forward declaration for ATL3 fix
-#if (_ATL_VER < 0x0700) && defined(_ATL_DLL) && !defined(_WIN32_WCE)
- namespace ATL { HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor); };
-#endif
-
-
-namespace WTL
-{
-
-#if (_ATL_VER >= 0x0700)
- DECLARE_TRACE_CATEGORY(atlTraceUI);
- #ifdef _DEBUG
- __declspec(selectany) ATL::CTraceCategory atlTraceUI(_T("atlTraceUI"));
- #endif // _DEBUG
-#else // !(_ATL_VER >= 0x0700)
- enum wtlTraceFlags
- {
- atlTraceUI = 0x10000000
- };
-#endif // !(_ATL_VER >= 0x0700)
-
-// Windows version helper
-inline bool AtlIsOldWindows()
-{
- OSVERSIONINFO ovi = { 0 };
- ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- BOOL bRet = ::GetVersionEx(&ovi);
- return (!bRet || !((ovi.dwMajorVersion >= 5) || (ovi.dwMajorVersion == 4 && ovi.dwMinorVersion >= 90)));
-}
-
-// Default GUI font helper - "MS Shell Dlg" stock font
-inline HFONT AtlGetDefaultGuiFont()
-{
-#ifndef _WIN32_WCE
- return (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
-#else // CE specific
- return (HFONT)::GetStockObject(SYSTEM_FONT);
-#endif // _WIN32_WCE
-}
-
-// Control font helper - default font for controls not in a dialog
-// (NOTE: Caller owns the font, and should destroy it when it's no longer needed)
-inline HFONT AtlCreateControlFont()
-{
-#ifndef _WIN32_WCE
- LOGFONT lf = { 0 };
- ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE);
- HFONT hFont = ::CreateFontIndirect(&lf);
- ATLASSERT(hFont != NULL);
- return hFont;
-#else // CE specific
- return (HFONT)::GetStockObject(SYSTEM_FONT);
-#endif // _WIN32_WCE
-}
-
-// Bold font helper
-// (NOTE: Caller owns the font, and should destroy it when it's no longer needed)
-inline HFONT AtlCreateBoldFont(HFONT hFont = NULL)
-{
- LOGFONT lf = { 0 };
-#ifndef _WIN32_WCE
- if(hFont == NULL)
- ATLVERIFY(::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, 0) != FALSE);
- else
- ATLVERIFY(::GetObject(hFont, sizeof(LOGFONT), &lf) == sizeof(LOGFONT));
-#else // CE specific
- if(hFont == NULL)
- hFont = (HFONT)::GetStockObject(SYSTEM_FONT);
- ATLVERIFY(::GetObject(hFont, sizeof(LOGFONT), &lf) == sizeof(LOGFONT));
-#endif // _WIN32_WCE
- lf.lfWeight = FW_BOLD;
- HFONT hFontBold = ::CreateFontIndirect(&lf);
- ATLASSERT(hFontBold != NULL);
- return hFontBold;
-}
-
-// Common Controls initialization helper
-inline BOOL AtlInitCommonControls(DWORD dwFlags)
-{
- INITCOMMONCONTROLSEX iccx = { sizeof(INITCOMMONCONTROLSEX), dwFlags };
- BOOL bRet = ::InitCommonControlsEx(&iccx);
- ATLASSERT(bRet);
- return bRet;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// RunTimeHelper - helper functions for Windows version and structure sizes
-
-// Not for Windows CE
-#if defined(_WIN32_WCE) && !defined(_WTL_NO_RUNTIME_STRUCT_SIZE)
- #define _WTL_NO_RUNTIME_STRUCT_SIZE
-#endif
-
-#ifndef _WTL_NO_RUNTIME_STRUCT_SIZE
-
-#ifndef _SIZEOF_STRUCT
- #define _SIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member))
-#endif
-
-#if (_WIN32_WINNT >= 0x0600) && !defined(REBARBANDINFO_V6_SIZE)
- #define REBARBANDINFO_V6_SIZE _SIZEOF_STRUCT(REBARBANDINFO, cxHeader)
-#endif // (_WIN32_WINNT >= 0x0600) && !defined(REBARBANDINFO_V6_SIZE)
-
-#if (_WIN32_WINNT >= 0x0600) && !defined(LVGROUP_V5_SIZE)
- #define LVGROUP_V5_SIZE _SIZEOF_STRUCT(LVGROUP, uAlign)
-#endif // (_WIN32_WINNT >= 0x0600) && !defined(LVGROUP_V5_SIZE)
-
-#if (_WIN32_WINNT >= 0x0600) && !defined(LVTILEINFO_V5_SIZE)
- #define LVTILEINFO_V5_SIZE _SIZEOF_STRUCT(LVTILEINFO, puColumns)
-#endif // (_WIN32_WINNT >= 0x0600) && !defined(LVTILEINFO_V5_SIZE)
-
-#if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) && !defined(MCHITTESTINFO_V1_SIZE)
- #define MCHITTESTINFO_V1_SIZE _SIZEOF_STRUCT(MCHITTESTINFO, st)
-#endif // defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN) && !defined(MCHITTESTINFO_V1_SIZE)
-
-#if !defined(_WIN32_WCE) && (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE)
- #define NONCLIENTMETRICS_V1_SIZE _SIZEOF_STRUCT(NONCLIENTMETRICS, lfMessageFont)
-#endif // !defined(_WIN32_WCE) && (WINVER >= 0x0600) && !defined(NONCLIENTMETRICS_V1_SIZE)
-
-#endif // !_WTL_NO_RUNTIME_STRUCT_SIZE
-
-namespace RunTimeHelper
-{
-#ifndef _WIN32_WCE
- inline bool IsCommCtrl6()
- {
- DWORD dwMajor = 0, dwMinor = 0;
- HRESULT hRet = ATL::AtlGetCommCtrlVersion(&dwMajor, &dwMinor);
- return (SUCCEEDED(hRet) && (dwMajor >= 6));
- }
-
- inline bool IsVista()
- {
- OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) };
- BOOL bRet = ::GetVersionEx(&ovi);
- return ((bRet != FALSE) && (ovi.dwMajorVersion >= 6));
- }
-
- inline bool IsThemeAvailable()
- {
- bool bRet = false;
-
- if(IsCommCtrl6())
- {
- HMODULE hThemeDLL = ::LoadLibrary(_T("uxtheme.dll"));
- if(hThemeDLL != NULL)
- {
- typedef BOOL (STDAPICALLTYPE *PFN_IsThemeActive)();
- PFN_IsThemeActive pfnIsThemeActive = (PFN_IsThemeActive)::GetProcAddress(hThemeDLL, "IsThemeActive");
- ATLASSERT(pfnIsThemeActive != NULL);
- bRet = (pfnIsThemeActive != NULL) && (pfnIsThemeActive() != FALSE);
- if(bRet)
- {
- typedef BOOL (STDAPICALLTYPE *PFN_IsAppThemed)();
- PFN_IsAppThemed pfnIsAppThemed = (PFN_IsAppThemed)::GetProcAddress(hThemeDLL, "IsAppThemed");
- ATLASSERT(pfnIsAppThemed != NULL);
- bRet = (pfnIsAppThemed != NULL) && (pfnIsAppThemed() != FALSE);
- }
-
- ::FreeLibrary(hThemeDLL);
- }
- }
-
- return bRet;
- }
-
- inline bool IsWin7()
- {
- OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) };
- BOOL bRet = ::GetVersionEx(&ovi);
- return ((bRet != FALSE) && (ovi.dwMajorVersion == 6) && (ovi.dwMinorVersion >= 1));
- }
-
- inline bool IsRibbonUIAvailable()
- {
- static INT iRibbonUI = -1;
-
-#if defined(NTDDI_WIN7) && (NTDDI_VERSION >= NTDDI_WIN7)
- if (iRibbonUI == -1)
- {
- HMODULE hRibbonDLL = ::LoadLibrary(_T("propsys.dll"));
- if (hRibbonDLL != NULL)
- {
- const GUID CLSID_UIRibbonFramework = { 0x926749fa, 0x2615, 0x4987, { 0x88, 0x45, 0xc3, 0x3e, 0x65, 0xf2, 0xb9, 0x57 } };
- // block - create instance
- {
- ATL::CComPtr pIUIFramework;
- iRibbonUI = SUCCEEDED(pIUIFramework.CoCreateInstance(CLSID_UIRibbonFramework)) ? 1 : 0;
- }
- ::FreeLibrary(hRibbonDLL);
- }
- else
- {
- iRibbonUI = 0;
- }
- }
-#endif // defined(NTDDI_WIN7) && (NTDDI_VERSION >= NTDDI_WIN7)
-
- return (iRibbonUI == 1);
- }
-
-#endif // !_WIN32_WCE
-
- inline int SizeOf_REBARBANDINFO()
- {
- int nSize = sizeof(REBARBANDINFO);
-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
- if(!(IsVista() && IsCommCtrl6()))
- nSize = REBARBANDINFO_V6_SIZE;
-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
- return nSize;
- }
-
-#if (_WIN32_WINNT >= 0x501)
- inline int SizeOf_LVGROUP()
- {
- int nSize = sizeof(LVGROUP);
-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
- if(!IsVista())
- nSize = LVGROUP_V5_SIZE;
-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
- return nSize;
- }
-
- inline int SizeOf_LVTILEINFO()
- {
- int nSize = sizeof(LVTILEINFO);
-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
- if(!IsVista())
- nSize = LVTILEINFO_V5_SIZE;
-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (_WIN32_WINNT >= 0x0600)
- return nSize;
- }
-#endif // (_WIN32_WINNT >= 0x501)
-
- inline int SizeOf_MCHITTESTINFO()
- {
- int nSize = sizeof(MCHITTESTINFO);
-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN)
- if(!(IsVista() && IsCommCtrl6()))
- nSize = MCHITTESTINFO_V1_SIZE;
-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_LONGHORN)
- return nSize;
- }
-
-#ifndef _WIN32_WCE
- inline int SizeOf_NONCLIENTMETRICS()
- {
- int nSize = sizeof(NONCLIENTMETRICS);
-#if !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (WINVER >= 0x0600)
- if(!IsVista())
- nSize = NONCLIENTMETRICS_V1_SIZE;
-#endif // !defined(_WTL_NO_RUNTIME_STRUCT_SIZE) && (WINVER >= 0x0600)
- return nSize;
- }
-#endif // !_WIN32_WCE
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// ModuleHelper - helper functions for ATL3 and ATL7 module classes
-
-namespace ModuleHelper
-{
- inline HINSTANCE GetModuleInstance()
- {
-#if (_ATL_VER >= 0x0700)
- return ATL::_AtlBaseModule.GetModuleInstance();
-#else // !(_ATL_VER >= 0x0700)
- return ATL::_pModule->GetModuleInstance();
-#endif // !(_ATL_VER >= 0x0700)
- }
-
- inline HINSTANCE GetResourceInstance()
- {
-#if (_ATL_VER >= 0x0700)
- return ATL::_AtlBaseModule.GetResourceInstance();
-#else // !(_ATL_VER >= 0x0700)
- return ATL::_pModule->GetResourceInstance();
-#endif // !(_ATL_VER >= 0x0700)
- }
-
- inline void AddCreateWndData(ATL::_AtlCreateWndData* pData, void* pObject)
- {
-#if (_ATL_VER >= 0x0700)
- ATL::_AtlWinModule.AddCreateWndData(pData, pObject);
-#else // !(_ATL_VER >= 0x0700)
- ATL::_pModule->AddCreateWndData(pData, pObject);
-#endif // !(_ATL_VER >= 0x0700)
- }
-
- inline void* ExtractCreateWndData()
- {
-#if (_ATL_VER >= 0x0700)
- return ATL::_AtlWinModule.ExtractCreateWndData();
-#else // !(_ATL_VER >= 0x0700)
- return ATL::_pModule->ExtractCreateWndData();
-#endif // !(_ATL_VER >= 0x0700)
- }
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// SecureHelper - helper functions for VS2005 secure CRT
-
-namespace SecureHelper
-{
- inline void strcpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc)
- {
-#if _SECURE_ATL
- ATL::Checked::strcpy_s(lpstrDest, cchDest, lpstrSrc);
-#else
- if(cchDest > (size_t)lstrlenA(lpstrSrc))
- ATLVERIFY(lstrcpyA(lpstrDest, lpstrSrc) != NULL);
- else
- ATLASSERT(FALSE);
-#endif
- }
-
- inline void strcpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc)
- {
-#if _SECURE_ATL
- ATL::Checked::wcscpy_s(lpstrDest, cchDest, lpstrSrc);
-#else
- if(cchDest > (size_t)lstrlenW(lpstrSrc))
- ATLVERIFY(lstrcpyW(lpstrDest, lpstrSrc) != NULL);
- else
- ATLASSERT(FALSE);
-#endif
- }
-
- inline void strcpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc)
- {
-#ifdef _UNICODE
- strcpyW_x(lpstrDest, cchDest, lpstrSrc);
-#else
- strcpyA_x(lpstrDest, cchDest, lpstrSrc);
-#endif
- }
-
- inline errno_t strncpyA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc, size_t cchCount)
- {
-#if _SECURE_ATL
- return ATL::Checked::strncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount);
-#else
- errno_t nRet = 0;
- if(lpstrDest == NULL || cchDest == 0 || lpstrSrc == NULL)
- {
- nRet = EINVAL;
- }
- else if(cchCount == _TRUNCATE)
- {
- cchCount = min(cchDest - 1, size_t(lstrlenA(lpstrSrc)));
- nRet = STRUNCATE;
- }
- else if(cchDest <= cchCount)
- {
- lpstrDest[0] = 0;
- nRet = EINVAL;
- }
- if(nRet == 0 || nRet == STRUNCATE)
- nRet = (lstrcpynA(lpstrDest, lpstrSrc, (int)cchCount + 1) != NULL) ? nRet : EINVAL;
- ATLASSERT(nRet == 0 || nRet == STRUNCATE);
- return nRet;
-#endif
- }
-
- inline errno_t strncpyW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc, size_t cchCount)
- {
-#if _SECURE_ATL
- return ATL::Checked::wcsncpy_s(lpstrDest, cchDest, lpstrSrc, cchCount);
-#else
- errno_t nRet = 0;
- if(lpstrDest == NULL || cchDest == 0 || lpstrSrc == NULL)
- {
- nRet = EINVAL;
- }
- else if(cchCount == _TRUNCATE)
- {
- cchCount = min(cchDest - 1, size_t(lstrlenW(lpstrSrc)));
- nRet = STRUNCATE;
- }
- else if(cchDest <= cchCount)
- {
- lpstrDest[0] = 0;
- nRet = EINVAL;
- }
- if(nRet == 0 || nRet == STRUNCATE)
- nRet = (lstrcpynW(lpstrDest, lpstrSrc, (int)cchCount + 1) != NULL) ? nRet : EINVAL;
- ATLASSERT(nRet == 0 || nRet == STRUNCATE);
- return nRet;
-#endif
- }
-
- inline errno_t strncpy_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc, size_t cchCount)
- {
-#ifdef _UNICODE
- return strncpyW_x(lpstrDest, cchDest, lpstrSrc, cchCount);
-#else
- return strncpyA_x(lpstrDest, cchDest, lpstrSrc, cchCount);
-#endif
- }
-
- inline void strcatA_x(char* lpstrDest, size_t cchDest, const char* lpstrSrc)
- {
-#if _SECURE_ATL
- ATL::Checked::strcat_s(lpstrDest, cchDest, lpstrSrc);
-#else
- if(cchDest > (size_t)lstrlenA(lpstrSrc))
- ATLVERIFY(lstrcatA(lpstrDest, lpstrSrc) != NULL);
- else
- ATLASSERT(FALSE);
-#endif
- }
-
- inline void strcatW_x(wchar_t* lpstrDest, size_t cchDest, const wchar_t* lpstrSrc)
- {
-#if _SECURE_ATL
- ATL::Checked::wcscat_s(lpstrDest, cchDest, lpstrSrc);
-#else
- if(cchDest > (size_t)lstrlenW(lpstrSrc))
- ATLVERIFY(lstrcatW(lpstrDest, lpstrSrc) != NULL);
- else
- ATLASSERT(FALSE);
-#endif
- }
-
- inline void strcat_x(LPTSTR lpstrDest, size_t cchDest, LPCTSTR lpstrSrc)
- {
-#ifdef _UNICODE
- strcatW_x(lpstrDest, cchDest, lpstrSrc);
-#else
- strcatA_x(lpstrDest, cchDest, lpstrSrc);
-#endif
- }
-
- inline void memcpy_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc)
- {
-#if _SECURE_ATL
- ATL::Checked::memcpy_s(pDest, cbDest, pSrc, cbSrc);
-#else
- if(cbDest >= cbSrc)
- memcpy(pDest, pSrc, cbSrc);
- else
- ATLASSERT(FALSE);
-#endif
- }
-
- inline void memmove_x(void* pDest, size_t cbDest, const void* pSrc, size_t cbSrc)
- {
-#if _SECURE_ATL
- ATL::Checked::memmove_s(pDest, cbDest, pSrc, cbSrc);
-#else
- if(cbDest >= cbSrc)
- memmove(pDest, pSrc, cbSrc);
- else
- ATLASSERT(FALSE);
-#endif
- }
-
- inline int vsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args)
- {
-#if _SECURE_ATL && !defined(_ATL_MIN_CRT) && !defined(_WIN32_WCE)
- return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args);
-#else
- cchBuff; // Avoid unused argument warning
-#pragma warning(disable: 4996)
- return _vstprintf(lpstrBuff, lpstrFormat, args);
-#pragma warning(default: 4996)
-#endif
- }
-
- inline int wvsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, va_list args)
- {
-#if _SECURE_ATL && !defined(_ATL_MIN_CRT) && !defined(_WIN32_WCE)
- return _vstprintf_s(lpstrBuff, cchBuff, lpstrFormat, args);
-#else
- cchBuff; // Avoid unused argument warning
- return ::wvsprintf(lpstrBuff, lpstrFormat, args);
-#endif
- }
-
- inline int sprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, ...)
- {
- va_list args;
- va_start(args, lpstrFormat);
- int nRes = vsprintf_x(lpstrBuff, cchBuff, lpstrFormat, args);
- va_end(args);
- return nRes;
- }
-
- inline int wsprintf_x(LPTSTR lpstrBuff, size_t cchBuff, LPCTSTR lpstrFormat, ...)
- {
- va_list args;
- va_start(args, lpstrFormat);
- int nRes = wvsprintf_x(lpstrBuff, cchBuff, lpstrFormat, args);
- va_end(args);
- return nRes;
- }
-}; // namespace SecureHelper
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CMessageFilter - Interface for message filter support
-
-class CMessageFilter
-{
-public:
- virtual BOOL PreTranslateMessage(MSG* pMsg) = 0;
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CIdleHandler - Interface for idle processing
-
-class CIdleHandler
-{
-public:
- virtual BOOL OnIdle() = 0;
-};
-
-#ifndef _ATL_NO_OLD_NAMES
- // for compatilibility with old names only
- typedef CIdleHandler CUpdateUIObject;
- #define DoUpdate OnIdle
-#endif // !_ATL_NO_OLD_NAMES
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CMessageLoop - message loop implementation
-
-class CMessageLoop
-{
-public:
- ATL::CSimpleArray m_aMsgFilter;
- ATL::CSimpleArray m_aIdleHandler;
- MSG m_msg;
-
-// Message filter operations
- BOOL AddMessageFilter(CMessageFilter* pMessageFilter)
- {
- return m_aMsgFilter.Add(pMessageFilter);
- }
-
- BOOL RemoveMessageFilter(CMessageFilter* pMessageFilter)
- {
- return m_aMsgFilter.Remove(pMessageFilter);
- }
-
-// Idle handler operations
- BOOL AddIdleHandler(CIdleHandler* pIdleHandler)
- {
- return m_aIdleHandler.Add(pIdleHandler);
- }
-
- BOOL RemoveIdleHandler(CIdleHandler* pIdleHandler)
- {
- return m_aIdleHandler.Remove(pIdleHandler);
- }
-
-#ifndef _ATL_NO_OLD_NAMES
- // for compatilibility with old names only
- BOOL AddUpdateUI(CIdleHandler* pIdleHandler)
- {
- ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIObject and AddUpdateUI are deprecated. Please change your code to use CIdleHandler and OnIdle\n"));
- return AddIdleHandler(pIdleHandler);
- }
-
- BOOL RemoveUpdateUI(CIdleHandler* pIdleHandler)
- {
- ATLTRACE2(atlTraceUI, 0, _T("CUpdateUIObject and RemoveUpdateUI are deprecated. Please change your code to use CIdleHandler and OnIdle\n"));
- return RemoveIdleHandler(pIdleHandler);
- }
-#endif // !_ATL_NO_OLD_NAMES
-
-// message loop
- int Run()
- {
- BOOL bDoIdle = TRUE;
- int nIdleCount = 0;
- BOOL bRet;
-
- for(;;)
- {
- while(bDoIdle && !::PeekMessage(&m_msg, NULL, 0, 0, PM_NOREMOVE))
- {
- if(!OnIdle(nIdleCount++))
- bDoIdle = FALSE;
- }
-
- bRet = ::GetMessage(&m_msg, NULL, 0, 0);
-
- if(bRet == -1)
- {
- ATLTRACE2(atlTraceUI, 0, _T("::GetMessage returned -1 (error)\n"));
- continue; // error, don't process
- }
- else if(!bRet)
- {
- ATLTRACE2(atlTraceUI, 0, _T("CMessageLoop::Run - exiting\n"));
- break; // WM_QUIT, exit message loop
- }
-
- if(!PreTranslateMessage(&m_msg))
- {
- ::TranslateMessage(&m_msg);
- ::DispatchMessage(&m_msg);
- }
-
- if(IsIdleMessage(&m_msg))
- {
- bDoIdle = TRUE;
- nIdleCount = 0;
- }
- }
-
- return (int)m_msg.wParam;
- }
-
- static BOOL IsIdleMessage(MSG* pMsg)
- {
- // These messages should NOT cause idle processing
- switch(pMsg->message)
- {
- case WM_MOUSEMOVE:
-#ifndef _WIN32_WCE
- case WM_NCMOUSEMOVE:
-#endif // !_WIN32_WCE
- case WM_PAINT:
- case 0x0118: // WM_SYSTIMER (caret blink)
- return FALSE;
- }
-
- return TRUE;
- }
-
-// Overrideables
- // Override to change message filtering
- virtual BOOL PreTranslateMessage(MSG* pMsg)
- {
- // loop backwards
- for(int i = m_aMsgFilter.GetSize() - 1; i >= 0; i--)
- {
- CMessageFilter* pMessageFilter = m_aMsgFilter[i];
- if(pMessageFilter != NULL && pMessageFilter->PreTranslateMessage(pMsg))
- return TRUE;
- }
- return FALSE; // not translated
- }
-
- // override to change idle processing
- virtual BOOL OnIdle(int /*nIdleCount*/)
- {
- for(int i = 0; i < m_aIdleHandler.GetSize(); i++)
- {
- CIdleHandler* pIdleHandler = m_aIdleHandler[i];
- if(pIdleHandler != NULL)
- pIdleHandler->OnIdle();
- }
- return FALSE; // don't continue
- }
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CStaticDataInitCriticalSectionLock and CWindowCreateCriticalSectionLock
-// internal classes to manage critical sections for both ATL3 and ATL7
-
-class CStaticDataInitCriticalSectionLock
-{
-public:
-#if (_ATL_VER >= 0x0700)
- ATL::CComCritSecLock m_cslock;
-
- CStaticDataInitCriticalSectionLock() : m_cslock(ATL::_pAtlModule->m_csStaticDataInitAndTypeInfo, false)
- { }
-#endif // (_ATL_VER >= 0x0700)
-
- HRESULT Lock()
- {
-#if (_ATL_VER >= 0x0700)
- return m_cslock.Lock();
-#else // !(_ATL_VER >= 0x0700)
- ::EnterCriticalSection(&ATL::_pModule->m_csStaticDataInit);
- return S_OK;
-#endif // !(_ATL_VER >= 0x0700)
- }
-
- void Unlock()
- {
-#if (_ATL_VER >= 0x0700)
- m_cslock.Unlock();
-#else // !(_ATL_VER >= 0x0700)
- ::LeaveCriticalSection(&ATL::_pModule->m_csStaticDataInit);
-#endif // !(_ATL_VER >= 0x0700)
- }
-};
-
-
-class CWindowCreateCriticalSectionLock
-{
-public:
-#if (_ATL_VER >= 0x0700)
- ATL::CComCritSecLock m_cslock;
-
- CWindowCreateCriticalSectionLock() : m_cslock(ATL::_AtlWinModule.m_csWindowCreate, false)
- { }
-#endif // (_ATL_VER >= 0x0700)
-
- HRESULT Lock()
- {
-#if (_ATL_VER >= 0x0700)
- return m_cslock.Lock();
-#else // !(_ATL_VER >= 0x0700)
- ::EnterCriticalSection(&ATL::_pModule->m_csWindowCreate);
- return S_OK;
-#endif // !(_ATL_VER >= 0x0700)
- }
-
- void Unlock()
- {
-#if (_ATL_VER >= 0x0700)
- m_cslock.Unlock();
-#else // !(_ATL_VER >= 0x0700)
- ::LeaveCriticalSection(&ATL::_pModule->m_csWindowCreate);
-#endif // !(_ATL_VER >= 0x0700)
- }
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CTempBuffer - helper class for stack allocations for ATL3
-
-#ifndef _WTL_STACK_ALLOC_THRESHOLD
- #define _WTL_STACK_ALLOC_THRESHOLD 512
-#endif
-
-#if (_ATL_VER >= 0x0700)
-
-using ATL::CTempBuffer;
-
-#else // !(_ATL_VER >= 0x0700)
-
-#ifndef SIZE_MAX
- #ifdef _WIN64
- #define SIZE_MAX _UI64_MAX
- #else
- #define SIZE_MAX UINT_MAX
- #endif
-#endif
-
-#pragma warning(disable: 4284) // warning for operator ->
-
-template
-class CTempBuffer
-{
-public:
- CTempBuffer() : m_p(NULL)
- {
- }
-
- CTempBuffer(size_t nElements) : m_p(NULL)
- {
- Allocate(nElements);
- }
-
- ~CTempBuffer()
- {
- if(m_p != reinterpret_cast(m_abFixedBuffer))
- free(m_p);
- }
-
- operator T*() const
- {
- return m_p;
- }
-
- T* operator ->() const
- {
- ATLASSERT(m_p != NULL);
- return m_p;
- }
-
- T* Allocate(size_t nElements)
- {
- ATLASSERT(nElements <= (SIZE_MAX / sizeof(T)));
- return AllocateBytes(nElements * sizeof(T));
- }
-
- T* AllocateBytes(size_t nBytes)
- {
- ATLASSERT(m_p == NULL);
- if(nBytes > t_nFixedBytes)
- m_p = static_cast(malloc(nBytes));
- else
- m_p = reinterpret_cast(m_abFixedBuffer);
-
- return m_p;
- }
-
-private:
- T* m_p;
- BYTE m_abFixedBuffer[t_nFixedBytes];
-};
-
-#pragma warning(default: 4284)
-
-#endif // !(_ATL_VER >= 0x0700)
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CAppModule - module class for an application
-
-class CAppModule : public ATL::CComModule
-{
-public:
- DWORD m_dwMainThreadID;
- ATL::CSimpleMap* m_pMsgLoopMap;
- ATL::CSimpleArray* m_pSettingChangeNotify;
-
-// Overrides of CComModule::Init and Term
- HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL)
- {
- HRESULT hRet = CComModule::Init(pObjMap, hInstance, pLibID);
- if(FAILED(hRet))
- return hRet;
-
- m_dwMainThreadID = ::GetCurrentThreadId();
- typedef ATL::CSimpleMap _mapClass;
- m_pMsgLoopMap = NULL;
- ATLTRY(m_pMsgLoopMap = new _mapClass);
- if(m_pMsgLoopMap == NULL)
- return E_OUTOFMEMORY;
- m_pSettingChangeNotify = NULL;
-
- return hRet;
- }
-
- void Term()
- {
- TermSettingChangeNotify();
- delete m_pMsgLoopMap;
- CComModule::Term();
- }
-
-// Message loop map methods
- BOOL AddMessageLoop(CMessageLoop* pMsgLoop)
- {
- CStaticDataInitCriticalSectionLock lock;
- if(FAILED(lock.Lock()))
- {
- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::AddMessageLoop.\n"));
- ATLASSERT(FALSE);
- return FALSE;
- }
-
- ATLASSERT(pMsgLoop != NULL);
- ATLASSERT(m_pMsgLoopMap->Lookup(::GetCurrentThreadId()) == NULL); // not in map yet
-
- BOOL bRet = m_pMsgLoopMap->Add(::GetCurrentThreadId(), pMsgLoop);
-
- lock.Unlock();
-
- return bRet;
- }
-
- BOOL RemoveMessageLoop()
- {
- CStaticDataInitCriticalSectionLock lock;
- if(FAILED(lock.Lock()))
- {
- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::RemoveMessageLoop.\n"));
- ATLASSERT(FALSE);
- return FALSE;
- }
-
- BOOL bRet = m_pMsgLoopMap->Remove(::GetCurrentThreadId());
-
- lock.Unlock();
-
- return bRet;
- }
-
- CMessageLoop* GetMessageLoop(DWORD dwThreadID = ::GetCurrentThreadId()) const
- {
- CStaticDataInitCriticalSectionLock lock;
- if(FAILED(lock.Lock()))
- {
- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::GetMessageLoop.\n"));
- ATLASSERT(FALSE);
- return NULL;
- }
-
- CMessageLoop* pLoop = m_pMsgLoopMap->Lookup(dwThreadID);
-
- lock.Unlock();
-
- return pLoop;
- }
-
-// Setting change notify methods
- // Note: Call this from the main thread for MSDI apps
- BOOL InitSettingChangeNotify(DLGPROC pfnDlgProc = _SettingChangeDlgProc)
- {
- CStaticDataInitCriticalSectionLock lock;
- if(FAILED(lock.Lock()))
- {
- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::InitSettingChangeNotify.\n"));
- ATLASSERT(FALSE);
- return FALSE;
- }
-
- if(m_pSettingChangeNotify == NULL)
- {
- typedef ATL::CSimpleArray _notifyClass;
- ATLTRY(m_pSettingChangeNotify = new _notifyClass);
- ATLASSERT(m_pSettingChangeNotify != NULL);
- }
-
- BOOL bRet = (m_pSettingChangeNotify != NULL);
- if(bRet && m_pSettingChangeNotify->GetSize() == 0)
- {
- // init everything
- _ATL_EMPTY_DLGTEMPLATE templ;
- HWND hNtfWnd = ::CreateDialogIndirect(GetModuleInstance(), &templ, NULL, pfnDlgProc);
- ATLASSERT(::IsWindow(hNtfWnd));
- if(::IsWindow(hNtfWnd))
- {
-// need conditional code because types don't match in winuser.h
-#ifdef _WIN64
- ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, (LONG_PTR)this);
-#else
- ::SetWindowLongPtr(hNtfWnd, GWLP_USERDATA, PtrToLong(this));
-#endif
- bRet = m_pSettingChangeNotify->Add(hNtfWnd);
- }
- else
- {
- bRet = FALSE;
- }
- }
-
- lock.Unlock();
-
- return bRet;
- }
-
- void TermSettingChangeNotify()
- {
- CStaticDataInitCriticalSectionLock lock;
- if(FAILED(lock.Lock()))
- {
- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::TermSettingChangeNotify.\n"));
- ATLASSERT(FALSE);
- return;
- }
-
- if(m_pSettingChangeNotify != NULL && m_pSettingChangeNotify->GetSize() > 0)
- ::DestroyWindow((*m_pSettingChangeNotify)[0]);
- delete m_pSettingChangeNotify;
- m_pSettingChangeNotify = NULL;
-
- lock.Unlock();
- }
-
- BOOL AddSettingChangeNotify(HWND hWnd)
- {
- CStaticDataInitCriticalSectionLock lock;
- if(FAILED(lock.Lock()))
- {
- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::AddSettingChangeNotify.\n"));
- ATLASSERT(FALSE);
- return FALSE;
- }
-
- ATLASSERT(::IsWindow(hWnd));
- BOOL bRet = FALSE;
- if(InitSettingChangeNotify() != FALSE)
- bRet = m_pSettingChangeNotify->Add(hWnd);
-
- lock.Unlock();
-
- return bRet;
- }
-
- BOOL RemoveSettingChangeNotify(HWND hWnd)
- {
- CStaticDataInitCriticalSectionLock lock;
- if(FAILED(lock.Lock()))
- {
- ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CAppModule::RemoveSettingChangeNotify.\n"));
- ATLASSERT(FALSE);
- return FALSE;
- }
-
- BOOL bRet = FALSE;
- if(m_pSettingChangeNotify != NULL)
- bRet = m_pSettingChangeNotify->Remove(hWnd);
-
- lock.Unlock();
-
- return bRet;
- }
-
-// Implementation - setting change notify dialog template and dialog procedure
- struct _ATL_EMPTY_DLGTEMPLATE : DLGTEMPLATE
- {
- _ATL_EMPTY_DLGTEMPLATE()
- {
- memset(this, 0, sizeof(_ATL_EMPTY_DLGTEMPLATE));
- style = WS_POPUP;
- }
- WORD wMenu, wClass, wTitle;
- };
-
-#ifdef _WIN64
- static INT_PTR CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-#else
- static BOOL CALLBACK _SettingChangeDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-#endif
- {
- if(uMsg == WM_SETTINGCHANGE)
- {
-// need conditional code because types don't match in winuser.h
-#ifdef _WIN64
- CAppModule* pModule = (CAppModule*)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
-#else
- CAppModule* pModule = (CAppModule*)LongToPtr(::GetWindowLongPtr(hWnd, GWLP_USERDATA));
-#endif
- ATLASSERT(pModule != NULL);
- ATLASSERT(pModule->m_pSettingChangeNotify != NULL);
- const UINT uTimeout = 1500; // ms
- for(int i = 1; i < pModule->m_pSettingChangeNotify->GetSize(); i++)
- {
-#if !defined(_WIN32_WCE)
- ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_ABORTIFHUNG, uTimeout, NULL);
-#elif(_WIN32_WCE >= 400) // CE specific
- ::SendMessageTimeout((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam, SMTO_NORMAL, uTimeout, NULL);
-#else // _WIN32_WCE < 400 specific
- uTimeout;
- ::SendMessage((*pModule->m_pSettingChangeNotify)[i], uMsg, wParam, lParam);
-#endif
- }
- return TRUE;
- }
- return FALSE;
- }
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CServerAppModule - module class for a COM server application
-
-class CServerAppModule : public CAppModule
-{
-public:
- HANDLE m_hEventShutdown;
- bool m_bActivity;
- DWORD m_dwTimeOut;
- DWORD m_dwPause;
-
-// Override of CAppModule::Init
- HRESULT Init(ATL::_ATL_OBJMAP_ENTRY* pObjMap, HINSTANCE hInstance, const GUID* pLibID = NULL)
- {
- m_dwTimeOut = 5000;
- m_dwPause = 1000;
- return CAppModule::Init(pObjMap, hInstance, pLibID);
- }
-
- void Term()
- {
- if(m_hEventShutdown != NULL && ::CloseHandle(m_hEventShutdown))
- m_hEventShutdown = NULL;
- CAppModule::Term();
- }
-
-// COM Server methods
- LONG Unlock()
- {
- LONG lRet = CComModule::Unlock();
- if(lRet == 0)
- {
- m_bActivity = true;
- ::SetEvent(m_hEventShutdown); // tell monitor that we transitioned to zero
- }
- return lRet;
- }
-
- void MonitorShutdown()
- {
- for(;;)
- {
- ::WaitForSingleObject(m_hEventShutdown, INFINITE);
- DWORD dwWait = 0;
- do
- {
- m_bActivity = false;
- dwWait = ::WaitForSingleObject(m_hEventShutdown, m_dwTimeOut);
- }
- while(dwWait == WAIT_OBJECT_0);
- // timed out
- if(!m_bActivity && m_nLockCnt == 0) // if no activity let's really bail
- {
-#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) && defined(_ATL_FREE_THREADED) && !defined(_WIN32_WCE)
- ::CoSuspendClassObjects();
- if(!m_bActivity && m_nLockCnt == 0)
-#endif
- break;
- }
- }
- // This handle should be valid now. If it isn't,
- // check if _Module.Term was called first (it shouldn't)
- if(::CloseHandle(m_hEventShutdown))
- m_hEventShutdown = NULL;
- ::PostThreadMessage(m_dwMainThreadID, WM_QUIT, 0, 0);
- }
-
- bool StartMonitor()
- {
- m_hEventShutdown = ::CreateEvent(NULL, false, false, NULL);
- if(m_hEventShutdown == NULL)
- return false;
- DWORD dwThreadID = 0;
-#if !defined(_ATL_MIN_CRT) && defined(_MT) && !defined(_WIN32_WCE)
- HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, (UINT (WINAPI*)(void*))MonitorProc, this, 0, (UINT*)&dwThreadID);
-#else
- HANDLE hThread = ::CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID);
-#endif
- bool bRet = (hThread != NULL);
- if(bRet)
- ::CloseHandle(hThread);
- return bRet;
- }
-
- static DWORD WINAPI MonitorProc(void* pv)
- {
- CServerAppModule* p = (CServerAppModule*)pv;
- p->MonitorShutdown();
- return 0;
- }
-
-#if (_ATL_VER < 0x0700)
- // search for an occurence of string p2 in string p1
- static LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2)
- {
- while(p1 != NULL && *p1 != NULL)
- {
- LPCTSTR p = p2;
- while(p != NULL && *p != NULL)
- {
- if(*p1 == *p)
- return ::CharNext(p1);
- p = ::CharNext(p);
- }
- p1 = ::CharNext(p1);
- }
- return NULL;
- }
-#endif // (_ATL_VER < 0x0700)
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CRegKeyEx - adds type-specific methods to ATL3 CRegKey
-
-#if (_ATL_VER < 0x0700)
-
-class CRegKeyEx : public ATL::CRegKey
-{
-public:
-// Constructors and operators
- CRegKeyEx(HKEY hKey = NULL)
- {
- m_hKey = hKey;
- }
-
- CRegKeyEx(CRegKeyEx& key)
- {
- Attach(key.Detach());
- }
-
- CRegKeyEx& operator =(CRegKeyEx& key)
- {
- Close();
- Attach(key.Detach());
- return *this;
- }
-
-// Methods
- LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void* pValue, ULONG nBytes)
- {
- ATLASSERT(m_hKey != NULL);
- return ::RegSetValueEx(m_hKey, pszValueName, NULL, dwType, static_cast(pValue), nBytes);
- }
-
- LONG SetGUIDValue(LPCTSTR pszValueName, REFGUID guidValue)
- {
- ATLASSERT(m_hKey != NULL);
-
- OLECHAR szGUID[64] = { 0 };
- ::StringFromGUID2(guidValue, szGUID, 64);
-
- USES_CONVERSION;
- LPCTSTR lpstr = OLE2CT(szGUID);
-#ifndef _UNICODE
- if(lpstr == NULL)
- return E_OUTOFMEMORY;
-#endif
- return SetStringValue(pszValueName, lpstr);
- }
-
- LONG SetBinaryValue(LPCTSTR pszValueName, const void* pValue, ULONG nBytes)
- {
- ATLASSERT(m_hKey != NULL);
- return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_BINARY, reinterpret_cast(pValue), nBytes);
- }
-
- LONG SetDWORDValue(LPCTSTR pszValueName, DWORD dwValue)
- {
- ATLASSERT(m_hKey != NULL);
- return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_DWORD, reinterpret_cast(&dwValue), sizeof(DWORD));
- }
-
-#ifndef _WIN32_WCE
- LONG SetQWORDValue(LPCTSTR pszValueName, ULONGLONG qwValue)
- {
- ATLASSERT(m_hKey != NULL);
- return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_QWORD, reinterpret_cast(&qwValue), sizeof(ULONGLONG));
- }
-#endif
-
- LONG SetStringValue(LPCTSTR pszValueName, LPCTSTR pszValue, DWORD dwType = REG_SZ)
- {
- ATLASSERT(m_hKey != NULL);
- if(pszValue == NULL)
- {
- ATLASSERT(FALSE);
- return ERROR_INVALID_DATA;
- }
- ATLASSERT((dwType == REG_SZ) || (dwType == REG_EXPAND_SZ));
-
- return ::RegSetValueEx(m_hKey, pszValueName, NULL, dwType, reinterpret_cast(pszValue), (lstrlen(pszValue) + 1) * sizeof(TCHAR));
- }
-
- LONG SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue)
- {
- ATLASSERT(m_hKey != NULL);
- if(pszValue == NULL)
- {
- ATLASSERT(FALSE);
- return ERROR_INVALID_DATA;
- }
-
- ULONG nBytes = 0;
- ULONG nLength = 0;
- LPCTSTR pszTemp = pszValue;
- do
- {
- nLength = lstrlen(pszTemp) + 1;
- pszTemp += nLength;
- nBytes += nLength * sizeof(TCHAR);
- } while (nLength != 1);
-
- return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_MULTI_SZ, reinterpret_cast(pszValue), nBytes);
- }
-
- LONG QueryValue(LPCTSTR pszValueName, DWORD* pdwType, void* pData, ULONG* pnBytes)
- {
- ATLASSERT(m_hKey != NULL);
- return ::RegQueryValueEx(m_hKey, pszValueName, NULL, pdwType, static_cast(pData), pnBytes);
- }
-
- LONG QueryGUIDValue(LPCTSTR pszValueName, GUID& guidValue)
- {
- ATLASSERT(m_hKey != NULL);
-
- guidValue = GUID_NULL;
-
- TCHAR szGUID[64] = { 0 };
- ULONG nCount = 64;
- LONG lRes = QueryStringValue(pszValueName, szGUID, &nCount);
-
- if (lRes != ERROR_SUCCESS)
- return lRes;
-
- if(szGUID[0] != _T('{'))
- return ERROR_INVALID_DATA;
-
- USES_CONVERSION;
- LPOLESTR lpstr = T2OLE(szGUID);
-#ifndef _UNICODE
- if(lpstr == NULL)
- return E_OUTOFMEMORY;
-#endif
-
- HRESULT hr = ::CLSIDFromString(lpstr, &guidValue);
- if (FAILED(hr))
- return ERROR_INVALID_DATA;
-
- return ERROR_SUCCESS;
- }
-
- LONG QueryBinaryValue(LPCTSTR pszValueName, void* pValue, ULONG* pnBytes)
- {
- ATLASSERT(pnBytes != NULL);
- ATLASSERT(m_hKey != NULL);
-
- DWORD dwType = 0;
- LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pValue), pnBytes);
- if (lRes != ERROR_SUCCESS)
- return lRes;
- if (dwType != REG_BINARY)
- return ERROR_INVALID_DATA;
-
- return ERROR_SUCCESS;
- }
-
- LONG QueryDWORDValue(LPCTSTR pszValueName, DWORD& dwValue)
- {
- ATLASSERT(m_hKey != NULL);
-
- ULONG nBytes = sizeof(DWORD);
- DWORD dwType = 0;
- LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(&dwValue), &nBytes);
- if (lRes != ERROR_SUCCESS)
- return lRes;
- if (dwType != REG_DWORD)
- return ERROR_INVALID_DATA;
-
- return ERROR_SUCCESS;
- }
-
- LONG QueryQWORDValue(LPCTSTR pszValueName, ULONGLONG& qwValue)
- {
- ATLASSERT(m_hKey != NULL);
-
- ULONG nBytes = sizeof(ULONGLONG);
- DWORD dwType = 0;
- LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(&qwValue), &nBytes);
- if (lRes != ERROR_SUCCESS)
- return lRes;
- if (dwType != REG_QWORD)
- return ERROR_INVALID_DATA;
-
- return ERROR_SUCCESS;
- }
-
- LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG* pnChars)
- {
- ATLASSERT(m_hKey != NULL);
- ATLASSERT(pnChars != NULL);
-
- ULONG nBytes = (*pnChars) * sizeof(TCHAR);
- DWORD dwType = 0;
- *pnChars = 0;
- LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pszValue), &nBytes);
-
- if (lRes != ERROR_SUCCESS)
- {
- return lRes;
- }
-
- if(dwType != REG_SZ && dwType != REG_EXPAND_SZ)
- {
- return ERROR_INVALID_DATA;
- }
-
- if (pszValue != NULL)
- {
- if(nBytes != 0)
- {
- if ((nBytes % sizeof(TCHAR) != 0) || (pszValue[nBytes / sizeof(TCHAR) -1] != 0))
- return ERROR_INVALID_DATA;
- }
- else
- {
- pszValue[0] = _T('\0');
- }
- }
-
- *pnChars = nBytes / sizeof(TCHAR);
-
- return ERROR_SUCCESS;
- }
-
- LONG QueryMultiStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG* pnChars)
- {
- ATLASSERT(m_hKey != NULL);
- ATLASSERT(pnChars != NULL);
-
- if (pszValue != NULL && *pnChars < 2)
- return ERROR_INSUFFICIENT_BUFFER;
-
- ULONG nBytes = (*pnChars) * sizeof(TCHAR);
- DWORD dwType = 0;
- *pnChars = 0;
- LONG lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pszValue), &nBytes);
- if (lRes != ERROR_SUCCESS)
- return lRes;
- if (dwType != REG_MULTI_SZ)
- return ERROR_INVALID_DATA;
- if (pszValue != NULL && (nBytes % sizeof(TCHAR) != 0 || nBytes / sizeof(TCHAR) < 1 || pszValue[nBytes / sizeof(TCHAR) - 1] != 0 || ((nBytes / sizeof(TCHAR)) > 1 && pszValue[nBytes / sizeof(TCHAR) - 2] != 0)))
- return ERROR_INVALID_DATA;
-
- *pnChars = nBytes / sizeof(TCHAR);
-
- return ERROR_SUCCESS;
- }
-};
-
-#else // !(_ATL_VER < 0x0700)
-
-typedef ATL::CRegKey CRegKeyEx;
-
-#endif // !(_ATL_VER < 0x0700)
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CString forward reference (enables CString use in atluser.h and atlgdi.h)
-
-#if defined(_WTL_FORWARD_DECLARE_CSTRING) && !defined(_WTL_USE_CSTRING)
- #define _WTL_USE_CSTRING
-#endif // defined(_WTL_FORWARD_DECLARE_CSTRING) && !defined(_WTL_USE_CSTRING)
-
-#ifdef _WTL_USE_CSTRING
- class CString; // forward declaration (include atlmisc.h for the whole class)
-#endif // _WTL_USE_CSTRING
-
-// CString namespace
-#ifndef _CSTRING_NS
- #ifdef __ATLSTR_H__
- #define _CSTRING_NS ATL
- #else
- #define _CSTRING_NS WTL
- #endif
-#endif // _CSTRING_NS
-
-// Type classes namespace
-#ifndef _WTYPES_NS
- #ifdef __ATLTYPES_H__
- #define _WTYPES_NS
- #else
- #define _WTYPES_NS WTL
- #endif
-#endif // _WTYPES_NS
-
-}; // namespace WTL
-
-
-///////////////////////////////////////////////////////////////////////////////
-// General DLL version helpers (excluded from atlbase.h if _ATL_DLL is defined)
-
-#if (_ATL_VER < 0x0700) && defined(_ATL_DLL) && !defined(_WIN32_WCE)
-
-namespace ATL
-{
-
-inline HRESULT AtlGetDllVersion(HINSTANCE hInstDLL, DLLVERSIONINFO* pDllVersionInfo)
-{
- ATLASSERT(pDllVersionInfo != NULL);
- if(pDllVersionInfo == NULL)
- return E_INVALIDARG;
-
- // We must get this function explicitly because some DLLs don't implement it.
- DLLGETVERSIONPROC pfnDllGetVersion = (DLLGETVERSIONPROC)::GetProcAddress(hInstDLL, "DllGetVersion");
- if(pfnDllGetVersion == NULL)
- return E_NOTIMPL;
-
- return (*pfnDllGetVersion)(pDllVersionInfo);
-}
-
-inline HRESULT AtlGetDllVersion(LPCTSTR lpstrDllName, DLLVERSIONINFO* pDllVersionInfo)
-{
- HINSTANCE hInstDLL = ::LoadLibrary(lpstrDllName);
- if(hInstDLL == NULL)
- return E_FAIL;
- HRESULT hRet = AtlGetDllVersion(hInstDLL, pDllVersionInfo);
- ::FreeLibrary(hInstDLL);
- return hRet;
-}
-
-// Common Control Versions:
-// Win95/WinNT 4.0 maj=4 min=00
-// IE 3.x maj=4 min=70
-// IE 4.0 maj=4 min=71
-inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor)
-{
- ATLASSERT(pdwMajor != NULL && pdwMinor != NULL);
- if(pdwMajor == NULL || pdwMinor == NULL)
- return E_INVALIDARG;
-
- DLLVERSIONINFO dvi;
- ::ZeroMemory(&dvi, sizeof(dvi));
- dvi.cbSize = sizeof(dvi);
- HRESULT hRet = AtlGetDllVersion(_T("comctl32.dll"), &dvi);
-
- if(SUCCEEDED(hRet))
- {
- *pdwMajor = dvi.dwMajorVersion;
- *pdwMinor = dvi.dwMinorVersion;
- }
- else if(hRet == E_NOTIMPL)
- {
- // If DllGetVersion is not there, then the DLL is a version
- // previous to the one shipped with IE 3.x
- *pdwMajor = 4;
- *pdwMinor = 0;
- hRet = S_OK;
- }
-
- return hRet;
-}
-
-// Shell Versions:
-// Win95/WinNT 4.0 maj=4 min=00
-// IE 3.x, IE 4.0 without Web Integrated Desktop maj=4 min=00
-// IE 4.0 with Web Integrated Desktop maj=4 min=71
-// IE 4.01 with Web Integrated Desktop maj=4 min=72
-inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor)
-{
- ATLASSERT(pdwMajor != NULL && pdwMinor != NULL);
- if(pdwMajor == NULL || pdwMinor == NULL)
- return E_INVALIDARG;
-
- DLLVERSIONINFO dvi;
- ::ZeroMemory(&dvi, sizeof(dvi));
- dvi.cbSize = sizeof(dvi);
- HRESULT hRet = AtlGetDllVersion(_T("shell32.dll"), &dvi);
-
- if(SUCCEEDED(hRet))
- {
- *pdwMajor = dvi.dwMajorVersion;
- *pdwMinor = dvi.dwMinorVersion;
- }
- else if(hRet == E_NOTIMPL)
- {
- // If DllGetVersion is not there, then the DLL is a version
- // previous to the one shipped with IE 4.x
- *pdwMajor = 4;
- *pdwMinor = 0;
- hRet = S_OK;
- }
-
- return hRet;
-}
-
-}; // namespace ATL
-
-#endif // (_ATL_VER < 0x0700) && defined(_ATL_DLL) && !defined(_WIN32_WCE)
-
-
-// These are always included
-#include "atlwinx.h"
-#include "atluser.h"
-#include "atlgdi.h"
-
-#ifndef _WTL_NO_AUTOMATIC_NAMESPACE
-using namespace WTL;
-#endif // !_WTL_NO_AUTOMATIC_NAMESPACE
-
-#endif // __ATLAPP_H__
diff --git a/WTL/atlcrack.h b/WTL/atlcrack.h
deleted file mode 100644
index 9666c5a..0000000
--- a/WTL/atlcrack.h
+++ /dev/null
@@ -1,2384 +0,0 @@
-// Windows Template Library - WTL version 8.1
-// Copyright (C) Microsoft Corporation. All rights reserved.
-//
-// This file is a part of the Windows Template Library.
-// The use and distribution terms for this software are covered by the
-// Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
-// which can be found in the file CPL.TXT at the root of this distribution.
-// By using this software in any fashion, you are agreeing to be bound by
-// the terms of this license. You must not remove this notice, or
-// any other, from this software.
-
-#ifndef __ATLCRACK_H__
-#define __ATLCRACK_H__
-
-#pragma once
-
-#ifndef __ATLAPP_H__
- #error atlcrack.h requires atlapp.h to be included first
-#endif
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Message map macro for cracked handlers
-
-// Note about message maps with cracked handlers:
-// For ATL 3.0, a message map using cracked handlers MUST use BEGIN_MSG_MAP_EX.
-// For ATL 7.0 or higher, you can use BEGIN_MSG_MAP for CWindowImpl/CDialogImpl derived classes,
-// but must use BEGIN_MSG_MAP_EX for classes that don't derive from CWindowImpl/CDialogImpl.
-
-#define BEGIN_MSG_MAP_EX(theClass) \
-public: \
- BOOL m_bMsgHandled; \
- /* "handled" management for cracked handlers */ \
- BOOL IsMsgHandled() const \
- { \
- return m_bMsgHandled; \
- } \
- void SetMsgHandled(BOOL bHandled) \
- { \
- m_bMsgHandled = bHandled; \
- } \
- BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
- { \
- BOOL bOldMsgHandled = m_bMsgHandled; \
- BOOL bRet = _ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \
- m_bMsgHandled = bOldMsgHandled; \
- return bRet; \
- } \
- BOOL _ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID) \
- { \
- BOOL bHandled = TRUE; \
- hWnd; \
- uMsg; \
- wParam; \
- lParam; \
- lResult; \
- bHandled; \
- switch(dwMsgMapID) \
- { \
- case 0:
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Standard Windows message macros
-
-// int OnCreate(LPCREATESTRUCT lpCreateStruct)
-#define MSG_WM_CREATE(func) \
- if (uMsg == WM_CREATE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
-#define MSG_WM_INITDIALOG(func) \
- if (uMsg == WM_INITDIALOG) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HWND)wParam, lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnCopyData(CWindow wnd, PCOPYDATASTRUCT pCopyDataStruct)
-#define MSG_WM_COPYDATA(func) \
- if (uMsg == WM_COPYDATA) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HWND)wParam, (PCOPYDATASTRUCT)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDestroy()
-#define MSG_WM_DESTROY(func) \
- if (uMsg == WM_DESTROY) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMove(CPoint ptPos)
-#define MSG_WM_MOVE(func) \
- if (uMsg == WM_MOVE) \
- { \
- SetMsgHandled(TRUE); \
- func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSize(UINT nType, CSize size)
-#define MSG_WM_SIZE(func) \
- if (uMsg == WM_SIZE) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnActivate(UINT nState, BOOL bMinimized, CWindow wndOther)
-#define MSG_WM_ACTIVATE(func) \
- if (uMsg == WM_ACTIVATE) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)LOWORD(wParam), (BOOL)HIWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSetFocus(CWindow wndOld)
-#define MSG_WM_SETFOCUS(func) \
- if (uMsg == WM_SETFOCUS) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnKillFocus(CWindow wndFocus)
-#define MSG_WM_KILLFOCUS(func) \
- if (uMsg == WM_KILLFOCUS) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnEnable(BOOL bEnable)
-#define MSG_WM_ENABLE(func) \
- if (uMsg == WM_ENABLE) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnPaint(CDCHandle dc)
-#define MSG_WM_PAINT(func) \
- if (uMsg == WM_PAINT) \
- { \
- SetMsgHandled(TRUE); \
- func((HDC)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnClose()
-#define MSG_WM_CLOSE(func) \
- if (uMsg == WM_CLOSE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnQueryEndSession(UINT nSource, UINT uLogOff)
-#define MSG_WM_QUERYENDSESSION(func) \
- if (uMsg == WM_QUERYENDSESSION) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)wParam, (UINT)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnQueryOpen()
-#define MSG_WM_QUERYOPEN(func) \
- if (uMsg == WM_QUERYOPEN) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func(); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnEraseBkgnd(CDCHandle dc)
-#define MSG_WM_ERASEBKGND(func) \
- if (uMsg == WM_ERASEBKGND) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSysColorChange()
-#define MSG_WM_SYSCOLORCHANGE(func) \
- if (uMsg == WM_SYSCOLORCHANGE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnEndSession(BOOL bEnding, UINT uLogOff)
-#define MSG_WM_ENDSESSION(func) \
- if (uMsg == WM_ENDSESSION) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)wParam, (UINT)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnShowWindow(BOOL bShow, UINT nStatus)
-#define MSG_WM_SHOWWINDOW(func) \
- if (uMsg == WM_SHOWWINDOW) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)wParam, (int)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnCtlColorEdit(CDCHandle dc, CEdit edit)
-#define MSG_WM_CTLCOLOREDIT(func) \
- if (uMsg == WM_CTLCOLOREDIT) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnCtlColorListBox(CDCHandle dc, CListBox listBox)
-#define MSG_WM_CTLCOLORLISTBOX(func) \
- if (uMsg == WM_CTLCOLORLISTBOX) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnCtlColorBtn(CDCHandle dc, CButton button)
-#define MSG_WM_CTLCOLORBTN(func) \
- if (uMsg == WM_CTLCOLORBTN) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnCtlColorDlg(CDCHandle dc, CWindow wnd)
-#define MSG_WM_CTLCOLORDLG(func) \
- if (uMsg == WM_CTLCOLORDLG) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
-#define MSG_WM_CTLCOLORSCROLLBAR(func) \
- if (uMsg == WM_CTLCOLORSCROLLBAR) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnCtlColorStatic(CDCHandle dc, CStatic wndStatic)
-#define MSG_WM_CTLCOLORSTATIC(func) \
- if (uMsg == WM_CTLCOLORSTATIC) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
-#define MSG_WM_SETTINGCHANGE(func) \
- if (uMsg == WM_SETTINGCHANGE) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPCTSTR)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDevModeChange(LPCTSTR lpDeviceName)
-#define MSG_WM_DEVMODECHANGE(func) \
- if (uMsg == WM_DEVMODECHANGE) \
- { \
- SetMsgHandled(TRUE); \
- func((LPCTSTR)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnActivateApp(BOOL bActive, DWORD dwThreadID)
-#define MSG_WM_ACTIVATEAPP(func) \
- if (uMsg == WM_ACTIVATEAPP) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)wParam, (DWORD)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnFontChange()
-#define MSG_WM_FONTCHANGE(func) \
- if (uMsg == WM_FONTCHANGE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnTimeChange()
-#define MSG_WM_TIMECHANGE(func) \
- if (uMsg == WM_TIMECHANGE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCancelMode()
-#define MSG_WM_CANCELMODE(func) \
- if (uMsg == WM_CANCELMODE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnSetCursor(CWindow wnd, UINT nHitTest, UINT message)
-#define MSG_WM_SETCURSOR(func) \
- if (uMsg == WM_SETCURSOR) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnMouseActivate(CWindow wndTopLevel, UINT nHitTest, UINT message)
-#define MSG_WM_MOUSEACTIVATE(func) \
- if (uMsg == WM_MOUSEACTIVATE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnChildActivate()
-#define MSG_WM_CHILDACTIVATE(func) \
- if (uMsg == WM_CHILDACTIVATE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnGetMinMaxInfo(LPMINMAXINFO lpMMI)
-#define MSG_WM_GETMINMAXINFO(func) \
- if (uMsg == WM_GETMINMAXINFO) \
- { \
- SetMsgHandled(TRUE); \
- func((LPMINMAXINFO)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnIconEraseBkgnd(CDCHandle dc)
-#define MSG_WM_ICONERASEBKGND(func) \
- if (uMsg == WM_ICONERASEBKGND) \
- { \
- SetMsgHandled(TRUE); \
- func((HDC)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSpoolerStatus(UINT nStatus, UINT nJobs)
-#define MSG_WM_SPOOLERSTATUS(func) \
- if (uMsg == WM_SPOOLERSTATUS) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (UINT)LOWORD(lParam)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
-#define MSG_WM_DRAWITEM(func) \
- if (uMsg == WM_DRAWITEM) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
-#define MSG_WM_MEASUREITEM(func) \
- if (uMsg == WM_MEASUREITEM) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
-#define MSG_WM_DELETEITEM(func) \
- if (uMsg == WM_DELETEITEM) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-//int OnCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
-#define MSG_WM_CHARTOITEM(func) \
- if (uMsg == WM_CHARTOITEM) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
-#define MSG_WM_VKEYTOITEM(func) \
- if (uMsg == WM_VKEYTOITEM) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HCURSOR OnQueryDragIcon()
-#define MSG_WM_QUERYDRAGICON(func) \
- if (uMsg == WM_QUERYDRAGICON) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func(); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct)
-#define MSG_WM_COMPAREITEM(func) \
- if (uMsg == WM_COMPAREITEM) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCompacting(UINT nCpuTime)
-#define MSG_WM_COMPACTING(func) \
- if (uMsg == WM_COMPACTING) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct)
-#define MSG_WM_NCCREATE(func) \
- if (uMsg == WM_NCCREATE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcDestroy()
-#define MSG_WM_NCDESTROY(func) \
- if (uMsg == WM_NCDESTROY) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnNcCalcSize(BOOL bCalcValidRects, LPARAM lParam)
-#define MSG_WM_NCCALCSIZE(func) \
- if (uMsg == WM_NCCALCSIZE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((BOOL)wParam, lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// UINT OnNcHitTest(CPoint point)
-#define MSG_WM_NCHITTEST(func) \
- if (uMsg == WM_NCHITTEST) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcPaint(CRgn rgn)
-#define MSG_WM_NCPAINT(func) \
- if (uMsg == WM_NCPAINT) \
- { \
- SetMsgHandled(TRUE); \
- func((HRGN)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnNcActivate(BOOL bActive)
-#define MSG_WM_NCACTIVATE(func) \
- if (uMsg == WM_NCACTIVATE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((BOOL)wParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// UINT OnGetDlgCode(LPMSG lpMsg)
-#define MSG_WM_GETDLGCODE(func) \
- if (uMsg == WM_GETDLGCODE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((LPMSG)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcMouseMove(UINT nHitTest, CPoint point)
-#define MSG_WM_NCMOUSEMOVE(func) \
- if (uMsg == WM_NCMOUSEMOVE) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcLButtonDown(UINT nHitTest, CPoint point)
-#define MSG_WM_NCLBUTTONDOWN(func) \
- if (uMsg == WM_NCLBUTTONDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcLButtonUp(UINT nHitTest, CPoint point)
-#define MSG_WM_NCLBUTTONUP(func) \
- if (uMsg == WM_NCLBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcLButtonDblClk(UINT nHitTest, CPoint point)
-#define MSG_WM_NCLBUTTONDBLCLK(func) \
- if (uMsg == WM_NCLBUTTONDBLCLK) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcRButtonDown(UINT nHitTest, CPoint point)
-#define MSG_WM_NCRBUTTONDOWN(func) \
- if (uMsg == WM_NCRBUTTONDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcRButtonUp(UINT nHitTest, CPoint point)
-#define MSG_WM_NCRBUTTONUP(func) \
- if (uMsg == WM_NCRBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcRButtonDblClk(UINT nHitTest, CPoint point)
-#define MSG_WM_NCRBUTTONDBLCLK(func) \
- if (uMsg == WM_NCRBUTTONDBLCLK) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcMButtonDown(UINT nHitTest, CPoint point)
-#define MSG_WM_NCMBUTTONDOWN(func) \
- if (uMsg == WM_NCMBUTTONDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcMButtonUp(UINT nHitTest, CPoint point)
-#define MSG_WM_NCMBUTTONUP(func) \
- if (uMsg == WM_NCMBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNcMButtonDblClk(UINT nHitTest, CPoint point)
-#define MSG_WM_NCMBUTTONDBLCLK(func) \
- if (uMsg == WM_NCMBUTTONDBLCLK) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_KEYDOWN(func) \
- if (uMsg == WM_KEYDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_KEYUP(func) \
- if (uMsg == WM_KEYUP) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_CHAR(func) \
- if (uMsg == WM_CHAR) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_DEADCHAR(func) \
- if (uMsg == WM_DEADCHAR) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_SYSKEYDOWN(func) \
- if (uMsg == WM_SYSKEYDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_SYSKEYUP(func) \
- if (uMsg == WM_SYSKEYUP) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_SYSCHAR(func) \
- if (uMsg == WM_SYSCHAR) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_SYSDEADCHAR(func) \
- if (uMsg == WM_SYSDEADCHAR) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSysCommand(UINT nID, LPARAM lParam)
-#define MSG_WM_SYSCOMMAND(func) \
- if (uMsg == WM_SYSCOMMAND) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnTCard(UINT idAction, DWORD dwActionData)
-#define MSG_WM_TCARD(func) \
- if (uMsg == WM_TCARD) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (DWORD)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnTimer(UINT_PTR nIDEvent)
-#define MSG_WM_TIMER(func) \
- if (uMsg == WM_TIMER) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT_PTR)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
-#define MSG_WM_HSCROLL(func) \
- if (uMsg == WM_HSCROLL) \
- { \
- SetMsgHandled(TRUE); \
- func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
-#define MSG_WM_VSCROLL(func) \
- if (uMsg == WM_VSCROLL) \
- { \
- SetMsgHandled(TRUE); \
- func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnInitMenu(CMenu menu)
-#define MSG_WM_INITMENU(func) \
- if (uMsg == WM_INITMENU) \
- { \
- SetMsgHandled(TRUE); \
- func((HMENU)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnInitMenuPopup(CMenu menuPopup, UINT nIndex, BOOL bSysMenu)
-#define MSG_WM_INITMENUPOPUP(func) \
- if (uMsg == WM_INITMENUPOPUP) \
- { \
- SetMsgHandled(TRUE); \
- func((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMenuSelect(UINT nItemID, UINT nFlags, CMenu menu)
-#define MSG_WM_MENUSELECT(func) \
- if (uMsg == WM_MENUSELECT) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu menu)
-#define MSG_WM_MENUCHAR(func) \
- if (uMsg == WM_MENUCHAR) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnNotify(int idCtrl, LPNMHDR pnmh)
-#define MSG_WM_NOTIFY(func) \
- if (uMsg == WM_NOTIFY) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((int)wParam, (LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnEnterIdle(UINT nWhy, CWindow wndWho)
-#define MSG_WM_ENTERIDLE(func) \
- if (uMsg == WM_ENTERIDLE) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMouseMove(UINT nFlags, CPoint point)
-#define MSG_WM_MOUSEMOVE(func) \
- if (uMsg == WM_MOUSEMOVE) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
-#define MSG_WM_MOUSEWHEEL(func) \
- if (uMsg == WM_MOUSEWHEEL) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnLButtonDown(UINT nFlags, CPoint point)
-#define MSG_WM_LBUTTONDOWN(func) \
- if (uMsg == WM_LBUTTONDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnLButtonUp(UINT nFlags, CPoint point)
-#define MSG_WM_LBUTTONUP(func) \
- if (uMsg == WM_LBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnLButtonDblClk(UINT nFlags, CPoint point)
-#define MSG_WM_LBUTTONDBLCLK(func) \
- if (uMsg == WM_LBUTTONDBLCLK) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnRButtonDown(UINT nFlags, CPoint point)
-#define MSG_WM_RBUTTONDOWN(func) \
- if (uMsg == WM_RBUTTONDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnRButtonUp(UINT nFlags, CPoint point)
-#define MSG_WM_RBUTTONUP(func) \
- if (uMsg == WM_RBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnRButtonDblClk(UINT nFlags, CPoint point)
-#define MSG_WM_RBUTTONDBLCLK(func) \
- if (uMsg == WM_RBUTTONDBLCLK) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMButtonDown(UINT nFlags, CPoint point)
-#define MSG_WM_MBUTTONDOWN(func) \
- if (uMsg == WM_MBUTTONDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMButtonUp(UINT nFlags, CPoint point)
-#define MSG_WM_MBUTTONUP(func) \
- if (uMsg == WM_MBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMButtonDblClk(UINT nFlags, CPoint point)
-#define MSG_WM_MBUTTONDBLCLK(func) \
- if (uMsg == WM_MBUTTONDBLCLK) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnParentNotify(UINT message, UINT nChildID, LPARAM lParam)
-#define MSG_WM_PARENTNOTIFY(func) \
- if (uMsg == WM_PARENTNOTIFY) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMDIActivate(CWindow wndActivate, CWindow wndDeactivate)
-#define MSG_WM_MDIACTIVATE(func) \
- if (uMsg == WM_MDIACTIVATE) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam, (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnRenderFormat(UINT nFormat)
-#define MSG_WM_RENDERFORMAT(func) \
- if (uMsg == WM_RENDERFORMAT) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnRenderAllFormats()
-#define MSG_WM_RENDERALLFORMATS(func) \
- if (uMsg == WM_RENDERALLFORMATS) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDestroyClipboard()
-#define MSG_WM_DESTROYCLIPBOARD(func) \
- if (uMsg == WM_DESTROYCLIPBOARD) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDrawClipboard()
-#define MSG_WM_DRAWCLIPBOARD(func) \
- if (uMsg == WM_DRAWCLIPBOARD) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnPaintClipboard(CWindow wndViewer, const LPPAINTSTRUCT lpPaintStruct)
-#define MSG_WM_PAINTCLIPBOARD(func) \
- if (uMsg == WM_PAINTCLIPBOARD) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam, (const LPPAINTSTRUCT)::GlobalLock((HGLOBAL)lParam)); \
- ::GlobalUnlock((HGLOBAL)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnVScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos)
-#define MSG_WM_VSCROLLCLIPBOARD(func) \
- if (uMsg == WM_VSCROLLCLIPBOARD) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnContextMenu(CWindow wnd, CPoint point)
-#define MSG_WM_CONTEXTMENU(func) \
- if (uMsg == WM_CONTEXTMENU) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSizeClipboard(CWindow wndViewer, const LPRECT lpRect)
-#define MSG_WM_SIZECLIPBOARD(func) \
- if (uMsg == WM_SIZECLIPBOARD) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam, (const LPRECT)::GlobalLock((HGLOBAL)lParam)); \
- ::GlobalUnlock((HGLOBAL)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnAskCbFormatName(UINT nMaxCount, LPTSTR lpszString)
-#define MSG_WM_ASKCBFORMATNAME(func) \
- if (uMsg == WM_ASKCBFORMATNAME) \
- { \
- SetMsgHandled(TRUE); \
- func((DWORD)wParam, (LPTSTR)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnChangeCbChain(CWindow wndRemove, CWindow wndAfter)
-#define MSG_WM_CHANGECBCHAIN(func) \
- if (uMsg == WM_CHANGECBCHAIN) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam, (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnHScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos)
-#define MSG_WM_HSCROLLCLIPBOARD(func) \
- if (uMsg == WM_HSCROLLCLIPBOARD) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnQueryNewPalette()
-#define MSG_WM_QUERYNEWPALETTE(func) \
- if (uMsg == WM_QUERYNEWPALETTE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func(); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnPaletteChanged(CWindow wndFocus)
-#define MSG_WM_PALETTECHANGED(func) \
- if (uMsg == WM_PALETTECHANGED) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnPaletteIsChanging(CWindow wndPalChg)
-#define MSG_WM_PALETTEISCHANGING(func) \
- if (uMsg == WM_PALETTEISCHANGING) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDropFiles(HDROP hDropInfo)
-#define MSG_WM_DROPFILES(func) \
- if (uMsg == WM_DROPFILES) \
- { \
- SetMsgHandled(TRUE); \
- func((HDROP)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnWindowPosChanging(LPWINDOWPOS lpWndPos)
-#define MSG_WM_WINDOWPOSCHANGING(func) \
- if (uMsg == WM_WINDOWPOSCHANGING) \
- { \
- SetMsgHandled(TRUE); \
- func((LPWINDOWPOS)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnWindowPosChanged(LPWINDOWPOS lpWndPos)
-#define MSG_WM_WINDOWPOSCHANGED(func) \
- if (uMsg == WM_WINDOWPOSCHANGED) \
- { \
- SetMsgHandled(TRUE); \
- func((LPWINDOWPOS)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnExitMenuLoop(BOOL fIsTrackPopupMenu)
-#define MSG_WM_EXITMENULOOP(func) \
- if (uMsg == WM_EXITMENULOOP) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnEnterMenuLoop(BOOL fIsTrackPopupMenu)
-#define MSG_WM_ENTERMENULOOP(func) \
- if (uMsg == WM_ENTERMENULOOP) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
-#define MSG_WM_STYLECHANGED(func) \
- if (uMsg == WM_STYLECHANGED) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
-#define MSG_WM_STYLECHANGING(func) \
- if (uMsg == WM_STYLECHANGING) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSizing(UINT fwSide, LPRECT pRect)
-#define MSG_WM_SIZING(func) \
- if (uMsg == WM_SIZING) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPRECT)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMoving(UINT fwSide, LPRECT pRect)
-#define MSG_WM_MOVING(func) \
- if (uMsg == WM_MOVING) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPRECT)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCaptureChanged(CWindow wnd)
-#define MSG_WM_CAPTURECHANGED(func) \
- if (uMsg == WM_CAPTURECHANGED) \
- { \
- SetMsgHandled(TRUE); \
- func((HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnDeviceChange(UINT nEventType, DWORD dwData)
-#define MSG_WM_DEVICECHANGE(func) \
- if (uMsg == WM_DEVICECHANGE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)wParam, (DWORD)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define MSG_WM_COMMAND(func) \
- if (uMsg == WM_COMMAND) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDisplayChange(UINT uBitsPerPixel, CSize sizeScreen)
-#define MSG_WM_DISPLAYCHANGE(func) \
- if (uMsg == WM_DISPLAYCHANGE) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnEnterSizeMove()
-#define MSG_WM_ENTERSIZEMOVE(func) \
- if (uMsg == WM_ENTERSIZEMOVE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnExitSizeMove()
-#define MSG_WM_EXITSIZEMOVE(func) \
- if (uMsg == WM_EXITSIZEMOVE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HFONT OnGetFont()
-#define MSG_WM_GETFONT(func) \
- if (uMsg == WM_GETFONT) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func(); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnGetHotKey()
-#define MSG_WM_GETHOTKEY(func) \
- if (uMsg == WM_GETHOTKEY) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func(); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HICON OnGetIcon()
-#define MSG_WM_GETICON(func) \
- if (uMsg == WM_GETICON) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)wParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnGetText(int cchTextMax, LPTSTR lpszText)
-#define MSG_WM_GETTEXT(func) \
- if (uMsg == WM_GETTEXT) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((int)wParam, (LPTSTR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnGetTextLength()
-#define MSG_WM_GETTEXTLENGTH(func) \
- if (uMsg == WM_GETTEXTLENGTH) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func(); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnHelp(LPHELPINFO lpHelpInfo)
-#define MSG_WM_HELP(func) \
- if (uMsg == WM_HELP) \
- { \
- SetMsgHandled(TRUE); \
- func((LPHELPINFO)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnHotKey(int nHotKeyID, UINT uModifiers, UINT uVirtKey)
-#define MSG_WM_HOTKEY(func) \
- if (uMsg == WM_HOTKEY) \
- { \
- SetMsgHandled(TRUE); \
- func((int)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnInputLangChange(DWORD dwCharSet, HKL hKbdLayout)
-#define MSG_WM_INPUTLANGCHANGE(func) \
- if (uMsg == WM_INPUTLANGCHANGE) \
- { \
- SetMsgHandled(TRUE); \
- func((DWORD)wParam, (HKL)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnInputLangChangeRequest(BOOL bSysCharSet, HKL hKbdLayout)
-#define MSG_WM_INPUTLANGCHANGEREQUEST(func) \
- if (uMsg == WM_INPUTLANGCHANGEREQUEST) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)wParam, (HKL)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNextDlgCtl(BOOL bHandle, WPARAM wCtlFocus)
-#define MSG_WM_NEXTDLGCTL(func) \
- if (uMsg == WM_NEXTDLGCTL) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)LOWORD(lParam), wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNextMenu(int nVirtKey, LPMDINEXTMENU lpMdiNextMenu)
-#define MSG_WM_NEXTMENU(func) \
- if (uMsg == WM_NEXTMENU) \
- { \
- SetMsgHandled(TRUE); \
- func((int)wParam, (LPMDINEXTMENU)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnNotifyFormat(CWindow wndFrom, int nCommand)
-#define MSG_WM_NOTIFYFORMAT(func) \
- if (uMsg == WM_NOTIFYFORMAT) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HWND)wParam, (int)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// BOOL OnPowerBroadcast(DWORD dwPowerEvent, DWORD dwData)
-#define MSG_WM_POWERBROADCAST(func) \
- if (uMsg == WM_POWERBROADCAST) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((DWORD)wParam, (DWORD)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnPrint(CDCHandle dc, UINT uFlags)
-#define MSG_WM_PRINT(func) \
- if (uMsg == WM_PRINT) \
- { \
- SetMsgHandled(TRUE); \
- func((HDC)wParam, (UINT)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnPrintClient(CDCHandle dc, UINT uFlags)
-#define MSG_WM_PRINTCLIENT(func) \
- if (uMsg == WM_PRINTCLIENT) \
- { \
- SetMsgHandled(TRUE); \
- func((HDC)wParam, (UINT)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnRasDialEvent(RASCONNSTATE rasconnstate, DWORD dwError)
-#define MSG_WM_RASDIALEVENT(func) \
- if (uMsg == WM_RASDIALEVENT) \
- { \
- SetMsgHandled(TRUE); \
- func((RASCONNSTATE)wParam, (DWORD)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSetFont(CFont font, BOOL bRedraw)
-#define MSG_WM_SETFONT(func) \
- if (uMsg == WM_SETFONT) \
- { \
- SetMsgHandled(TRUE); \
- func((HFONT)wParam, (BOOL)LOWORD(lParam)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnSetHotKey(int nVirtKey, UINT uFlags)
-#define MSG_WM_SETHOTKEY(func) \
- if (uMsg == WM_SETHOTKEY) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((int)LOBYTE(LOWORD(wParam)), (UINT)HIBYTE(LOWORD(wParam))); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HICON OnSetIcon(UINT uType, HICON hIcon)
-#define MSG_WM_SETICON(func) \
- if (uMsg == WM_SETICON) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)wParam, (HICON)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnSetRedraw(BOOL bRedraw)
-#define MSG_WM_SETREDRAW(func) \
- if (uMsg == WM_SETREDRAW) \
- { \
- SetMsgHandled(TRUE); \
- func((BOOL)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnSetText(LPCTSTR lpstrText)
-#define MSG_WM_SETTEXT(func) \
- if (uMsg == WM_SETTEXT) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((LPCTSTR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnUserChanged()
-#define MSG_WM_USERCHANGED(func) \
- if (uMsg == WM_USERCHANGED) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-///////////////////////////////////////////////////////////////////////////////
-// New NT4 & NT5 messages
-
-#if(_WIN32_WINNT >= 0x0400)
-
-// void OnMouseHover(WPARAM wParam, CPoint ptPos)
-#define MSG_WM_MOUSEHOVER(func) \
- if (uMsg == WM_MOUSEHOVER) \
- { \
- SetMsgHandled(TRUE); \
- func(wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMouseLeave()
-#define MSG_WM_MOUSELEAVE(func) \
- if (uMsg == WM_MOUSELEAVE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-#endif /* _WIN32_WINNT >= 0x0400 */
-
-#if(WINVER >= 0x0500)
-
-// void OnMenuRButtonUp(WPARAM wParam, CMenu menu)
-#define MSG_WM_MENURBUTTONUP(func) \
- if (uMsg == WM_MENURBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func(wParam, (HMENU)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnMenuDrag(WPARAM wParam, CMenu menu)
-#define MSG_WM_MENUDRAG(func) \
- if (uMsg == WM_MENUDRAG) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func(wParam, (HMENU)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnMenuGetObject(PMENUGETOBJECTINFO info)
-#define MSG_WM_MENUGETOBJECT(func) \
- if (uMsg == WM_MENUGETOBJECT) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((PMENUGETOBJECTINFO)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnUnInitMenuPopup(UINT nID, CMenu menu)
-#define MSG_WM_UNINITMENUPOPUP(func) \
- if (uMsg == WM_UNINITMENUPOPUP) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(lParam), (HMENU)wParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnMenuCommand(WPARAM nIndex, CMenu menu)
-#define MSG_WM_MENUCOMMAND(func) \
- if (uMsg == WM_MENUCOMMAND) \
- { \
- SetMsgHandled(TRUE); \
- func(wParam, (HMENU)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-#endif /* WINVER >= 0x0500 */
-
-#if(_WIN32_WINNT >= 0x0500)
-
-// BOOL OnAppCommand(CWindow wndFocus, short cmd, WORD uDevice, int dwKeys)
-#define MSG_WM_APPCOMMAND(func) \
- if (uMsg == WM_APPCOMMAND) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam)); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNCXButtonDown(int fwButton, short nHittest, CPoint ptPos)
-#define MSG_WM_NCXBUTTONDOWN(func) \
- if (uMsg == WM_NCXBUTTONDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNCXButtonUp(int fwButton, short nHittest, CPoint ptPos)
-#define MSG_WM_NCXBUTTONUP(func) \
- if (uMsg == WM_NCXBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnNCXButtonDblClk(int fwButton, short nHittest, CPoint ptPos)
-#define MSG_WM_NCXBUTTONDBLCLK(func) \
- if (uMsg == WM_NCXBUTTONDBLCLK) \
- { \
- SetMsgHandled(TRUE); \
- func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnXButtonDown(int fwButton, int dwKeys, CPoint ptPos)
-#define MSG_WM_XBUTTONDOWN(func) \
- if (uMsg == WM_XBUTTONDOWN) \
- { \
- SetMsgHandled(TRUE); \
- func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnXButtonUp(int fwButton, int dwKeys, CPoint ptPos)
-#define MSG_WM_XBUTTONUP(func) \
- if (uMsg == WM_XBUTTONUP) \
- { \
- SetMsgHandled(TRUE); \
- func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnXButtonDblClk(int fwButton, int dwKeys, CPoint ptPos)
-#define MSG_WM_XBUTTONDBLCLK(func) \
- if (uMsg == WM_XBUTTONDBLCLK) \
- { \
- SetMsgHandled(TRUE); \
- func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnChangeUIState(WORD nAction, WORD nState)
-#define MSG_WM_CHANGEUISTATE(func) \
- if (uMsg == WM_CHANGEUISTATE) \
- { \
- SetMsgHandled(TRUE); \
- func(LOWORD(wParam), HIWORD(wParam)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnUpdateUIState(WORD nAction, WORD nState)
-#define MSG_WM_UPDATEUISTATE(func) \
- if (uMsg == WM_UPDATEUISTATE) \
- { \
- SetMsgHandled(TRUE); \
- func(LOWORD(wParam), HIWORD(wParam)); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnQueryUIState()
-#define MSG_WM_QUERYUISTATE(func) \
- if (uMsg == WM_QUERYUISTATE) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func(); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-#endif // (_WIN32_WINNT >= 0x0500)
-
-#if(_WIN32_WINNT >= 0x0501)
-
-// void OnInput(WPARAM RawInputCode, HRAWINPUT hRawInput)
-#define MSG_WM_INPUT(func) \
- if (uMsg == WM_INPUT) \
- { \
- SetMsgHandled(TRUE); \
- func(GET_RAWINPUT_CODE_WPARAM(wParam), (HRAWINPUT)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnUniChar(TCHAR nChar, UINT nRepCnt, UINT nFlags)
-#define MSG_WM_UNICHAR(func) \
- if (uMsg == WM_UNICHAR) \
- { \
- SetMsgHandled(TRUE); \
- func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
- if(IsMsgHandled()) \
- { \
- lResult = (wParam == UNICODE_NOCHAR) ? TRUE : FALSE; \
- return TRUE; \
- } \
- }
-
-// void OnWTSSessionChange(WPARAM nStatusCode, PWTSSESSION_NOTIFICATION nSessionID)
-#define MSG_WM_WTSSESSION_CHANGE(func) \
- if (uMsg == WM_WTSSESSION_CHANGE) \
- { \
- SetMsgHandled(TRUE); \
- func(wParam, (PWTSSESSION_NOTIFICATION)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// OnThemeChanged()
-#define MSG_WM_THEMECHANGED(func) \
- if (uMsg == WM_THEMECHANGED) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-#endif /* _WIN32_WINNT >= 0x0501 */
-
-///////////////////////////////////////////////////////////////////////////////
-// ATL defined messages
-
-// BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData)
-#define MSG_WM_FORWARDMSG(func) \
- if (uMsg == WM_FORWARDMSG) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-///////////////////////////////////////////////////////////////////////////////
-// Dialog specific messages
-
-// LRESULT OnDMGetDefID()
-#define MSG_DM_GETDEFID(func) \
- if (uMsg == DM_GETDEFID) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func(); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDMSetDefID(UINT DefID)
-#define MSG_DM_SETDEFID(func) \
- if (uMsg == DM_SETDEFID) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnDMReposition()
-#define MSG_DM_REPOSITION(func) \
- if (uMsg == DM_REPOSITION) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-///////////////////////////////////////////////////////////////////////////////
-// Reflected messages
-
-// void OnReflectedCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define MSG_OCM_COMMAND(func) \
- if (uMsg == OCM_COMMAND) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedNotify(int idCtrl, LPNMHDR pnmh)
-#define MSG_OCM_NOTIFY(func) \
- if (uMsg == OCM_NOTIFY) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((int)wParam, (LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnReflectedParentNotify(UINT message, UINT nChildID, LPARAM lParam)
-#define MSG_OCM_PARENTNOTIFY(func) \
- if (uMsg == OCM_PARENTNOTIFY) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnReflectedDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
-#define MSG_OCM_DRAWITEM(func) \
- if (uMsg == OCM_DRAWITEM) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnReflectedMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
-#define MSG_OCM_MEASUREITEM(func) \
- if (uMsg == OCM_MEASUREITEM) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnReflectedCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct)
-#define MSG_OCM_COMPAREITEM(func) \
- if (uMsg == OCM_COMPAREITEM) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnReflectedDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
-#define MSG_OCM_DELETEITEM(func) \
- if (uMsg == OCM_DELETEITEM) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
- lResult = TRUE; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// int OnReflectedVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
-#define MSG_OCM_VKEYTOITEM(func) \
- if (uMsg == OCM_VKEYTOITEM) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-//int OnReflectedCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
-#define MSG_OCM_CHARTOITEM(func) \
- if (uMsg == OCM_CHARTOITEM) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnReflectedHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
-#define MSG_OCM_HSCROLL(func) \
- if (uMsg == OCM_HSCROLL) \
- { \
- SetMsgHandled(TRUE); \
- func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnReflectedVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
-#define MSG_OCM_VSCROLL(func) \
- if (uMsg == OCM_VSCROLL) \
- { \
- SetMsgHandled(TRUE); \
- func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnReflectedCtlColorEdit(CDCHandle dc, CEdit edit)
-#define MSG_OCM_CTLCOLOREDIT(func) \
- if (uMsg == OCM_CTLCOLOREDIT) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnReflectedCtlColorListBox(CDCHandle dc, CListBox listBox)
-#define MSG_OCM_CTLCOLORLISTBOX(func) \
- if (uMsg == OCM_CTLCOLORLISTBOX) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnReflectedCtlColorBtn(CDCHandle dc, CButton button)
-#define MSG_OCM_CTLCOLORBTN(func) \
- if (uMsg == OCM_CTLCOLORBTN) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnReflectedCtlColorDlg(CDCHandle dc, CWindow wnd)
-#define MSG_OCM_CTLCOLORDLG(func) \
- if (uMsg == OCM_CTLCOLORDLG) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnReflectedCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
-#define MSG_OCM_CTLCOLORSCROLLBAR(func) \
- if (uMsg == OCM_CTLCOLORSCROLLBAR) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// HBRUSH OnReflectedCtlColorStatic(CDCHandle dc, CStatic wndStatic)
-#define MSG_OCM_CTLCOLORSTATIC(func) \
- if (uMsg == OCM_CTLCOLORSTATIC) \
- { \
- SetMsgHandled(TRUE); \
- lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-///////////////////////////////////////////////////////////////////////////////
-// Edit specific messages
-
-// void OnClear()
-#define MSG_WM_CLEAR(func) \
- if (uMsg == WM_CLEAR) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCopy()
-#define MSG_WM_COPY(func) \
- if (uMsg == WM_COPY) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCut()
-#define MSG_WM_CUT(func) \
- if (uMsg == WM_CUT) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnPaste()
-#define MSG_WM_PASTE(func) \
- if (uMsg == WM_PASTE) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnUndo()
-#define MSG_WM_UNDO(func) \
- if (uMsg == WM_UNDO) \
- { \
- SetMsgHandled(TRUE); \
- func(); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-///////////////////////////////////////////////////////////////////////////////
-// Generic message handlers
-
-// LRESULT OnMessageHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
-#define MESSAGE_HANDLER_EX(msg, func) \
- if(uMsg == msg) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func(uMsg, wParam, lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnMessageRangeHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
-#define MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \
- if(uMsg >= msgFirst && uMsg <= msgLast) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func(uMsg, wParam, lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-///////////////////////////////////////////////////////////////////////////////
-// Commands and notifications
-
-// void OnCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define COMMAND_HANDLER_EX(id, code, func) \
- if (uMsg == WM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define COMMAND_ID_HANDLER_EX(id, func) \
- if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define COMMAND_CODE_HANDLER_EX(code, func) \
- if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnNotifyHandlerEX(LPNMHDR pnmh)
-#define NOTIFY_HANDLER_EX(id, cd, func) \
- if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnNotifyIDHandlerEX(LPNMHDR pnmh)
-#define NOTIFY_ID_HANDLER_EX(id, func) \
- if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnNotifyCodeHandlerEX(LPNMHDR pnmh)
-#define NOTIFY_CODE_HANDLER_EX(cd, func) \
- if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
- if(uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
- if(uMsg == WM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnNotifyRangeHandlerEX(LPNMHDR pnmh)
-#define NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
- if(uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
-#define NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
- if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define REFLECTED_COMMAND_HANDLER_EX(id, code, func) \
- if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \
- if (uMsg == OCM_COMMAND && id == LOWORD(wParam)) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \
- if (uMsg == OCM_COMMAND && code == HIWORD(wParam)) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedNotifyHandlerEX(LPNMHDR pnmh)
-#define REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \
- if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedNotifyIDHandlerEX(LPNMHDR pnmh)
-#define REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \
- if (uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedNotifyCodeHandlerEX(LPNMHDR pnmh)
-#define REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \
- if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnReflectedCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
- if(uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// void OnReflectedCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
-#define REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
- if(uMsg == OCM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
- { \
- SetMsgHandled(TRUE); \
- func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
- lResult = 0; \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedNotifyRangeHandlerEX(LPNMHDR pnmh)
-#define REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
- if(uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-// LRESULT OnReflectedNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
-#define REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
- if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
- { \
- SetMsgHandled(TRUE); \
- lResult = func((LPNMHDR)lParam); \
- if(IsMsgHandled()) \
- return TRUE; \
- }
-
-#endif // __ATLCRACK_H__
diff --git a/WTL/atlctrls.h b/WTL/atlctrls.h
deleted file mode 100644
index e6aca7d..0000000
--- a/WTL/atlctrls.h
+++ /dev/null
@@ -1,10035 +0,0 @@
-// Windows Template Library - WTL version 8.1
-// Copyright (C) Microsoft Corporation. All rights reserved.
-//
-// This file is a part of the Windows Template Library.
-// The use and distribution terms for this software are covered by the
-// Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
-// which can be found in the file CPL.TXT at the root of this distribution.
-// By using this software in any fashion, you are agreeing to be bound by
-// the terms of this license. You must not remove this notice, or
-// any other, from this software.
-
-#ifndef __ATLCTRLS_H__
-#define __ATLCTRLS_H__
-
-#pragma once
-
-#ifndef __ATLAPP_H__
- #error atlctrls.h requires atlapp.h to be included first
-#endif
-
-#ifndef __ATLWIN_H__
- #error atlctrls.h requires atlwin.h to be included first
-#endif
-
-#ifndef _WIN32_WCE
- #include
- #include
-#elif defined(WIN32_PLATFORM_WFSP) && !defined(_WINUSERM_H_)
- #include
-#endif // !_WIN32_WCE
-
-// protect template members from windowsx.h macros
-#ifdef _INC_WINDOWSX
- #undef GetNextSibling
- #undef GetPrevSibling
-#endif // _INC_WINDOWSX
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Classes in this file:
-//
-// CStaticT - CStatic
-// CButtonT - CButton
-// CListBoxT - CListBox
-// CComboBoxT - CComboBox
-// CEditT - CEdit
-// CEditCommands
-// CScrollBarT - CScrollBar
-//
-// CImageList
-// CListViewCtrlT - CListViewCtrl
-// CTreeViewCtrlT - CTreeViewCtrl
-// CTreeItemT - CTreeItem
-// CTreeViewCtrlExT - CTreeViewCtrlEx
-// CHeaderCtrlT - CHeaderCtrl
-// CToolBarCtrlT - CToolBarCtrl
-// CStatusBarCtrlT - CStatusBarCtrl
-// CTabCtrlT - CTabCtrl
-// CToolInfo
-// CToolTipCtrlT - CToolTipCtrl
-// CTrackBarCtrlT - CTrackBarCtrl
-// CUpDownCtrlT - CUpDownCtrl
-// CProgressBarCtrlT - CProgressBarCtrl
-// CHotKeyCtrlT - CHotKeyCtrl
-// CAnimateCtrlT - CAnimateCtrl
-// CRichEditCtrlT - CRichEditCtrl
-// CRichEditCommands
-// CDragListBoxT - CDragListBox
-// CDragListNotifyImpl
-// CReBarCtrlT - CReBarCtrl
-// CComboBoxExT - CComboBoxEx
-// CDateTimePickerCtrlT - CDateTimePickerCtrl
-// CMonthCalendarCtrlT - CMonthCalendarCtrl
-// CFlatScrollBarImpl
-// CFlatScrollBarT - CFlatScrollBar
-// CIPAddressCtrlT - CIPAddressCtrl
-// CPagerCtrlT - CPagerCtrl
-// CLinkCtrlT - CLinkCtrl
-//
-// CCustomDraw
-//
-// CCECommandBarCtrlT - CCECommandBarCtrl
-// CCECommandBandsCtrlT - CCECommandBandsCtrl
-
-
-namespace WTL
-{
-
-// These are wrapper classes for Windows standard and common controls.
-// To implement a window based on a control, use following:
-// Example: Implementing a window based on a list box
-//
-// class CMyListBox : CWindowImpl
-// {
-// public:
-// BEGIN_MSG_MAP(CMyListBox)
-// // put your message handler entries here
-// END_MSG_MAP()
-// };
-
-
-
-// --- Standard Windows controls ---
-
-///////////////////////////////////////////////////////////////////////////////
-// CStatic - client side for a Windows STATIC control
-
-template
-class CStaticT : public TBase
-{
-public:
-// Constructors
- CStaticT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CStaticT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("STATIC");
- }
-
-#ifndef _WIN32_WCE
- HICON GetIcon() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, STM_GETICON, 0, 0L);
- }
-
- HICON SetIcon(HICON hIcon)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, STM_SETICON, (WPARAM)hIcon, 0L);
- }
-
- HENHMETAFILE GetEnhMetaFile() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HENHMETAFILE)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ENHMETAFILE, 0L);
- }
-
- HENHMETAFILE SetEnhMetaFile(HENHMETAFILE hMetaFile)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HENHMETAFILE)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hMetaFile);
- }
-#else // CE specific
- HICON GetIcon() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_ICON, 0L);
- }
-
- HICON SetIcon(HICON hIcon)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- }
-#endif // _WIN32_WCE
-
- CBitmapHandle GetBitmap() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_BITMAP, 0L));
- }
-
- CBitmapHandle SetBitmap(HBITMAP hBitmap)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap));
- }
-
- HCURSOR GetCursor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HCURSOR)::SendMessage(m_hWnd, STM_GETIMAGE, IMAGE_CURSOR, 0L);
- }
-
- HCURSOR SetCursor(HCURSOR hCursor)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HCURSOR)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_CURSOR, (LPARAM)hCursor);
- }
-};
-
-typedef CStaticT CStatic;
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CButton - client side for a Windows BUTTON control
-
-template
-class CButtonT : public TBase
-{
-public:
-// Constructors
- CButtonT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CButtonT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("BUTTON");
- }
-
- UINT GetState() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, BM_GETSTATE, 0, 0L);
- }
-
- void SetState(BOOL bHighlight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_SETSTATE, bHighlight, 0L);
- }
-
- int GetCheck() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, BM_GETCHECK, 0, 0L);
- }
-
- void SetCheck(int nCheck)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_SETCHECK, nCheck, 0L);
- }
-
- UINT GetButtonStyle() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::GetWindowLong(m_hWnd, GWL_STYLE) & 0xFFFF;
- }
-
- void SetButtonStyle(UINT nStyle, BOOL bRedraw = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_SETSTYLE, nStyle, (LPARAM)bRedraw);
- }
-
-#ifndef _WIN32_WCE
- HICON GetIcon() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_ICON, 0L);
- }
-
- HICON SetIcon(HICON hIcon)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HICON)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- }
-
- CBitmapHandle GetBitmap() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_GETIMAGE, IMAGE_BITMAP, 0L));
- }
-
- CBitmapHandle SetBitmap(HBITMAP hBitmap)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CBitmapHandle((HBITMAP)::SendMessage(m_hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap));
- }
-#endif // !_WIN32_WCE
-
-#if (_WIN32_WINNT >= 0x0501)
- BOOL GetIdealSize(LPSIZE lpSize) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_GETIDEALSIZE, 0, (LPARAM)lpSize);
- }
-
- BOOL GetImageList(PBUTTON_IMAGELIST pButtonImagelist) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_GETIMAGELIST, 0, (LPARAM)pButtonImagelist);
- }
-
- BOOL SetImageList(PBUTTON_IMAGELIST pButtonImagelist)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_SETIMAGELIST, 0, (LPARAM)pButtonImagelist);
- }
-
- BOOL GetTextMargin(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_GETTEXTMARGIN, 0, (LPARAM)lpRect);
- }
-
- BOOL SetTextMargin(LPRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, BCM_SETTEXTMARGIN, 0, (LPARAM)lpRect);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-
-#if (WINVER >= 0x0600)
- void SetDontClick(BOOL bDontClick)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_SETDONTCLICK, (WPARAM)bDontClick, 0L);
- }
-#endif // (WINVER >= 0x0600)
-
-#if (_WIN32_WINNT >= 0x0600)
- BOOL SetDropDownState(BOOL bDropDown)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_SETDROPDOWNSTATE, (WPARAM)bDropDown, 0L);
- }
-
- BOOL GetSplitInfo(PBUTTON_SPLITINFO pSplitInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_GETSPLITINFO, 0, (LPARAM)pSplitInfo);
- }
-
- BOOL SetSplitInfo(PBUTTON_SPLITINFO pSplitInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_SPLITBUTTON | BS_DEFSPLITBUTTON)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_SETSPLITINFO, 0, (LPARAM)pSplitInfo);
- }
-
- int GetNoteLength() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
- return (int)::SendMessage(m_hWnd, BCM_GETNOTELENGTH, 0, 0L);
- }
-
- BOOL GetNote(LPWSTR lpstrNoteText, int cchNoteText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_GETNOTE, cchNoteText, (LPARAM)lpstrNoteText);
- }
-
- BOOL SetNote(LPCWSTR lpstrNoteText)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (BS_COMMANDLINK | BS_DEFCOMMANDLINK)) != 0);
- return (BOOL)::SendMessage(m_hWnd, BCM_SETNOTE, 0, (LPARAM)lpstrNoteText);
- }
-
- LRESULT SetElevationRequiredState(BOOL bSet)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::SendMessage(m_hWnd, BCM_SETSHIELD, 0, (LPARAM)bSet);
- }
-#endif // (_WIN32_WINNT >= 0x0600)
-
-// Operations
- void Click()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, BM_CLICK, 0, 0L);
- }
-};
-
-typedef CButtonT CButton;
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CListBox - client side for a Windows LISTBOX control
-
-template
-class CListBoxT : public TBase
-{
-public:
-// Constructors
- CListBoxT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CListBoxT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("LISTBOX");
- }
-
- // for entire listbox
- int GetCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETCOUNT, 0, 0L);
- }
-
-#ifndef _WIN32_WCE
- int SetCount(int cItems)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(((GetStyle() & LBS_NODATA) != 0) && ((GetStyle() & LBS_HASSTRINGS) == 0));
- return (int)::SendMessage(m_hWnd, LB_SETCOUNT, cItems, 0L);
- }
-#endif // !_WIN32_WCE
-
- int GetHorizontalExtent() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETHORIZONTALEXTENT, 0, 0L);
- }
-
- void SetHorizontalExtent(int cxExtent)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LB_SETHORIZONTALEXTENT, cxExtent, 0L);
- }
-
- int GetTopIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETTOPINDEX, 0, 0L);
- }
-
- int SetTopIndex(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SETTOPINDEX, nIndex, 0L);
- }
-
- LCID GetLocale() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (LCID)::SendMessage(m_hWnd, LB_GETLOCALE, 0, 0L);
- }
-
- LCID SetLocale(LCID nNewLocale)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (LCID)::SendMessage(m_hWnd, LB_SETLOCALE, (WPARAM)nNewLocale, 0L);
- }
-
-#if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
- DWORD GetListBoxInfo() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
-#if (_WIN32_WINNT >= 0x0501)
- return (DWORD)::SendMessage(m_hWnd, LB_GETLISTBOXINFO, 0, 0L);
-#else // !(_WIN32_WINNT >= 0x0501)
- return ::GetListBoxInfo(m_hWnd);
-#endif // !(_WIN32_WINNT >= 0x0501)
- }
-#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
-
- // for single-selection listboxes
- int GetCurSel() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0);
- return (int)::SendMessage(m_hWnd, LB_GETCURSEL, 0, 0L);
- }
-
- int SetCurSel(int nSelect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) == 0);
- return (int)::SendMessage(m_hWnd, LB_SETCURSEL, nSelect, 0L);
- }
-
- // for multiple-selection listboxes
- int GetSel(int nIndex) const // also works for single-selection
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETSEL, nIndex, 0L);
- }
-
- int SetSel(int nIndex, BOOL bSelect = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- return (int)::SendMessage(m_hWnd, LB_SETSEL, bSelect, nIndex);
- }
-
- int GetSelCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- return (int)::SendMessage(m_hWnd, LB_GETSELCOUNT, 0, 0L);
- }
-
- int GetSelItems(int nMaxItems, LPINT rgIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- return (int)::SendMessage(m_hWnd, LB_GETSELITEMS, nMaxItems, (LPARAM)rgIndex);
- }
-
- int GetAnchorIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- return (int)::SendMessage(m_hWnd, LB_GETANCHORINDEX, 0, 0L);
- }
-
- void SetAnchorIndex(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- ::SendMessage(m_hWnd, LB_SETANCHORINDEX, nIndex, 0L);
- }
-
- int GetCaretIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETCARETINDEX, 0, 0);
- }
-
- int SetCaretIndex(int nIndex, BOOL bScroll = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SETCARETINDEX, nIndex, MAKELONG(bScroll, 0));
- }
-
- // for listbox items
- DWORD_PTR GetItemData(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD_PTR)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L);
- }
-
- int SetItemData(int nIndex, DWORD_PTR dwItemData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
- }
-
- void* GetItemDataPtr(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (void*)::SendMessage(m_hWnd, LB_GETITEMDATA, nIndex, 0L);
- }
-
- int SetItemDataPtr(int nIndex, void* pData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItemData(nIndex, (DWORD_PTR)pData);
- }
-
- int GetItemRect(int nIndex, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETITEMRECT, nIndex, (LPARAM)lpRect);
- }
-
- int GetText(int nIndex, LPTSTR lpszBuffer) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETTEXT, nIndex, (LPARAM)lpszBuffer);
- }
-
-#ifndef _ATL_NO_COM
-#ifdef _OLEAUTO_H_
- BOOL GetTextBSTR(int nIndex, BSTR& bstrText) const
- {
- USES_CONVERSION;
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(bstrText == NULL);
-
- int nLen = GetTextLen(nIndex);
- if(nLen == LB_ERR)
- return FALSE;
-
- CTempBuffer buff;
- LPTSTR lpstrText = buff.Allocate(nLen + 1);
- if(lpstrText == NULL)
- return FALSE;
-
- if(GetText(nIndex, lpstrText) == LB_ERR)
- return FALSE;
-
- bstrText = ::SysAllocString(T2OLE(lpstrText));
- return (bstrText != NULL) ? TRUE : FALSE;
- }
-#endif // _OLEAUTO_H_
-#endif // !_ATL_NO_COM
-
-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
- int GetText(int nIndex, _CSTRING_NS::CString& strText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- int cchLen = GetTextLen(nIndex);
- if(cchLen == LB_ERR)
- return LB_ERR;
- int nRet = LB_ERR;
- LPTSTR lpstr = strText.GetBufferSetLength(cchLen);
- if(lpstr != NULL)
- {
- nRet = GetText(nIndex, lpstr);
- strText.ReleaseBuffer();
- }
- return nRet;
- }
-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
-
- int GetTextLen(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETTEXTLEN, nIndex, 0L);
- }
-
- int GetItemHeight(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_GETITEMHEIGHT, nIndex, 0L);
- }
-
- int SetItemHeight(int nIndex, UINT cyItemHeight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
- }
-
- // Settable only attributes
- void SetColumnWidth(int cxWidth)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LB_SETCOLUMNWIDTH, cxWidth, 0L);
- }
-
- BOOL SetTabStops(int nTabStops, LPINT rgTabStops)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
- }
-
- BOOL SetTabStops()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 0, 0L);
- }
-
- BOOL SetTabStops(const int& cxEachStop) // takes an 'int'
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LBS_USETABSTOPS) != 0);
- return (BOOL)::SendMessage(m_hWnd, LB_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
- }
-
-// Operations
- int InitStorage(int nItems, UINT nBytes)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_INITSTORAGE, (WPARAM)nItems, nBytes);
- }
-
- void ResetContent()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LB_RESETCONTENT, 0, 0L);
- }
-
- UINT ItemFromPoint(POINT pt, BOOL& bOutside) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dw = (DWORD)::SendMessage(m_hWnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
- bOutside = (BOOL)HIWORD(dw);
- return (UINT)LOWORD(dw);
- }
-
- // manipulating listbox items
- int AddString(LPCTSTR lpszItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_ADDSTRING, 0, (LPARAM)lpszItem);
- }
-
- int DeleteString(UINT nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_DELETESTRING, nIndex, 0L);
- }
-
- int InsertString(int nIndex, LPCTSTR lpszItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_INSERTSTRING, nIndex, (LPARAM)lpszItem);
- }
-
-#ifndef _WIN32_WCE
- int Dir(UINT attr, LPCTSTR lpszWildCard)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_DIR, attr, (LPARAM)lpszWildCard);
- }
-
- int AddFile(LPCTSTR lpstrFileName)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_ADDFILE, 0, (LPARAM)lpstrFileName);
- }
-#endif // !_WIN32_WCE
-
- // selection helpers
- int FindString(int nStartAfter, LPCTSTR lpszItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_FINDSTRING, nStartAfter, (LPARAM)lpszItem);
- }
-
- int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
- }
-
- int SelectString(int nStartAfter, LPCTSTR lpszItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LB_SELECTSTRING, nStartAfter, (LPARAM)lpszItem);
- }
-
- int SelItemRange(BOOL bSelect, int nFirstItem, int nLastItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) != 0);
- ATLASSERT(nFirstItem <= nLastItem);
- return bSelect ? (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nFirstItem, nLastItem) : (int)::SendMessage(m_hWnd, LB_SELITEMRANGEEX, nLastItem, nFirstItem);
- }
-
-#ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages
- DWORD GetInputMode(BOOL bCurrentMode = TRUE)
- {
- return SendMessage(LB_GETINPUTMODE, 0, (LPARAM)bCurrentMode);
- }
-
- BOOL SetInputMode(DWORD dwMode)
- {
- return SendMessage(LB_SETINPUTMODE, 0, (LPARAM)dwMode);
- }
-#endif // WIN32_PLATFORM_WFSP
-};
-
-typedef CListBoxT CListBox;
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CComboBox - client side for a Windows COMBOBOX control
-
-#ifndef WIN32_PLATFORM_WFSP // No COMBOBOX on SmartPhones
-
-template
-class CComboBoxT : public TBase
-{
-public:
-// Constructors
- CComboBoxT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CComboBoxT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("COMBOBOX");
- }
-
- // for entire combo box
- int GetCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETCOUNT, 0, 0L);
- }
-
- int GetCurSel() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0L);
- }
-
- int SetCurSel(int nSelect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0L);
- }
-
- LCID GetLocale() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (LCID)::SendMessage(m_hWnd, CB_GETLOCALE, 0, 0L);
- }
-
- LCID SetLocale(LCID nNewLocale)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (LCID)::SendMessage(m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0L);
- }
-
- int GetTopIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETTOPINDEX, 0, 0L);
- }
-
- int SetTopIndex(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETTOPINDEX, nIndex, 0L);
- }
-
- UINT GetHorizontalExtent() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0L);
- }
-
- void SetHorizontalExtent(UINT nExtent)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0L);
- }
-
- int GetDroppedWidth() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETDROPPEDWIDTH, 0, 0L);
- }
-
- int SetDroppedWidth(UINT nWidth)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0L);
- }
-
-#if ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
- BOOL GetComboBoxInfo(PCOMBOBOXINFO pComboBoxInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
-#if ((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
- return (BOOL)::SendMessage(m_hWnd, CB_GETCOMBOBOXINFO, 0, (LPARAM)pComboBoxInfo);
-#else // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
- return ::GetComboBoxInfo(m_hWnd, pComboBoxInfo);
-#endif // !((_WIN32_WINNT >= 0x0501) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
- }
-#endif // ((WINVER >= 0x0500) && !defined(_WIN32_WCE)) || (defined(_WIN32_WCE) && (_WIN32_WCE >= 420))
-
- // for edit control
- DWORD GetEditSel() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, CB_GETEDITSEL, 0, 0L);
- }
-
- BOOL SetEditSel(int nStartChar, int nEndChar)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar));
- }
-
- // for combobox item
- DWORD_PTR GetItemData(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD_PTR)::SendMessage(m_hWnd, CB_GETITEMDATA, nIndex, 0L);
- }
-
- int SetItemData(int nIndex, DWORD_PTR dwItemData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
- }
-
- void* GetItemDataPtr(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (void*)GetItemData(nIndex);
- }
-
- int SetItemDataPtr(int nIndex, void* pData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItemData(nIndex, (DWORD_PTR)pData);
- }
-
- int GetLBText(int nIndex, LPTSTR lpszText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText);
- }
-
-#ifndef _ATL_NO_COM
- BOOL GetLBTextBSTR(int nIndex, BSTR& bstrText) const
- {
- USES_CONVERSION;
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(bstrText == NULL);
-
- int nLen = GetLBTextLen(nIndex);
- if(nLen == CB_ERR)
- return FALSE;
-
- CTempBuffer buff;
- LPTSTR lpstrText = buff.Allocate(nLen + 1);
- if(lpstrText == NULL)
- return FALSE;
-
- if(GetLBText(nIndex, lpstrText) == CB_ERR)
- return FALSE;
-
- bstrText = ::SysAllocString(T2OLE(lpstrText));
- return (bstrText != NULL) ? TRUE : FALSE;
- }
-#endif // !_ATL_NO_COM
-
-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
- int GetLBText(int nIndex, _CSTRING_NS::CString& strText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- int cchLen = GetLBTextLen(nIndex);
- if(cchLen == CB_ERR)
- return CB_ERR;
- int nRet = CB_ERR;
- LPTSTR lpstr = strText.GetBufferSetLength(cchLen);
- if(lpstr != NULL)
- {
- nRet = GetLBText(nIndex, lpstr);
- strText.ReleaseBuffer();
- }
- return nRet;
- }
-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
-
- int GetLBTextLen(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETLBTEXTLEN, nIndex, 0L);
- }
-
- int GetItemHeight(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L);
- }
-
- int SetItemHeight(int nIndex, UINT cyItemHeight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
- }
-
- BOOL GetExtendedUI() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_GETEXTENDEDUI, 0, 0L);
- }
-
- int SetExtendedUI(BOOL bExtended = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L);
- }
-
- void GetDroppedControlRect(LPRECT lprect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect);
- }
-
- BOOL GetDroppedState() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_GETDROPPEDSTATE, 0, 0L);
- }
-
-#if (_WIN32_WINNT >= 0x0501)
- int GetMinVisible() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_GETMINVISIBLE, 0, 0L);
- }
-
- BOOL SetMinVisible(int nMinVisible)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_SETMINVISIBLE, nMinVisible, 0L);
- }
-
- // Vista only
- BOOL GetCueBannerText(LPWSTR lpwText, int cchText) const
- {
-#ifndef CB_GETCUEBANNER
- const UINT CB_GETCUEBANNER = (CBM_FIRST + 4);
-#endif
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_GETCUEBANNER, (WPARAM)lpwText, cchText);
- }
-
- // Vista only
- BOOL SetCueBannerText(LPCWSTR lpcwText)
- {
-#ifndef CB_SETCUEBANNER
- const UINT CB_SETCUEBANNER = (CBM_FIRST + 3);
-#endif
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_SETCUEBANNER, 0, (LPARAM)lpcwText);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-
-// Operations
- int InitStorage(int nItems, UINT nBytes)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes);
- }
-
- void ResetContent()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0L);
- }
-
- // for edit control
- BOOL LimitText(int nMaxChars)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, CB_LIMITTEXT, nMaxChars, 0L);
- }
-
- // for drop-down combo boxes
- void ShowDropDown(BOOL bShowIt = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0L);
- }
-
- // manipulating listbox items
- int AddString(LPCTSTR lpszString)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString);
- }
-
- int DeleteString(UINT nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_DELETESTRING, nIndex, 0L);
- }
-
- int InsertString(int nIndex, LPCTSTR lpszString)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString);
- }
-
-#ifndef _WIN32_WCE
- int Dir(UINT attr, LPCTSTR lpszWildCard)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard);
- }
-#endif // !_WIN32_WCE
-
- // selection helpers
- int FindString(int nStartAfter, LPCTSTR lpszString) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_FINDSTRING, nStartAfter, (LPARAM)lpszString);
- }
-
- int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
- }
-
- int SelectString(int nStartAfter, LPCTSTR lpszString)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString);
- }
-
- // Clipboard operations
- void Clear()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L);
- }
-
- void Copy()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_COPY, 0, 0L);
- }
-
- void Cut()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_CUT, 0, 0L);
- }
-
- void Paste()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_PASTE, 0, 0L);
- }
-};
-
-typedef CComboBoxT CComboBox;
-
-#endif // !WIN32_PLATFORM_WFSP
-
-///////////////////////////////////////////////////////////////////////////////
-// CEdit - client side for a Windows EDIT control
-
-template
-class CEditT : public TBase
-{
-public:
-// Constructors
- CEditT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CEditT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("EDIT");
- }
-
- BOOL CanUndo() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0L);
- }
-
- int GetLineCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0L);
- }
-
- BOOL GetModify() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0L);
- }
-
- void SetModify(BOOL bModified = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0L);
- }
-
- void GetRect(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect);
- }
-
- DWORD GetSel() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, EM_GETSEL, 0, 0L);
- }
-
- void GetSel(int& nStartChar, int& nEndChar) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM)&nStartChar, (LPARAM)&nEndChar);
- }
-
-#ifndef _WIN32_WCE
- HLOCAL GetHandle() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HLOCAL)::SendMessage(m_hWnd, EM_GETHANDLE, 0, 0L);
- }
-
- void SetHandle(HLOCAL hBuffer)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0L);
- }
-#endif // !_WIN32_WCE
-
- DWORD GetMargins() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0L);
- }
-
- void SetMargins(UINT nLeft, UINT nRight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(nLeft, nRight));
- }
-
- UINT GetLimitText() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0L);
- }
-
- void SetLimitText(UINT nMax)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETLIMITTEXT, nMax, 0L);
- }
-
- POINT PosFromChar(UINT nChar) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_POSFROMCHAR, nChar, 0);
- POINT point = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) };
- return point;
- }
-
- int CharFromPos(POINT pt, int* pLine = NULL) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y));
- if(pLine != NULL)
- *pLine = (int)(short)HIWORD(dwRet);
- return (int)(short)LOWORD(dwRet);
- }
-
- // NOTE: first word in lpszBuffer must contain the size of the buffer!
- int GetLine(int nIndex, LPTSTR lpszBuffer) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
- }
-
- int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- *(LPWORD)lpszBuffer = (WORD)nMaxLength;
- return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer);
- }
-
- TCHAR GetPasswordChar() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (TCHAR)::SendMessage(m_hWnd, EM_GETPASSWORDCHAR, 0, 0L);
- }
-
- void SetPasswordChar(TCHAR ch)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETPASSWORDCHAR, ch, 0L);
- }
-
-#ifndef _WIN32_WCE
- EDITWORDBREAKPROC GetWordBreakProc() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (EDITWORDBREAKPROC)::SendMessage(m_hWnd, EM_GETWORDBREAKPROC, 0, 0L);
- }
-
- void SetWordBreakProc(EDITWORDBREAKPROC ewbprc)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0, (LPARAM)ewbprc);
- }
-#endif // !_WIN32_WCE
-
- int GetFirstVisibleLine() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L);
- }
-
-#ifndef _WIN32_WCE
- int GetThumb() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & ES_MULTILINE) != 0);
- return (int)::SendMessage(m_hWnd, EM_GETTHUMB, 0, 0L);
- }
-#endif // !_WIN32_WCE
-
- BOOL SetReadOnly(BOOL bReadOnly = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L);
- }
-
-#if (WINVER >= 0x0500) && !defined(_WIN32_WCE)
- UINT GetImeStatus(UINT uStatus) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, EM_GETIMESTATUS, uStatus, 0L);
- }
-
- UINT SetImeStatus(UINT uStatus, UINT uData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, EM_SETIMESTATUS, uStatus, uData);
- }
-#endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE)
-
-#if (_WIN32_WINNT >= 0x0501)
- BOOL GetCueBannerText(LPCWSTR lpstrText, int cchText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_GETCUEBANNER, (WPARAM)lpstrText, cchText);
- }
-
- // bKeepWithFocus - Vista only
- BOOL SetCueBannerText(LPCWSTR lpstrText, BOOL bKeepWithFocus = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETCUEBANNER, (WPARAM)bKeepWithFocus, (LPARAM)(lpstrText));
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-
-// Operations
- void EmptyUndoBuffer()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0L);
- }
-
- BOOL FmtLines(BOOL bAddEOL)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_FMTLINES, bAddEOL, 0L);
- }
-
- void LimitText(int nChars = 0)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_LIMITTEXT, nChars, 0L);
- }
-
- int LineFromChar(int nIndex = -1) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_LINEFROMCHAR, nIndex, 0L);
- }
-
- int LineIndex(int nLine = -1) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0L);
- }
-
- int LineLength(int nLine = -1) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0L);
- }
-
- void LineScroll(int nLines, int nChars = 0)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines);
- }
-
- void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_REPLACESEL, (WPARAM) bCanUndo, (LPARAM)lpszNewText);
- }
-
- void SetRect(LPCRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect);
- }
-
- void SetRectNP(LPCRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect);
- }
-
- void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection));
- if(!bNoScroll)
- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
- }
-
- void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar);
- if(!bNoScroll)
- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
- }
-
- void SetSelAll(BOOL bNoScroll = FALSE)
- {
- SetSel(0, -1, bNoScroll);
- }
-
- void SetSelNone(BOOL bNoScroll = FALSE)
- {
- SetSel(-1, 0, bNoScroll);
- }
-
- BOOL SetTabStops(int nTabStops, LPINT rgTabStops)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops, (LPARAM)rgTabStops);
- }
-
- BOOL SetTabStops()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0L);
- }
-
- BOOL SetTabStops(const int& cxEachStop) // takes an 'int'
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1, (LPARAM)(LPINT)&cxEachStop);
- }
-
- void ScrollCaret()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0L);
- }
-
- int Scroll(int nScrollAction)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & ES_MULTILINE) != 0);
- LRESULT lRet = ::SendMessage(m_hWnd, EM_SCROLL, nScrollAction, 0L);
- if(!(BOOL)HIWORD(lRet))
- return -1; // failed
- return (int)(short)LOWORD(lRet);
-
- }
-
- void InsertText(int nInsertAfterChar, LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE)
- {
- SetSel(nInsertAfterChar, nInsertAfterChar, bNoScroll);
- ReplaceSel(lpstrText, bCanUndo);
- }
-
- void AppendText(LPCTSTR lpstrText, BOOL bNoScroll = FALSE, BOOL bCanUndo = FALSE)
- {
- InsertText(GetWindowTextLength(), lpstrText, bNoScroll, bCanUndo);
- }
-
-#if (_WIN32_WINNT >= 0x0501)
- BOOL ShowBalloonTip(PEDITBALLOONTIP pEditBaloonTip)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_SHOWBALLOONTIP, 0, (LPARAM)pEditBaloonTip);
- }
-
- BOOL HideBalloonTip()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_HIDEBALLOONTIP, 0, 0L);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-
-#if (_WIN32_WINNT >= 0x0600)
- DWORD GetHilite() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L);
- }
-
- void GetHilite(int& nStartChar, int& nEndChar) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, EM_GETHILITE, 0, 0L);
- nStartChar = (int)(short)LOWORD(dwRet);
- nEndChar = (int)(short)HIWORD(dwRet);
- }
-
- void SetHilite(int nStartChar, int nEndChar)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, EM_SETHILITE, nStartChar, nEndChar);
- }
-#endif // (_WIN32_WINNT >= 0x0600)
-
- // Clipboard operations
- BOOL Undo()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0L);
- }
-
- void Clear()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_CLEAR, 0, 0L);
- }
-
- void Copy()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_COPY, 0, 0L);
- }
-
- void Cut()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_CUT, 0, 0L);
- }
-
- void Paste()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, WM_PASTE, 0, 0L);
- }
-
-#ifdef WIN32_PLATFORM_WFSP // SmartPhone only messages
- DWORD GetExtendedStyle()
- {
- return SendMessage(EM_GETEXTENDEDSTYLE);
- }
-
- DWORD SetExtendedStyle(DWORD dwMask, DWORD dwExStyle)
- {
- return SendMessage(EM_SETEXTENDEDSTYLE, (WPARAM)dwMask, (LPARAM)dwExStyle);
- }
-
- DWORD GetInputMode(BOOL bCurrentMode = TRUE)
- {
- return SendMessage(EM_GETINPUTMODE, 0, (LPARAM)bCurrentMode);
- }
-
- BOOL SetInputMode(DWORD dwMode)
- {
- return SendMessage(EM_SETINPUTMODE, 0, (LPARAM)dwMode);
- }
-
- BOOL SetSymbols(LPCTSTR szSymbols)
- {
- return SendMessage(EM_SETSYMBOLS, 0, (LPARAM)szSymbols);
- }
-
- BOOL ResetSymbols()
- {
- return SendMessage(EM_SETSYMBOLS);
- }
-#endif // WIN32_PLATFORM_WFSP
-};
-
-typedef CEditT CEdit;
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CEditCommands - message handlers for standard EDIT commands
-
-// Chain to CEditCommands message map. Your class must also derive from CEdit.
-// Example:
-// class CMyEdit : public CWindowImpl,
-// public CEditCommands
-// {
-// public:
-// BEGIN_MSG_MAP(CMyEdit)
-// // your handlers...
-// CHAIN_MSG_MAP_ALT(CEditCommands, 1)
-// END_MSG_MAP()
-// // other stuff...
-// };
-
-template
-class CEditCommands
-{
-public:
- BEGIN_MSG_MAP(CEditCommands< T >)
- ALT_MSG_MAP(1)
- COMMAND_ID_HANDLER(ID_EDIT_CLEAR, OnEditClear)
- COMMAND_ID_HANDLER(ID_EDIT_CLEAR_ALL, OnEditClearAll)
- COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy)
- COMMAND_ID_HANDLER(ID_EDIT_CUT, OnEditCut)
- COMMAND_ID_HANDLER(ID_EDIT_PASTE, OnEditPaste)
- COMMAND_ID_HANDLER(ID_EDIT_SELECT_ALL, OnEditSelectAll)
- COMMAND_ID_HANDLER(ID_EDIT_UNDO, OnEditUndo)
- END_MSG_MAP()
-
- LRESULT OnEditClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast(this);
- pT->Clear();
- return 0;
- }
-
- LRESULT OnEditClearAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast(this);
- pT->SetSel(0, -1);
- pT->Clear();
- return 0;
- }
-
- LRESULT OnEditCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast(this);
- pT->Copy();
- return 0;
- }
-
- LRESULT OnEditCut(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast(this);
- pT->Cut();
- return 0;
- }
-
- LRESULT OnEditPaste(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast(this);
- pT->Paste();
- return 0;
- }
-
- LRESULT OnEditSelectAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast(this);
- pT->SetSel(0, -1);
- return 0;
- }
-
- LRESULT OnEditUndo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- T* pT = static_cast(this);
- pT->Undo();
- return 0;
- }
-
-// State (update UI) helpers
- BOOL CanCut() const
- { return HasSelection(); }
-
- BOOL CanCopy() const
- { return HasSelection(); }
-
- BOOL CanClear() const
- { return HasSelection(); }
-
- BOOL CanSelectAll() const
- { return HasText(); }
-
- BOOL CanFind() const
- { return HasText(); }
-
- BOOL CanRepeat() const
- { return HasText(); }
-
- BOOL CanReplace() const
- { return HasText(); }
-
- BOOL CanClearAll() const
- { return HasText(); }
-
-// Implementation
- BOOL HasSelection() const
- {
- const T* pT = static_cast(this);
- int nMin, nMax;
- ::SendMessage(pT->m_hWnd, EM_GETSEL, (WPARAM)&nMin, (LPARAM)&nMax);
- return (nMin != nMax);
- }
-
- BOOL HasText() const
- {
- const T* pT = static_cast(this);
- return (pT->GetWindowTextLength() > 0);
- }
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CScrollBar - client side for a Windows SCROLLBAR control
-
-template
-class CScrollBarT : public TBase
-{
-public:
-// Constructors
- CScrollBarT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CScrollBarT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return _T("SCROLLBAR");
- }
-
-#ifndef _WIN32_WCE
- int GetScrollPos() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::GetScrollPos(m_hWnd, SB_CTL);
- }
-#endif // !_WIN32_WCE
-
- int SetScrollPos(int nPos, BOOL bRedraw = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::SetScrollPos(m_hWnd, SB_CTL, nPos, bRedraw);
- }
-
-#ifndef _WIN32_WCE
- void GetScrollRange(LPINT lpMinPos, LPINT lpMaxPos) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::GetScrollRange(m_hWnd, SB_CTL, lpMinPos, lpMaxPos);
- }
-#endif // !_WIN32_WCE
-
- void SetScrollRange(int nMinPos, int nMaxPos, BOOL bRedraw = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SetScrollRange(m_hWnd, SB_CTL, nMinPos, nMaxPos, bRedraw);
- }
-
- BOOL GetScrollInfo(LPSCROLLINFO lpScrollInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::GetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo);
- }
-
- int SetScrollInfo(LPSCROLLINFO lpScrollInfo, BOOL bRedraw = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::SetScrollInfo(m_hWnd, SB_CTL, lpScrollInfo, bRedraw);
- }
-
-#ifndef _WIN32_WCE
- int GetScrollLimit() const
- {
- int nMin = 0, nMax = 0;
- ::GetScrollRange(m_hWnd, SB_CTL, &nMin, &nMax);
- SCROLLINFO info = { 0 };
- info.cbSize = sizeof(SCROLLINFO);
- info.fMask = SIF_PAGE;
- if(::GetScrollInfo(m_hWnd, SB_CTL, &info))
- nMax -= ((info.nPage - 1) > 0) ? (info.nPage - 1) : 0;
-
- return nMax;
- }
-
-#if (WINVER >= 0x0500)
- BOOL GetScrollBarInfo(PSCROLLBARINFO pScrollBarInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
-#if (_WIN32_WINNT >= 0x0501)
- return (BOOL)::SendMessage(m_hWnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)pScrollBarInfo);
-#else // !(_WIN32_WINNT >= 0x0501)
- return ::GetScrollBarInfo(m_hWnd, OBJID_CLIENT, pScrollBarInfo);
-#endif // !(_WIN32_WINNT >= 0x0501)
- }
-#endif // (WINVER >= 0x0500)
-
-// Operations
- void ShowScrollBar(BOOL bShow = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::ShowScrollBar(m_hWnd, SB_CTL, bShow);
- }
-
- BOOL EnableScrollBar(UINT nArrowFlags = ESB_ENABLE_BOTH)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return ::EnableScrollBar(m_hWnd, SB_CTL, nArrowFlags);
- }
-#endif // !_WIN32_WCE
-};
-
-typedef CScrollBarT CScrollBar;
-
-
-// --- Windows Common Controls ---
-
-///////////////////////////////////////////////////////////////////////////////
-// CImageList
-
-class CImageList
-{
-public:
- HIMAGELIST m_hImageList;
-
-// Constructor
- CImageList(HIMAGELIST hImageList = NULL) : m_hImageList(hImageList)
- { }
-
-// Operators, etc.
- CImageList& operator =(HIMAGELIST hImageList)
- {
- m_hImageList = hImageList;
- return *this;
- }
-
- operator HIMAGELIST() const { return m_hImageList; }
-
- void Attach(HIMAGELIST hImageList)
- {
- ATLASSERT(m_hImageList == NULL);
- ATLASSERT(hImageList != NULL);
- m_hImageList = hImageList;
- }
-
- HIMAGELIST Detach()
- {
- HIMAGELIST hImageList = m_hImageList;
- m_hImageList = NULL;
- return hImageList;
- }
-
- bool IsNull() const { return (m_hImageList == NULL); }
-
-// Attributes
- int GetImageCount() const
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_GetImageCount(m_hImageList);
- }
-
- COLORREF GetBkColor() const
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_GetBkColor(m_hImageList);
- }
-
- COLORREF SetBkColor(COLORREF cr)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_SetBkColor(m_hImageList, cr);
- }
-
- BOOL GetImageInfo(int nImage, IMAGEINFO* pImageInfo) const
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_GetImageInfo(m_hImageList, nImage, pImageInfo);
- }
-
- HICON GetIcon(int nIndex, UINT uFlags = ILD_NORMAL) const
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_GetIcon(m_hImageList, nIndex, uFlags);
- }
-
- BOOL GetIconSize(int& cx, int& cy) const
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_GetIconSize(m_hImageList, &cx, &cy);
- }
-
- BOOL GetIconSize(SIZE& size) const
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_GetIconSize(m_hImageList, (int*)&size.cx, (int*)&size.cy);
- }
-
- BOOL SetIconSize(int cx, int cy)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_SetIconSize(m_hImageList, cx, cy);
- }
-
- BOOL SetIconSize(SIZE size)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_SetIconSize(m_hImageList, size.cx, size.cy);
- }
-
- BOOL SetImageCount(UINT uNewCount)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_SetImageCount(m_hImageList, uNewCount);
- }
-
- BOOL SetOverlayImage(int nImage, int nOverlay)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_SetOverlayImage(m_hImageList, nImage, nOverlay);
- }
-
-// Operations
- BOOL Create(int cx, int cy, UINT nFlags, int nInitial, int nGrow)
- {
- ATLASSERT(m_hImageList == NULL);
- m_hImageList = ImageList_Create(cx, cy, nFlags, nInitial, nGrow);
- return (m_hImageList != NULL) ? TRUE : FALSE;
- }
-
- BOOL Create(ATL::_U_STRINGorID bitmap, int cx, int nGrow, COLORREF crMask)
- {
- ATLASSERT(m_hImageList == NULL);
- m_hImageList = ImageList_LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr, cx, nGrow, crMask);
- return (m_hImageList != NULL) ? TRUE : FALSE;
- }
-
- BOOL CreateFromImage(ATL::_U_STRINGorID image, int cx, int nGrow, COLORREF crMask, UINT uType, UINT uFlags = LR_DEFAULTCOLOR | LR_DEFAULTSIZE)
- {
- ATLASSERT(m_hImageList == NULL);
- m_hImageList = ImageList_LoadImage(ModuleHelper::GetResourceInstance(), image.m_lpstr, cx, nGrow, crMask, uType, uFlags);
- return (m_hImageList != NULL) ? TRUE : FALSE;
- }
-
- BOOL Merge(HIMAGELIST hImageList1, int nImage1, HIMAGELIST hImageList2, int nImage2, int dx, int dy)
- {
- ATLASSERT(m_hImageList == NULL);
- m_hImageList = ImageList_Merge(hImageList1, nImage1, hImageList2, nImage2, dx, dy);
- return (m_hImageList != NULL) ? TRUE : FALSE;
- }
-
-#ifndef _WIN32_WCE
-#ifdef __IStream_INTERFACE_DEFINED__
- BOOL CreateFromStream(LPSTREAM lpStream)
- {
- ATLASSERT(m_hImageList == NULL);
- m_hImageList = ImageList_Read(lpStream);
- return (m_hImageList != NULL) ? TRUE : FALSE;
- }
-#endif // __IStream_INTERFACE_DEFINED__
-#endif // !_WIN32_WCE
-
- BOOL Destroy()
- {
- if (m_hImageList == NULL)
- return FALSE;
- BOOL bRet = ImageList_Destroy(m_hImageList);
- if(bRet)
- m_hImageList = NULL;
- return bRet;
- }
-
- int Add(HBITMAP hBitmap, HBITMAP hBitmapMask = NULL)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_Add(m_hImageList, hBitmap, hBitmapMask);
- }
-
- int Add(HBITMAP hBitmap, COLORREF crMask)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_AddMasked(m_hImageList, hBitmap, crMask);
- }
-
- BOOL Remove(int nImage)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_Remove(m_hImageList, nImage);
- }
-
- BOOL RemoveAll()
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_RemoveAll(m_hImageList);
- }
-
- BOOL Replace(int nImage, HBITMAP hBitmap, HBITMAP hBitmapMask)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_Replace(m_hImageList, nImage, hBitmap, hBitmapMask);
- }
-
- int AddIcon(HICON hIcon)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_AddIcon(m_hImageList, hIcon);
- }
-
- int ReplaceIcon(int nImage, HICON hIcon)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_ReplaceIcon(m_hImageList, nImage, hIcon);
- }
-
- HICON ExtractIcon(int nImage)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_ExtractIcon(NULL, m_hImageList, nImage);
- }
-
- BOOL Draw(HDC hDC, int nImage, int x, int y, UINT nStyle)
- {
- ATLASSERT(m_hImageList != NULL);
- ATLASSERT(hDC != NULL);
- return ImageList_Draw(m_hImageList, nImage, hDC, x, y, nStyle);
- }
-
- BOOL Draw(HDC hDC, int nImage, POINT pt, UINT nStyle)
- {
- ATLASSERT(m_hImageList != NULL);
- ATLASSERT(hDC != NULL);
- return ImageList_Draw(m_hImageList, nImage, hDC, pt.x, pt.y, nStyle);
- }
-
- BOOL DrawEx(int nImage, HDC hDC, int x, int y, int dx, int dy, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle)
- {
- ATLASSERT(m_hImageList != NULL);
- ATLASSERT(hDC != NULL);
- return ImageList_DrawEx(m_hImageList, nImage, hDC, x, y, dx, dy, rgbBk, rgbFg, fStyle);
- }
-
- BOOL DrawEx(int nImage, HDC hDC, RECT& rect, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle)
- {
- ATLASSERT(m_hImageList != NULL);
- ATLASSERT(hDC != NULL);
- return ImageList_DrawEx(m_hImageList, nImage, hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, rgbBk, rgbFg, fStyle);
- }
-
- static BOOL DrawIndirect(IMAGELISTDRAWPARAMS* pimldp)
- {
- return ImageList_DrawIndirect(pimldp);
- }
-
- BOOL Copy(int nSrc, int nDst, UINT uFlags = ILCF_MOVE)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_Copy(m_hImageList, nDst, m_hImageList, nSrc, uFlags);
- }
-
-#ifdef __IStream_INTERFACE_DEFINED__
-#ifndef _WIN32_WCE
- static HIMAGELIST Read(LPSTREAM lpStream)
- {
- return ImageList_Read(lpStream);
- }
-
- BOOL Write(LPSTREAM lpStream)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_Write(m_hImageList, lpStream);
- }
-#endif // !_WIN32_WCE
-
-#if (_WIN32_WINNT >= 0x0501)
- static HRESULT ReadEx(DWORD dwFlags, LPSTREAM lpStream, REFIID riid, PVOID* ppv)
- {
- return ImageList_ReadEx(dwFlags, lpStream, riid, ppv);
- }
-
- HRESULT WriteEx(DWORD dwFlags, LPSTREAM lpStream)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_WriteEx(m_hImageList, dwFlags, lpStream);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-#endif // __IStream_INTERFACE_DEFINED__
-
- // Drag operations
- BOOL BeginDrag(int nImage, POINT ptHotSpot)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_BeginDrag(m_hImageList, nImage, ptHotSpot.x, ptHotSpot.y);
- }
-
- BOOL BeginDrag(int nImage, int xHotSpot, int yHotSpot)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_BeginDrag(m_hImageList, nImage, xHotSpot, yHotSpot);
- }
-
- static void EndDrag()
- {
- ImageList_EndDrag();
- }
-
- static BOOL DragMove(POINT pt)
- {
- return ImageList_DragMove(pt.x, pt.y);
- }
-
- static BOOL DragMove(int x, int y)
- {
- return ImageList_DragMove(x, y);
- }
-
- BOOL SetDragCursorImage(int nDrag, POINT ptHotSpot)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_SetDragCursorImage(m_hImageList, nDrag, ptHotSpot.x, ptHotSpot.y);
- }
-
- BOOL SetDragCursorImage(int nDrag, int xHotSpot, int yHotSpot)
- {
- ATLASSERT(m_hImageList != NULL);
- return ImageList_SetDragCursorImage(m_hImageList, nDrag, xHotSpot, yHotSpot);
- }
-
- static BOOL DragShowNolock(BOOL bShow = TRUE)
- {
- return ImageList_DragShowNolock(bShow);
- }
-
- static CImageList GetDragImage(LPPOINT lpPoint, LPPOINT lpPointHotSpot)
- {
- return CImageList(ImageList_GetDragImage(lpPoint, lpPointHotSpot));
- }
-
- static BOOL DragEnter(HWND hWnd, POINT point)
- {
- return ImageList_DragEnter(hWnd, point.x, point.y);
- }
-
- static BOOL DragEnter(HWND hWnd, int x, int y)
- {
- return ImageList_DragEnter(hWnd, x, y);
- }
-
- static BOOL DragLeave(HWND hWnd)
- {
- return ImageList_DragLeave(hWnd);
- }
-
-#if (_WIN32_IE >= 0x0400)
- CImageList Duplicate() const
- {
- ATLASSERT(m_hImageList != NULL);
- return CImageList(ImageList_Duplicate(m_hImageList));
- }
-
- static CImageList Duplicate(HIMAGELIST hImageList)
- {
- ATLASSERT(hImageList != NULL);
- return CImageList(ImageList_Duplicate(hImageList));
- }
-#endif // (_WIN32_IE >= 0x0400)
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CToolTipCtrl
-
-#ifndef _WIN32_WCE
-
-class CToolInfo : public TOOLINFO
-{
-public:
- CToolInfo(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL)
- {
- Init(nFlags, hWnd, nIDTool, lpRect, lpstrText, lUserParam);
- }
-
- operator LPTOOLINFO() { return this; }
-
- operator LPARAM() { return (LPARAM)this; }
-
- void Init(UINT nFlags, HWND hWnd, UINT nIDTool = 0, LPRECT lpRect = NULL, LPTSTR lpstrText = LPSTR_TEXTCALLBACK, LPARAM lUserParam = NULL)
- {
- ATLASSERT(::IsWindow(hWnd));
- memset(this, 0, sizeof(TOOLINFO));
- cbSize = sizeof(TOOLINFO);
- uFlags = nFlags;
- if(nIDTool == 0)
- {
- hwnd = ::GetParent(hWnd);
- uFlags |= TTF_IDISHWND;
- uId = (UINT_PTR)hWnd;
- }
- else
- {
- hwnd = hWnd;
- uId = nIDTool;
- }
- if(lpRect != NULL)
- rect = *lpRect;
- hinst = ModuleHelper::GetResourceInstance();
- lpszText = lpstrText;
- lParam = lUserParam;
- }
-};
-
-template
-class CToolTipCtrlT : public TBase
-{
-public:
-// Constructors
- CToolTipCtrlT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CToolTipCtrlT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return TOOLTIPS_CLASS;
- }
-
- void GetText(LPTOOLINFO lpToolInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_GETTEXT, 0, (LPARAM)&lpToolInfo);
- }
-
- void GetText(LPTSTR lpstrText, HWND hWnd, UINT nIDTool = 0) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(hWnd != NULL);
- CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText);
- ::SendMessage(m_hWnd, TTM_GETTEXT, 0, ti);
- }
-
- BOOL GetToolInfo(LPTOOLINFO lpToolInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, (LPARAM)lpToolInfo);
- }
-
- BOOL GetToolInfo(HWND hWnd, UINT nIDTool, UINT* puFlags, LPRECT lpRect, LPTSTR lpstrText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(hWnd != NULL);
- ATLASSERT(puFlags != NULL);
- ATLASSERT(lpRect != NULL);
- CToolInfo ti(0, hWnd, nIDTool, NULL, lpstrText);
- BOOL bRet = (BOOL)::SendMessage(m_hWnd, TTM_GETTOOLINFO, 0, ti);
- if(bRet != FALSE)
- {
- *puFlags = ti.uFlags;
- *lpRect = ti.rect;
- }
- return bRet;
- }
-
- void SetToolInfo(LPTOOLINFO lpToolInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_SETTOOLINFO, 0, (LPARAM)lpToolInfo);
- }
-
- void SetToolRect(LPTOOLINFO lpToolInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, (LPARAM)lpToolInfo);
- }
-
- void SetToolRect(HWND hWnd, UINT nIDTool, LPCRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(hWnd != NULL);
- ATLASSERT(nIDTool != 0);
-
- CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRect, NULL);
- ::SendMessage(m_hWnd, TTM_NEWTOOLRECT, 0, ti);
- }
-
- int GetToolCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TTM_GETTOOLCOUNT, 0, 0L);
- }
-
- int GetDelayTime(DWORD dwType) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TTM_GETDELAYTIME, dwType, 0L);
- }
-
- void SetDelayTime(DWORD dwType, int nTime)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_SETDELAYTIME, dwType, MAKELPARAM(nTime, 0));
- }
-
- void GetMargin(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_GETMARGIN, 0, (LPARAM)lpRect);
- }
-
- void SetMargin(LPRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_SETMARGIN, 0, (LPARAM)lpRect);
- }
-
- int GetMaxTipWidth() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TTM_GETMAXTIPWIDTH, 0, 0L);
- }
-
- int SetMaxTipWidth(int nWidth)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TTM_SETMAXTIPWIDTH, 0, nWidth);
- }
-
- COLORREF GetTipBkColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPBKCOLOR, 0, 0L);
- }
-
- void SetTipBkColor(COLORREF clr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_SETTIPBKCOLOR, (WPARAM)clr, 0L);
- }
-
- COLORREF GetTipTextColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TTM_GETTIPTEXTCOLOR, 0, 0L);
- }
-
- void SetTipTextColor(COLORREF clr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)clr, 0L);
- }
-
- BOOL GetCurrentTool(LPTOOLINFO lpToolInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TTM_GETCURRENTTOOL, 0, (LPARAM)lpToolInfo);
- }
-
-#if (_WIN32_IE >= 0x0500)
- SIZE GetBubbleSize(LPTOOLINFO lpToolInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, TTM_GETBUBBLESIZE, 0, (LPARAM)lpToolInfo);
- SIZE size = { GET_X_LPARAM(dwRet), GET_Y_LPARAM(dwRet) };
- return size;
- }
-
- BOOL SetTitle(UINT uIcon, LPCTSTR lpstrTitle)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TTM_SETTITLE, uIcon, (LPARAM)lpstrTitle);
- }
-#endif // (_WIN32_IE >= 0x0500)
-
-#if (_WIN32_WINNT >= 0x0501)
- void GetTitle(PTTGETTITLE pTTGetTitle) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_GETTITLE, 0, (LPARAM)pTTGetTitle);
- }
-
- void SetWindowTheme(LPCWSTR lpstrTheme)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_SETWINDOWTHEME, 0, (LPARAM)lpstrTheme);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-
-// Operations
- void Activate(BOOL bActivate)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_ACTIVATE, bActivate, 0L);
- }
-
- BOOL AddTool(LPTOOLINFO lpToolInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, (LPARAM)lpToolInfo);
- }
-
- BOOL AddTool(HWND hWnd, ATL::_U_STRINGorID text = LPSTR_TEXTCALLBACK, LPCRECT lpRectTool = NULL, UINT nIDTool = 0)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(hWnd != NULL);
- // the toolrect and toolid must both be zero or both valid
- ATLASSERT((lpRectTool != NULL && nIDTool != 0) || (lpRectTool == NULL && nIDTool == 0));
-
- CToolInfo ti(0, hWnd, nIDTool, (LPRECT)lpRectTool, (LPTSTR)text.m_lpstr);
- return (BOOL)::SendMessage(m_hWnd, TTM_ADDTOOL, 0, ti);
- }
-
- void DelTool(LPTOOLINFO lpToolInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_DELTOOL, 0, (LPARAM)lpToolInfo);
- }
-
- void DelTool(HWND hWnd, UINT nIDTool = 0)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(hWnd != NULL);
-
- CToolInfo ti(0, hWnd, nIDTool, NULL, NULL);
- ::SendMessage(m_hWnd, TTM_DELTOOL, 0, ti);
- }
-
- BOOL HitTest(LPTTHITTESTINFO lpHitTestInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)lpHitTestInfo);
- }
-
- BOOL HitTest(HWND hWnd, POINT pt, LPTOOLINFO lpToolInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(hWnd != NULL);
- ATLASSERT(lpToolInfo != NULL);
-
- TTHITTESTINFO hti = { 0 };
- hti.ti.cbSize = sizeof(TOOLINFO);
- hti.hwnd = hWnd;
- hti.pt.x = pt.x;
- hti.pt.y = pt.y;
- if((BOOL)::SendMessage(m_hWnd, TTM_HITTEST, 0, (LPARAM)&hti) != FALSE)
- {
- *lpToolInfo = hti.ti;
- return TRUE;
- }
- return FALSE;
- }
-
- void RelayEvent(LPMSG lpMsg)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg);
- }
-
- void UpdateTipText(LPTOOLINFO lpToolInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, (LPARAM)lpToolInfo);
- }
-
- void UpdateTipText(ATL::_U_STRINGorID text, HWND hWnd, UINT nIDTool = 0)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(hWnd != NULL);
-
- CToolInfo ti(0, hWnd, nIDTool, NULL, (LPTSTR)text.m_lpstr);
- ::SendMessage(m_hWnd, TTM_UPDATETIPTEXT, 0, ti);
- }
-
- BOOL EnumTools(UINT nTool, LPTOOLINFO lpToolInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TTM_ENUMTOOLS, nTool, (LPARAM)lpToolInfo);
- }
-
- void Pop()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_POP, 0, 0L);
- }
-
- void TrackActivate(LPTOOLINFO lpToolInfo, BOOL bActivate)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_TRACKACTIVATE, bActivate, (LPARAM)lpToolInfo);
- }
-
- void TrackPosition(int xPos, int yPos)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos));
- }
-
-#if (_WIN32_IE >= 0x0400)
- void Update()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_UPDATE, 0, 0L);
- }
-#endif // (_WIN32_IE >= 0x0400)
-
-#if (_WIN32_IE >= 0x0500)
- BOOL AdjustRect(LPRECT lpRect, BOOL bLarger /*= TRUE*/)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TTM_ADJUSTRECT, bLarger, (LPARAM)lpRect);
- }
-#endif // (_WIN32_IE >= 0x0500)
-
-#if (_WIN32_WINNT >= 0x0501)
- void Popup()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TTM_POPUP, 0, 0L);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-};
-
-typedef CToolTipCtrlT CToolTipCtrl;
-
-#endif // !_WIN32_WCE
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CHeaderCtrl
-
-template
-class CHeaderCtrlT : public TBase
-{
-public:
-// Constructors
- CHeaderCtrlT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CHeaderCtrlT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return WC_HEADER;
- }
-
- int GetItemCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_GETITEMCOUNT, 0, 0L);
- }
-
- BOOL GetItem(int nIndex, LPHDITEM pHeaderItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_GETITEM, nIndex, (LPARAM)pHeaderItem);
- }
-
- BOOL SetItem(int nIndex, LPHDITEM pHeaderItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_SETITEM, nIndex, (LPARAM)pHeaderItem);
- }
-
- CImageList GetImageList() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_GETIMAGELIST, 0, 0L));
- }
-
- CImageList SetImageList(HIMAGELIST hImageList)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_SETIMAGELIST, 0, (LPARAM)hImageList));
- }
-
- BOOL GetOrderArray(int nSize, int* lpnArray) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_GETORDERARRAY, nSize, (LPARAM)lpnArray);
- }
-
- BOOL SetOrderArray(int nSize, int* lpnArray)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_SETORDERARRAY, nSize, (LPARAM)lpnArray);
- }
-
- BOOL GetItemRect(int nIndex, LPRECT lpItemRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMRECT, nIndex, (LPARAM)lpItemRect);
- }
-
- int SetHotDivider(BOOL bPos, DWORD dwInputValue)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_SETHOTDIVIDER, bPos, dwInputValue);
- }
-
-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
- BOOL GetUnicodeFormat() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_GETUNICODEFORMAT, 0, 0L);
- }
-
- BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_SETUNICODEFORMAT, bUnicode, 0L);
- }
-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
-
-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
- int GetBitmapMargin() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_GETBITMAPMARGIN, 0, 0L);
- }
-
- int SetBitmapMargin(int nWidth)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_SETBITMAPMARGIN, nWidth, 0L);
- }
-
- int SetFilterChangeTimeout(DWORD dwTimeOut)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_SETFILTERCHANGETIMEOUT, 0, dwTimeOut);
- }
-#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
-
-#if (_WIN32_WINNT >= 0x0600)
- BOOL GetItemDropDownRect(int nIndex, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_GETITEMDROPDOWNRECT, nIndex, (LPARAM)lpRect);
- }
-
- BOOL GetOverflowRect(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_GETOVERFLOWRECT, 0, (LPARAM)lpRect);
- }
-
- int GetFocusedItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_GETFOCUSEDITEM, 0, 0L);
- }
-
- BOOL SetFocusedItem(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex);
- }
-#endif // (_WIN32_WINNT >= 0x0600)
-
-// Operations
- int InsertItem(int nIndex, LPHDITEM phdi)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_INSERTITEM, nIndex, (LPARAM)phdi);
- }
-
- int AddItem(LPHDITEM phdi)
- {
- return InsertItem(GetItemCount(), phdi);
- }
-
- BOOL DeleteItem(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_DELETEITEM, nIndex, 0L);
- }
-
- BOOL Layout(HD_LAYOUT* pHeaderLayout)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, HDM_LAYOUT, 0, (LPARAM)pHeaderLayout);
- }
-
- int HitTest(LPHDHITTESTINFO lpHitTestInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_HITTEST, 0, (LPARAM)lpHitTestInfo);
- }
-
- int OrderToIndex(int nOrder)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_ORDERTOINDEX, nOrder, 0L);
- }
-
- CImageList CreateDragImage(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, HDM_CREATEDRAGIMAGE, nIndex, 0L));
- }
-
-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
- int EditFilter(int nColumn, BOOL bDiscardChanges)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_EDITFILTER, nColumn, MAKELPARAM(bDiscardChanges, 0));
- }
-
- int ClearFilter(int nColumn)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, nColumn, 0L);
- }
-
- int ClearAllFilters()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, HDM_CLEARFILTER, (WPARAM)-1, 0L);
- }
-#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
-};
-
-typedef CHeaderCtrlT CHeaderCtrl;
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CListViewCtrl
-
-template
-class CListViewCtrlT : public TBase
-{
-public:
-// Constructors
- CListViewCtrlT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CListViewCtrlT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return WC_LISTVIEW;
- }
-
- COLORREF GetBkColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, LVM_GETBKCOLOR, 0, 0L);
- }
-
- BOOL SetBkColor(COLORREF cr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETBKCOLOR, 0, cr);
- }
-
- CImageList GetImageList(int nImageListType) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_GETIMAGELIST, nImageListType, 0L));
- }
-
- CImageList SetImageList(HIMAGELIST hImageList, int nImageList)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST, nImageList, (LPARAM)hImageList));
- }
-
- int GetItemCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETITEMCOUNT, 0, 0L);
- }
-
- BOOL SetItemCount(int nItems)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, 0L);
- }
-
- BOOL GetItem(LPLVITEM pItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem);
- }
-
- BOOL SetItem(const LVITEM* pItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)pItem);
- }
-
- BOOL SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem,
- int nImage, UINT nState, UINT nStateMask, LPARAM lParam)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVITEM lvi = { 0 };
- lvi.mask = nMask;
- lvi.iItem = nItem;
- lvi.iSubItem = nSubItem;
- lvi.stateMask = nStateMask;
- lvi.state = nState;
- lvi.pszText = (LPTSTR) lpszItem;
- lvi.iImage = nImage;
- lvi.lParam = lParam;
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEM, 0, (LPARAM)&lvi);
- }
-
- UINT GetItemState(int nItem, UINT nMask) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, LVM_GETITEMSTATE, nItem, nMask);
- }
-
- BOOL SetItemState(int nItem, UINT nState, UINT nStateMask)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVITEM lvi = { 0 };
- lvi.state = nState;
- lvi.stateMask = nStateMask;
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)&lvi);
- }
-
- BOOL SetItemState(int nItem, LPLVITEM pItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMSTATE, nItem, (LPARAM)pItem);
- }
-
-#ifndef _ATL_NO_COM
- BOOL GetItemText(int nItem, int nSubItem, BSTR& bstrText) const
- {
- USES_CONVERSION;
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(bstrText == NULL);
- LVITEM lvi = { 0 };
- lvi.iSubItem = nSubItem;
-
- LPTSTR lpstrText = NULL;
- int nRes = 0;
- for(int nLen = 256; ; nLen *= 2)
- {
- ATLTRY(lpstrText = new TCHAR[nLen]);
- if(lpstrText == NULL)
- break;
- lpstrText[0] = NULL;
- lvi.cchTextMax = nLen;
- lvi.pszText = lpstrText;
- nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi);
- if(nRes < nLen - 1)
- break;
- delete [] lpstrText;
- lpstrText = NULL;
- }
-
- if(lpstrText != NULL)
- {
- if(nRes != 0)
- bstrText = ::SysAllocString(T2OLE(lpstrText));
- delete [] lpstrText;
- }
-
- return (bstrText != NULL) ? TRUE : FALSE;
- }
-#endif // !_ATL_NO_COM
-
-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
- int GetItemText(int nItem, int nSubItem, _CSTRING_NS::CString& strText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVITEM lvi = { 0 };
- lvi.iSubItem = nSubItem;
-
- strText.Empty();
- int nRes = 0;
- for(int nLen = 256; ; nLen *= 2)
- {
- lvi.cchTextMax = nLen;
- lvi.pszText = strText.GetBufferSetLength(nLen);
- if(lvi.pszText == NULL)
- {
- nRes = 0;
- break;
- }
- nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi);
- if(nRes < nLen - 1)
- break;
- }
- strText.ReleaseBuffer();
- return nRes;
- }
-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
-
- int GetItemText(int nItem, int nSubItem, LPTSTR lpszText, int nLen) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVITEM lvi = { 0 };
- lvi.iSubItem = nSubItem;
- lvi.cchTextMax = nLen;
- lvi.pszText = lpszText;
- return (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)&lvi);
- }
-
- BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpszText)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItem(nItem, nSubItem, LVIF_TEXT, lpszText, 0, 0, 0, 0);
- }
-
- DWORD_PTR GetItemData(int nItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVITEM lvi = { 0 };
- lvi.iItem = nItem;
- lvi.mask = LVIF_PARAM;
- BOOL bRet = (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)&lvi);
- return (DWORD_PTR)(bRet ? lvi.lParam : NULL);
- }
-
- BOOL SetItemData(int nItem, DWORD_PTR dwData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItem(nItem, 0, LVIF_PARAM, NULL, 0, 0, 0, (LPARAM)dwData);
- }
-
- UINT GetCallbackMask() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, LVM_GETCALLBACKMASK, 0, 0L);
- }
-
- BOOL SetCallbackMask(UINT nMask)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETCALLBACKMASK, nMask, 0L);
- }
-
- BOOL GetItemPosition(int nItem, LPPOINT lpPoint) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMPOSITION, nItem, (LPARAM)lpPoint);
- }
-
- BOOL SetItemPosition(int nItem, POINT pt)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt);
- }
-
- BOOL SetItemPosition(int nItem, int x, int y)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(((GetStyle() & LVS_TYPEMASK) == LVS_ICON) || ((GetStyle() & LVS_TYPEMASK) == LVS_SMALLICON));
- POINT pt = { x, y };
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMPOSITION32, nItem, (LPARAM)&pt);
- }
-
- int GetStringWidth(LPCTSTR lpsz) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETSTRINGWIDTH, 0, (LPARAM)lpsz);
- }
-
- CEdit GetEditControl() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CEdit((HWND)::SendMessage(m_hWnd, LVM_GETEDITCONTROL, 0, 0L));
- }
-
- BOOL GetColumn(int nCol, LVCOLUMN* pColumn) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMN, nCol, (LPARAM)pColumn);
- }
-
- BOOL SetColumn(int nCol, const LVCOLUMN* pColumn)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMN, nCol, (LPARAM)pColumn);
- }
-
- int GetColumnWidth(int nCol) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETCOLUMNWIDTH, nCol, 0L);
- }
-
- BOOL SetColumnWidth(int nCol, int cx)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNWIDTH, nCol, MAKELPARAM(cx, 0));
- }
-
- BOOL GetViewRect(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETVIEWRECT, 0, (LPARAM)lpRect);
- }
-
- COLORREF GetTextColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTCOLOR, 0, 0L);
- }
-
- BOOL SetTextColor(COLORREF cr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTCOLOR, 0, cr);
- }
-
- COLORREF GetTextBkColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, LVM_GETTEXTBKCOLOR, 0, 0L);
- }
-
- BOOL SetTextBkColor(COLORREF cr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETTEXTBKCOLOR, 0, cr);
- }
-
- int GetTopIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETTOPINDEX, 0, 0L);
- }
-
- int GetCountPerPage() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETCOUNTPERPAGE, 0, 0L);
- }
-
- BOOL GetOrigin(LPPOINT lpPoint) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETORIGIN, 0, (LPARAM)lpPoint);
- }
-
- UINT GetSelectedCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, LVM_GETSELECTEDCOUNT, 0, 0L);
- }
-
- BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- lpRect->left = nCode;
- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMRECT, (WPARAM)nItem, (LPARAM)lpRect);
- }
-
-#ifndef _WIN32_WCE
- HCURSOR GetHotCursor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HCURSOR)::SendMessage(m_hWnd, LVM_GETHOTCURSOR, 0, 0L);
- }
-
- HCURSOR SetHotCursor(HCURSOR hHotCursor)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HCURSOR)::SendMessage(m_hWnd, LVM_SETHOTCURSOR, 0, (LPARAM)hHotCursor);
- }
-
- int GetHotItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETHOTITEM, 0, 0L);
- }
-
- int SetHotItem(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_SETHOTITEM, nIndex, 0L);
- }
-#endif // !_WIN32_WCE
-
- BOOL GetColumnOrderArray(int nCount, int* lpnArray) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray);
- }
-
- BOOL SetColumnOrderArray(int nCount, int* lpnArray)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETCOLUMNORDERARRAY, nCount, (LPARAM)lpnArray);
- }
-
- CHeaderCtrl GetHeader() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CHeaderCtrl((HWND)::SendMessage(m_hWnd, LVM_GETHEADER, 0, 0L));
- }
-
- BOOL GetSubItemRect(int nItem, int nSubItem, int nFlag, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_REPORT);
- ATLASSERT(lpRect != NULL);
- lpRect->top = nSubItem;
- lpRect->left = nFlag;
- return (BOOL)::SendMessage(m_hWnd, LVM_GETSUBITEMRECT, nItem, (LPARAM)lpRect);
- }
-
- DWORD SetIconSpacing(int cx, int cy)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LVS_TYPEMASK) == LVS_ICON);
- return (DWORD)::SendMessage(m_hWnd, LVM_SETICONSPACING, 0, MAKELPARAM(cx, cy));
- }
-
- int GetISearchString(LPTSTR lpstr) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETISEARCHSTRING, 0, (LPARAM)lpstr);
- }
-
- void GetItemSpacing(SIZE& sizeSpacing, BOOL bSmallIconView = FALSE) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- DWORD dwRet = (DWORD)::SendMessage(m_hWnd, LVM_GETITEMSPACING, bSmallIconView, 0L);
- sizeSpacing.cx = GET_X_LPARAM(dwRet);
- sizeSpacing.cy = GET_Y_LPARAM(dwRet);
- }
-
-#if (_WIN32_WCE >= 410)
- void SetItemSpacing(INT cySpacing)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ListView_SetItemSpacing(m_hWnd, cySpacing);
- }
-#endif // (_WIN32_WCE >= 410)
-
- // single-selection only
- int GetSelectedIndex() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0);
- return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0));
- }
-
- BOOL GetSelectedItem(LPLVITEM pItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & LVS_SINGLESEL) != 0);
- ATLASSERT(pItem != NULL);
- pItem->iItem = (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, (WPARAM)-1, MAKELPARAM(LVNI_ALL | LVNI_SELECTED, 0));
- if(pItem->iItem == -1)
- return FALSE;
- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEM, 0, (LPARAM)pItem);
- }
-
- // extended list view styles
- DWORD GetExtendedListViewStyle() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0L);
- }
-
- // dwExMask = 0 means all styles
- DWORD SetExtendedListViewStyle(DWORD dwExStyle, DWORD dwExMask = 0)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, dwExMask, dwExStyle);
- }
-
- // checkboxes only
- BOOL GetCheckState(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetExtendedListViewStyle() & LVS_EX_CHECKBOXES) != 0);
- UINT uRet = GetItemState(nIndex, LVIS_STATEIMAGEMASK);
- return (uRet >> 12) - 1;
- }
-
- BOOL SetCheckState(int nItem, BOOL bCheck)
- {
- int nCheck = bCheck ? 2 : 1; // one based index
- return SetItemState(nItem, INDEXTOSTATEIMAGEMASK(nCheck), LVIS_STATEIMAGEMASK);
- }
-
- // view type
- DWORD GetViewType() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (GetStyle() & LVS_TYPEMASK);
- }
-
- DWORD SetViewType(DWORD dwType)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(dwType == LVS_ICON || dwType == LVS_SMALLICON || dwType == LVS_LIST || dwType == LVS_REPORT);
- DWORD dwOldType = GetViewType();
- if(dwType != dwOldType)
- ModifyStyle(LVS_TYPEMASK, (dwType & LVS_TYPEMASK));
- return dwOldType;
- }
-
-#if (_WIN32_IE >= 0x0400)
-#ifndef _WIN32_WCE
- BOOL GetBkImage(LPLVBKIMAGE plvbki) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETBKIMAGE, 0, (LPARAM)plvbki);
- }
-
- BOOL SetBkImage(LPLVBKIMAGE plvbki)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETBKIMAGE, 0, (LPARAM)plvbki);
- }
-#endif // !_WIN32_WCE
-
- int GetSelectionMark() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETSELECTIONMARK, 0, 0L);
- }
-
- int SetSelectionMark(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_SETSELECTIONMARK, 0, nIndex);
- }
-
-#ifndef _WIN32_WCE
- BOOL GetWorkAreas(int nWorkAreas, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETWORKAREAS, nWorkAreas, (LPARAM)lpRect);
- }
-
- BOOL SetWorkAreas(int nWorkAreas, LPRECT lpRect)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETWORKAREAS, nWorkAreas, (LPARAM)lpRect);
- }
-
- DWORD GetHoverTime() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0);
- return (DWORD)::SendMessage(m_hWnd, LVM_GETHOVERTIME, 0, 0L);
- }
-
- DWORD SetHoverTime(DWORD dwHoverTime)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetExtendedListViewStyle() & (LVS_EX_TRACKSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_TWOCLICKACTIVATE)) != 0);
- return (DWORD)::SendMessage(m_hWnd, LVM_SETHOVERTIME, 0, dwHoverTime);
- }
-
- BOOL GetNumberOfWorkAreas(int* pnWorkAreas) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)pnWorkAreas);
- }
-#endif // !_WIN32_WCE
-
- BOOL SetItemCountEx(int nItems, DWORD dwFlags)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(((GetStyle() & LVS_OWNERDATA) != 0) && (((GetStyle() & LVS_TYPEMASK) == LVS_REPORT) || ((GetStyle() & LVS_TYPEMASK) == LVS_LIST)));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMCOUNT, nItems, dwFlags);
- }
-
-#ifndef _WIN32_WCE
- CToolTipCtrl GetToolTips() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_GETTOOLTIPS, 0, 0L));
- }
-
- CToolTipCtrl SetToolTips(HWND hWndTT)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CToolTipCtrl((HWND)::SendMessage(m_hWnd, LVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L));
- }
-
- BOOL GetUnicodeFormat() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETUNICODEFORMAT, 0, 0L);
- }
-
- BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETUNICODEFORMAT, bUnicode, 0L);
- }
-#endif // !_WIN32_WCE
-#endif // (_WIN32_IE >= 0x0400)
-
-#if (_WIN32_WINNT >= 0x0501)
- int GetSelectedColumn() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETSELECTEDCOLUMN, 0, 0L);
- }
-
- void SetSelectedColumn(int nColumn)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_SETSELECTEDCOLUMN, nColumn, 0L);
- }
-
- DWORD GetView() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, LVM_GETVIEW, 0, 0L);
- }
-
- int SetView(DWORD dwView)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_SETVIEW, dwView, 0L);
- }
-
- BOOL IsGroupViewEnabled() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_ISGROUPVIEWENABLED, 0, 0L);
- }
-
- int GetGroupInfo(int nGroupID, PLVGROUP pGroup) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETGROUPINFO, nGroupID, (LPARAM)pGroup);
- }
-
- int SetGroupInfo(int nGroupID, PLVGROUP pGroup)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_SETGROUPINFO, nGroupID, (LPARAM)pGroup);
- }
-
- void GetGroupMetrics(PLVGROUPMETRICS pGroupMetrics) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics);
- }
-
- void SetGroupMetrics(PLVGROUPMETRICS pGroupMetrics)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics);
- }
-
- void GetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_GETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo);
- }
-
- BOOL SetTileViewInfo(PLVTILEVIEWINFO pTileViewInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEVIEWINFO, 0, (LPARAM)pTileViewInfo);
- }
-
- void GetTileInfo(PLVTILEINFO pTileInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_GETTILEINFO, 0, (LPARAM)pTileInfo);
- }
-
- BOOL SetTileInfo(PLVTILEINFO pTileInfo)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETTILEINFO, 0, (LPARAM)pTileInfo);
- }
-
- BOOL GetInsertMark(LPLVINSERTMARK pInsertMark) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETINSERTMARK, 0, (LPARAM)pInsertMark);
- }
-
- BOOL SetInsertMark(LPLVINSERTMARK pInsertMark)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETINSERTMARK, 0, (LPARAM)pInsertMark);
- }
-
- int GetInsertMarkRect(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETINSERTMARKRECT, 0, (LPARAM)lpRect);
- }
-
- COLORREF GetInsertMarkColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, LVM_GETINSERTMARKCOLOR, 0, 0L);
- }
-
- COLORREF SetInsertMarkColor(COLORREF clr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, LVM_SETINSERTMARKCOLOR, 0, clr);
- }
-
- COLORREF GetOutlineColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, LVM_GETOUTLINECOLOR, 0, 0L);
- }
-
- COLORREF SetOutlineColor(COLORREF clr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, LVM_SETOUTLINECOLOR, 0, clr);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-
-#if (_WIN32_WINNT >= 0x0600)
- int GetGroupCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETGROUPCOUNT, 0, 0L);
- }
-
- BOOL GetGroupInfoByIndex(int nIndex, PLVGROUP pGroup) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPINFOBYINDEX, nIndex, (LPARAM)pGroup);
- }
-
- BOOL GetGroupRect(int nGroupID, int nType, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(lpRect != NULL);
- if(lpRect != NULL)
- lpRect->top = nType;
- return (BOOL)::SendMessage(m_hWnd, LVM_GETGROUPRECT, nGroupID, (LPARAM)lpRect);
- }
-
- UINT GetGroupState(int nGroupID, UINT uMask) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, LVM_GETGROUPSTATE, nGroupID, (LPARAM)uMask);
- }
-
- int GetFocusedGroup() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETFOCUSEDGROUP, 0, 0L);
- }
-
- BOOL GetEmptyText(LPWSTR lpstrText, int cchText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETEMPTYTEXT, cchText, (LPARAM)lpstrText);
- }
-
- BOOL GetFooterRect(LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERRECT, 0, (LPARAM)lpRect);
- }
-
- BOOL GetFooterInfo(LPLVFOOTERINFO lpFooterInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERINFO, 0, (LPARAM)lpFooterInfo);
- }
-
- BOOL GetFooterItemRect(int nItem, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEMRECT, nItem, (LPARAM)lpRect);
- }
-
- BOOL GetFooterItem(int nItem, LPLVFOOTERITEM lpFooterItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETFOOTERITEM, nItem, (LPARAM)lpFooterItem);
- }
-
- BOOL GetItemIndexRect(PLVITEMINDEX pItemIndex, int nSubItem, int nType, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(pItemIndex != NULL);
- ATLASSERT(lpRect != NULL);
- if(lpRect != NULL)
- {
- lpRect->top = nSubItem;
- lpRect->left = nType;
- }
- return (BOOL)::SendMessage(m_hWnd, LVM_GETITEMINDEXRECT, (WPARAM)pItemIndex, (LPARAM)lpRect);
- }
-
- BOOL SetItemIndexState(PLVITEMINDEX pItemIndex, UINT uState, UINT dwMask)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVITEM lvi = { 0 };
- lvi.state = uState;
- lvi.stateMask = dwMask;
- return (BOOL)::SendMessage(m_hWnd, LVM_SETITEMINDEXSTATE, (WPARAM)pItemIndex, (LPARAM)&lvi);
- }
-
- BOOL GetNextItemIndex(PLVITEMINDEX pItemIndex, WORD wFlags) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_GETNEXTITEMINDEX, (WPARAM)pItemIndex, MAKELPARAM(wFlags, 0));
- }
-#endif // (_WIN32_WINNT >= 0x0600)
-
-// Operations
- int InsertColumn(int nCol, const LVCOLUMN* pColumn)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn);
- }
-
- int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat = LVCFMT_LEFT,
- int nWidth = -1, int nSubItem = -1, int iImage = -1, int iOrder = -1)
- {
- LVCOLUMN column = { 0 };
- column.mask = LVCF_TEXT|LVCF_FMT;
- column.pszText = (LPTSTR)lpszColumnHeading;
- column.fmt = nFormat;
- if (nWidth != -1)
- {
- column.mask |= LVCF_WIDTH;
- column.cx = nWidth;
- }
- if (nSubItem != -1)
- {
- column.mask |= LVCF_SUBITEM;
- column.iSubItem = nSubItem;
- }
- if (iImage != -1)
- {
- column.mask |= LVCF_IMAGE;
- column.iImage = iImage;
- }
- if (iOrder != -1)
- {
- column.mask |= LVCF_ORDER;
- column.iOrder = iOrder;
- }
- return InsertColumn(nCol, &column);
- }
-
- BOOL DeleteColumn(int nCol)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_DELETECOLUMN, nCol, 0L);
- }
-
- int InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem, UINT nState, UINT nStateMask, int nImage, LPARAM lParam)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVITEM item = { 0 };
- item.mask = nMask;
- item.iItem = nItem;
- item.iSubItem = 0;
- item.pszText = (LPTSTR)lpszItem;
- item.state = nState;
- item.stateMask = nStateMask;
- item.iImage = nImage;
- item.lParam = lParam;
- return InsertItem(&item);
- }
-
- int InsertItem(const LVITEM* pItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_INSERTITEM, 0, (LPARAM)pItem);
- }
-
- int InsertItem(int nItem, LPCTSTR lpszItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return InsertItem(LVIF_TEXT, nItem, lpszItem, 0, 0, 0, 0);
- }
-
- int InsertItem(int nItem, LPCTSTR lpszItem, int nImage)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return InsertItem(LVIF_TEXT|LVIF_IMAGE, nItem, lpszItem, 0, 0, nImage, 0);
- }
-
- int GetNextItem(int nItem, int nFlags) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_GETNEXTITEM, nItem, MAKELPARAM(nFlags, 0));
- }
-
- BOOL DeleteItem(int nItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_DELETEITEM, nItem, 0L);
- }
-
- BOOL DeleteAllItems()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L);
- }
-
- int FindItem(LVFINDINFO* pFindInfo, int nStart) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_FINDITEM, nStart, (LPARAM)pFindInfo);
- }
-
- int HitTest(LVHITTESTINFO* pHitTestInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)pHitTestInfo);
- }
-
- int HitTest(POINT pt, UINT* pFlags) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVHITTESTINFO hti = { 0 };
- hti.pt = pt;
- int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, 0, (LPARAM)&hti);
- if (pFlags != NULL)
- *pFlags = hti.flags;
- return nRes;
- }
-
- BOOL EnsureVisible(int nItem, BOOL bPartialOK)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_ENSUREVISIBLE, nItem, MAKELPARAM(bPartialOK, 0));
- }
-
- BOOL Scroll(SIZE size)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SCROLL, size.cx, size.cy);
- }
-
- BOOL RedrawItems(int nFirst, int nLast)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_REDRAWITEMS, nFirst, nLast);
- }
-
- BOOL Arrange(UINT nCode)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_ARRANGE, nCode, 0L);
- }
-
- CEdit EditLabel(int nItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CEdit((HWND)::SendMessage(m_hWnd, LVM_EDITLABEL, nItem, 0L));
- }
-
- BOOL Update(int nItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_UPDATE, nItem, 0L);
- }
-
- BOOL SortItems(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMS, (WPARAM)lParamSort, (LPARAM)pfnCompare);
- }
-
- CImageList RemoveImageList(int nImageList)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_SETIMAGELIST, (WPARAM)nImageList, NULL));
- }
-
- CImageList CreateDragImage(int nItem, LPPOINT lpPoint)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, LVM_CREATEDRAGIMAGE, nItem, (LPARAM)lpPoint));
- }
-
- DWORD ApproximateViewRect(int cx = -1, int cy = -1, int nCount = -1)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, LVM_APPROXIMATEVIEWRECT, nCount, MAKELPARAM(cx, cy));
- }
-
- int SubItemHitTest(LPLVHITTESTINFO lpInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, 0, (LPARAM)lpInfo);
- }
-
- int AddColumn(LPCTSTR strItem, int nItem, int nSubItem = -1,
- int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
- int nFmt = LVCFMT_LEFT)
- {
- const int cxOffset = 15;
- ATLASSERT(::IsWindow(m_hWnd));
- LVCOLUMN lvc = { 0 };
- lvc.mask = nMask;
- lvc.fmt = nFmt;
- lvc.pszText = (LPTSTR)strItem;
- lvc.cx = GetStringWidth(lvc.pszText) + cxOffset;
- if(nMask & LVCF_SUBITEM)
- lvc.iSubItem = (nSubItem != -1) ? nSubItem : nItem;
- return InsertColumn(nItem, &lvc);
- }
-
- int AddItem(int nItem, int nSubItem, LPCTSTR strItem, int nImageIndex = -1)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVITEM lvItem = { 0 };
- lvItem.mask = LVIF_TEXT;
- lvItem.iItem = nItem;
- lvItem.iSubItem = nSubItem;
- lvItem.pszText = (LPTSTR)strItem;
- if(nImageIndex != -1)
- {
- lvItem.mask |= LVIF_IMAGE;
- lvItem.iImage = nImageIndex;
- }
- if(nSubItem == 0)
- return InsertItem(&lvItem);
- return SetItem(&lvItem) ? nItem : -1;
- }
-
-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
- BOOL SortItemsEx(PFNLVCOMPARE pfnCompare, LPARAM lParamSort)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SORTITEMSEX, (WPARAM)lParamSort, (LPARAM)pfnCompare);
- }
-#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
-
-#if (_WIN32_WINNT >= 0x0501)
- int InsertGroup(int nItem, PLVGROUP pGroup)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_INSERTGROUP, nItem, (LPARAM)pGroup);
- }
-
- int AddGroup(PLVGROUP pGroup)
- {
- return InsertGroup(-1, pGroup);
- }
-
- int RemoveGroup(int nGroupID)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_REMOVEGROUP, nGroupID, 0L);
- }
-
- void MoveGroup(int nGroupID, int nItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_MOVEGROUP, nGroupID, nItem);
- }
-
- void MoveItemToGroup(int nItem, int nGroupID)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_MOVEITEMTOGROUP, nItem, nGroupID);
- }
-
- int EnableGroupView(BOOL bEnable)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_ENABLEGROUPVIEW, bEnable, 0L);
- }
-
- int SortGroups(PFNLVGROUPCOMPARE pCompareFunc, LPVOID lpVoid = NULL)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_SORTGROUPS, (WPARAM)pCompareFunc, (LPARAM)lpVoid);
- }
-
- void InsertGroupSorted(PLVINSERTGROUPSORTED pInsertGroupSorted)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_INSERTGROUPSORTED, (WPARAM)pInsertGroupSorted, 0L);
- }
-
- void RemoveAllGroups()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_REMOVEALLGROUPS, 0, 0L);
- }
-
- BOOL HasGroup(int nGroupID)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_HASGROUP, nGroupID, 0L);
- }
-
- BOOL InsertMarkHitTest(LPPOINT lpPoint, LPLVINSERTMARK pInsertMark) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_INSERTMARKHITTEST, (WPARAM)lpPoint, (LPARAM)pInsertMark);
- }
-
- BOOL SetInfoTip(PLVSETINFOTIP pSetInfoTip)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, LVM_SETINFOTIP, 0, (LPARAM)pSetInfoTip);
- }
-
- void CancelEditLabel()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, LVM_CANCELEDITLABEL, 0, 0L);
- }
-
- UINT MapIndexToID(int nIndex) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, LVM_MAPINDEXTOID, nIndex, 0L);
- }
-
- int MapIDToIndex(UINT uID) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_MAPIDTOINDEX, uID, 0L);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-
-#if (_WIN32_WINNT >= 0x0600)
- int HitTestEx(LPLVHITTESTINFO lpHitTestInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo);
- }
-
- int HitTestEx(POINT pt, UINT* pFlags) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- LVHITTESTINFO hti = { 0 };
- hti.pt = pt;
- int nRes = (int)::SendMessage(m_hWnd, LVM_HITTEST, (WPARAM)-1, (LPARAM)&hti);
- if (pFlags != NULL)
- *pFlags = hti.flags;
- return nRes;
- }
-
- int SubItemHitTestEx(LPLVHITTESTINFO lpHitTestInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, LVM_SUBITEMHITTEST, (WPARAM)-1, (LPARAM)lpHitTestInfo);
- }
-#endif // (_WIN32_WINNT >= 0x0600)
-
- // Note: selects only one item
- BOOL SelectItem(int nIndex)
- {
- ATLASSERT(::IsWindow(m_hWnd));
-
- // multi-selection only: de-select all items
- if((GetStyle() & LVS_SINGLESEL) == 0)
- SetItemState(-1, 0, LVIS_SELECTED);
-
- BOOL bRet = SetItemState(nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- if(bRet)
- bRet = EnsureVisible(nIndex, FALSE);
-
- return bRet;
- }
-};
-
-typedef CListViewCtrlT CListViewCtrl;
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CTreeViewCtrl
-
-template
-class CTreeViewCtrlT : public TBase
-{
-public:
-// Constructors
- CTreeViewCtrlT(HWND hWnd = NULL) : TBase(hWnd)
- { }
-
- CTreeViewCtrlT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
- HWND Create(HWND hWndParent, ATL::_U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
- DWORD dwStyle = 0, DWORD dwExStyle = 0,
- ATL::_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
- {
- return TBase::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
- }
-
-// Attributes
- static LPCTSTR GetWndClassName()
- {
- return WC_TREEVIEW;
- }
-
- UINT GetCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, TVM_GETCOUNT, 0, 0L);
- }
-
- UINT GetIndent() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, TVM_GETINDENT, 0, 0L);
- }
-
- void SetIndent(UINT nIndent)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TVM_SETINDENT, nIndent, 0L);
- }
-
- CImageList GetImageList(int nImageListType = TVSIL_NORMAL) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_GETIMAGELIST, (WPARAM)nImageListType, 0L));
- }
-
- CImageList SetImageList(HIMAGELIST hImageList, int nImageListType = TVSIL_NORMAL)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageListType, (LPARAM)hImageList));
- }
-
- BOOL GetItem(LPTVITEM pItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem);
- }
-
- BOOL SetItem(LPTVITEM pItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem);
- }
-
- BOOL SetItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage,
- int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- TVITEM item = { 0 };
- item.hItem = hItem;
- item.mask = nMask;
- item.pszText = (LPTSTR) lpszItem;
- item.iImage = nImage;
- item.iSelectedImage = nSelectedImage;
- item.state = nState;
- item.stateMask = nStateMask;
- item.lParam = lParam;
- return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)&item);
- }
-
- BOOL GetItemText(HTREEITEM hItem, LPTSTR lpstrText, int nLen) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(lpstrText != NULL);
-
- TVITEM item = { 0 };
- item.hItem = hItem;
- item.mask = TVIF_TEXT;
- item.pszText = lpstrText;
- item.cchTextMax = nLen;
-
- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
- }
-
-#ifndef _ATL_NO_COM
- BOOL GetItemText(HTREEITEM hItem, BSTR& bstrText) const
- {
- USES_CONVERSION;
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT(bstrText == NULL);
- TVITEM item = { 0 };
- item.hItem = hItem;
- item.mask = TVIF_TEXT;
-
- LPTSTR lpstrText = NULL;
- BOOL bRet = FALSE;
- for(int nLen = 256; ; nLen *= 2)
- {
- ATLTRY(lpstrText = new TCHAR[nLen]);
- if(lpstrText == NULL)
- break;
- lpstrText[0] = NULL;
- item.pszText = lpstrText;
- item.cchTextMax = nLen;
- bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
- if(!bRet || (lstrlen(item.pszText) < nLen - 1))
- break;
- delete [] lpstrText;
- lpstrText = NULL;
- }
-
- if(lpstrText != NULL)
- {
- if(bRet)
- bstrText = ::SysAllocString(T2OLE(lpstrText));
- delete [] lpstrText;
- }
-
- return (bstrText != NULL) ? TRUE : FALSE;
- }
-#endif // !_ATL_NO_COM
-
-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
- BOOL GetItemText(HTREEITEM hItem, _CSTRING_NS::CString& strText) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- TVITEM item = { 0 };
- item.hItem = hItem;
- item.mask = TVIF_TEXT;
-
- strText.Empty();
- BOOL bRet = FALSE;
- for(int nLen = 256; ; nLen *= 2)
- {
- item.pszText = strText.GetBufferSetLength(nLen);
- if(item.pszText == NULL)
- {
- bRet = FALSE;
- break;
- }
- item.cchTextMax = nLen;
- bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
- if(!bRet || (lstrlen(item.pszText) < nLen - 1))
- break;
- }
- strText.ReleaseBuffer();
- return bRet;
- }
-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
-
- BOOL SetItemText(HTREEITEM hItem, LPCTSTR lpszItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItem(hItem, TVIF_TEXT, lpszItem, 0, 0, 0, 0, NULL);
- }
-
- BOOL GetItemImage(HTREEITEM hItem, int& nImage, int& nSelectedImage) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- TVITEM item = { 0 };
- item.hItem = hItem;
- item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE;
- BOOL bRes = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
- if (bRes)
- {
- nImage = item.iImage;
- nSelectedImage = item.iSelectedImage;
- }
- return bRes;
- }
-
- BOOL SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItem(hItem, TVIF_IMAGE|TVIF_SELECTEDIMAGE, NULL, nImage, nSelectedImage, 0, 0, NULL);
- }
-
- UINT GetItemState(HTREEITEM hItem, UINT nStateMask) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
- return (((UINT)::SendMessage(m_hWnd, TVM_GETITEMSTATE, (WPARAM)hItem, (LPARAM)nStateMask)) & nStateMask);
-#else // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE))
- TVITEM item = { 0 };
- item.hItem = hItem;
- item.mask = TVIF_STATE;
- item.state = 0;
- item.stateMask = nStateMask;
- ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
- return (item.state & nStateMask);
-#endif // !((_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE))
- }
-
- BOOL SetItemState(HTREEITEM hItem, UINT nState, UINT nStateMask)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItem(hItem, TVIF_STATE, NULL, 0, 0, nState, nStateMask, NULL);
- }
-
- DWORD_PTR GetItemData(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- TVITEM item = { 0 };
- item.hItem = hItem;
- item.mask = TVIF_PARAM;
- BOOL bRet = (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
- return (DWORD_PTR)(bRet ? item.lParam : NULL);
- }
-
- BOOL SetItemData(HTREEITEM hItem, DWORD_PTR dwData)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return SetItem(hItem, TVIF_PARAM, NULL, 0, 0, 0, 0, (LPARAM)dwData);
- }
-
- CEdit GetEditControl() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CEdit((HWND)::SendMessage(m_hWnd, TVM_GETEDITCONTROL, 0, 0L));
- }
-
- UINT GetVisibleCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, TVM_GETVISIBLECOUNT, 0, 0L);
- }
-
- BOOL GetItemRect(HTREEITEM hItem, LPRECT lpRect, BOOL bTextOnly) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- *(HTREEITEM*)lpRect = hItem;
- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMRECT, (WPARAM)bTextOnly, (LPARAM)lpRect);
- }
-
- BOOL ItemHasChildren(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- TVITEM item = { 0 };
- item.hItem = hItem;
- item.mask = TVIF_CHILDREN;
- ::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)&item);
- return item.cChildren;
- }
-
-#ifndef _WIN32_WCE
- CToolTipCtrl GetToolTips() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_GETTOOLTIPS, 0, 0L));
- }
-
- CToolTipCtrl SetToolTips(HWND hWndTT)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CToolTipCtrl((HWND)::SendMessage(m_hWnd, TVM_SETTOOLTIPS, (WPARAM)hWndTT, 0L));
- }
-#endif // !_WIN32_WCE
-
- int GetISearchString(LPTSTR lpstr) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TVM_GETISEARCHSTRING, 0, (LPARAM)lpstr);
- }
-
- // checkboxes only
- BOOL GetCheckState(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ATLASSERT((GetStyle() & TVS_CHECKBOXES) != 0);
- UINT uRet = GetItemState(hItem, TVIS_STATEIMAGEMASK);
- return (uRet >> 12) - 1;
- }
-
- BOOL SetCheckState(HTREEITEM hItem, BOOL bCheck)
- {
- int nCheck = bCheck ? 2 : 1; // one based index
- return SetItemState(hItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_STATEIMAGEMASK);
- }
-
-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
- COLORREF GetBkColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TVM_GETBKCOLOR, 0, 0L);
- }
-
- COLORREF SetBkColor(COLORREF clr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)clr);
- }
-
- COLORREF GetInsertMarkColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TVM_GETINSERTMARKCOLOR, 0, 0L);
- }
-
- COLORREF SetInsertMarkColor(COLORREF clr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TVM_SETINSERTMARKCOLOR, 0, (LPARAM)clr);
- }
-
- int GetItemHeight() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TVM_GETITEMHEIGHT, 0, 0L);
- }
-
- int SetItemHeight(int cyHeight)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TVM_SETITEMHEIGHT, cyHeight, 0L);
- }
-
- int GetScrollTime() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TVM_GETSCROLLTIME, 0, 0L);
- }
-
- int SetScrollTime(int nScrollTime)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (int)::SendMessage(m_hWnd, TVM_SETSCROLLTIME, nScrollTime, 0L);
- }
-
- COLORREF GetTextColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TVM_GETTEXTCOLOR, 0, 0L);
- }
-
- COLORREF SetTextColor(COLORREF clr)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr);
- }
-
- BOOL GetUnicodeFormat() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_GETUNICODEFORMAT, 0, 0L);
- }
-
- BOOL SetUnicodeFormat(BOOL bUnicode = TRUE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SETUNICODEFORMAT, bUnicode, 0L);
- }
-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
-
-#if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
- COLORREF GetLineColor() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TVM_GETLINECOLOR, 0, 0L);
- }
-
- COLORREF SetLineColor(COLORREF clrNew /*= CLR_DEFAULT*/)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (COLORREF)::SendMessage(m_hWnd, TVM_SETLINECOLOR, 0, (LPARAM)clrNew);
- }
-#endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE)
-
-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
- BOOL GetItem(LPTVITEMEX pItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEM, 0, (LPARAM)pItem);
- }
-
- BOOL SetItem(LPTVITEMEX pItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SETITEM, 0, (LPARAM)pItem);
- }
-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
-
- DWORD GetExtendedStyle() const
- {
-#ifndef TVM_GETEXTENDEDSTYLE
- const UINT TVM_GETEXTENDEDSTYLE = (TV_FIRST + 45);
-#endif
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, TVM_GETEXTENDEDSTYLE, 0, 0L);
- }
-
- DWORD SetExtendedStyle(DWORD dwStyle, DWORD dwMask)
- {
-#ifndef TVM_SETEXTENDEDSTYLE
- const UINT TVM_SETEXTENDEDSTYLE = (TV_FIRST + 44);
-#endif
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, TVM_SETEXTENDEDSTYLE, dwMask, dwStyle);
- }
-
-#if (_WIN32_WINNT >= 0x0600)
- BOOL SetAutoScrollInfo(UINT uPixPerSec, UINT uUpdateTime)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SETAUTOSCROLLINFO, (WPARAM)uPixPerSec, (LPARAM)uUpdateTime);
- }
-
- DWORD GetSelectedCount() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (DWORD)::SendMessage(m_hWnd, TVM_GETSELECTEDCOUNT, 0, 0L);
- }
-
- BOOL GetItemPartRect(HTREEITEM hItem, TVITEMPART partID, LPRECT lpRect) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- TVGETITEMPARTRECTINFO gipri = { hItem, lpRect, partID };
- return (BOOL)::SendMessage(m_hWnd, TVM_GETITEMPARTRECT, 0, (LPARAM)&gipri);
- }
-#endif // (_WIN32_WINNT >= 0x0600)
-
-// Operations
- HTREEITEM InsertItem(LPTVINSERTSTRUCT lpInsertStruct)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct);
- }
-
- HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage,
- int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter);
- }
-
- HTREEITEM InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter);
- }
-
- HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage,
- int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam,
- HTREEITEM hParent, HTREEITEM hInsertAfter)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- TVINSERTSTRUCT tvis = { 0 };
- tvis.hParent = hParent;
- tvis.hInsertAfter = hInsertAfter;
- tvis.item.mask = nMask;
- tvis.item.pszText = (LPTSTR) lpszItem;
- tvis.item.iImage = nImage;
- tvis.item.iSelectedImage = nSelectedImage;
- tvis.item.state = nState;
- tvis.item.stateMask = nStateMask;
- tvis.item.lParam = lParam;
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvis);
- }
-
- BOOL DeleteItem(HTREEITEM hItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)hItem);
- }
-
- BOOL DeleteAllItems()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);
- }
-
- BOOL Expand(HTREEITEM hItem, UINT nCode = TVE_EXPAND)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_EXPAND, nCode, (LPARAM)hItem);
- }
-
- HTREEITEM GetNextItem(HTREEITEM hItem, UINT nCode) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem);
- }
-
- HTREEITEM GetChildItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem);
- }
-
- HTREEITEM GetNextSiblingItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem);
- }
-
- HTREEITEM GetPrevSiblingItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem);
- }
-
- HTREEITEM GetParentItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem);
- }
-
- HTREEITEM GetFirstVisibleItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L);
- }
-
- HTREEITEM GetNextVisibleItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)hItem);
- }
-
- HTREEITEM GetPrevVisibleItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUSVISIBLE, (LPARAM)hItem);
- }
-
- HTREEITEM GetSelectedItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CARET, 0L);
- }
-
- HTREEITEM GetDropHilightItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0L);
- }
-
- HTREEITEM GetRootItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0L);
- }
-
-#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
- HTREEITEM GetLastVisibleItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_LASTVISIBLE, 0L);
- }
-#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
-
-#if (_WIN32_IE >= 0x0600)
- HTREEITEM GetNextSelectedItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXTSELECTED, 0L);
- }
-#endif // (_WIN32_IE >= 0x0600)
-
- BOOL Select(HTREEITEM hItem, UINT nCode)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, nCode, (LPARAM)hItem);
- }
-
- BOOL SelectItem(HTREEITEM hItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem);
- }
-
- BOOL SelectDropTarget(HTREEITEM hItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_DROPHILITE, (LPARAM)hItem);
- }
-
- BOOL SelectSetFirstVisible(HTREEITEM hItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SELECTITEM, TVGN_FIRSTVISIBLE, (LPARAM)hItem);
- }
-
- CEdit EditLabel(HTREEITEM hItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CEdit((HWND)::SendMessage(m_hWnd, TVM_EDITLABEL, 0, (LPARAM)hItem));
- }
-
- BOOL EndEditLabelNow(BOOL bCancel)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_ENDEDITLABELNOW, bCancel, 0L);
- }
-
- HTREEITEM HitTest(TVHITTESTINFO* pHitTestInfo) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)pHitTestInfo);
- }
-
- HTREEITEM HitTest(POINT pt, UINT* pFlags) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- TVHITTESTINFO hti = { 0 };
- hti.pt = pt;
- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_HITTEST, 0, (LPARAM)&hti);
- if (pFlags != NULL)
- *pFlags = hti.flags;
- return hTreeItem;
- }
-
- BOOL SortChildren(HTREEITEM hItem, BOOL bRecurse = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDREN, (WPARAM)bRecurse, (LPARAM)hItem);
- }
-
- BOOL EnsureVisible(HTREEITEM hItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItem);
- }
-
- BOOL SortChildrenCB(LPTVSORTCB pSort, BOOL bRecurse = FALSE)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SORTCHILDRENCB, (WPARAM)bRecurse, (LPARAM)pSort);
- }
-
- CImageList RemoveImageList(int nImageList)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_SETIMAGELIST, (WPARAM)nImageList, NULL));
- }
-
- CImageList CreateDragImage(HTREEITEM hItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return CImageList((HIMAGELIST)::SendMessage(m_hWnd, TVM_CREATEDRAGIMAGE, 0, (LPARAM)hItem));
- }
-
-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
- BOOL SetInsertMark(HTREEITEM hTreeItem, BOOL bAfter)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, bAfter, (LPARAM)hTreeItem);
- }
-
- BOOL RemoveInsertMark()
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (BOOL)::SendMessage(m_hWnd, TVM_SETINSERTMARK, 0, 0L);
- }
-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
-
-#if (_WIN32_WINNT >= 0x0501)
- HTREEITEM MapAccIDToHTREEITEM(UINT uID) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (HTREEITEM)::SendMessage(m_hWnd, TVM_MAPACCIDTOHTREEITEM, uID, 0L);
- }
-
- UINT MapHTREEITEMToAccID(HTREEITEM hTreeItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return (UINT)::SendMessage(m_hWnd, TVM_MAPHTREEITEMTOACCID, (WPARAM)hTreeItem, 0L);
- }
-#endif // (_WIN32_WINNT >= 0x0501)
-
-#if (_WIN32_WINNT >= 0x0600)
- void ShowInfoTip(HTREEITEM hItem)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- ::SendMessage(m_hWnd, TVM_SHOWINFOTIP, 0, (LPARAM)hItem);
- }
-#endif // (_WIN32_WINNT >= 0x0600)
-};
-
-typedef CTreeViewCtrlT CTreeViewCtrl;
-
-
-///////////////////////////////////////////////////////////////////////////////
-// CTreeViewCtrlEx
-
-// forward declaration
-template class CTreeViewCtrlExT;
-
-// Note: TBase here is for CTreeViewCtrlExT, and not for CTreeItemT itself
-template
-class CTreeItemT
-{
-public:
- HTREEITEM m_hTreeItem;
- CTreeViewCtrlExT* m_pTreeView;
-
-// Construction
- CTreeItemT(HTREEITEM hTreeItem = NULL, CTreeViewCtrlExT* pTreeView = NULL) : m_hTreeItem(hTreeItem), m_pTreeView(pTreeView)
- { }
-
- CTreeItemT(const CTreeItemT& posSrc)
- {
- *this = posSrc;
- }
-
- operator HTREEITEM() { return m_hTreeItem; }
-
- CTreeItemT& operator =(const CTreeItemT& itemSrc)
- {
- m_hTreeItem = itemSrc.m_hTreeItem;
- m_pTreeView = itemSrc.m_pTreeView;
- return *this;
- }
-
-// Attributes
- CTreeViewCtrlExT* GetTreeView() const { return m_pTreeView; }
-
- BOOL operator !() const { return m_hTreeItem == NULL; }
-
- BOOL IsNull() const { return m_hTreeItem == NULL; }
-
- BOOL GetRect(LPRECT lpRect, BOOL bTextOnly) const;
- BOOL GetText(LPTSTR lpstrText, int nLen) const;
-#ifndef _ATL_NO_COM
- BOOL GetText(BSTR& bstrText) const;
-#endif // !_ATL_NO_COM
-#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
- BOOL GetText(_CSTRING_NS::CString& strText) const;
-#endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
- BOOL SetText(LPCTSTR lpszItem);
- BOOL GetImage(int& nImage, int& nSelectedImage) const;
- BOOL SetImage(int nImage, int nSelectedImage);
- UINT GetState(UINT nStateMask) const;
- BOOL SetState(UINT nState, UINT nStateMask);
- DWORD_PTR GetData() const;
- BOOL SetData(DWORD_PTR dwData);
- BOOL SetItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam);
-
-// Operations
- CTreeItemT InsertAfter(LPCTSTR lpstrItem, HTREEITEM hItemAfter, int nImageIndex)
- {
- return _Insert(lpstrItem, nImageIndex, hItemAfter);
- }
-
- CTreeItemT AddHead(LPCTSTR lpstrItem, int nImageIndex)
- {
- return _Insert(lpstrItem, nImageIndex, TVI_FIRST);
- }
-
- CTreeItemT AddTail(LPCTSTR lpstrItem, int nImageIndex)
- {
- return _Insert(lpstrItem, nImageIndex, TVI_LAST);
- }
-
- CTreeItemT GetChild() const;
- CTreeItemT GetNext(UINT nCode) const;
- CTreeItemT GetNextSibling() const;
- CTreeItemT GetPrevSibling() const;
- CTreeItemT GetParent() const;
- CTreeItemT GetFirstVisible() const;
- CTreeItemT GetNextVisible() const;
- CTreeItemT GetPrevVisible() const;
- CTreeItemT GetSelected() const;
- CTreeItemT GetDropHilight() const;
- CTreeItemT GetRoot() const;
-#if !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
- CTreeItemT GetLastVisible() const;
-#endif // !defined(_WIN32_WCE) && (_WIN32_IE >= 0x0400)
-#if (_WIN32_IE >= 0x0600)
- CTreeItemT GetNextSelected() const;
-#endif // (_WIN32_IE >= 0x0600)
- BOOL HasChildren() const;
- BOOL Delete();
- BOOL Expand(UINT nCode = TVE_EXPAND);
- BOOL Select(UINT nCode);
- BOOL Select();
- BOOL SelectDropTarget();
- BOOL SelectSetFirstVisible();
- HWND EditLabel();
- HIMAGELIST CreateDragImage();
- BOOL SortChildren(BOOL bRecurse = FALSE);
- BOOL EnsureVisible();
- CTreeItemT _Insert(LPCTSTR lpstrItem, int nImageIndex, HTREEITEM hItemAfter);
- int GetImageIndex() const;
-#if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
- BOOL SetInsertMark(BOOL bAfter);
-#endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE)
-#if (_WIN32_WINNT >= 0x0501)
- UINT MapHTREEITEMToAccID() const;
-#endif // (_WIN32_WINNT >= 0x0501)
-#if (_WIN32_WINNT >= 0x0600)
- void ShowInfoTip();
- BOOL GetPartRect(TVITEMPART partID, LPRECT lpRect) const;
-#endif // (_WIN32_WINNT >= 0x0600)
-};
-
-typedef CTreeItemT CTreeItem;
-
-
-template
-class CTreeViewCtrlExT : public CTreeViewCtrlT< TBase >
-{
-public:
-// Constructors
- CTreeViewCtrlExT(HWND hWnd = NULL) : CTreeViewCtrlT< TBase >(hWnd)
- { }
-
- CTreeViewCtrlExT< TBase >& operator =(HWND hWnd)
- {
- m_hWnd = hWnd;
- return *this;
- }
-
-// Operations (overides that return CTreeItem)
- CTreeItemT InsertItem(LPTVINSERTSTRUCT lpInsertStruct)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_INSERTITEM, 0, (LPARAM)lpInsertStruct);
- return CTreeItemT(hTreeItem, this);
- }
-
- CTreeItemT InsertItem(LPCTSTR lpszItem, int nImage,
- int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, lpszItem, nImage, nSelectedImage, 0, 0, 0, hParent, hInsertAfter);
- }
-
- CTreeItemT InsertItem(LPCTSTR lpszItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
- {
- ATLASSERT(::IsWindow(m_hWnd));
- return InsertItem(TVIF_TEXT, lpszItem, 0, 0, 0, 0, 0, hParent, hInsertAfter);
- }
-
- CTreeItemT GetNextItem(HTREEITEM hItem, UINT nCode) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, nCode, (LPARAM)hItem);
- return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this);
- }
-
- CTreeItemT GetChildItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem);
- return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this);
- }
-
- CTreeItemT GetNextSiblingItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem);
- return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this);
- }
-
- CTreeItemT GetPrevSiblingItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PREVIOUS, (LPARAM)hItem);
- return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this);
- }
-
- CTreeItemT GetParentItem(HTREEITEM hItem) const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)hItem);
- return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this);
- }
-
- CTreeItemT GetFirstVisibleItem() const
- {
- ATLASSERT(::IsWindow(m_hWnd));
- HTREEITEM hTreeItem = (HTREEITEM)::SendMessage(m_hWnd, TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0L);
- return CTreeItemT(hTreeItem, (CTreeViewCtrlExT*)this);
- }
-
- CTreeItemT