Tue, 14 Feb 2006 05:43:43 +0000
[gaim-migrate @ 15646]
Always show a vertical scrollbar on conversations imhtmls. This will solve the shrinking conversation window bug. I chose this approach instead of saving the size of the window (as I had previous talked about), as this prevents the contents of the scrollback from rewrapping when the scrollbars appear or disappear. It also just seems to feel like the right thing to do, but maybe that's me being lazy.
| 11709 | 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 doesn't | |
| 13 | * always appear as the foreground window unless we call SetForegroundWindow | |
| 14 | * | |
| 15 | * Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com> | |
| 16 | */ | |
|
11845
7dc7b5b05a9a
[gaim-migrate @ 14136]
Daniel Atallah <datallah@pidgin.im>
parents:
11709
diff
changeset
|
17 | #include <windows.h> |
| 11709 | 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 | { | |
| 101 | if(!IsWindowVisible(hWnd)) | |
| 102 | return; | |
| 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 | { | |
| 118 | if(IsWindowVisible(hWnd)) | |
| 119 | return; | |
| 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 |