Show
Ignore:
Timestamp:
04/12/09 15:33:54 (4 years ago)
Author:
saturday06
Message:

jn

Location:
lang/objective-cplusplus/i3/trunk/src/gui-windows
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-cplusplus/i3/trunk/src/gui-windows/Gui.cpp

    r32299 r32306  
    55{ 
    66 
    7 HRESULT (*dll_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset) = NULL; 
    8 HRESULT (*dll_DwmIsCompositionEnabled)(BOOL *pfEnabled) = NULL; 
    9 HRESULT (*dll_DwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND *pBlurBehind) = NULL; 
     7dll_ dll = {}; 
     8OSVERSIONINFO version_info = {}; 
    109 
    1110int global_loop() 
     
    3938    init_hInstance(); 
    4039 
     40    version_info.dwOSVersionInfoSize = sizeof(version_info); 
     41    BOOL result = GetVersionEx(&version_info); 
    4142 
    42 #define SET_DLL_ADDRESS(dll, name) dll_##name = (decltype(dll_##name))GetProcAddress(dll, #name); 
     43    if (version_info.dwMajorVersion >= 6) { 
    4344 
    44     HMODULE dwmapi_dll = LoadLibrary(_T("dwmapi.dll")); 
    45     if (dwmapi_dll) { 
    46         SET_DLL_ADDRESS(dwmapi_dll, DwmExtendFrameIntoClientArea); 
    47         SET_DLL_ADDRESS(dwmapi_dll, DwmIsCompositionEnabled); 
    48         SET_DLL_ADDRESS(dwmapi_dll, DwmEnableBlurBehindWindow); 
     45        #define SET_DLL_ADDRESS(module, name) i3::dll.dll_##name = (decltype(i3::dll.dll_##name))GetProcAddress(module, #name); 
     46 
     47        HMODULE dwmapi_dll = LoadLibrary(_T("dwmapi.dll")); 
     48        if (dwmapi_dll) { 
     49            dll.have_dwmapi_dll = true; 
     50            SET_DLL_ADDRESS(dwmapi_dll, DwmExtendFrameIntoClientArea); 
     51            SET_DLL_ADDRESS(dwmapi_dll, DwmIsCompositionEnabled); 
     52            SET_DLL_ADDRESS(dwmapi_dll, DwmEnableBlurBehindWindow); 
     53        } 
    4954    } 
    5055    return 0; 
  • lang/objective-cplusplus/i3/trunk/src/gui-windows/Gui.h

    r32300 r32306  
    4747typedef boost::basic_format<TCHAR> format; 
    4848 
    49 extern HRESULT (*dll_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset); 
    50 extern HRESULT (*dll_DwmIsCompositionEnabled)(BOOL *pfEnabled); 
    51 extern HRESULT (*dll_DwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND *pBlurBehind); 
     49extern struct dll_ { 
     50    bool have_dwmapi_dll; 
     51    HRESULT (*dll_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset); 
     52    HRESULT (*dll_DwmIsCompositionEnabled)(BOOL *pfEnabled); 
     53    HRESULT (*dll_DwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND *pBlurBehind); 
     54} dll; 
    5255 
    5356} 
  • lang/objective-cplusplus/i3/trunk/src/gui-windows/InputWindowPlatform.cpp

    r32299 r32306  
    264264    HDC hdc = BeginPaint(hwnd , &ps); 
    265265 
    266     FillRect(ps.hdc, &ps.rcPaint, (HBRUSH)GetStockObject(BLACK_BRUSH)); 
     266    if (dll.have_dwmapi_dll) { 
     267        FillRect(ps.hdc, &ps.rcPaint, (HBRUSH)GetStockObject(BLACK_BRUSH)); 
     268    } 
    267269 
    268270    //HBRUSH hBrushYellow = NULL; 
     
    280282    } 
    281283 
    282     EndPaint(hwnd , &ps); 
     284    EndPaint(hwnd, &ps); 
    283285    SetMsgHandled(false); 
    284286} 
     
    345347 
    346348    int richedit_style = WS_CHILD | WS_VISIBLE; 
    347     if (!dll_DwmExtendFrameIntoClientArea) { 
     349    if (!dll.dll_DwmExtendFrameIntoClientArea) { 
    348350        richedit_style |= WS_BORDER; 
    349351    } 
     
    411413    SetWindowPos(hEdit, 0, edit_height, 0, DEFAULT_WINDOW_WIDTH - nc_width - edit_height, edit_height, SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOOWNERZORDER | SWP_NOZORDER); 
    412414 
    413  
    414     LRESULT dwEvent = SendMessage(hEdit, EM_GETEVENTMASK, 0, 0); 
    415     dwEvent |= ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE; 
    416     SendMessage(hEdit, EM_SETEVENTMASK, 0, (LPARAM)dwEvent); 
    417  
    418     InvalidateRect(w, NULL, FALSE); 
    419     UpdateWindow(w); 
    420     ShowWindow(w, nCmdShow); 
    421     SetFocus(hEdit); 
    422  
    423     //SetLayeredWindowAttributes(w, 0, 200, LWA_ALPHA); 
    424  
    425     // �^�X�N�g���C�p�̃A�C�R���̍쐬 
    426     NOTIFYICONDATA connectingIcon = {}; 
    427         connectingIcon.cbSize = sizeof(connectingIcon); 
    428     connectingIcon.hIcon = LoadIcon(get_hInstance(), _T("IDI_ICON1")); 
    429     connectingIcon.hWnd = w; 
    430     connectingIcon.uCallbackMessage = WM_USER + 10; 
    431     connectingIcon.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; 
    432     _tcscpy_s(connectingIcon.szTip, _T("")); 
    433     Shell_NotifyIcon(NIM_ADD, &connectingIcon); 
    434  
    435415    setWindow(w); 
    436416    wndproc.set(w); 
    437417 
    438418    // f 
    439     if (dll_DwmIsCompositionEnabled &&  
    440         dll_DwmExtendFrameIntoClientArea && 
    441         dll_DwmEnableBlurBehindWindow) { 
     419    if (dll.have_dwmapi_dll) { 
    442420        BOOL enabled = FALSE; 
    443         HRESULT hr = dll_DwmIsCompositionEnabled(&enabled); 
     421        HRESULT hr = dll.dll_DwmIsCompositionEnabled(&enabled); 
    444422        if (SUCCEEDED(hr) && enabled) { 
    445423            HRESULT hr = S_OK; 
     
    455433            //SendMessage(hEdit, EM_SETBKGNDCOLOR, (WPARAM)0, (LPARAM)RGB(0, 0, 0)); 
    456434            MARGINS margins = {edit_height, 0, 0, 0}; 
    457             hr = dll_DwmExtendFrameIntoClientArea(w,&margins); 
    458         } 
    459     } 
     435            hr = dll.dll_DwmExtendFrameIntoClientArea(w,&margins); 
     436        } 
     437    } 
     438    //InvalidateRect(w, NULL, FALSE); 
     439    UpdateWindow(w); 
     440    ShowWindow(w, nCmdShow); 
     441    //UpdateWindow(hEdit); 
     442    SetFocus(hEdit); 
     443 
     444 
     445    // ------------------------------------------------------------- 
     446    // lazy init 
     447 
     448    LRESULT dwEvent = SendMessage(hEdit, EM_GETEVENTMASK, 0, 0); 
     449    dwEvent |= ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_CHANGE; 
     450    SendMessage(hEdit, EM_SETEVENTMASK, 0, (LPARAM)dwEvent); 
     451 
     452    //SetLayeredWindowAttributes(w, 0, 200, LWA_ALPHA); 
     453 
     454    // �^�X�N�g���C�p�̃A�C�R���̍쐬 
     455    NOTIFYICONDATA connectingIcon = {}; 
     456        connectingIcon.cbSize = sizeof(connectingIcon); 
     457    connectingIcon.hIcon = LoadIcon(get_hInstance(), _T("IDI_ICON1")); 
     458    connectingIcon.hWnd = w; 
     459    connectingIcon.uCallbackMessage = WM_USER + 10; 
     460    connectingIcon.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; 
     461    _tcscpy_s(connectingIcon.szTip, _T("")); 
     462    Shell_NotifyIcon(NIM_ADD, &connectingIcon); 
    460463} 
    461464