xref: /reactos/base/applications/sndvol32/tray.c (revision 8540ab04)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS Sound Volume Control
4  * FILE:        base/applications/sndvol32/tray.c
5  * PROGRAMMERS: Eric Kohl <eric.kohl@reactos.org>
6  */
7 
8 #include "sndvol32.h"
9 
10 static VOID
11 OnTrayInitDialog(
12     HWND hwnd,
13     WPARAM wParam,
14     LPARAM lParam)
15 {
16     POINT ptCursor;
17     RECT rcWindow;
18     RECT rcScreen;
19     LONG x, y, cx, cy;
20 
21     GetCursorPos(&ptCursor);
22 
23     GetWindowRect(hwnd, &rcWindow);
24 
25     GetWindowRect(GetDesktopWindow(), &rcScreen);
26 
27     cx = rcWindow.right - rcWindow.left;
28     cy = rcWindow.bottom - rcWindow.top;
29 
30     if (ptCursor.y + cy > rcScreen.bottom)
31         y = ptCursor.y - cy;
32     else
33         y = ptCursor.y;
34 
35     if (ptCursor.x + cx > rcScreen.right)
36         x = ptCursor.x - cx;
37     else
38         x = ptCursor.x;
39 
40     SetWindowPos(hwnd, HWND_TOPMOST, x, y, 0, 0, SWP_NOSIZE);
41 
42     /* Disable the controls for now */
43     EnableWindow(GetDlgItem(hwnd, IDC_LINE_SLIDER_VERT), FALSE);
44     EnableWindow(GetDlgItem(hwnd, IDC_LINE_SWITCH), FALSE);
45 }
46 
47 
48 INT_PTR
49 CALLBACK
50 TrayDlgProc(
51     HWND hwndDlg,
52     UINT uMsg,
53     WPARAM wParam,
54     LPARAM lParam)
55 {
56     switch (uMsg)
57     {
58         case WM_INITDIALOG:
59             OnTrayInitDialog(hwndDlg, wParam, lParam);
60             break;
61 
62         case WM_ACTIVATE:
63             if (LOWORD(wParam) == WA_INACTIVE)
64                 EndDialog(hwndDlg, IDOK);
65             break;
66     }
67 
68     return 0;
69 }
70 
71 /* EOF */
72