+ fix: refactoring for Scintilla DLL version

This commit is contained in:
Rainer Kottenhoff 2020-03-21 22:20:23 +01:00
parent 82c3a7abc1
commit 56bbc626c6
12 changed files with 155 additions and 165 deletions

View File

@ -138,7 +138,7 @@
<LinkTimeCodeGeneration>false</LinkTimeCodeGeneration>
</Lib>
<Link>
<AdditionalDependencies>imm32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>imm32.lib;Shlwapi.lib;Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -165,7 +165,7 @@
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalDependencies>imm32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>imm32.lib;Shlwapi.lib;Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -192,7 +192,7 @@
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalDependencies>imm32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>imm32.lib;Shlwapi.lib;Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -220,7 +220,7 @@
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalDependencies>imm32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>imm32.lib;Shlwapi.lib;Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -15,14 +15,20 @@
extern "C" {
#endif
typedef struct _dpi_t { int x; int y; } DPI_T;
#if defined(_WIN32)
/* Return false on failure: */
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
__declspec(dllexport) int Scintilla_RegisterClasses(void *hInstance);
__declspec(dllexport) int Scintilla_ReleaseResources(void);
__declspec(dllexport) int Scintilla_InputCodePage(void);
__declspec(dllexport) int Scintilla_RegisterClasses(void *hInstance);
__declspec(dllexport) int Scintilla_ReleaseResources(void);
__declspec(dllexport) int Scintilla_InputCodePage(void);
__declspec(dllexport) DPI_T Scintilla_GetCurrentDPI(void* hwnd);
__declspec(dllexport) int Scintilla_GetSystemMetricsEx(void* hwnd, int nIndex);
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
#endif
int Scintilla_LinkLexers(void);
#ifdef __cplusplus

View File

@ -43,6 +43,7 @@
#include <richedit.h>
#include <windowsx.h>
#include <shlwapi.h>
#include <VersionHelpers.h>
#include "Platform.h"
#include "Scintilla.h"
@ -69,13 +70,9 @@
#endif
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
#if NP2_FORCE_COMPILE_C_AS_CPP
extern DWORD kSystemLibraryLoadFlags;
#else
extern "C" DWORD kSystemLibraryLoadFlags;
#endif
#else
#define kSystemLibraryLoadFlags LOAD_LIBRARY_SEARCH_SYSTEM32
#define kSystemLibraryLoadFlags LOAD_LIBRARY_SEARCH_SYSTEM32
#endif
namespace Scintilla {
@ -2631,7 +2628,7 @@ PRectangle ListBoxX::GetDesiredRect() {
rcDesired.right = rcDesired.left + TextOffset() + width + (TextInset.x * 2);
if (Length() > rows)
rcDesired.right += GetSystemMetricsEx(SM_CXVSCROLL);
rcDesired.right += GetSystemMetricsEx(GetHWND(), SM_CXVSCROLL);
AdjustWindowRect(&rcDesired);
return rcDesired;
@ -2879,7 +2876,7 @@ POINT ListBoxX::MinTrackSize() const {
POINT ListBoxX::MaxTrackSize() const {
const int width = maxCharWidth * maxItemCharacters + static_cast<int>(TextInset.x) * 2 +
TextOffset() + GetSystemMetricsEx(SM_CXVSCROLL);
TextOffset() + GetSystemMetricsEx(GetHWND(), SM_CXVSCROLL);
PRectangle rc = PRectangle::FromInts(0, 0,
std::max(MinClientWidth(), width),
ItemHeight() * lti.Count());
@ -2990,7 +2987,7 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const noexcept {
// window caption height + frame, even if one is hovering over the bottom edge of
// the frame, so workaround that here
if (hit >= HTTOP && hit <= HTTOPRIGHT) {
const int minHeight = GetSystemMetricsEx(SM_CYMINTRACK);
const int minHeight = GetSystemMetricsEx(GetHWND(), SM_CYMINTRACK);
const int yPos = GET_Y_LPARAM(lParam);
if ((rc.Height() < minHeight) && (yPos > ((rc.top + rc.bottom)/2))) {
hit += HTBOTTOM - HTTOP;
@ -2998,9 +2995,9 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const noexcept {
}
#if LISTBOXX_USE_BORDER || LISTBOXX_USE_FAKE_FRAME
else if (hit < HTSIZEFIRST || hit > HTSIZELAST) {
const int cx = GetSystemMetricsEx(SM_CXVSCROLL);
const int cx = GetSystemMetricsEx(GetHWND(), SM_CXVSCROLL);
#if LISTBOXX_USE_BORDER
const PRectangle rcInner = rc.Deflate(GetSystemMetricsEx(SM_CXBORDER), GetSystemMetricsEx(SM_CYBORDER));
const PRectangle rcInner = rc.Deflate(GetSystemMetricsEx(GetHWND(), SM_CXBORDER), GetSystemMetricsEx(GetHWND(), SM_CYBORDER));
#else
const PRectangle rcInner = rc.Deflate(ListBoxXFakeFrameSize, ListBoxXFakeFrameSize);
#endif
@ -3575,4 +3572,71 @@ void Platform_Finalise(bool fromDllMain) noexcept {
#endif
}
//=============================================================================
//
// GetCurrentDPI()
//
#ifdef _WIN64
typedef INT_PTR(FAR WINAPI* FARPROCHWND)(HWND);
typedef INT_PTR(FAR WINAPI* FARPROCMONI)(HMONITOR, int, UINT*, UINT*);
#else
typedef int (FAR WINAPI* FARPROCHWND)(HWND);
typedef int (FAR WINAPI* FARPROCMONI)(HMONITOR, int, UINT*, UINT*);
#endif // _WIN64
DPI_T GetCurrentDPI(HWND hwnd) {
DPI_T curDPI = { 0, 0 };
if (IsWindows10OrGreater()) {
HMODULE const hModule = GetModuleHandle(L"user32.dll");
if (hModule) {
FARPROCHWND const pfnGetDpiForWindow = (FARPROCHWND)GetProcAddress(hModule, "GetDpiForWindow");
if (pfnGetDpiForWindow) {
curDPI.x = curDPI.y = (int)pfnGetDpiForWindow(hwnd);
}
}
}
if ((curDPI.x == 0) && IsWindows8Point1OrGreater()) {
HMODULE hShcore = LoadLibrary(L"shcore.dll");
if (hShcore) {
FARPROCMONI const pfnGetDpiForMonitor = (FARPROCMONI)GetProcAddress(hShcore, "GetDpiForMonitor");
if (pfnGetDpiForMonitor) {
HMONITOR const hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
UINT dpiX = 0, dpiY = 0;
if (pfnGetDpiForMonitor(hMonitor, 0 /* MDT_EFFECTIVE_DPI */, &dpiX, &dpiY) == S_OK) {
curDPI.x = dpiX;
curDPI.y = dpiY;
}
}
FreeLibrary(hShcore);
}
}
if (curDPI.x == 0) {
HDC hDC = GetDC(hwnd);
curDPI.x = GetDeviceCaps(hDC, LOGPIXELSX);
curDPI.y = GetDeviceCaps(hDC, LOGPIXELSY);
ReleaseDC(hwnd, hDC);
}
curDPI.x = std::max((int)curDPI.x, USER_DEFAULT_SCREEN_DPI);
curDPI.y = std::max((int)curDPI.y, USER_DEFAULT_SCREEN_DPI);
return curDPI;
}
//=============================================================================
//
// GetSystemMetricsEx()
// get system metric for current DPI
// https://docs.microsoft.com/de-de/windows/desktop/api/winuser/nf-winuser-getsystemmetricsfordpi
//
int GetSystemMetricsEx(HWND hwnd, int nIndex)
{
return ScaleIntToDPI_Y(hwnd, GetSystemMetrics(nIndex));
}
}

View File

@ -43,15 +43,6 @@
#endif
// force compile C as CPP
#define NP2_FORCE_COMPILE_C_AS_CPP 0
#if NP2_FORCE_COMPILE_C_AS_CPP
extern int GetSystemMetricsEx(int nIndex);
#else
extern "C" int GetSystemMetricsEx(int nIndex);
#endif
namespace Scintilla {
@ -86,6 +77,12 @@ extern ID2D1Factory *pD2DFactory;
extern IDWriteFactory *pIDWriteFactory;
#endif
DPI_T GetCurrentDPI(HWND hwnd);
int GetSystemMetricsEx(HWND hwnd, int nIndex);
inline int ScaleIntToDPI_X(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); return MulDiv((val), dpi.x, USER_DEFAULT_SCREEN_DPI); }
inline int ScaleIntToDPI_Y(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); return MulDiv((val), dpi.y, USER_DEFAULT_SCREEN_DPI); }
}
#endif

View File

@ -50,6 +50,7 @@
#include <shlwapi.h>
#include <shlobj.h>
#include <shellapi.h>
#include <VersionHelpers.h>
#define DebugDragAndDropDataFormat 0
@ -150,6 +151,7 @@ constexpr UINT SC_WORK_IDLE = 5002;
#endif
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
DWORD kSystemLibraryLoadFlags = 0;
using SetCoalescableTimerSig = UINT_PTR (WINAPI *)(HWND hwnd, UINT_PTR nIDEvent,
UINT uElapse, TIMERPROC lpTimerFunc, ULONG uToleranceDelay);
#endif
@ -822,8 +824,8 @@ bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) noexcept {
const Point ptDifference = ptStart - ptNow;
const XYPOSITION xMove = std::trunc(std::abs(ptDifference.x));
const XYPOSITION yMove = std::trunc(std::abs(ptDifference.y));
return (xMove > GetSystemMetricsEx(SM_CXDRAG)) ||
(yMove > GetSystemMetricsEx(SM_CYDRAG));
return (xMove > GetSystemMetricsEx(MainHWND(), SM_CXDRAG)) ||
(yMove > GetSystemMetricsEx(MainHWND(), SM_CYDRAG));
}
void ScintillaWin::StartDrag() {
@ -3779,7 +3781,14 @@ namespace Scintilla {
// Must be called once only.
extern "C" __declspec(dllexport)
int Scintilla_RegisterClasses(void *hInstance) {
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
// see LoadD2D() in PlatWin.cxx
kSystemLibraryLoadFlags = (IsWindows8Point1OrGreater() || GetProcAddress(GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories")) ? LOAD_LIBRARY_SEARCH_SYSTEM32 : 0;
#endif
Platform_Initialise(hInstance);
const bool result = ScintillaWin::Register(static_cast<HINSTANCE>(hInstance));
#ifdef SCI_LEXER
Scintilla_LinkLexers();
@ -3797,3 +3806,14 @@ extern "C" __declspec(dllexport)
int Scintilla_InputCodePage(void) {
return InputCodePage();
}
extern "C" __declspec(dllexport)
DPI_T Scintilla_GetCurrentDPI(void* hwnd) {
return GetCurrentDPI(static_cast<HWND>(hwnd));
}
extern "C" __declspec(dllexport)
int Scintilla_GetSystemMetricsEx(void* hwnd, int nIndex) {
return GetSystemMetricsEx(static_cast<HWND>(hwnd), nIndex);
}

View File

@ -12,6 +12,7 @@
#include "ChooseFont.h"
#include "FontEnumeration.h"
#include "GdiTextRenderer.h"
#include "Scintilla.h"
extern "C" {
#include "../resource.h"

View File

@ -699,7 +699,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
{
UpdateWindowLayoutForDPI(hwnd, 0, 0, 0, 0);
DPI_T const dpi = GetCurrentDPI(hwnd);
DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd);
SendDlgItemMessage(hwnd, IDC_RICHEDITABOUT, EM_SETZOOM, (WPARAM)dpi.y, (LPARAM)USER_DEFAULT_SCREEN_DPI);
//~~// get current richedit box format
@ -844,7 +844,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Screen-Resolution = %i x %i [pix]", ResX, ResY);
StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
DPI_T dpi = GetCurrentDPI(hwnd);
DPI_T dpi = Scintilla_GetCurrentDPI(hwnd);
StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"\n- Display-DPI = %i x %i (Scale: %i%%).", dpi.x, dpi.y, ScaleIntToDPI_X(hwnd, 100));
StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchBuf);
@ -3778,7 +3778,7 @@ void ResizeDlg_InitEx(HWND hwnd, int cxFrame, int cyFrame, int nIdGrip, int iDir
HWND hwndCtl = GetDlgItem(hwnd, nIdGrip);
SetWindowLongPtr(hwndCtl, GWL_STYLE, GetWindowLongPtr(hwndCtl, GWL_STYLE) | SBS_SIZEGRIP | WS_CLIPSIBLINGS);
/// TODO: per-window DPI
const int cGrip = GetSystemMetricsEx(hwnd, SM_CXHTHUMB);
const int cGrip = Scintilla_GetSystemMetricsEx(hwnd, SM_CXHTHUMB);
SetWindowPos(hwndCtl, NULL, pm->cxClient - cGrip, pm->cyClient - cGrip, cGrip, cGrip, SWP_NOZORDER);
}

View File

@ -214,26 +214,26 @@ void GetWinVersionString(LPWSTR szVersionStr, size_t cchVersionStr)
{
StringCchCopy(szVersionStr, cchVersionStr, L"OS Version: Windows ");
if (IsWin10OrHigher()) {
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2016 " : L"10 ");
if (IsWindows10OrGreater()) {
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2016 " : L"10 ");
}
else if (IsWin81OrHigher()) {
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2012 R2 " : L"8.1");
else if (IsWindows8Point1OrGreater()) {
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2012 R2 " : L"8.1");
}
else if (IsWin8OrHigher()) {
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2012 " : L"8");
else if (IsWindows8OrGreater()) {
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2012 " : L"8");
}
else if (IsWin71OrHigher()) {
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2008 R2 " : L"7 (SP1)");
else if (IsWindows7SP1OrGreater()) {
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2008 R2 " : L"7 (SP1)");
}
else if (IsWin7OrHigher()) {
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Server 2008 " : L"7");
else if (IsWindows7OrGreater()) {
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Server 2008 " : L"7");
}
else {
StringCchCat(szVersionStr, cchVersionStr, IsWinServer() ? L"Unkown Server " : L"?");
StringCchCat(szVersionStr, cchVersionStr, IsWindowsServer() ? L"Unkown Server " : L"?");
}
if (IsWin10OrHigher()) {
if (IsWindows10OrGreater()) {
WCHAR win10ver[80] = { L'\0' };
if (s_OSversion.dwOSVersionInfoSize == 0) { _GetTrueWindowsVersion(); }
DWORD const build = s_OSversion.dwBuildNumber;
@ -318,53 +318,6 @@ void SetUACIcon(const HMENU hMenu, const UINT nItem)
}
//=============================================================================
//
// GetCurrentDPI()
//
DPI_T GetCurrentDPI(HWND hwnd) {
DPI_T curDPI = { 0, 0 };
if (IsWin10OrHigher()) {
HMODULE const hModule = GetModuleHandle(L"user32.dll");
if (hModule) {
FARPROC const pfnGetDpiForWindow = GetProcAddress(hModule, "GetDpiForWindow");
if (pfnGetDpiForWindow) {
curDPI.x = curDPI.y = (UINT)pfnGetDpiForWindow(hwnd);
}
}
}
if ((curDPI.x == 0) && IsWin81OrHigher()) {
HMODULE hShcore = LoadLibrary(L"shcore.dll");
if (hShcore) {
FARPROC const pfnGetDpiForMonitor = GetProcAddress(hShcore, "GetDpiForMonitor");
if (pfnGetDpiForMonitor) {
HMONITOR const hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
UINT dpiX = 0, dpiY = 0;
if (pfnGetDpiForMonitor(hMonitor, 0 /* MDT_EFFECTIVE_DPI */, &dpiX, &dpiY) == S_OK) {
curDPI.x = dpiX;
curDPI.y = dpiY;
}
}
FreeLibrary(hShcore);
}
}
if (curDPI.x == 0) {
HDC hDC = GetDC(hwnd);
curDPI.x = GetDeviceCaps(hDC, LOGPIXELSX);
curDPI.y = GetDeviceCaps(hDC, LOGPIXELSY);
ReleaseDC(hwnd, hDC);
}
curDPI.x = max_u(curDPI.x, USER_DEFAULT_SCREEN_DPI);
curDPI.y = max_u(curDPI.y, USER_DEFAULT_SCREEN_DPI);
return curDPI;
}
//=============================================================================
//
// GetCurrentPPI()
@ -392,18 +345,6 @@ if (!bSucceed) {
}*/
//=============================================================================
//
// GetSystemMetricsEx()
// get system metric for current DPI
// https://docs.microsoft.com/de-de/windows/desktop/api/winuser/nf-winuser-getsystemmetricsfordpi
//
int GetSystemMetricsEx(HWND hwnd, int nValue) {
return ScaleIntToDPI_Y(hwnd, GetSystemMetrics(nValue));
}
//=============================================================================
//
// UpdateWindowLayoutForDPI()
@ -438,7 +379,7 @@ HBITMAP ResizeImageForCurrentDPI(HWND hwnd, HBITMAP hbmp)
if (hbmp) {
BITMAP bmp;
if (GetObject(hbmp, sizeof(BITMAP), &bmp)) {
DPI_T const DPI = GetCurrentDPI(hwnd);
DPI_T const DPI = Scintilla_GetCurrentDPI(hwnd);
int const width = MulDiv(bmp.bmWidth, DPI.x, USER_DEFAULT_SCREEN_DPI);
int const height = MulDiv(bmp.bmHeight, DPI.y, USER_DEFAULT_SCREEN_DPI);
if ((width != bmp.bmWidth) || (height != bmp.bmHeight)) {
@ -497,7 +438,7 @@ bool IsProcessElevated() {
// Vista, GetTokenInformation returns FALSE with the
// ERROR_INVALID_PARAMETER error code because TokenElevation is
// not supported on those operating systems.
if (!IsVistaOrHigher()) { return false; }
if (!IsWindowsVistaOrGreater()) { return false; }
bool bIsElevated = false;
HANDLE hToken = NULL;

View File

@ -24,6 +24,8 @@
#include <heapapi.h>
#include <versionhelpers.h>
#include <Scintilla.h>
// ============================================================================
// --- Disable/Enable some CodeAnalysis Warnings ---
@ -178,30 +180,6 @@ inline COLORREF GetBackgroundColor(HWND hwnd) { return GetBkColor(GetDC(hwnd));
// ----------------------------------------------------------------------------
//#define Is2k() (g_uWinVer >= 0x0500)
#define IsXPOrHigher() IsWindowsXPOrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP version.
#define IsXP1OrHigher() IsWindowsXPSP1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP with Service Pack 1 (SP1)version.
#define IsXP2OrHigher() IsWindowsXPSP2OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP with Service Pack 2 (SP2)version.
#define IsXP3OrHigher() IsWindowsXPSP3OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP with Service Pack 3 (SP3)version.
#define IsVistaOrHigher() IsWindowsVistaOrGreater() // Indicates if the current OS version matches,or is greater than,the Windows Vista version.
#define IsVista1OrHigher() IsWindowsVistaSP1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows Vista with Service Pack 1 (SP1)version.
#define IsVista2OrHigher() IsWindowsVistaSP2OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows Vista with Service Pack 2 (SP2)version.
#define IsWin7OrHigher() IsWindows7OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows 7 version.
#define IsWin71OrHigher() IsWindows7SP1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows 7 with Service Pack 1 (SP1)version.
#define IsWin8OrHigher() IsWindows8OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows 8 version.
#define IsWin81OrHigher() IsWindows8Point1OrGreater() // Indicates if the current OS version matches,or is greater than,the Windows 8.1 version.
// For Windows 10,IsWindows8Point1OrGreater returns false unless the application contains a manifest that includes
// a compatibility section that contains the GUIDs that designate Windows 8.1 and/or Windows 10.
#define IsWin10OrHigher() IsWindows10OrGreater() // Indicates if the current OS version matches, or is greater than, the Windows 10 version.
// For Windows 10,IsWindows10OrGreater returns false unless the application contains a manifest that includes
// a compatibility section that contains the GUID that designates Windows 10.
#define IsWinServer() IsWindowsServer() // Indicates if the current OS is a Windows Server release.
// Applications that need to distinguish between server and client versions of Windows should call this function.
void GetWinVersionString(LPWSTR szVersionStr, size_t cchVersionStr);
// ----------------------------------------------------------------------------
@ -218,22 +196,20 @@ void SetUACIcon(const HMENU hMenu, const UINT nItem);
// ----------------------------------------------------------------------------
DPI_T GetCurrentDPI(HWND hwnd);
DPI_T GetCurrentPPI(HWND hwnd);
void UpdateWindowLayoutForDPI(HWND hWnd, int x_96dpi, int y_96dpi, int w_96dpi, int h_96dpi);
HBITMAP ResizeImageForCurrentDPI(HWND hwnd, HBITMAP hbmp);
inline int ScaleIntToDPI_X(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); return MulDiv((val), dpi.x, USER_DEFAULT_SCREEN_DPI); }
inline int ScaleIntToDPI_Y(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); return MulDiv((val), dpi.y, USER_DEFAULT_SCREEN_DPI); }
inline int ScaleToCurrentDPIX(HWND hwnd, float fVal) { DPI_T const dpi = GetCurrentDPI(hwnd); return float2int((fVal * dpi.x) / (float)USER_DEFAULT_SCREEN_DPI); }
inline int ScaleToCurrentDPIY(HWND hwnd, float fVal) { DPI_T const dpi = GetCurrentDPI(hwnd); return float2int((fVal * dpi.y) / (float)USER_DEFAULT_SCREEN_DPI); }
inline int ScaleIntFontSizeW(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); DPI_T const ppi = GetCurrentPPI(hwnd); return MulDiv((val), dpi.x, ppi.x); }
inline int ScaleIntFontSizeH(HWND hwnd, int val) { DPI_T const dpi = GetCurrentDPI(hwnd); DPI_T const ppi = GetCurrentPPI(hwnd); return MulDiv((val), dpi.y, ppi.y); }
inline int ScaleFontSize(HWND hwnd, float fSize) { DPI_T const dpi = GetCurrentDPI(hwnd); DPI_T const ppi = GetCurrentPPI(hwnd); return float2int((fSize * dpi.y) / (float)ppi.y); }
inline int ScaleFractionalFontSize(HWND hwnd, float fSize) { DPI_T const dpi = GetCurrentDPI(hwnd); DPI_T const ppi = GetCurrentPPI(hwnd); return float2int((fSize * 10.0f * dpi.y) / (float)ppi.y) * 10; }
inline int ScaleIntToDPI_X(HWND hwnd, int val) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); return MulDiv((val), dpi.x, USER_DEFAULT_SCREEN_DPI); }
inline int ScaleIntToDPI_Y(HWND hwnd, int val) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); return MulDiv((val), dpi.y, USER_DEFAULT_SCREEN_DPI); }
inline int ScaleToCurrentDPIX(HWND hwnd, float fVal) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); return float2int((fVal * dpi.x) / (float)USER_DEFAULT_SCREEN_DPI); }
inline int ScaleToCurrentDPIY(HWND hwnd, float fVal) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); return float2int((fVal * dpi.y) / (float)USER_DEFAULT_SCREEN_DPI); }
inline int ScaleIntFontSizeW(HWND hwnd, int val) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); DPI_T const ppi = GetCurrentPPI(hwnd); return MulDiv((val), dpi.x, ppi.x); }
inline int ScaleIntFontSizeH(HWND hwnd, int val) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); DPI_T const ppi = GetCurrentPPI(hwnd); return MulDiv((val), dpi.y, ppi.y); }
inline int ScaleFontSize(HWND hwnd, float fSize) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); DPI_T const ppi = GetCurrentPPI(hwnd); return float2int((fSize * dpi.y) / (float)ppi.y); }
inline int ScaleFractionalFontSize(HWND hwnd, float fSize) { DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd); DPI_T const ppi = GetCurrentPPI(hwnd); return float2int((fSize * 10.0f * dpi.y) / (float)ppi.y) * 10; }
int GetSystemMetricsEx(HWND hwnd, int nValue);
// ----------------------------------------------------------------------------

View File

@ -201,10 +201,6 @@ static TBBUTTON s_tbbMainWnd[] = {
};
static const int NUMTOOLBITMAPS = 29;
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
DWORD kSystemLibraryLoadFlags = 0;
#endif
// ----------------------------------------------------------------------------
const WCHAR* const TBBUTTON_DEFAULT_IDS_V1 = L"1 2 4 3 28 0 5 6 0 7 8 9 0 10 11 0 12 0 24 26 0 22 23 0 13 14 0 27 0 15 0 25 0 17";
@ -661,7 +657,7 @@ static void _InitGlobals()
Flags.RelativeFileMRU = DefaultFlags.RelativeFileMRU = true;
Flags.PortableMyDocs = DefaultFlags.PortableMyDocs = Flags.RelativeFileMRU;
Flags.NoFadeHidden = DefaultFlags.NoFadeHidden = false;
Flags.ToolbarLook = DefaultFlags.ToolbarLook = IsXPOrHigher() ? 1 : 2;
Flags.ToolbarLook = DefaultFlags.ToolbarLook = IsWindowsXPSP3OrGreater() ? 1 : 2;
Flags.SimpleIndentGuides = DefaultFlags.SimpleIndentGuides = false;
Flags.NoHTMLGuess =DefaultFlags.NoHTMLGuess = false;
Flags.NoCGIGuess = DefaultFlags.NoCGIGuess = false;
@ -811,8 +807,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
// check if running at least on Windows 7
if (!IsWin7OrHigher()) {
// check if running at least on Windows 7 (SP1)
if (!IsWindows7SP1OrGreater()) {
MsgBoxLastError(L"Application Initialization", ERROR_OLD_WIN_VERSION);
return 1; // exit
}
@ -850,11 +846,6 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
icex.dwICC = ICC_WIN95_CLASSES | ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_USEREX_CLASSES;
InitCommonControlsEx(&icex);
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
// see LoadD2D() in PlatWin.cxx
kSystemLibraryLoadFlags = (IsWin8OrHigher() || GetProcAddress(GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories")) ? LOAD_LIBRARY_SEARCH_SYSTEM32 : 0;
#endif
Scintilla_RegisterClasses(hInstance);
//SetProcessDPIAware(); -> .manifest
@ -1750,7 +1741,7 @@ static void _SetWrapVisualFlags(HWND hwndEditCtrl)
//
static void _InitializeSciEditCtrl(HWND hwndEditCtrl)
{
if (IsVistaOrHigher()) {
if (IsWindowsVistaOrGreater()) {
// Current platforms perform window buffering so it is almost always better for this option to be turned off.
// There are some older platforms and unusual modes where buffering may still be useful - so keep it ON
//~SciCall_SetBufferedDraw(true); // default is true
@ -1988,7 +1979,7 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam)
SetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
SetWindowPos(Globals.hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
if (IsVistaOrHigher()) {
if (IsWindowsVistaOrGreater()) {
s_cxEditFrame = 0;
s_cyEditFrame = 0;
}
@ -2184,7 +2175,7 @@ static HIMAGELIST CreateScaledImageListFromBitmap(HWND hWnd, HBITMAP hBmp)
HIMAGELIST himl = ImageList_Create(cx, cy, ILC_COLOR32 | ILC_MASK, NUMTOOLBITMAPS, NUMTOOLBITMAPS);
ImageList_AddMasked(himl, hBmp, CLR_DEFAULT);
DPI_T dpi = GetCurrentDPI(hWnd);
DPI_T dpi = Scintilla_GetCurrentDPI(hWnd);
if (!Settings.DpiScaleToolBar ||
((dpi.x == USER_DEFAULT_SCREEN_DPI) && (dpi.y == USER_DEFAULT_SCREEN_DPI)))
{
@ -2335,10 +2326,10 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance)
if (Flags.ToolbarLook == 1) {
bProcessed = BitmapAlphaBlend(hbmpCopy, GetSysColor(COLOR_3DFACE), 0x60);
}
else if (Flags.ToolbarLook == 2 || (!IsXPOrHigher() && Flags.ToolbarLook == 0)) {
else if (Flags.ToolbarLook == 2 || (!IsWindowsXPSP3OrGreater() && Flags.ToolbarLook == 0)) {
bProcessed = BitmapGrayScale(hbmpCopy);
}
if (bProcessed && !IsXPOrHigher()) {
if (bProcessed && !IsWindowsXPSP3OrGreater()) {
BitmapMergeAlpha(hbmpCopy, GetSysColor(COLOR_3DFACE));
}
if (bProcessed)
@ -2554,7 +2545,7 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam)
SetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE);
SetWindowPos(Globals.hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
if (IsVistaOrHigher()) {
if (IsWindowsVistaOrGreater()) {
s_cxEditFrame = 0;
s_cyEditFrame = 0;
}
@ -10384,7 +10375,7 @@ bool RelaunchMultiInst() {
//
bool RelaunchElevated(LPWSTR lpNewCmdLnArgs)
{
if (!IsVistaOrHigher() || !Flags.bDoRelaunchElevated ||
if (!IsWindowsVistaOrGreater() || !Flags.bDoRelaunchElevated ||
s_bIsProcessElevated || s_IsThisAnElevatedRelaunch || s_bIsRunAsAdmin ||
s_flagDisplayHelp)
{

View File

@ -3094,7 +3094,7 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam
// --- open systems Font Selection dialog ---
if (Settings.RenderingTechnology > 0) {
DPI_T const dpi = GetCurrentDPI(hwnd);
DPI_T const dpi = Scintilla_GetCurrentDPI(hwnd);
if (!ChooseFontDirectWrite(Globals.hwndMain, Settings2.PreferredLanguageLocaleName, dpi, &cf) ||
(lf.lfFaceName[0] == L'\0')) {
return false;
@ -4452,7 +4452,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR
SetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP),GWL_STYLE,
GetWindowLongPtr(GetDlgItem(hwnd,IDC_RESIZEGRIP),GWL_STYLE)|SBS_SIZEGRIP|WS_CLIPSIBLINGS);
int cGrip = GetSystemMetricsEx(hwnd, SM_CXHTHUMB);
int cGrip = Scintilla_GetSystemMetricsEx(hwnd, SM_CXHTHUMB);
SetWindowPos(GetDlgItem(hwnd,IDC_RESIZEGRIP),NULL,cxClient-cGrip,
cyClient-cGrip,cGrip,cGrip,SWP_NOZORDER);

View File

@ -72,12 +72,6 @@ typedef DocPos DocLn; // Sci::Line
//typedef intptr_t cpi_enc_t;
typedef int cpi_enc_t;
typedef struct _dpi_t
{
UINT x;
UINT y;
} DPI_T;
typedef struct _wi
{
int x;