aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--win32/PlatWin.cxx22
2 files changed, 21 insertions, 5 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index ac3eda073..88ce4b440 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -596,6 +596,10 @@
SciTE fixed a bug where, on GTK+, when the output pane had focus, menu commands
performed by mouse were sent instead to the edit pane.
</li>
+ <li>
+ Fix failure to load Direct2D on Windows when used on old versions of Windows.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1653/">Bug #1653</a>.
+ </li>
</ul>
<h3>
<a href="http://www.scintilla.org/scite373.zip">Release 3.7.3</a>
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 363ae42fd..cef6973d7 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -46,6 +46,10 @@
#define SPI_GETFONTSMOOTHINGCONTRAST 0x200C
#endif
+#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
+#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
+#endif
+
static void *PointerFromWindow(HWND hWnd) {
return reinterpret_cast<void *>(::GetWindowLongPtr(hWnd, 0));
}
@@ -59,8 +63,6 @@ extern UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage);
static CRITICAL_SECTION crPlatformLock;
static HINSTANCE hinstPlatformRes = 0;
-static HMODULE hDLLUser32 = 0;
-
static HCURSOR reverseArrowCursor = NULL;
#ifdef SCI_NAMESPACE
@@ -89,12 +91,23 @@ static HMODULE hDLLDWrite = NULL;
bool LoadD2D() {
static bool triedLoadingD2D = false;
if (!triedLoadingD2D) {
+ DWORD loadLibraryFlags = 0;
+ HMODULE kernel32 = ::GetModuleHandle(TEXT("kernel32.dll"));
+ if (kernel32) {
+ if (::GetProcAddress(kernel32, "SetDefaultDllDirectories")) {
+ // Availability of SetDefaultDllDirectories implies Windows 8+ or
+ // that KB2533623 has been installed so LoadLibraryEx can be called
+ // with LOAD_LIBRARY_SEARCH_SYSTEM32.
+ loadLibraryFlags = LOAD_LIBRARY_SEARCH_SYSTEM32;
+ }
+ }
+
typedef HRESULT (WINAPI *D2D1CFSig)(D2D1_FACTORY_TYPE factoryType, REFIID riid,
CONST D2D1_FACTORY_OPTIONS *pFactoryOptions, IUnknown **factory);
typedef HRESULT (WINAPI *DWriteCFSig)(DWRITE_FACTORY_TYPE factoryType, REFIID iid,
IUnknown **factory);
- hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/);
+ hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, loadLibraryFlags);
if (hDLLD2D) {
D2D1CFSig fnD2DCF = (D2D1CFSig)::GetProcAddress(hDLLD2D, "D2D1CreateFactory");
if (fnD2DCF) {
@@ -105,7 +118,7 @@ bool LoadD2D() {
reinterpret_cast<IUnknown**>(&pD2DFactory));
}
}
- hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/);
+ hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, loadLibraryFlags);
if (hDLLDWrite) {
DWriteCFSig fnDWCF = (DWriteCFSig)::GetProcAddress(hDLLDWrite, "DWriteCreateFactory");
if (fnDWCF) {
@@ -3135,7 +3148,6 @@ int Platform::Clamp(int val, int minVal, int maxVal) {
void Platform_Initialise(void *hInstance) {
::InitializeCriticalSection(&crPlatformLock);
hinstPlatformRes = static_cast<HINSTANCE>(hInstance);
-
ListBoxX_Register();
}