summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-12-19 17:28:12 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-12-19 17:28:12 +0300
commit0ea58a3f52fbebe2532e2b19a08b1a0422d7296e (patch)
tree63cf880a33a8af1797cab24c7e3101d751e38ed6
parentf37d8e059796ae661318656939d577198c67db3b (diff)
Windows API declarations isolated inside modules
-rw-r--r--include/m_fontservice.h4
-rw-r--r--include/m_hotkeys.h4
-rw-r--r--include/m_srmm_int.h2
-rw-r--r--src/mir_app/mir_app.vcxproj1
-rw-r--r--src/mir_app/mir_app.vcxproj.filters3
-rw-r--r--src/mir_app/src/FontOptions.cpp1
-rw-r--r--src/mir_app/src/headerbar.cpp28
-rw-r--r--src/mir_app/src/imgconv.cpp61
-rw-r--r--src/mir_app/src/miranda.cpp63
-rw-r--r--src/mir_app/src/miranda.h24
-rw-r--r--src/mir_app/src/options.cpp6
-rw-r--r--src/mir_app/src/stdafx.h2
12 files changed, 81 insertions, 118 deletions
diff --git a/include/m_fontservice.h b/include/m_fontservice.h
index d95642d3b5..61ac81df28 100644
--- a/include/m_fontservice.h
+++ b/include/m_fontservice.h
@@ -112,8 +112,8 @@ EXTERN_C MIR_APP_DLL(int) Font_RegisterW(FontIDW *pFont, HPLUGIN);
// global default font is gotten using SPI_GETICONTITLELOGFONT, color COLOR_WINDOWTEXT, size 8.
// returns the font's colour
-EXTERN_C MIR_APP_DLL(COLORREF) Font_Get(const char *szGroup, const char *szName, struct LOGFONTA *pFont);
-EXTERN_C MIR_APP_DLL(COLORREF) Font_GetW(const wchar_t *wszGroup, const wchar_t *wszName, struct LOGFONTW *pFont);
+EXTERN_C MIR_APP_DLL(COLORREF) Font_Get(const char *szGroup, const char *szName, LOGFONTA *pFont);
+EXTERN_C MIR_APP_DLL(COLORREF) Font_GetW(const wchar_t *wszGroup, const wchar_t *wszName, LOGFONTW *pFont);
__forceinline COLORREF Font_Get(FontID &p, LOGFONTA *pFont)
{ return Font_Get(p.group, p.name, pFont);
diff --git a/include/m_hotkeys.h b/include/m_hotkeys.h
index 6c6eea4c7a..712af60f15 100644
--- a/include/m_hotkeys.h
+++ b/include/m_hotkeys.h
@@ -64,7 +64,7 @@ EXTERN_C MIR_APP_DLL(int) Hotkey_Unregister(const char *pszName);
// Checks if "manual" hotkey was activated and returns its id.
// Returns lParam associated with activated hotkey
-EXTERN_C MIR_APP_DLL(int) Hotkey_Check(struct MSG *pEvent, const char *pszSection);
+EXTERN_C MIR_APP_DLL(int) Hotkey_Check(MSG *pEvent, const char *pszSection);
/////////////////////////////////////////////////////////////////////////////////////////
// Subclasss/unsubclass edit box to act as hotkey control
@@ -84,7 +84,7 @@ EXTERN_C MIR_APP_DLL(void) Hotkey_Unsubclass(HWND hwndEdit);
// This event is fired when hotkeys were changed
// wParam = lParam = 0
-#define ME_HOTKEYS_CHANGED "CoreHotkeys/Changed"
+#define ME_HOTKEYS_CHANGED "CoreHotkeys/Changed"
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h
index 7dc1d9cb62..99369c026d 100644
--- a/include/m_srmm_int.h
+++ b/include/m_srmm_int.h
@@ -279,7 +279,7 @@ class CMsgDialog : public CSrmmBaseDialog {};
/////////////////////////////////////////////////////////////////////////////////////////
// receives LOGSTREAMDATA* as the first parameter
-EXTERN_C MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(UINT_PTR dwCookie, BYTE *pbBuff, LONG cb, LONG *pcb);
+EXTERN_C MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, BYTE *pbBuff, LONG cb, LONG *pcb);
/////////////////////////////////////////////////////////////////////////////////////////
// sends a message to all SRMM windows
diff --git a/src/mir_app/mir_app.vcxproj b/src/mir_app/mir_app.vcxproj
index b38165d029..4ced95c9a1 100644
--- a/src/mir_app/mir_app.vcxproj
+++ b/src/mir_app/mir_app.vcxproj
@@ -88,7 +88,6 @@
<ClCompile Include="src\idle.cpp" />
<ClCompile Include="src\ignore.cpp" />
<ClCompile Include="src\image_utils.cpp" />
- <ClCompile Include="src\imgconv.cpp" />
<ClCompile Include="src\keyboard.cpp" />
<ClCompile Include="src\lpopts.cpp" />
<ClCompile Include="src\MDatabaseCache.cpp" />
diff --git a/src/mir_app/mir_app.vcxproj.filters b/src/mir_app/mir_app.vcxproj.filters
index 77c64bfaff..7686b8957a 100644
--- a/src/mir_app/mir_app.vcxproj.filters
+++ b/src/mir_app/mir_app.vcxproj.filters
@@ -71,9 +71,6 @@
<ClCompile Include="src\image_utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\imgconv.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\keyboard.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp
index e92b7e7a96..f7aa329692 100644
--- a/src/mir_app/src/FontOptions.cpp
+++ b/src/mir_app/src/FontOptions.cpp
@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "FontService.h"
+#include <m_skin_eng.h>
// *_w2 is working copy of list
// *_w3 is stores initial configuration
diff --git a/src/mir_app/src/headerbar.cpp b/src/mir_app/src/headerbar.cpp
index 2fdde4e629..2397ffa008 100644
--- a/src/mir_app/src/headerbar.cpp
+++ b/src/mir_app/src/headerbar.cpp
@@ -25,7 +25,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-static BOOL IsAeroMode()
+typedef HRESULT(STDAPICALLTYPE* pfnDrawThemeTextEx)(HTHEME, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS*);
+static pfnDrawThemeTextEx drawThemeTextEx;
+
+typedef HRESULT(STDAPICALLTYPE* pfnSetWindowThemeAttribute)(HWND, enum WINDOWTHEMEATTRIBUTETYPE, PVOID, DWORD);
+static pfnSetWindowThemeAttribute setWindowThemeAttribute;
+
+typedef HRESULT(STDAPICALLTYPE* pfnDwmExtendFrameIntoClientArea)(HWND hwnd, const MARGINS* margins);
+static pfnDwmExtendFrameIntoClientArea dwmExtendFrameIntoClientArea;
+
+typedef HRESULT(STDAPICALLTYPE* pfnDwmIsCompositionEnabled)(BOOL*);
+static pfnDwmIsCompositionEnabled dwmIsCompositionEnabled;
+
+BOOL IsAeroMode()
{
BOOL result;
return dwmIsCompositionEnabled && (dwmIsCompositionEnabled(&result) == S_OK) && result;
@@ -327,6 +339,20 @@ static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT msg, WPARAM wParam
int LoadHeaderbarModule()
{
+ if (IsWinVerVistaPlus()) {
+ HINSTANCE hThemeAPI = LoadLibraryA("uxtheme.dll");
+ if (hThemeAPI) {
+ drawThemeTextEx = (pfnDrawThemeTextEx)GetProcAddress(hThemeAPI, "DrawThemeTextEx");
+ setWindowThemeAttribute = (pfnSetWindowThemeAttribute)GetProcAddress(hThemeAPI, "SetWindowThemeAttribute");
+ }
+
+ HINSTANCE hDwmApi = LoadLibrary(L"dwmapi.dll");
+ if (hDwmApi) {
+ dwmExtendFrameIntoClientArea = (pfnDwmExtendFrameIntoClientArea)GetProcAddress(hDwmApi, "DwmExtendFrameIntoClientArea");
+ dwmIsCompositionEnabled = (pfnDwmIsCompositionEnabled)GetProcAddress(hDwmApi, "DwmIsCompositionEnabled");
+ }
+ }
+
WNDCLASSEX wc = { 0 };
wc.cbSize = sizeof(wc);
wc.lpszClassName = L"MHeaderbarCtrl";
diff --git a/src/mir_app/src/imgconv.cpp b/src/mir_app/src/imgconv.cpp
deleted file mode 100644
index 3d50c860fe..0000000000
--- a/src/mir_app/src/imgconv.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (C) 2012-21 Miranda NG team (https://miranda-ng.org),
-Copyright (c) 2000-12 Miranda IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "stdafx.h"
-
-typedef DWORD ARGB;
-
-HBITMAP ConvertIconToBitmap(HIMAGELIST hIml, int iconId)
-{
- BITMAPINFO bmi = { 0 };
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biWidth = g_iIconSX;
- bmi.bmiHeader.biHeight = g_iIconSY;
-
- HDC hdc = CreateCompatibleDC(nullptr);
- HBITMAP hbmp = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, nullptr, nullptr, 0);
- HBITMAP hbmpOld = (HBITMAP)SelectObject(hdc, hbmp);
-
- BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
- BP_PAINTPARAMS paintParams = {0};
- paintParams.cbSize = sizeof(paintParams);
- paintParams.dwFlags = BPPF_ERASE;
- paintParams.pBlendFunction = &bfAlpha;
-
- HDC hdcBuffer;
- RECT rcIcon = { 0, 0, g_iIconSX, g_iIconSY };
- HANDLE hPaintBuffer = beginBufferedPaint(hdc, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer);
- if (hPaintBuffer) {
- ImageList_Draw(hIml, iconId, hdc, 0, 0, ILD_TRANSPARENT);
- endBufferedPaint(hPaintBuffer, TRUE);
- }
-
- SelectObject(hdc, hbmpOld);
- DeleteDC(hdc);
-
- return hbmp;
-}
diff --git a/src/mir_app/src/miranda.cpp b/src/mir_app/src/miranda.cpp
index 4c64666701..36648eeb59 100644
--- a/src/mir_app/src/miranda.cpp
+++ b/src/mir_app/src/miranda.cpp
@@ -36,16 +36,17 @@ int LoadDefaultModules(void);
void UnloadNewPluginsModule(void);
void UnloadDefaultModules(void);
-pfnDrawThemeTextEx drawThemeTextEx;
-pfnSetWindowThemeAttribute setWindowThemeAttribute;
+typedef HRESULT(STDAPICALLTYPE* pfnBufferedPaintInit)(void);
pfnBufferedPaintInit bufferedPaintInit;
+
+typedef HRESULT(STDAPICALLTYPE* pfnBufferedPaintUninit)(void);
pfnBufferedPaintUninit bufferedPaintUninit;
+
+typedef HANDLE(STDAPICALLTYPE* pfnBeginBufferedPaint)(HDC, RECT*, BP_BUFFERFORMAT, BP_PAINTPARAMS*, HDC*);
pfnBeginBufferedPaint beginBufferedPaint;
-pfnEndBufferedPaint endBufferedPaint;
-pfnGetBufferedPaintBits getBufferedPaintBits;
-pfnDwmExtendFrameIntoClientArea dwmExtendFrameIntoClientArea;
-pfnDwmIsCompositionEnabled dwmIsCompositionEnabled;
+typedef HRESULT(STDAPICALLTYPE* pfnEndBufferedPaint)(HANDLE, BOOL);
+pfnEndBufferedPaint endBufferedPaint;
HANDLE hOkToExitEvent, hModulesLoadedEvent;
HANDLE hShutdownEvent, hPreShutdownEvent;
@@ -57,6 +58,42 @@ CMPlugin g_plugin;
/////////////////////////////////////////////////////////////////////////////////////////
+HBITMAP ConvertIconToBitmap(HIMAGELIST hIml, int iconId)
+{
+ BITMAPINFO bmi = { 0 };
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biCompression = BI_RGB;
+ bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biWidth = g_iIconSX;
+ bmi.bmiHeader.biHeight = g_iIconSY;
+
+ HDC hdc = CreateCompatibleDC(nullptr);
+ HBITMAP hbmp = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, nullptr, nullptr, 0);
+ HBITMAP hbmpOld = (HBITMAP)SelectObject(hdc, hbmp);
+
+ BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
+ BP_PAINTPARAMS paintParams = { 0 };
+ paintParams.cbSize = sizeof(paintParams);
+ paintParams.dwFlags = BPPF_ERASE;
+ paintParams.pBlendFunction = &bfAlpha;
+
+ HDC hdcBuffer;
+ RECT rcIcon = { 0, 0, g_iIconSX, g_iIconSY };
+ HANDLE hPaintBuffer = beginBufferedPaint(hdc, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer);
+ if (hPaintBuffer) {
+ ImageList_Draw(hIml, iconId, hdc, 0, 0, ILD_TRANSPARENT);
+ endBufferedPaint(hPaintBuffer, TRUE);
+ }
+
+ SelectObject(hdc, hbmpOld);
+ DeleteDC(hdc);
+
+ return hbmp;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
"Miranda NG",
@@ -310,25 +347,17 @@ int WINAPI mir_main(LPTSTR cmdLine)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
- HMODULE hDwmApi, hThemeAPI;
+ HMODULE hThemeAPI;
if (IsWinVerVistaPlus()) {
- hDwmApi = LoadLibrary(L"dwmapi.dll");
- if (hDwmApi) {
- dwmExtendFrameIntoClientArea = (pfnDwmExtendFrameIntoClientArea)GetProcAddress(hDwmApi, "DwmExtendFrameIntoClientArea");
- dwmIsCompositionEnabled = (pfnDwmIsCompositionEnabled)GetProcAddress(hDwmApi, "DwmIsCompositionEnabled");
- }
hThemeAPI = LoadLibrary(L"uxtheme.dll");
if (hThemeAPI) {
- drawThemeTextEx = (pfnDrawThemeTextEx)GetProcAddress(hThemeAPI, "DrawThemeTextEx");
- setWindowThemeAttribute = (pfnSetWindowThemeAttribute)GetProcAddress(hThemeAPI, "SetWindowThemeAttribute");
bufferedPaintInit = (pfnBufferedPaintInit)GetProcAddress(hThemeAPI, "BufferedPaintInit");
bufferedPaintUninit = (pfnBufferedPaintUninit)GetProcAddress(hThemeAPI, "BufferedPaintUninit");
beginBufferedPaint = (pfnBeginBufferedPaint)GetProcAddress(hThemeAPI, "BeginBufferedPaint");
endBufferedPaint = (pfnEndBufferedPaint)GetProcAddress(hThemeAPI, "EndBufferedPaint");
- getBufferedPaintBits = (pfnGetBufferedPaintBits)GetProcAddress(hThemeAPI, "GetBufferedPaintBits");
}
}
- else hDwmApi = hThemeAPI = nullptr;
+ else hThemeAPI = nullptr;
if (bufferedPaintInit)
bufferedPaintInit();
@@ -412,8 +441,6 @@ int WINAPI mir_main(LPTSTR cmdLine)
UnloadNewPluginsModule();
UnloadCoreModule();
- if (hDwmApi)
- FreeLibrary(hDwmApi);
if (hThemeAPI)
FreeLibrary(hThemeAPI);
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h
index e7ab2da12b..dcf7b9d8fe 100644
--- a/src/mir_app/src/miranda.h
+++ b/src/mir_app/src/miranda.h
@@ -26,28 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MS_OPTIONS_OPEN "Options/OptionsCommand"
-typedef HRESULT (STDAPICALLTYPE *pfnDrawThemeTextEx)(HTHEME, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS *);
-typedef HRESULT (STDAPICALLTYPE *pfnSetWindowThemeAttribute)(HWND, enum WINDOWTHEMEATTRIBUTETYPE, PVOID, DWORD);
-typedef HRESULT (STDAPICALLTYPE *pfnBufferedPaintInit)(void);
-typedef HRESULT (STDAPICALLTYPE *pfnBufferedPaintUninit)(void);
-typedef HANDLE (STDAPICALLTYPE *pfnBeginBufferedPaint)(HDC, RECT *, BP_BUFFERFORMAT, BP_PAINTPARAMS *, HDC *);
-typedef HRESULT (STDAPICALLTYPE *pfnEndBufferedPaint)(HANDLE, BOOL);
-typedef HRESULT (STDAPICALLTYPE *pfnGetBufferedPaintBits)(HANDLE, RGBQUAD **, int *);
-
-extern pfnDrawThemeTextEx drawThemeTextEx;
-extern pfnSetWindowThemeAttribute setWindowThemeAttribute;
-extern pfnBufferedPaintInit bufferedPaintInit;
-extern pfnBufferedPaintUninit bufferedPaintUninit;
-extern pfnBeginBufferedPaint beginBufferedPaint;
-extern pfnEndBufferedPaint endBufferedPaint;
-extern pfnGetBufferedPaintBits getBufferedPaintBits;
-
-typedef HRESULT (STDAPICALLTYPE *pfnDwmExtendFrameIntoClientArea)(HWND hwnd, const MARGINS *margins);
-typedef HRESULT (STDAPICALLTYPE *pfnDwmIsCompositionEnabled)(BOOL *);
-
-extern pfnDwmExtendFrameIntoClientArea dwmExtendFrameIntoClientArea;
-extern pfnDwmIsCompositionEnabled dwmIsCompositionEnabled;
-
/**** database.cpp *********************************************************************/
extern MIR_CORE_EXPORT MDatabaseCommon *g_pCurrDb;
@@ -194,6 +172,8 @@ INT_PTR stubChainRecv(WPARAM, LPARAM);
/**** utils.cpp ************************************************************************/
+BOOL IsAeroMode();
+
bool ProcessFileDrop(HDROP hDrop, MCONTACT hContact);
void RegisterModule(CMPluginBase*);
diff --git a/src/mir_app/src/options.cpp b/src/mir_app/src/options.cpp
index d4c566acf1..7a32263296 100644
--- a/src/mir_app/src/options.cpp
+++ b/src/mir_app/src/options.cpp
@@ -87,12 +87,6 @@ static wchar_t* GetPluginName(HINSTANCE hInstance, wchar_t *buffer, int size)
return buffer;
}
-static BOOL IsAeroMode()
-{
- BOOL result;
- return dwmIsCompositionEnabled && (dwmIsCompositionEnabled(&result) == S_OK) && result;
-}
-
static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static void AeroPaintControl(HWND hwnd, HDC hdc, UINT msg, LPARAM lpFlags)
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h
index 3830bbb953..f3fc28e0ff 100644
--- a/src/mir_app/src/stdafx.h
+++ b/src/mir_app/src/stdafx.h
@@ -98,7 +98,7 @@ typedef struct SslHandle *HSSL;
#include <m_tipper.h>
#include <m_toptoolbar.h>
#include <m_userinfo.h>
-//#include <m_version.h>
+#include <m_version.h>
#include <m_xstatus.h>
#include "miranda.h"