Mercurial > pidgin
annotate src/win32/MinimizeToTray.c @ 4891:cfa045006bec
[gaim-migrate @ 5221]
this saves the blist.xml file to an alternate name, and then moves it, that
way we don't lose your precious buddies if gaim crashes.
Of course, if gaim were to crash, it wouldn't be gaim's fault, it would be
the fault of some external force. This is because gaim is perfect, and
Sean is perfect. Yeah.
This should be done for .gaimrc too, but i'm too tired to do that right now.
committer: Tailor Script <tailor@pidgin.im>
| author | Nathan Walp <nwalp@pidgin.im> |
|---|---|
| date | Tue, 25 Mar 2003 06:35:45 +0000 |
| parents | 7e384ded0d4e |
| children | 92cbf9713795 |
| 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 | |
| 12 * when minimized/hidden. This means that when restored/shown, it doen't | |
| 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 |
