Mercurial > pidgin
annotate plugins/docklet/MinimizeToTray.c @ 19809:b488205ad0bc
[gaim-migrate @ 16884]
chat function ok
debugging the multiple soap request in one ssl connection
not stable.
comitted by MaYuan<mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
author | Ma Yuan <mayuan2006@gmail.com> |
---|---|
date | Sat, 19 Aug 2006 14:12:41 +0000 |
parents | 6de39a8cc2c1 |
children |
rev | line source |
---|---|
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
1 /* MinimizeToTray |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
2 * |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
3 * A couple of routines to show how to make it produce a custom caption |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
4 * animation to make it look like we are minimizing to and maximizing |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
5 * from the system tray |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
6 * |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
7 * These routines are public domain, but it would be nice if you dropped |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
8 * me a line if you use them! |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
9 * |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
10 * 1.0 29.06.2000 Initial version |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
11 * 1.1 01.07.2000 The window retains it's place in the Z-order of windows |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
12 * when minimized/hidden. This means that when restored/shown, it doesn't |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
13 * always appear as the foreground window unless we call SetForegroundWindow |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
14 * |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
15 * Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com> |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
16 */ |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
17 #define _WIN32_WINNT 0x0500 |
11845
9beb663a6fb5
[gaim-migrate @ 14136]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11709
diff
changeset
|
18 #include <windows.h> |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
19 #include "MinimizeToTray.h" |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
20 |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
21 #define DEFAULT_RECT_WIDTH 150 |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
22 #define DEFAULT_RECT_HEIGHT 30 |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
23 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
24 static void GetTrayWndRect(LPRECT lpTrayRect) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
25 APPBARDATA appBarData; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
26 HWND hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
27 NULL); |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
28 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
29 if(hShellTrayWnd) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
30 HWND hTrayNotifyWnd = FindWindowEx(hShellTrayWnd, NULL, |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
31 TEXT("TrayNotifyWnd"), NULL); |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
32 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
33 if(hTrayNotifyWnd) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
34 GetWindowRect(hTrayNotifyWnd,lpTrayRect); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
35 return; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
36 } |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
37 } |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
38 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
39 appBarData.cbSize = sizeof(appBarData); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
40 if(SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData)) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
41 switch(appBarData.uEdge) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
42 case ABE_LEFT: |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
43 case ABE_RIGHT: |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
44 lpTrayRect->top = appBarData.rc.bottom - 100; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
45 lpTrayRect->bottom = appBarData.rc.bottom - 16; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
46 lpTrayRect->left = appBarData.rc.left; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
47 lpTrayRect->right = appBarData.rc.right; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
48 break; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
49 case ABE_TOP: |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
50 case ABE_BOTTOM: |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
51 lpTrayRect->top = appBarData.rc.top; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
52 lpTrayRect->bottom = appBarData.rc.bottom; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
53 lpTrayRect->left = appBarData.rc.right - 100; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
54 lpTrayRect->right = appBarData.rc.right - 16; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
55 break; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
56 } |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
57 return; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
58 } |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
59 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
60 hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), NULL); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
61 if(hShellTrayWnd) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
62 GetWindowRect(hShellTrayWnd, lpTrayRect); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
63 if(lpTrayRect->right-lpTrayRect->left > DEFAULT_RECT_WIDTH) |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
64 lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
65 if(lpTrayRect->bottom-lpTrayRect->top > DEFAULT_RECT_HEIGHT) |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
66 lpTrayRect->top=lpTrayRect->bottom - DEFAULT_RECT_HEIGHT; |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
67 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
68 return; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
69 } |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
70 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
71 SystemParametersInfo(SPI_GETWORKAREA, 0, lpTrayRect, 0); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
72 lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
73 lpTrayRect->top = lpTrayRect->bottom - DEFAULT_RECT_HEIGHT; |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
74 } |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
75 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
76 static BOOL GetDoAnimateMinimize(void) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
77 ANIMATIONINFO ai; |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
78 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
79 ai.cbSize = sizeof(ai); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
80 SystemParametersInfo(SPI_GETANIMATION, sizeof(ai), &ai, 0); |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
81 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
82 return ai.iMinAnimate ? TRUE : FALSE; |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
83 } |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
84 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
85 void MinimizeWndToTray(HWND hWnd) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
86 |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
87 if(!IsWindowVisible(hWnd)) |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
88 return; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
89 |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
90 if(GetDoAnimateMinimize()) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
91 RECT rcFrom, rcTo; |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
92 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
93 GetWindowRect(hWnd, &rcFrom); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
94 GetTrayWndRect(&rcTo); |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
95 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
96 DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
97 } |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
98 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
99 ShowWindow(hWnd, SW_HIDE); |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
100 } |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
101 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
102 void RestoreWndFromTray(HWND hWnd) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
103 |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
104 if(IsWindowVisible(hWnd)) |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
105 return; |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
106 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
107 if(GetDoAnimateMinimize()) { |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
108 RECT rcFrom, rcTo; |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
109 GetTrayWndRect(&rcFrom); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
110 GetWindowRect(hWnd, &rcTo); |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
111 |
13432
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
112 DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
113 } |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
114 |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
115 ShowWindow(hWnd, SW_SHOW); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
116 SetActiveWindow(hWnd); |
6de39a8cc2c1
[gaim-migrate @ 15807]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11845
diff
changeset
|
117 SetForegroundWindow(hWnd); |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
118 } |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff
changeset
|
119 |