summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-07-22 13:01:52 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-07-22 13:01:52 +0000
commitea7ac371c2f11dcb1b4fa230b6a6eff75768b001 (patch)
tree7d55b62e77c7df7700311acfbd5ed39f9961f7a6
parentc136cd1708b19561b84cf2ec019a0aacbbe87ac4 (diff)
MirLua: added timeout param to MessageBox in m_windows
git-svn-id: http://svn.miranda-ng.org/main/trunk@14629 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/MirLua/src/m_windows.cpp61
1 files changed, 60 insertions, 1 deletions
diff --git a/plugins/MirLua/src/m_windows.cpp b/plugins/MirLua/src/m_windows.cpp
index 26be06b0f2..f2974583f2 100644
--- a/plugins/MirLua/src/m_windows.cpp
+++ b/plugins/MirLua/src/m_windows.cpp
@@ -1,13 +1,72 @@
#include "stdafx.h"
+typedef int(__stdcall *MSGBOXAAPI)(IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
+typedef int(__stdcall *MSGBOXWAPI)(IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
+
+int MessageBoxTimeoutA(IN HWND hWnd, IN LPCSTR lpText, IN LPCSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
+int MessageBoxTimeoutW(IN HWND hWnd, IN LPCWSTR lpText, IN LPCWSTR lpCaption, IN UINT uType, IN WORD wLanguageId, IN DWORD dwMilliseconds);
+
+#ifdef UNICODE
+ #define MessageBoxTimeout MessageBoxTimeoutW
+#else
+ #define MessageBoxTimeout MessageBoxTimeoutA
+#endif
+
+#define MB_TIMEDOUT 32000
+
+int MessageBoxTimeoutA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, WORD wLanguageId, DWORD dwMilliseconds)
+{
+ static MSGBOXAAPI MsgBoxTOA = NULL;
+
+ if (!MsgBoxTOA)
+ {
+ if (HMODULE hUser32 = GetModuleHandle(_T("user32.dll")))
+ {
+ MsgBoxTOA = (MSGBOXAAPI)GetProcAddress(hUser32, "MessageBoxTimeoutA");
+ FreeLibrary(hUser32);
+ }
+ }
+
+ if (MsgBoxTOA)
+ {
+ return MsgBoxTOA(hWnd, lpText, lpCaption, uType, wLanguageId, dwMilliseconds);
+ }
+
+ return MessageBoxA(hWnd, lpText, lpCaption, uType);
+}
+
+int MessageBoxTimeoutW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType, WORD wLanguageId, DWORD dwMilliseconds)
+{
+ static MSGBOXWAPI MsgBoxTOW = NULL;
+
+ if (!MsgBoxTOW)
+ {
+ if (HMODULE hUser32 = GetModuleHandle(_T("user32.dll")))
+ {
+ MsgBoxTOW = (MSGBOXWAPI)GetProcAddress(hUser32, "MessageBoxTimeoutW");
+ FreeLibrary(hUser32);
+ }
+
+ }
+
+ if (MsgBoxTOW)
+ {
+ return MsgBoxTOW(hWnd, lpText, lpCaption, uType, wLanguageId, dwMilliseconds);
+ }
+
+ return MessageBoxW(hWnd, lpText, lpCaption, uType);
+}
+
static int lua_MessageBox(lua_State *L)
{
HWND hwnd = (HWND)lua_touserdata(L, 1);
ptrT text(mir_utf8decodeT(lua_tostring(L, 2)));
ptrT caption(mir_utf8decodeT(lua_tostring(L, 3)));
UINT flags = lua_tointeger(L, 4);
+ LANGID langId = GetUserDefaultUILanguage();
+ DWORD timeout = luaL_optinteger(L, 5, 0xFFFFFFFF);
- int res = ::MessageBox(hwnd, text, caption, flags);
+ int res = ::MessageBoxTimeout(hwnd, text, caption, flags, langId, timeout);
lua_pushinteger(L, res);
return 1;