Mercurial > pidgin
annotate src/win32/MinimizeToTray.c @ 10462:f7b32dd67bdf
[gaim-migrate @ 11735]
Fix for bug 1027454: Blank "Unable to open socket" window if locale is not UTF-8
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Fri, 31 Dec 2004 15:34:18 +0000 |
parents | 92cbf9713795 |
children |
rev | line source |
---|---|
3630 | 1 /* MinimizeToTray |
2 * | |
3 * A couple of routines to show how to make it produce a custom caption | |
4 * animation to make it look like we are minimizing to and maximizing | |
5 * from the system tray | |
6 * | |
7 * These routines are public domain, but it would be nice if you dropped | |
8 * me a line if you use them! | |
9 * | |
10 * 1.0 29.06.2000 Initial version | |
11 * 1.1 01.07.2000 The window retains it's place in the Z-order of windows | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
3957
diff
changeset
|
12 * when minimized/hidden. This means that when restored/shown, it doesn't |
3630 | 13 * always appear as the foreground window unless we call SetForegroundWindow |
14 * | |
15 * Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com> | |
16 */ | |
17 #include "stdafx.h" | |
18 | |
19 #ifndef IDANI_OPEN | |
20 #define IDANI_OPEN 1 | |
21 #endif | |
22 #ifndef IDANI_CLOSE | |
23 #define IDANI_CLOSE 2 | |
24 #endif | |
25 #ifndef IDANI_CAPTION | |
26 #define IDANI_CAPTION 3 | |
27 #endif | |
28 | |
29 #define DEFAULT_RECT_WIDTH 150 | |
30 #define DEFAULT_RECT_HEIGHT 30 | |
31 | |
32 static void GetTrayWndRect(LPRECT lpTrayRect) | |
33 { | |
34 APPBARDATA appBarData; | |
35 HWND hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); | |
36 | |
37 if(hShellTrayWnd) | |
38 { | |
39 HWND hTrayNotifyWnd=FindWindowEx(hShellTrayWnd,NULL,TEXT("TrayNotifyWnd"),NULL); | |
40 if(hTrayNotifyWnd) | |
41 { | |
42 GetWindowRect(hTrayNotifyWnd,lpTrayRect); | |
43 return; | |
44 } | |
45 } | |
46 | |
47 appBarData.cbSize=sizeof(appBarData); | |
48 if(SHAppBarMessage(ABM_GETTASKBARPOS,&appBarData)) | |
49 { | |
50 switch(appBarData.uEdge) | |
51 { | |
52 case ABE_LEFT: | |
53 case ABE_RIGHT: | |
54 lpTrayRect->top=appBarData.rc.bottom-100; | |
55 lpTrayRect->bottom=appBarData.rc.bottom-16; | |
56 lpTrayRect->left=appBarData.rc.left; | |
57 lpTrayRect->right=appBarData.rc.right; | |
58 break; | |
59 | |
60 case ABE_TOP: | |
61 case ABE_BOTTOM: | |
62 lpTrayRect->top=appBarData.rc.top; | |
63 lpTrayRect->bottom=appBarData.rc.bottom; | |
64 lpTrayRect->left=appBarData.rc.right-100; | |
65 lpTrayRect->right=appBarData.rc.right-16; | |
66 break; | |
67 } | |
68 | |
69 return; | |
70 } | |
71 | |
72 hShellTrayWnd=FindWindowEx(NULL,NULL,TEXT("Shell_TrayWnd"),NULL); | |
73 if(hShellTrayWnd) | |
74 { | |
75 GetWindowRect(hShellTrayWnd,lpTrayRect); | |
76 if(lpTrayRect->right-lpTrayRect->left>DEFAULT_RECT_WIDTH) | |
77 lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; | |
78 if(lpTrayRect->bottom-lpTrayRect->top>DEFAULT_RECT_HEIGHT) | |
79 lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; | |
80 | |
81 return; | |
82 } | |
83 | |
84 SystemParametersInfo(SPI_GETWORKAREA,0,lpTrayRect,0); | |
85 lpTrayRect->left=lpTrayRect->right-DEFAULT_RECT_WIDTH; | |
86 lpTrayRect->top=lpTrayRect->bottom-DEFAULT_RECT_HEIGHT; | |
87 } | |
88 | |
89 static int GetDoAnimateMinimize(void) | |
90 { | |
91 ANIMATIONINFO ai; | |
92 | |
93 ai.cbSize=sizeof(ai); | |
94 SystemParametersInfo(SPI_GETANIMATION,sizeof(ai),&ai,0); | |
95 | |
96 return ai.iMinAnimate?TRUE:FALSE; | |
97 } | |
98 | |
99 void MinimizeWndToTray(HWND hWnd) | |
100 { | |
3957
7e384ded0d4e
[gaim-migrate @ 4139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
101 if(!IsWindowVisible(hWnd)) |
7e384ded0d4e
[gaim-migrate @ 4139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
102 return; |
3630 | 103 if(GetDoAnimateMinimize()) |
104 { | |
105 RECT rcFrom,rcTo; | |
106 | |
107 GetWindowRect(hWnd,&rcFrom); | |
108 GetTrayWndRect(&rcTo); | |
109 | |
110 DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); | |
111 } | |
112 | |
113 ShowWindow(hWnd,SW_HIDE); | |
114 } | |
115 | |
116 void RestoreWndFromTray(HWND hWnd) | |
117 { | |
3957
7e384ded0d4e
[gaim-migrate @ 4139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
118 if(IsWindowVisible(hWnd)) |
7e384ded0d4e
[gaim-migrate @ 4139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
119 return; |
3630 | 120 if(GetDoAnimateMinimize()) |
121 { | |
122 RECT rcFrom,rcTo; | |
123 GetTrayWndRect(&rcFrom); | |
124 GetWindowRect(hWnd,&rcTo); | |
125 | |
126 DrawAnimatedRects(hWnd,IDANI_CAPTION,&rcFrom,&rcTo); | |
127 } | |
128 | |
129 ShowWindow(hWnd,SW_SHOW); | |
130 SetActiveWindow(hWnd); | |
131 SetForegroundWindow(hWnd); | |
132 } | |
133 | |
134 | |
135 |