Esempio n. 1
0
void ToggleState() {
    if (ENABLED()) {
        UnhookSystem();
    }
    else {
        SendMessage(g_hwnd, WM_UPDATESETTINGS, 0, 0);
        HookSystem();
    }
}
Esempio n. 2
0
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    if (msg == WM_DESTROY || msg == WM_QUERYENDSESSION) {
        showerror = 0;
        UnhookSystem();
        PostQuitMessage(0);
    }
    else if (msg == WM_TIMER) {
        // Exit if AltDrag is not running
        if (FindWindow(APP_NAME,NULL) == NULL) {
            SendMessage(hwnd, WM_CLOSE, 0, 0);
        }
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}
Esempio n. 3
0
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    if (msg == WM_TRAY) {
        if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) {
            ToggleState();
            if (lParam == WM_LBUTTONDBLCLK && !(GetAsyncKeyState(VK_SHIFT)&0x8000)) {
                SendMessage(hwnd, WM_OPENCONFIG, 0, 0);
            }
        }
        else if (lParam == WM_MBUTTONDOWN) {
            ShellExecute(NULL, L"open", inipath, NULL, NULL, SW_SHOWNORMAL);
        }
        else if (lParam == WM_RBUTTONDOWN) {
            ShowContextMenu(hwnd);
        }
        else if (lParam == NIN_BALLOONUSERCLICK) {
            hide = 0;
            SendMessage(hwnd, WM_COMMAND, SWM_UPDATE, 0);
        }
        else if (lParam == NIN_BALLOONTIMEOUT) {
            if (hide) {
                RemoveTray();
            }
        }
    }
    else if (msg == WM_UPDATESETTINGS) {
        UpdateLanguage();
        // Reload hooks
        if (ENABLED()) {
            UnhookSystem();
            HookSystem();
        }
        // Reload config language
        if (!wParam && IsWindow(g_cfgwnd)) {
            SendMessage(g_cfgwnd, WM_UPDATESETTINGS, 0, 0);
        }
    }
    else if (msg == WM_ADDTRAY) {
        hide = 0;
        UpdateTray();
    }
    else if (msg == WM_HIDETRAY) {
        hide = 1;
        RemoveTray();
    }
    else if (msg == WM_OPENCONFIG && (lParam || !hide)) {
        OpenConfig(wParam);
    }
    else if (msg == WM_CLOSECONFIG) {
        CloseConfig();
    }
    else if (msg == WM_TASKBARCREATED) {
        tray_added = 0;
        UpdateTray();
    }
    else if (msg == WM_COMMAND) {
        int wmId=LOWORD(wParam), wmEvent=HIWORD(wParam);
        if (wmId == SWM_TOGGLE) {
            ToggleState();
        }
        else if (wmId == SWM_HIDE) {
            hide = 1;
            RemoveTray();
        }
        else if (wmId == SWM_UPDATE) {
            if (MessageBox(NULL,l10n->update_dialog,APP_NAME,MB_ICONINFORMATION|MB_YESNO|MB_TOPMOST|MB_SETFOREGROUND) == IDYES) {
                OpenUrl(APP_URL);
            }
        }
        else if (wmId == SWM_CONFIG) {
            SendMessage(hwnd, WM_OPENCONFIG, 0, 0);
        }
        else if (wmId == SWM_ABOUT) {
            SendMessage(hwnd, WM_OPENCONFIG, 4, 0);
        }
        else if (wmId == SWM_EXIT) {
            DestroyWindow(hwnd);
        }
    }
    else if (msg == WM_QUERYENDSESSION && msghook) {
        showerror = 0;
        UnhookSystem();
    }
    else if (msg == WM_DESTROY) {
        showerror = 0;
        UnhookSystem();
        RemoveTray();
        PostQuitMessage(0);
    }
    else if (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
        // Hide cursorwnd if clicked on, this might happen if it wasn't hidden by hooks.c for some reason
        ShowWindow(hwnd, SW_HIDE);
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}