Problem
If AlphaBlend (from msimg32.dll) is used and the Scintilla dll is loaded with:
::LoadLibraryExW(L"Scintilla.dll", nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
LoadLibrary fails with ERROR_MOD_NOT_FOUND
If LoadLibraryExW without the LOAD_LIBRARY_SEARCH_APPLICATION_DIR flag is used, it succeeds.
Cause
I have no idea what the cause is and it seems a rather unexpected behavior.
Solution
Using GdiAlphaBlend instead of AlphaBlend solves this issue
I believe the AlphaBlend API inside of msimg32.dll is just a wrapper which calls GdiAlphaBlend. But this needs to be confirmed.
But an undisputable benefit of using GdiAlphaBlend is that you don't need the extra dependency to msimg32.dll
I have attached a patch but it may be easier just to replace AlphaBlend with GdiAlphaBlend (and remove the msimg32.lib from the project)
GdiAlphaBlend isn't available when building with MinGW GCC.
Since msimg32.dll is a system DLL, it will be available if Scintilla is loaded with the flag that allows system DLLs:
Scintilla may, in the future, use other system DLLs so LOAD_LIBRARY_SEARCH_SYSTEM32 should be used.
Attached is a patch that extends the proposed patch by removing msimg32 from make and project files.
Thank you. I have incorrectly assumed that system dll dependencies will be loaded from the system32 folder, even when the LOAD_LIBRARY_SEARCH_SYSTEM32 is not present.
The patch for MinGW here mentions that GdiAlphaBlend and co have been added to the headers:
https://sourceforge.net/p/mingw-w64/patches/59/
Last edit: mberchtold 2017-03-22
Mingw-w64 is a fork from MinGW and (MinGW) does not have GdiAlphaBlend. The two projects differ in their approach to adding new system APIs to headers.
Last edit: Neil Hodgson 2017-03-23
As GCC 7 and later is required to build Scintilla 5, maybe the patch can be applied for now?
here is new win32api package for old MinGW GCC https://osdn.net/projects/mingw/releases/p15587 (not checked as I don't see any downloadable packages like https://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/).
Committed change as [04ed59].
Related
Commit: [04ed59]