root/lang/objective-cplusplus/i3/trunk/src/gui-windows/Gui.cpp @ 36530

Revision 36530, 2.9 kB (checked in by saturday06, 5 years ago)

fij

Line 
1#include <PrecompiledHeaders.h>
2#include "../Common.h"
3
4namespace i3 {
5
6
7
8int global_loop() {
9    MSG msg = {};
10    while (true) {
11        BOOL result = GetMessage(&msg, NULL, 0, 0);
12        if (likely(result != -1 && result != 0)) {
13            // dirty if-condition is for most expected branch
14            TranslateMessage(&msg);
15            DispatchMessage(&msg);
16            continue;
17        }
18
19        if (result == -1) {
20            // error
21            halt << msg.message;
22        }
23        break;
24    }
25    return (int)msg.wParam;
26}
27void alert(string message) {
28    MessageBox(NULL, message.c_str(), _("info"), MB_OK);
29}
30
31int init_gui_global_data(int argc, char** argv) {
32#if defined(ENABLE_NLS) && defined(UNICODE)
33    bind_textdomain_codeset(PACKAGE_NAME, "UTF-16LE");
34#endif
35
36    if (!i3::hInstance) {
37        i3::hInstance = GetModuleHandle(NULL);
38    }
39
40    InitCommonControls();
41
42#ifndef _WIN32_WCE
43
44#define SET_DLL_ADDRESS2(module, name)                                  \
45    {                                                                   \
46        *(uintptr_t*)(&i3::dll.##name) =                                \
47            (uintptr_t)GetProcAddress(module, #name);                   \
48    }
49
50#else
51
52#define SET_DLL_ADDRESS2(module, name)                                  \
53    {                                                                   \
54        uintptr_t* pointer = (uintptr_t*)&::i3::dll.name;               \
55        *pointer = (uintptr_t)GetProcAddress(module, _T(#name));        \
56    }
57
58#endif
59
60#if defined(_MSC_VER) && !defined(NDEBUG) && 0
61
62#define SET_DLL_ADDRESS(module, name)           \
63    {                                           \
64        ::i3::dll.name = name;                  \
65        SET_DLL_ADDRESS2(module, name);         \
66    }
67
68#else
69
70#define SET_DLL_ADDRESS(module, name) SET_DLL_ADDRESS2(module, name)
71
72#endif
73
74    HMODULE dwmapi_dll = LoadLibrary(_T("dwmapi.dll"));
75    if (dwmapi_dll) {
76        dll.have_dwmapi_dll = true;
77        SET_DLL_ADDRESS(dwmapi_dll, DwmExtendFrameIntoClientArea);
78        SET_DLL_ADDRESS(dwmapi_dll, DwmIsCompositionEnabled);
79        SET_DLL_ADDRESS(dwmapi_dll, DwmEnableBlurBehindWindow);
80        SET_DLL_ADDRESS(dwmapi_dll, DwmGetColorizationColor);
81        SET_DLL_ADDRESS(dwmapi_dll, DwmGetWindowAttribute);
82    }
83
84    //HMODULE user32_dll = LoadLibrary(_T("user32.dll"));
85    //if (user32_dll) {
86    //    SET_DLL_ADDRESS(user32_dll, SetLayeredWindowAttributes);
87    //}
88
89    HMODULE uxtheme_dll = LoadLibrary(_T("uxtheme.dll"));
90    if (uxtheme_dll) {
91        SET_DLL_ADDRESS(uxtheme_dll, BeginBufferedPaint);
92        SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintInit);
93        SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintUnInit);
94        SET_DLL_ADDRESS(uxtheme_dll, EndBufferedPaint);
95        SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintSetAlpha);
96    }
97    return 0;
98}
99}
100
Note: See TracBrowser for help on using the browser.