Changeset 496
- Timestamp:
- Aug 14, 1999, 6:13:16 PM (26 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/comctl32/animate.c ¶
r94 r496 1 /* $Id: animate.c,v 1. 3 1999-06-10 16:21:57 achimhaExp $ */1 /* $Id: animate.c,v 1.4 1999-08-14 16:13:09 cbratschi Exp $ */ 2 2 /* 3 3 * Animation control … … 34 34 hrsrc = FindResourceA (hInst, lpName, "AVI"); 35 35 if (!hrsrc) 36 36 return FALSE; 37 37 38 38 handle = LoadResource (hInst, hrsrc); 39 39 if (!handle) 40 40 return FALSE; 41 41 42 42 infoPtr->lpAvi = LockResource (handle); 43 43 if (!infoPtr->lpAvi) 44 44 return FALSE; 45 45 46 46 return TRUE; … … 54 54 55 55 infoPtr->hFile = 56 57 56 CreateFileA (lpName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 57 FILE_ATTRIBUTE_NORMAL, 0); 58 58 if (!infoPtr->hFile) 59 59 return FALSE; 60 60 61 61 handle = 62 63 62 CreateFileMappingA (infoPtr->hFile, NULL, PAGE_READONLY | SEC_COMMIT, 63 0, 0, NULL); 64 64 if (!handle) { 65 66 67 65 CloseHandle (infoPtr->hFile); 66 infoPtr->hFile = 0; 67 return FALSE; 68 68 } 69 69 70 70 infoPtr->lpAvi = MapViewOfFile (handle, FILE_MAP_READ, 0, 0, 0); 71 71 if (!infoPtr->lpAvi) { 72 73 74 72 CloseHandle (infoPtr->hFile); 73 infoPtr->hFile = 0; 74 return FALSE; 75 75 } 76 76 … … 83 83 { 84 84 if (infoPtr->hFile) { 85 86 87 85 UnmapViewOfFile (infoPtr->lpAvi); 86 CloseHandle (infoPtr->hFile); 87 infoPtr->lpAvi = NULL; 88 88 } 89 89 else { 90 91 90 GlobalFree ((HGLOBAL)infoPtr->lpAvi); 91 infoPtr->lpAvi = NULL; 92 92 } 93 93 } … … 111 111 112 112 if (!lParam) { 113 // 114 115 } 116 113 // TRACE (animate, "closing avi!\n"); 114 return TRUE; 115 } 116 117 117 if (HIWORD(lParam)) { 118 // 119 120 121 122 // 123 124 125 126 // 127 128 // 129 130 131 // 132 133 134 118 // FIXME (animate, "(\"%s\") empty stub!\n", (LPSTR)lParam); 119 120 if (ANIMATE_LoadResA (infoPtr, hInstance, (LPSTR)lParam)) { 121 122 // FIXME (animate, "AVI resource found!\n"); 123 124 } 125 else { 126 // FIXME (animate, "No AVI resource found!\n"); 127 if (ANIMATE_LoadFileA (infoPtr, (LPSTR)lParam)) { 128 // FIXME (animate, "AVI file found!\n"); 129 } 130 else { 131 // FIXME (animate, "No AVI file found!\n"); 132 return FALSE; 133 } 134 } 135 135 } 136 136 else { 137 // 138 139 140 141 // 142 143 144 // 145 146 137 // FIXME (animate, "(%u) empty stub!\n", (WORD)LOWORD(lParam)); 138 139 if (ANIMATE_LoadResA (infoPtr, hInstance, 140 MAKEINTRESOURCEA((INT)lParam))) { 141 // FIXME (animate, "AVI resource found!\n"); 142 } 143 else { 144 // FIXME (animate, "No AVI resource found!\n"); 145 return FALSE; 146 } 147 147 } 148 148 … … 167 167 /* nothing opened */ 168 168 if (...) 169 169 return FALSE; 170 170 #endif 171 171 172 172 if (nRepeat == -1) { 173 173 174 // 175 // 174 // FIXME (animate, "(loop from=%d to=%d) empty stub!\n", 175 // nFrom, nTo); 176 176 177 177 } 178 178 else { 179 179 180 // 181 // 180 // FIXME (animate, "(repeat=%d from=%d to=%d) empty stub!\n", 181 // nRepeat, nFrom, nTo); 182 182 183 183 } … … 196 196 /* nothing opened */ 197 197 if (...) 198 198 return FALSE; 199 199 #endif 200 200 201 201 return TRUE; 202 202 } … … 212 212 infoPtr = (ANIMATE_INFO *)COMCTL32_Alloc (sizeof(ANIMATE_INFO)); 213 213 if (!infoPtr) { 214 // 215 214 // ERR (animate, "could not allocate info memory!\n"); 215 return 0; 216 216 } 217 217 … … 262 262 263 263 264 LRESULT WINAPI264 static LRESULT WINAPI 265 265 ANIMATE_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 266 266 { 267 267 switch (uMsg) 268 268 { 269 270 271 272 /* 273 /* 269 case ACM_OPENA: 270 return ANIMATE_OpenA (hwnd, wParam, lParam); 271 272 /* case ACM_OPEN32W: */ 273 /* return ANIMATE_Open32W (hwnd, wParam, lParam); */ 274 274 275 275 case ACM_PLAY: 276 276 return ANIMATE_Play (hwnd, wParam, lParam); 277 277 278 279 280 281 282 283 284 285 286 287 288 /* 289 /* 290 291 /* 292 /* 293 /* 294 /* 295 /* 296 /* 297 298 299 // 300 // 301 // 302 278 case ACM_STOP: 279 return ANIMATE_Stop (hwnd, wParam, lParam); 280 281 282 case WM_CREATE: 283 return ANIMATE_Create (hwnd, wParam, lParam); 284 285 case WM_DESTROY: 286 return ANIMATE_Destroy (hwnd, wParam, lParam); 287 288 /* case WM_ERASEBKGND: */ 289 /* return ANIMATE_EraseBackground (hwnd, wParam, lParam); */ 290 291 /* case WM_NCCREATE: */ 292 /* case WM_NCHITTEST: */ 293 /* case WM_PAINT: */ 294 /* case WM_SIZE: */ 295 /* case WM_STYLECHANGED: */ 296 /* case WM_TIMER: */ 297 298 default: 299 // if (uMsg >= WM_USER) 300 // ERR (animate, "unknown msg %04x wp=%08x lp=%08lx\n", 301 // uMsg, wParam, lParam); 302 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 303 303 } 304 304 return 0; … … 321 321 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); 322 322 wndClass.lpszClassName = ANIMATE_CLASSA; 323 323 324 324 RegisterClassA (&wndClass); 325 325 } … … 330 330 { 331 331 if (GlobalFindAtomA (ANIMATE_CLASSA)) 332 333 } 334 332 UnregisterClassA (ANIMATE_CLASSA, (HINSTANCE)NULL); 333 } 334 -
TabularUnified trunk/src/comctl32/comboex.c ¶
r94 r496 1 /* $Id: comboex.c,v 1. 3 1999-06-10 16:21:57 achimhaExp $ */1 /* $Id: comboex.c,v 1.4 1999-08-14 16:13:09 cbratschi Exp $ */ 2 2 /* 3 3 * ComboBoxEx control … … 16 16 * 17 17 * FIXME: 18 * - should include "combo.h" 18 * - should include "combo.h" 19 19 */ 20 20 … … 50 50 51 51 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN) 52 52 return 0; 53 53 54 54 // TRACE (comboex, "-- 0x%x\n", GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT)); … … 103 103 104 104 if ((DWORD)wParam) { 105 105 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam; 106 106 } 107 107 else 108 108 infoPtr->dwExtStyle = (DWORD)lParam; 109 109 110 110 /* FIXME: repaint?? */ … … 150 150 // FIXME (comboex, "(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam); 151 151 152 if (infoPtr->hwndCombo) 153 152 if (infoPtr->hwndCombo) 153 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam); 154 154 155 155 return 0; … … 166 166 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO)); 167 167 if (infoPtr == NULL) { 168 // 169 168 // ERR (comboex, "could not allocate info memory!\n"); 169 return 0; 170 170 } 171 171 … … 178 178 /* create combo box */ 179 179 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) & 180 180 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD); 181 181 182 182 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "", 183 184 185 183 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle, 184 0, 0, 0, 0, hwnd, (HMENU)1, 185 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL); 186 186 187 187 return 0; … … 196 196 197 197 if (infoPtr->hwndCombo) 198 198 DestroyWindow (infoPtr->hwndCombo); 199 199 200 200 … … 217 217 218 218 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left, 219 220 221 return 0; 222 } 223 224 225 LRESULT WINAPI219 rect.bottom - rect.top, TRUE); 220 221 return 0; 222 } 223 224 225 static LRESULT WINAPI 226 226 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 227 227 { 228 228 switch (uMsg) 229 229 { 230 /* 231 232 233 234 235 236 237 238 239 240 241 242 243 244 /* 245 246 247 230 /* case CBEM_DELETEITEM: */ 231 232 case CBEM_GETCOMBOCONTROL: 233 return COMBOEX_GetComboControl (hwnd, wParam, lParam); 234 235 case CBEM_GETEDITCONTROL: 236 return COMBOEX_GetEditControl (hwnd, wParam, lParam); 237 238 case CBEM_GETEXTENDEDSTYLE: 239 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam); 240 241 case CBEM_GETIMAGELIST: 242 return COMBOEX_GetImageList (hwnd, wParam, lParam); 243 244 /* case CBEM_GETITEM32A: 245 case CBEM_GETITEM32W: 246 case CBEM_GETUNICODEFORMAT: 247 case CBEM_HASEDITCHANGED: 248 248 */ 249 249 250 251 252 253 /* 254 255 256 257 258 259 260 261 262 263 264 /* 265 250 case CBEM_INSERTITEMA: 251 return COMBOEX_InsertItemA (hwnd, wParam, lParam); 252 253 /* case CBEM_INSERTITEM32W: */ 254 255 case CBEM_SETEXTENDEDSTYLE: 256 return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam); 257 258 case CBEM_SETIMAGELIST: 259 return COMBOEX_SetImageList (hwnd, wParam, lParam); 260 261 case CBEM_SETITEMA: 262 return COMBOEX_SetItemA (hwnd, wParam, lParam); 263 264 /* case CBEM_SETITEM32W: 265 case CBEM_SETUNICODEFORMAT: 266 266 */ 267 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 // 302 // 303 // 304 268 case CB_DELETESTRING: 269 case CB_FINDSTRINGEXACT: 270 case CB_GETCOUNT: 271 case CB_GETCURSEL: 272 case CB_GETDROPPEDCONTROLRECT: 273 case CB_GETDROPPEDSTATE: 274 case CB_GETITEMDATA: 275 case CB_GETITEMHEIGHT: 276 case CB_GETLBTEXT: 277 case CB_GETLBTEXTLEN: 278 case CB_GETEXTENDEDUI: 279 case CB_LIMITTEXT: 280 case CB_RESETCONTENT: 281 case CB_SELECTSTRING: 282 case CB_SETCURSEL: 283 case CB_SETDROPPEDWIDTH: 284 case CB_SETEXTENDEDUI: 285 case CB_SETITEMDATA: 286 case CB_SETITEMHEIGHT: 287 case CB_SHOWDROPDOWN: 288 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam); 289 290 291 case WM_CREATE: 292 return COMBOEX_Create (hwnd, wParam, lParam); 293 294 case WM_DESTROY: 295 return COMBOEX_Destroy (hwnd, wParam, lParam); 296 297 case WM_SIZE: 298 return COMBOEX_Size (hwnd, wParam, lParam); 299 300 default: 301 // if (uMsg >= WM_USER) 302 // ERR (comboex, "unknown msg %04x wp=%08x lp=%08lx\n", 303 // uMsg, wParam, lParam); 304 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 305 305 } 306 306 return 0; … … 323 323 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 324 324 wndClass.lpszClassName = WC_COMBOBOXEXA; 325 325 326 326 RegisterClassA (&wndClass); 327 327 } … … 332 332 { 333 333 if (GlobalFindAtomA (WC_COMBOBOXEXA)) 334 335 } 336 334 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL); 335 } 336 -
TabularUnified trunk/src/comctl32/comctl32.def ¶
r144 r496 1 ; $Id: comctl32.def,v 1.1 0 1999-06-21 13:59:00 sandervlExp $1 ; $Id: comctl32.def,v 1.11 1999-08-14 16:13:09 cbratschi Exp $ 2 2 LIBRARY COMCTL32 INITINSTANCE 3 3 DESCRIPTION 'COMCTL32 Common Controls Library' … … 99 99 DSA_InsertItem = _DSA_InsertItem@12 @325 100 100 DSA_DeleteItem = _DSA_DeleteItem@8 @326 101 DSA_DeleteAllItems = _DSA_DeleteAllItems@4 @327 101 DSA_DeleteAllItems = _DSA_DeleteAllItems@4 @327 102 102 103 103 DPA_Create = _DPA_Create@4 @328 … … 136 136 StrStrW = _COMCTL32_StrStrW@8 @362 137 137 StrSpnW = _COMCTL32_StrSpnW@8 @364 138 139 comctl32_410 = _comctl32_410@16 @410 140 InitMUILanguage = _InitMUILanguage@4 @500 ;should be 70 -
TabularUnified trunk/src/comctl32/comctl32.h ¶
r94 r496 1 /* $Id: comctl32.h,v 1. 6 1999-06-10 16:21:58 achimhaExp $ */1 /* $Id: comctl32.h,v 1.7 1999-08-14 16:13:10 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 common controls implementation … … 67 67 #define IDC_MOVEDN_BTN 207 68 68 69 /* Toolbar imagelist bitmaps */ 70 #define IDB_STD_SMALL 120 71 #define IDB_STD_LARGE 121 72 #define IDB_VIEW_SMALL 124 73 #define IDB_VIEW_LARGE 125 74 #define IDB_HIST_SMALL 130 75 #define IDB_HIST_LARGE 131 76 77 78 /* Month calendar month menu popup */ 79 #define IDD_MCMONTHMENU 300 80 81 #define IDM_JAN 301 82 #define IDM_FEB 302 83 #define IDM_MAR 303 84 #define IDM_APR 304 85 #define IDM_MAY 305 86 #define IDM_JUN 306 87 #define IDM_JUL 307 88 #define IDM_AUG 308 89 #define IDM_SEP 309 90 #define IDM_OCT 310 91 #define IDM_NOV 311 92 #define IDM_DEC 312 69 93 70 94 #endif /* _H_COMCTL32 */ -
TabularUnified trunk/src/comctl32/comctl32undoc.c ¶
r403 r496 1 /* $Id: comctl32undoc.c,v 1. 9 1999-08-03 15:49:58cbratschi Exp $ */1 /* $Id: comctl32undoc.c,v 1.10 1999-08-14 16:13:10 cbratschi Exp $ */ 2 2 /* 3 3 * Undocumented functions from COMCTL32.DLL … … 45 45 PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam) 46 46 { 47 INT nCount; 48 49 #if 0 /* these go with the "incomplete implementation" below */ 47 50 LPVOID pWork1, pWork2; 48 51 INT nResult; 49 INT n Count, nIndex;52 INT nIndex; 50 53 INT nNewItems; 54 #endif 51 55 52 56 // TRACE (commctrl, "(%p %p %08lx %p %p %08lx): stub!\n", … … 1894 1898 // return (INT)(lpLoop-lpStr); 1895 1899 } 1900 1901 /************************************************************************** 1902 * comctl32_410 [COMCTL32.410] 1903 * 1904 * FIXME: What's this supposed to do? 1905 * Parameter 1 is an HWND, you're on your own for the rest. 1906 */ 1907 1908 BOOL WINAPI comctl32_410( HWND hw, DWORD b, DWORD c, DWORD d) { 1909 1910 //FIXME_(commctrl)("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d); 1911 1912 return TRUE; 1913 } 1914 1915 /************************************************************************* 1916 * InitMUILanguage [COMCTL32.70] 1917 * 1918 * FIXME: What's this supposed to do? Apparently some i18n thing. 1919 * 1920 */ 1921 1922 BOOL WINAPI InitMUILanguage( DWORD a ) { 1923 1924 //FIXME_(commctrl)("(%lx): stub!\n", a); 1925 1926 return TRUE; 1927 } 1928 -
TabularUnified trunk/src/comctl32/datetime.c ¶
r94 r496 1 /* $Id: datetime.c,v 1. 3 1999-06-10 16:21:58 achimhaExp $ */1 /* $Id: datetime.c,v 1.4 1999-08-14 16:13:10 cbratschi Exp $ */ 2 2 /* 3 3 * Date and time picker control 4 4 * 5 5 * Copyright 1998, 1999 Eric Kohl 6 * Copyright 1999 Alex Priem <alexp@sci.kun.nl> 6 7 * Copyright 1999 Achim Hasenmueller 8 * Copyright 1999 Christoph Bratschi 7 9 * 8 * NOTES9 * This is just a dummy control. An author is needed! Any volunteers?10 * I will only improve this control once in a while.11 * Eric <ekohl@abo.rhein-zeitung.de>12 10 * 13 11 * TODO: … … 20 18 #include "commctrl.h" 21 19 #include "datetime.h" 22 20 #include "monthcal.h" 21 #include <string.h> 22 #include <stdio.h> 23 23 24 24 25 25 #define DATETIME_GetInfoPtr(hwnd) ((DATETIME_INFO *)GetWindowLongA (hwnd, 0)) 26 static BOOL 27 28 DATETIME_SendSimpleNotify (HWND hwnd, UINT code); 29 30 static char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", 31 "Thursday", "Friday", "Saturday", NULL}; 32 33 static char *monthtxt[] = {"January", "February", "March", "April", "May", 34 "June", "July", "August", "September", "October", 35 "November", "December"}; 36 37 static LRESULT 38 DATETIME_GetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam ) 39 { 40 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 41 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 42 SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam; 43 44 if (!lParam) return GDT_NONE; 45 46 if ((dwStyle & DTS_SHOWNONE) && 47 (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0))) 48 return GDT_NONE; 49 50 MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray); 51 52 return GDT_VALID; 53 } 54 55 56 static LRESULT 57 DATETIME_SetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam ) 58 { 59 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 60 SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam; 61 62 if (!lParam) return 0; 63 64 if (lParam==GDT_VALID) 65 MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date); 66 if (lParam==GDT_NONE) { 67 infoPtr->dateValid=FALSE; 68 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 0, 0); 69 } 70 return 1; 71 } 72 73 74 static LRESULT 75 DATETIME_GetMonthCalColor (HWND hwnd, WPARAM wParam) 76 { 77 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 78 79 return SendMessageA (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0); 80 } 81 82 static LRESULT 83 DATETIME_SetMonthCalColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 84 { 85 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 86 87 return SendMessageA (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam); 88 } 89 90 91 /* FIXME: need to get way to force font into monthcal structure */ 92 93 static LRESULT 94 DATETIME_GetMonthCal (HWND hwnd) 95 { 96 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 97 98 return infoPtr->hMonthCal; 99 } 100 101 102 103 /* FIXME: need to get way to force font into monthcal structure */ 104 105 static LRESULT 106 DATETIME_GetMonthCalFont (HWND hwnd) 107 { 108 109 return 0; 110 } 111 112 static LRESULT 113 DATETIME_SetMonthCalFont (HWND hwnd, WPARAM wParam, LPARAM lParam) 114 { 115 116 return 0; 117 } 118 119 120 static void DATETIME_Refresh (HWND hwnd, HDC hdc) 121 122 { 123 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 124 RECT *daytxt = &infoPtr->daytxt; 125 RECT *daynumtxt= &infoPtr->daynumtxt; 126 RECT *rmonthtxt= &infoPtr->rmonthtxt; 127 RECT *yeartxt = &infoPtr->yeartxt; 128 RECT *calbutton= &infoPtr->calbutton; 129 RECT *checkbox = &infoPtr->checkbox; 130 RECT *rect = &infoPtr->rect; 131 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 132 SYSTEMTIME date = infoPtr->date; 133 SIZE size; 134 BOOL prssed=FALSE; 135 COLORREF oldBk; 136 137 138 139 if (infoPtr->dateValid) { 140 char txt[80]; 141 HFONT oldFont; 142 oldFont = SelectObject (hdc, infoPtr->hFont); 143 144 GetClientRect (hwnd, rect); 145 146 sprintf (txt,"%s,",days[date.wDayOfWeek]); 147 GetTextExtentPoint32A (hdc, txt, strlen (txt), &size); 148 rect->bottom=size.cy+2; 149 150 checkbox->left = 0; 151 checkbox->right = 0; 152 checkbox->top = rect->top; 153 checkbox->bottom= rect->bottom; 154 if (dwStyle & DTS_SHOWNONE) { /* FIXME: draw checkbox */ 155 checkbox->right=18; 156 } 157 158 159 if (infoPtr->select==(DTHT_DAY|DTHT_GOTFOCUS)) 160 oldBk=SetBkColor (hdc, COLOR_GRAYTEXT); 161 daytxt->left = checkbox->right; 162 daytxt->right = checkbox->right+size.cx; 163 daytxt->top = rect->top; 164 daytxt->bottom= rect->bottom; 165 DrawTextA ( hdc, txt, strlen(txt), daytxt, 166 DT_LEFT | DT_VCENTER | DT_SINGLELINE ); 167 if (infoPtr->select==(DTHT_DAY|DTHT_GOTFOCUS)) 168 SetBkColor (hdc, oldBk); 169 170 if (infoPtr->select==(DTHT_MONTH|DTHT_GOTFOCUS)) 171 oldBk=SetBkColor (hdc, COLOR_GRAYTEXT); 172 strcpy (txt, monthtxt[date.wMonth]); 173 GetTextExtentPoint32A (hdc, "September", 9, &size); 174 rmonthtxt->left = daytxt->right; 175 rmonthtxt->right = daytxt->right+size.cx; 176 rmonthtxt->top = rect->top; 177 rmonthtxt->bottom= rect->bottom; 178 DrawTextA ( hdc, txt, strlen(txt), rmonthtxt, 179 DT_CENTER | DT_VCENTER | DT_SINGLELINE ); 180 if (infoPtr->select==(DTHT_MONTH|DTHT_GOTFOCUS)) 181 SetBkColor (hdc, oldBk); 182 183 if (infoPtr->select==(DTHT_DAYNUM|DTHT_GOTFOCUS)) 184 oldBk=SetBkColor (hdc, COLOR_GRAYTEXT); 185 sprintf (txt,"%d,",date.wDay); 186 GetTextExtentPoint32A (hdc, "31,", 3, &size); 187 daynumtxt->left = rmonthtxt->right; 188 daynumtxt->right = rmonthtxt->right+size.cx; 189 daynumtxt->top = rect->top; 190 daynumtxt->bottom= rect->bottom; 191 DrawTextA ( hdc, txt, strlen(txt), daynumtxt, 192 DT_RIGHT | DT_VCENTER | DT_SINGLELINE ); 193 if (infoPtr->select==(DTHT_DAYNUM|DTHT_GOTFOCUS)) 194 SetBkColor (hdc, oldBk); 195 196 if (infoPtr->select==(DTHT_YEAR|DTHT_GOTFOCUS)) 197 oldBk=SetBkColor (hdc, COLOR_GRAYTEXT); 198 sprintf (txt,"%d",date.wYear); 199 GetTextExtentPoint32A (hdc, "2000", 5, &size); 200 yeartxt->left = daynumtxt->right; 201 yeartxt->right = daynumtxt->right+size.cx; 202 yeartxt->top = rect->top; 203 yeartxt->bottom= rect->bottom; 204 DrawTextA ( hdc, txt, strlen(txt), yeartxt, 205 DT_RIGHT | DT_VCENTER | DT_SINGLELINE ); 206 if (infoPtr->select==(DTHT_YEAR|DTHT_GOTFOCUS)) 207 SetBkColor (hdc, oldBk); 208 209 SelectObject (hdc, oldFont); 210 } 211 212 if (!(dwStyle & DTS_UPDOWN)) { 213 214 calbutton->right = rect->right; 215 calbutton->left = rect->right-15; 216 calbutton->top = rect->top; 217 calbutton->bottom= rect->bottom; 218 219 DrawFrameControl(hdc, calbutton, DFC_SCROLL, 220 DFCS_SCROLLDOWN | (prssed ? DFCS_PUSHED : 0) | 221 (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); 222 } 223 224 } 225 226 static LRESULT 227 DATETIME_HitTest (HWND hwnd, DATETIME_INFO *infoPtr, POINT pt) 228 { 229 //TRACE ("%ld, %ld\n",pt.x,pt.y); 230 231 if (PtInRect (&infoPtr->calbutton, pt)) return DTHT_MCPOPUP; 232 if (PtInRect (&infoPtr->yeartxt, pt)) return DTHT_YEAR; 233 if (PtInRect (&infoPtr->daynumtxt, pt)) return DTHT_DAYNUM; 234 if (PtInRect (&infoPtr->rmonthtxt, pt)) return DTHT_MONTH; 235 if (PtInRect (&infoPtr->daytxt, pt)) return DTHT_DAY; 236 if (PtInRect (&infoPtr->checkbox, pt)) return DTHT_CHECKBOX; 237 238 return 0; 239 } 240 241 static LRESULT 242 DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 243 { 244 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 245 POINT pt; 246 int old; 247 248 //TRACE ("\n"); 249 250 old=infoPtr->select; 251 pt.x=(INT)LOWORD(lParam); 252 pt.y=(INT)HIWORD(lParam); 253 infoPtr->select=DATETIME_HitTest (hwnd, infoPtr, pt); 254 255 if (infoPtr->select!=old) { 256 HDC hdc; 257 258 SetFocus (hwnd); 259 hdc=GetDC (hwnd); 260 DATETIME_Refresh (hwnd,hdc); 261 ReleaseDC (hwnd, hdc); 262 } 263 if (infoPtr->select==DTHT_MCPOPUP) { 264 POINT pt; 265 266 pt.x=8; 267 pt.y=infoPtr->rect.bottom+5; 268 ClientToScreen (hwnd, &pt); 269 infoPtr->hMonthCal=CreateWindowExA (0,"SysMonthCal32", 0, 270 WS_POPUP | WS_BORDER, 271 pt.x,pt.y,145,150, 272 GetParent (hwnd), 273 0,0,0); 274 275 //TRACE ("dt:%x mc:%x mc parent:%x, desktop:%x, mcpp:%x\n", 276 //hwnd,infoPtr->hMonthCal, 277 //GetParent (infoPtr->hMonthCal), 278 //GetDesktopWindow (), 279 //GetParent (GetParent (infoPtr->hMonthCal))); 280 281 SetFocus (hwnd); 282 DATETIME_SendSimpleNotify (hwnd, DTN_DROPDOWN); 283 } 284 return 0; 285 } 286 287 288 static LRESULT 289 DATETIME_Paint (HWND hwnd, WPARAM wParam) 290 { 291 HDC hdc; 292 PAINTSTRUCT ps; 293 294 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; 295 DATETIME_Refresh (hwnd, hdc); 296 if(!wParam) 297 EndPaint (hwnd, &ps); 298 return 0; 299 } 300 301 static LRESULT 302 DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam) 303 { 304 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 305 LPNMHDR lpnmh=(LPNMHDR) lParam; 306 307 //TRACE ("%x,%lx\n",wParam, lParam); 308 //TRACE ("Got notification %x from %x\n", lpnmh->code, lpnmh->hwndFrom); 309 //TRACE ("info: %x %x %x\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown); 310 return 0; 311 } 312 313 static LRESULT 314 DATETIME_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam) 315 316 { 317 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 318 LPNMHDR lpnmh=(LPNMHDR) lParam; 319 320 //TRACE ("%x,%lx\n",wParam, lParam); 321 //TRACE ("Got notification %x from %x\n", lpnmh->code, lpnmh->hwndFrom); 322 //TRACE ("info: %x %x %x\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown); 323 return 0; 324 } 325 326 static LRESULT 327 DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 328 { 329 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 330 HDC hdc; 331 332 //TRACE ("\n"); 333 334 if (infoPtr->select) { 335 DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS); 336 infoPtr->select&= ~DTHT_GOTFOCUS; 337 } 338 hdc = GetDC (hwnd); 339 DATETIME_Refresh (hwnd, hdc); 340 ReleaseDC (hwnd, hdc); 341 InvalidateRect (hwnd, NULL, TRUE); 342 343 return 0; 344 } 345 346 347 static LRESULT 348 DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 349 { 350 HDC hdc; 351 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 352 353 //TRACE ("\n"); 354 355 if (infoPtr->select) { 356 DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS); 357 infoPtr->select|=DTHT_GOTFOCUS; 358 } 359 hdc = GetDC (hwnd); 360 DATETIME_Refresh (hwnd, hdc); 361 ReleaseDC (hwnd, hdc); 362 363 return 0; 364 } 365 366 367 static BOOL 368 DATETIME_SendSimpleNotify (HWND hwnd, UINT code) 369 { 370 NMHDR nmhdr; 371 372 //TRACE("%x\n",code); 373 nmhdr.hwndFrom = hwnd; 374 nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 375 nmhdr.code = code; 376 377 return (BOOL) SendMessageA (GetParent (hwnd), WM_NOTIFY, 378 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 379 } 26 380 27 381 … … 33 387 DATETIME_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 34 388 { 35 DATETIME_INFO *infoPtr; 389 DATETIME_INFO *infoPtr; 390 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 36 391 37 392 /* allocate memory for info structure */ 38 393 infoPtr = (DATETIME_INFO *)COMCTL32_Alloc (sizeof(DATETIME_INFO)); 39 394 if (infoPtr == NULL) { 40 // ERR (datetime,"could not allocate info memory!\n");41 395 //ERR("could not allocate info memory!\n"); 396 return 0; 42 397 } 43 398 44 399 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); 45 400 401 if (dwStyle & DTS_SHOWNONE) { 402 infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0, 403 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 404 2,2,13,13, 405 hwnd, 406 0, GetWindowLongA (hwnd, GWL_HINSTANCE), 0); 407 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0); 408 } 409 410 if (dwStyle & DTS_UPDOWN) { 411 412 infoPtr->hUpdown=CreateUpDownControl ( 413 WS_CHILD | WS_BORDER | WS_VISIBLE, 414 120,1,20,20, 415 hwnd,1,0,0, 416 UD_MAXVAL, UD_MINVAL, 0); 417 } 46 418 47 419 /* initialize info structure */ 48 49 50 420 infoPtr->hMonthCal=0; 421 GetSystemTime (&infoPtr->date); 422 infoPtr->dateValid = TRUE; 423 infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT); 51 424 return 0; 52 425 } … … 58 431 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 59 432 60 /* free datetime info data */61 433 COMCTL32_Free (infoPtr); 62 63 return 0; 64 } 65 66 67 68 69 LRESULT WINAPI434 return 0; 435 } 436 437 438 439 440 441 static LRESULT WINAPI 70 442 DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 71 443 { 444 72 445 switch (uMsg) 73 446 { 74 447 75 448 case DTM_GETSYSTEMTIME: 76 // FIXME (datetime, "Unimplemented msg DTM_GETSYSTEMTIME\n"); 77 return GDT_VALID; 449 DATETIME_GetSystemTime (hwnd, wParam, lParam); 78 450 79 451 case DTM_SETSYSTEMTIME: 80 // FIXME (datetime, "Unimplemented msg DTM_SETSYSTEMTIME\n"); 452 DATETIME_SetSystemTime (hwnd, wParam, lParam); 453 454 case DTM_GETRANGE: 455 //FIXME("Unimplemented msg DTM_GETRANGE\n"); 456 return 0; 457 458 case DTM_SETRANGE: 459 //FIXME("Unimplemented msg DTM_SETRANGE\n"); 81 460 return 1; 82 461 83 case DTM_GETRANGE: 84 // FIXME (datetime, "Unimplemented msg DTM_GETRANGE\n"); 85 return 0; 86 87 case DTM_SETRANGE: 88 // FIXME (datetime, "Unimplemented msg DTM_SETRANGE\n"); 462 case DTM_SETFORMATA: 463 //FIXME("Unimplemented msg DTM_SETFORMAT32A\n"); 89 464 return 1; 90 465 91 case DTM_SETFORMAT A:92 // FIXME (datetime, "Unimplemented msg DTM_SETFORMAT32A\n");466 case DTM_SETFORMATW: 467 //FIXME("Unimplemented msg DTM_SETFORMAT32W\n"); 93 468 return 1; 94 469 95 case DTM_SETFORMATW:96 // FIXME (datetime, "Unimplemented msg DTM_SETFORMAT32W\n");97 return 1;98 99 470 case DTM_SETMCCOLOR: 100 // FIXME (datetime, "Unimplemented msg DTM_SETMCCOLOR\n"); 101 return 0; 471 return DATETIME_SetMonthCalColor (hwnd, wParam, lParam); 102 472 103 473 case DTM_GETMCCOLOR: 104 // FIXME (datetime, "Unimplemented msg DTM_GETMCCOLOR\n"); 105 return 0; 474 return DATETIME_GetMonthCalColor (hwnd, wParam); 106 475 107 476 case DTM_GETMONTHCAL: 108 // FIXME (datetime, "Unimplemented msg DTM_GETMONTHCAL\n"); 109 return 0; 477 return DATETIME_GetMonthCal (hwnd); 110 478 111 479 case DTM_SETMCFONT: 112 // FIXME (datetime, "Unimplemented msg DTM_SETMCFONT\n"); 113 return 0; 480 return DATETIME_SetMonthCalFont (hwnd, wParam, lParam); 114 481 115 482 case DTM_GETMCFONT: 116 // FIXME (datetime, "Unimplemented msg DTM_GETMCFONT\n"); 117 return 0; 118 119 case WM_CREATE: 120 return DATETIME_Create (hwnd, wParam, lParam); 121 122 case WM_DESTROY: 123 return DATETIME_Destroy (hwnd, wParam, lParam); 124 125 default: 126 // if (uMsg >= WM_USER) 127 // ERR (datetime, "unknown msg %04x wp=%08x lp=%08lx\n", 128 // uMsg, wParam, lParam); 129 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 483 return DATETIME_GetMonthCalFont (hwnd); 484 485 case WM_PARENTNOTIFY: 486 return DATETIME_ParentNotify (hwnd, wParam, lParam); 487 488 case WM_NOTIFY: 489 return DATETIME_Notify (hwnd, wParam, lParam); 490 491 case WM_PAINT: 492 return DATETIME_Paint (hwnd, wParam); 493 494 case WM_KILLFOCUS: 495 return DATETIME_KillFocus (hwnd, wParam, lParam); 496 497 case WM_SETFOCUS: 498 return DATETIME_SetFocus (hwnd, wParam, lParam); 499 500 case WM_LBUTTONDOWN: 501 return DATETIME_LButtonDown (hwnd, wParam, lParam); 502 503 case WM_CREATE: 504 return DATETIME_Create (hwnd, wParam, lParam); 505 506 case WM_DESTROY: 507 return DATETIME_Destroy (hwnd, wParam, lParam); 508 509 default: 510 //if (uMsg >= WM_USER) 511 //ERR("unknown msg %04x wp=%08x lp=%08lx\n", 512 // uMsg, wParam, lParam); 513 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 130 514 } 131 515 return 0; … … 134 518 135 519 VOID 136 DATETIME_Register ( VOID)520 DATETIME_Register (void) 137 521 { 138 522 WNDCLASSA wndClass; … … 148 532 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 149 533 wndClass.lpszClassName = DATETIMEPICK_CLASSA; 150 534 151 535 RegisterClassA (&wndClass); 152 536 } … … 154 538 155 539 VOID 156 DATETIME_Unregister ( VOID)540 DATETIME_Unregister (void) 157 541 { 158 542 if (GlobalFindAtomA (DATETIMEPICK_CLASSA)) 159 160 } 161 543 UnregisterClassA (DATETIMEPICK_CLASSA, (HINSTANCE)NULL); 544 } 545 -
TabularUnified trunk/src/comctl32/flatsb.c ¶
r94 r496 1 /* $Id: flatsb.c,v 1. 3 1999-06-10 16:21:58 achimhaExp $ */1 /* $Id: flatsb.c,v 1.4 1999-08-14 16:13:10 cbratschi Exp $ */ 2 2 /* 3 3 * Flat Scrollbar control … … 20 20 #include "winbase.h" 21 21 #include "commctrl.h" 22 #include "flatsb.h" 22 #include "flatsb.h" 23 23 24 24 … … 26 26 27 27 28 BOOL WINAPI 28 BOOL WINAPI 29 29 FlatSB_EnableScrollBar(HWND hwnd, INT dummy, UINT dummy2) 30 30 { … … 33 33 } 34 34 35 BOOL WINAPI 35 BOOL WINAPI 36 36 FlatSB_ShowScrollBar(HWND hwnd, INT code, BOOL flag) 37 37 { … … 40 40 } 41 41 42 BOOL WINAPI 42 BOOL WINAPI 43 43 FlatSB_GetScrollRange(HWND hwnd, INT code, LPINT min, LPINT max) 44 44 { … … 47 47 } 48 48 49 BOOL WINAPI 49 BOOL WINAPI 50 50 FlatSB_GetScrollInfo(HWND hwnd, INT code, LPSCROLLINFO info) 51 51 { … … 54 54 } 55 55 56 INT WINAPI 56 INT WINAPI 57 57 FlatSB_GetScrollPos(HWND hwnd, INT code) 58 58 { … … 61 61 } 62 62 63 BOOL WINAPI 63 BOOL WINAPI 64 64 FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop) 65 65 { … … 69 69 70 70 71 INT WINAPI 71 INT WINAPI 72 72 FlatSB_SetScrollPos(HWND hwnd, INT code, INT pos, BOOL fRedraw) 73 73 { … … 76 76 } 77 77 78 INT WINAPI 78 INT WINAPI 79 79 FlatSB_SetScrollInfo(HWND hwnd, INT code, LPSCROLLINFO info, BOOL fRedraw) 80 80 { … … 83 83 } 84 84 85 INT WINAPI 85 INT WINAPI 86 86 FlatSB_SetScrollRange(HWND hwnd, INT code, INT min, INT max, BOOL fRedraw) 87 87 { … … 90 90 } 91 91 92 BOOL WINAPI 92 BOOL WINAPI 93 93 FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag) 94 94 { … … 128 128 129 129 130 LRESULT WINAPI130 static LRESULT WINAPI 131 131 FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 132 132 { … … 134 134 { 135 135 136 137 136 case WM_CREATE: 137 return FlatSB_Create (hwnd, wParam, lParam); 138 138 139 140 139 case WM_DESTROY: 140 return FlatSB_Destroy (hwnd, wParam, lParam); 141 141 142 143 // 144 // 145 // 146 142 default: 143 // if (uMsg >= WM_USER) 144 // ERR_(datetime)("unknown msg %04x wp=%08x lp=%08lx\n", 145 // uMsg, wParam, lParam); 146 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 147 147 } 148 148 return 0; … … 165 165 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 166 166 wndClass.lpszClassName = FLATSB_CLASSA; 167 167 168 168 RegisterClassA (&wndClass); 169 169 } … … 174 174 { 175 175 if (GlobalFindAtomA (FLATSB_CLASSA)) 176 176 UnregisterClassA (FLATSB_CLASSA, (HINSTANCE)NULL); 177 177 } 178 178 -
TabularUnified trunk/src/comctl32/header.c ¶
r252 r496 1 /* $Id: header.c,v 1. 7 1999-06-30 15:52:16cbratschi Exp $ */1 /* $Id: header.c,v 1.8 1999-08-14 16:13:10 cbratschi Exp $ */ 2 2 /* 3 3 * Header control … … 1444 1444 1445 1445 1446 LRESULT WINAPI1446 static LRESULT WINAPI 1447 1447 HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1448 1448 { -
TabularUnified trunk/src/comctl32/hotkey.c ¶
r94 r496 1 /* $Id: hotkey.c,v 1. 3 1999-06-10 16:21:59 achimhaExp $ */1 /* $Id: hotkey.c,v 1.4 1999-08-14 16:13:10 cbratschi Exp $ */ 2 2 /* 3 3 * Hotkey control … … 79 79 80 80 hBrush = 81 82 81 (HBRUSH)SendMessageA (GetParent (hwnd), WM_CTLCOLOREDIT, 82 wParam, (LPARAM)hwnd); 83 83 if (hBrush) 84 84 hBrush = (HBRUSH)GetStockObject (WHITE_BRUSH); 85 85 GetClientRect (hwnd, &rc); 86 86 … … 106 106 107 107 switch (wParam) { 108 109 110 111 112 113 114 115 116 117 118 119 // 120 121 122 123 // 124 108 case VK_RETURN: 109 case VK_TAB: 110 case VK_SPACE: 111 case VK_DELETE: 112 case VK_ESCAPE: 113 case VK_BACK: 114 return DefWindowProcA (hwnd, WM_KEYDOWN, wParam, lParam); 115 116 case VK_SHIFT: 117 case VK_CONTROL: 118 case VK_MENU: 119 // FIXME (hotkey, "modifier key pressed!\n"); 120 break; 121 122 default: 123 // FIXME (hotkey, " %d\n", wParam); 124 break; 125 125 } 126 126 … … 206 206 hdc = GetDC (hwnd); 207 207 if (infoPtr->hFont) 208 208 hOldFont = SelectObject (hdc, infoPtr->hFont); 209 209 210 210 GetTextMetricsA (hdc, &tm); … … 212 212 213 213 if (infoPtr->hFont) 214 214 SelectObject (hdc, hOldFont); 215 215 ReleaseDC (hwnd, hdc); 216 216 217 217 if (LOWORD(lParam)) { 218 218 219 // 219 // FIXME (hotkey, "force redraw!\n"); 220 220 221 221 } … … 231 231 232 232 switch (wParam) { 233 234 235 236 237 238 239 240 241 242 243 244 // 245 246 247 248 // 249 233 case VK_RETURN: 234 case VK_TAB: 235 case VK_SPACE: 236 case VK_DELETE: 237 case VK_ESCAPE: 238 case VK_BACK: 239 return DefWindowProcA (hwnd, WM_SYSKEYDOWN, wParam, lParam); 240 241 case VK_SHIFT: 242 case VK_CONTROL: 243 case VK_MENU: 244 // FIXME (hotkey, "modifier key pressed!\n"); 245 break; 246 247 default: 248 // FIXME (hotkey, " %d\n", wParam); 249 break; 250 250 } 251 251 … … 266 266 267 267 268 LRESULT WINAPI268 static LRESULT WINAPI 269 269 HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 270 270 { 271 271 switch (uMsg) 272 272 { 273 /* 274 /* 275 /* 276 277 /* 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 /* 312 313 314 315 316 317 318 319 /* 320 321 322 // 323 // 324 // 325 273 /* case HKM_GETHOTKEY: */ 274 /* case HKM_SETHOTKEY: */ 275 /* case HKM_SETRULES: */ 276 277 /* case WM_CHAR: */ 278 279 case WM_CREATE: 280 return HOTKEY_Create (hwnd, wParam, lParam); 281 282 case WM_DESTROY: 283 return HOTKEY_Destroy (hwnd, wParam, lParam); 284 285 case WM_ERASEBKGND: 286 return HOTKEY_EraseBackground (hwnd, wParam, lParam); 287 288 case WM_GETDLGCODE: 289 return DLGC_WANTCHARS | DLGC_WANTARROWS; 290 291 case WM_GETFONT: 292 return HOTKEY_GetFont (hwnd, wParam, lParam); 293 294 case WM_KEYDOWN: 295 case WM_SYSKEYDOWN: 296 return HOTKEY_KeyDown (hwnd, wParam, lParam); 297 298 case WM_KEYUP: 299 case WM_SYSKEYUP: 300 return HOTKEY_KeyUp (hwnd, wParam, lParam); 301 302 case WM_KILLFOCUS: 303 return HOTKEY_KillFocus (hwnd, wParam, lParam); 304 305 case WM_LBUTTONDOWN: 306 return HOTKEY_LButtonDown (hwnd, wParam, lParam); 307 308 case WM_NCCREATE: 309 return HOTKEY_NCCreate (hwnd, wParam, lParam); 310 311 /* case WM_PAINT: */ 312 313 case WM_SETFOCUS: 314 return HOTKEY_SetFocus (hwnd, wParam, lParam); 315 316 case WM_SETFONT: 317 return HOTKEY_SetFont (hwnd, wParam, lParam); 318 319 /* case WM_SYSCHAR: */ 320 321 default: 322 // if (uMsg >= WM_USER) 323 // ERR (hotkey, "unknown msg %04x wp=%08x lp=%08lx\n", 324 // uMsg, wParam, lParam); 325 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 326 326 } 327 327 return 0; … … 344 344 wndClass.hbrBackground = 0; 345 345 wndClass.lpszClassName = HOTKEY_CLASSA; 346 346 347 347 RegisterClassA (&wndClass); 348 348 } … … 353 353 { 354 354 if (GlobalFindAtomA (HOTKEY_CLASSA)) 355 356 } 357 355 UnregisterClassA (HOTKEY_CLASSA, (HINSTANCE)NULL); 356 } 357 -
TabularUnified trunk/src/comctl32/imagelist.c ¶
r295 r496 1 /* $Id: imagelist.c,v 1. 5 1999-07-12 15:58:47cbratschi Exp $ */1 /* $Id: imagelist.c,v 1.6 1999-08-14 16:13:11 cbratschi Exp $ */ 2 2 /* 3 3 * ImageList implementation … … 76 76 * This function can NOT be used to reduce the number of images. 77 77 */ 78 79 78 static VOID 80 79 IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount) … … 142 141 */ 143 142 143 144 /************************************************************************* 145 * IMAGELIST_InternalDraw [Internal] 146 * 147 * Draws the image in the ImageList (without the mask) 148 * 149 * PARAMS 150 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 151 * cx [I] the width of the image to display 152 * cy............[I] the height of the image to display 153 * 154 * RETURNS 155 * nothing 156 * 157 * NOTES 158 * This functions is used by ImageList_DrawIndirect, when it is 159 * required to draw only the Image (without the mask) to the screen. 160 * 161 * Blending and Overlays styles are accomplised by another function 162 */ 163 static VOID 164 IMAGELIST_InternalDraw(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 165 { 166 HDC hImageDC; 167 HBITMAP hOldBitmap; 168 hImageDC = CreateCompatibleDC(0); 169 hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage); 170 BitBlt(pimldp->hdcDst, 171 pimldp->x, pimldp->y, cx, cy, 172 hImageDC, 173 pimldp->himl->cx * pimldp->i, 0, 174 SRCCOPY); 175 176 SelectObject(hImageDC, hOldBitmap); 177 DeleteDC(hImageDC); 178 } 179 180 181 /************************************************************************* 182 * IMAGELIST_InternalDrawMask [Internal] 183 * 184 * Draws the image in the ImageList witht the mask 185 * 186 * PARAMS 187 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 188 * cx [I] the width of the image to display 189 * cy............[I] the height of the image to display 190 * 191 * RETURNS 192 * nothing 193 * 194 * NOTES 195 * This functions is used by ImageList_DrawIndirect, when it is 196 * required to draw the Image with the mask to the screen. 197 * 198 * Blending and Overlays styles are accomplised by another function. 199 */ 200 static VOID 201 IMAGELIST_InternalDrawMask(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 202 { 203 HDC hMaskDC, hImageDC; 204 BOOL bUseCustomBackground, bBlendFlag; 205 HBRUSH hBrush, hOldBrush; 206 HBITMAP hOldBitmapImage, hOldBitmapMask; 207 HIMAGELIST himlLocal = pimldp->himl; 208 209 bUseCustomBackground = (himlLocal->clrBk != CLR_NONE); 210 bBlendFlag = (pimldp->fStyle & ILD_BLEND50 ) 211 || (pimldp->fStyle & ILD_BLEND25); 212 213 hImageDC = CreateCompatibleDC(0); 214 hMaskDC = CreateCompatibleDC(0); 215 216 hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage); 217 hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask); 218 /* Draw the Background for the appropriate Styles 219 */ 220 if( bUseCustomBackground && (pimldp->fStyle == ILD_NORMAL 221 || pimldp->fStyle & ILD_IMAGE 222 || bBlendFlag)) 223 { 224 hBrush = CreateSolidBrush (himlLocal->clrBk); 225 hOldBrush = SelectObject (pimldp->hdcDst, hBrush); 226 PatBlt (pimldp->hdcDst, 227 pimldp->x, pimldp->y, cx, cy, 228 PATCOPY); 229 230 DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush)); 231 } 232 233 /* Draw Image Transparently over the current background 234 */ 235 if(pimldp->fStyle == ILD_NORMAL 236 || pimldp->fStyle & ILD_TRANSPARENT 237 || ((pimldp->fStyle & ILD_IMAGE) && bUseCustomBackground) 238 || bBlendFlag) 239 { 240 BitBlt(pimldp->hdcDst, 241 pimldp->x, pimldp->y, cx, cy, 242 hMaskDC, 243 himlLocal->cx * pimldp->i, 0, 244 SRCAND); 245 246 BitBlt(pimldp->hdcDst, 247 pimldp->x, pimldp->y, cx, cy, 248 hImageDC, 249 himlLocal->cx * pimldp->i, 0, 250 SRCPAINT); 251 } 252 /* Draw the image when no Background is specified 253 */ 254 else if(pimldp->fStyle & ILD_IMAGE && !bUseCustomBackground) 255 { 256 BitBlt(pimldp->hdcDst, 257 pimldp->x, pimldp->y, cx, cy, 258 hImageDC, 259 himlLocal->cx * pimldp->i, 0, 260 SRCCOPY); 261 } 262 /* Draw the mask with or without a background 263 */ 264 else if(pimldp->fStyle & ILD_MASK) 265 { 266 BitBlt(pimldp->hdcDst, 267 pimldp->x, pimldp->y, cx, cy, 268 hMaskDC, 269 himlLocal->cx * pimldp->i, 0, 270 bUseCustomBackground ? SRCCOPY : SRCAND); 271 } 272 SelectObject(hImageDC, hOldBitmapImage); 273 SelectObject(hMaskDC, hOldBitmapMask); 274 DeleteDC(hImageDC); 275 DeleteDC(hMaskDC); 276 } 277 278 /************************************************************************* 279 * IMAGELIST_InternalDrawBlend [Internal] 280 * 281 * Draws the Blend over the current image 282 * 283 * PARAMS 284 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 285 * cx [I] the width of the image to display 286 * cy............[I] the height of the image to display 287 * 288 * RETURNS 289 * nothing 290 * 291 * NOTES 292 * This functions is used by ImageList_DrawIndirect, when it is 293 * required to add the blend to the current image. 294 * 295 */ 296 static VOID 297 IMAGELIST_InternalDrawBlend(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 298 { 299 300 HDC hBlendMaskDC,hMaskDC; 301 HBRUSH hBlendColorBrush, hBlendBrush, hOldBrush; 302 HBITMAP hBlendMaskBitmap, hOldBitmap; 303 COLORREF clrBlend, OldTextColor, OldBkColor; 304 HIMAGELIST himlLocal = pimldp->himl; 305 306 clrBlend = GetSysColor (COLOR_HIGHLIGHT); 307 if (!(pimldp->rgbFg == CLR_DEFAULT)) 308 { 309 clrBlend = pimldp->rgbFg; 310 } 311 /* Create the blend Mask 312 */ 313 hBlendMaskDC = CreateCompatibleDC(0); 314 hBlendBrush = pimldp->fStyle & ILD_BLEND50 ? 315 himlLocal->hbrBlend50 : himlLocal->hbrBlend25; 316 317 hBlendMaskBitmap = CreateBitmap(cx, cy, 1, 1, NULL); 318 hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBitmap); 319 320 hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush); 321 PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY); 322 SelectObject(hBlendMaskDC, hOldBrush); 323 324 /* Modify the blend mask if an Image Mask exist 325 */ 326 if(pimldp->himl->hbmMask != 0) 327 { 328 HBITMAP hOldMaskBitmap; 329 hMaskDC = CreateCompatibleDC(0); 330 hOldMaskBitmap = (HBITMAP) SelectObject(hMaskDC, himlLocal->hbmMask); 331 332 BitBlt(hBlendMaskDC, 333 0,0, cx, cy, 334 hMaskDC, 335 himlLocal->cx * pimldp->i,0, 336 0x220326); /* NOTSRCAND */ 337 338 BitBlt(hBlendMaskDC, 339 0,0, cx, cy, 340 hBlendMaskDC, 341 0,0, 342 NOTSRCCOPY); 343 344 SelectObject(hMaskDC, hOldMaskBitmap); 345 DeleteDC(hMaskDC); 346 347 } 348 /* Apply blend to the current image given the BlendMask 349 */ 350 OldTextColor = SetTextColor(pimldp->hdcDst, 0); 351 OldBkColor = SetBkColor(pimldp->hdcDst, RGB(255,255,255)); 352 hBlendColorBrush = CreateSolidBrush(clrBlend); 353 hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush); 354 355 BitBlt (pimldp->hdcDst, 356 pimldp->x, pimldp->y, cx, cy, 357 hBlendMaskDC, 358 0, 0, 359 0xB8074A); /* PSDPxax */ 360 361 SelectObject(pimldp->hdcDst, hOldBrush); 362 SetTextColor(pimldp->hdcDst, OldTextColor); 363 SetBkColor(pimldp->hdcDst, OldBkColor); 364 SelectObject(hBlendMaskDC, hOldBitmap); 365 DeleteDC(hBlendMaskDC); 366 DeleteObject(hBlendMaskBitmap); 367 DeleteObject(hBlendColorBrush); 368 } 369 370 /************************************************************************* 371 * IMAGELIST_InternalDrawOverlay [Internal] 372 * 373 * Draws the overlay image 374 * 375 * PARAMS 376 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 377 * cx [I] the width of the image to display 378 * cy............[I] the height of the image to display 379 * 380 * RETURNS 381 * nothing 382 * 383 * NOTES 384 * This functions is used by ImageList_DrawIndirect, when it is 385 * required to draw the overlay 386 * 387 * 388 */ 389 static VOID 390 IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 391 { 392 INT nOvlIdx; 393 HDC hImageDC; 394 HBITMAP hOldBitmap; 395 396 nOvlIdx = (pimldp->fStyle & 0x0700) >> 8; 397 if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) 398 { 399 nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1]; 400 if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage)) 401 { 402 hImageDC = CreateCompatibleDC(0); 403 if (pimldp->himl->hbmMask) 404 { 405 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 406 pimldp->himl->hbmMask); 407 408 BitBlt (pimldp->hdcDst, 409 pimldp->x, pimldp->y, cx, cy, 410 hImageDC, pimldp->himl->cx * nOvlIdx, 0, 411 SRCAND); 412 413 SelectObject(hImageDC, hOldBitmap); 414 } 415 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 416 pimldp->himl->hbmImage); 417 418 BitBlt (pimldp->hdcDst, 419 pimldp->x, pimldp->y, cx, cy, 420 hImageDC, 421 pimldp->himl->cx * nOvlIdx, 0, 422 SRCPAINT); 423 424 SelectObject(hImageDC, hOldBitmap); 425 DeleteDC(hImageDC); 426 } 427 } 428 } 429 430 431 432 433 144 434 INT WINAPI 145 435 ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask) 146 436 { 147 HDC hdcSrc, hdcDst; 148 INT nFirstIndex, nImageCount; 149 INT nStartX; 150 BITMAP bmp; 437 HDC hdcImage, hdcBitmap; 438 INT nFirstIndex, nImageCount; 439 INT nStartX; 440 BITMAP bmp; 441 HBITMAP hOldBitmapImage, hOldBitmap; 151 442 152 443 if (!himl || !hbmImage) 153 444 return -1; 154 445 155 446 GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp); … … 161 452 nStartX = himl->cCurImage * himl->cx; 162 453 163 hdcSrc = CreateCompatibleDC (0); 164 hdcDst = CreateCompatibleDC (0); 165 166 /* copy image bitmap */ 167 SelectObject (hdcDst, himl->hbmImage); 168 SelectObject (hdcSrc, hbmImage); 169 BitBlt (hdcDst, himl->cCurImage * himl->cx, 0, 170 bmp.bmWidth, himl->cy, hdcSrc, 0, 0, SRCCOPY); 171 172 if (himl->hbmMask) { 173 if (hbmMask) { 174 /* copy mask bitmap */ 175 SelectObject (hdcDst, himl->hbmMask); 176 SelectObject (hdcSrc, hbmMask); 177 BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy, 178 hdcSrc, 0, 0, SRCCOPY); 179 } 180 else { 181 /* copy monochrome image to the mask bitmap */ 182 SelectObject (hdcDst, himl->hbmMask); 183 SelectObject (hdcSrc, hbmImage); 184 SetBkColor (hdcSrc, GetNearestColor (hdcSrc, 185 GetPixel (hdcSrc, 0, 0))); 186 BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy, 187 hdcSrc, nStartX, 0, SRCCOPY); 188 } 189 } 190 191 DeleteDC (hdcSrc); 192 DeleteDC (hdcDst); 454 hdcImage = CreateCompatibleDC(0); 455 hdcBitmap = CreateCompatibleDC(0); 456 457 hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage); 458 hOldBitmap = SelectObject(hdcBitmap, hbmImage); 459 460 /* Copy result to the imagelist 461 */ 462 BitBlt (hdcImage, nStartX, 0, bmp.bmWidth, himl->cy, 463 hdcBitmap, 0, 0, SRCCOPY); 464 465 if(himl->hbmMask) 466 { 467 HDC hdcMask, hdcTemp, hOldBitmapMask, hOldBitmapTemp; 468 469 hdcMask = CreateCompatibleDC (0); 470 hdcTemp = CreateCompatibleDC(0); 471 hOldBitmapMask = (HBITMAP) SelectObject(hdcMask, himl->hbmMask); 472 hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask); 473 474 BitBlt (hdcMask, 475 nStartX, 0, bmp.bmWidth, himl->cy, 476 hdcTemp, 477 0, 0, 478 SRCCOPY); 479 480 SelectObject(hdcTemp, hOldBitmapTemp); 481 DeleteDC(hdcTemp); 482 483 /* Remove the background from the image 484 */ 485 BitBlt (hdcImage, 486 nStartX, 0, bmp.bmWidth, himl->cy, 487 hdcMask, 488 nStartX, 0, 489 0x220326); /* NOTSRCAND */ 490 491 SelectObject(hdcMask, hOldBitmapMask); 492 DeleteDC(hdcMask); 493 } 494 495 SelectObject(hdcImage, hOldBitmapImage); 496 SelectObject(hdcBitmap, hOldBitmap); 497 DeleteDC(hdcImage); 498 DeleteDC(hdcBitmap); 193 499 194 500 nFirstIndex = himl->cCurImage; … … 240 546 { 241 547 HDC hdcImage, hdcMask, hdcBitmap; 242 INT nIndex, nImageCount ;548 INT nIndex, nImageCount, nMaskXOffset=0; 243 549 BITMAP bmp; 550 HBITMAP hOldBitmap, hOldBitmapMask, hOldBitmapImage; 551 HBITMAP hMaskBitmap=0; 552 COLORREF bkColor; 244 553 245 554 if (himl == NULL) … … 252 561 253 562 if (himl->cCurImage + nImageCount >= himl->cMaxImage) 563 { 254 564 IMAGELIST_InternalExpandBitmaps (himl, nImageCount); 565 } 255 566 256 567 nIndex = himl->cCurImage; 257 568 himl->cCurImage += nImageCount; 258 569 259 hdcImage = CreateCompatibleDC (0); 260 hdcBitmap = CreateCompatibleDC (0); 261 262 SelectObject (hdcBitmap, hBitmap); 263 SelectObject (hdcImage, himl->hbmImage); 264 BitBlt (hdcImage, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy, 265 hdcBitmap, 0, 0, SRCCOPY); 266 267 if (himl->hbmMask) { 268 COLORREF bkColor = (clrMask != CLR_DEFAULT) ? clrMask : 269 GetNearestColor (hdcBitmap, GetPixel (hdcBitmap, 0, 0)); 270 271 /* create mask from image */ 272 hdcMask = CreateCompatibleDC (0); 273 SelectObject (hdcMask, himl->hbmMask); 274 275 /* create monochrome image to the mask bitmap */ 276 SetBkColor (hdcBitmap, bkColor); 277 BitBlt (hdcMask, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy, 278 hdcBitmap, 0, 0, SRCCOPY); 279 280 DeleteDC (hdcMask); 281 } 282 283 DeleteDC (hdcImage); 284 DeleteDC (hdcBitmap); 570 hdcMask = CreateCompatibleDC (0); 571 hdcImage = CreateCompatibleDC(0); 572 hdcBitmap = CreateCompatibleDC(0); 573 574 575 hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage); 576 hOldBitmap = SelectObject(hdcBitmap, hBitmap); 577 if(himl->hbmMask) 578 { 579 hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask); 580 nMaskXOffset = nIndex * himl->cx; 581 } 582 else 583 { 584 /* 585 Create a temp Mask so we can remove the background of 586 the Image (Windows does this even if there is no mask) 587 */ 588 hMaskBitmap = CreateBitmap(bmp.bmWidth, himl->cy, 1, 1, NULL); 589 hOldBitmapMask = SelectObject(hdcMask, hMaskBitmap); 590 nMaskXOffset = 0; 591 } 592 /* create monochrome image to the mask bitmap */ 593 bkColor = (clrMask != CLR_DEFAULT) ? clrMask : 594 GetPixel (hdcBitmap, 0, 0); 595 SetBkColor (hdcBitmap, bkColor); 596 BitBlt (hdcMask, 597 nMaskXOffset, 0, bmp.bmWidth, himl->cy, 598 hdcBitmap, 0, 0, 599 SRCCOPY); 600 601 SetBkColor(hdcBitmap, RGB(255,255,255)); 602 /*Remove the background from the image 603 */ 604 /* 605 WINDOWS BUG ALERT!!!!!! 606 The statement below should not be done in common practice 607 but this is how ImageList_AddMasked works in Windows. 608 It overwrites the original bitmap passed, this was discovered 609 by using the same bitmap to itterated the different styles 610 on windows where it failed (BUT ImageList_Add is OK) 611 This is here in case some apps really on this bug 612 */ 613 BitBlt(hdcBitmap, 614 0, 0, bmp.bmWidth, himl->cy, 615 hdcMask, 616 nMaskXOffset, 0, 617 0x220326); /* NOTSRCAND */ 618 /* Copy result to the imagelist 619 */ 620 BitBlt (hdcImage, 621 nIndex * himl->cx, 0, bmp.bmWidth, himl->cy, 622 hdcBitmap, 623 0, 0, 624 SRCCOPY); 625 /* Clean up 626 */ 627 SelectObject(hdcMask,hOldBitmapMask); 628 SelectObject(hdcImage, hOldBitmapImage); 629 SelectObject(hdcBitmap, hOldBitmap); 630 DeleteDC(hdcMask); 631 DeleteDC(hdcImage); 632 DeleteDC(hdcBitmap); 633 if(!himl->hbmMask) 634 { 635 DeleteObject(hMaskBitmap); 636 } 285 637 286 638 return nIndex; … … 878 1230 ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) 879 1231 { 880 HIMAGELIST himlLocal;881 HDC hdcImageList, hdcTempImage;882 HBITMAP hbmTempImage;883 HBRUSH hBrush, hOldBrush;884 1232 INT cx, cy; 885 INT nOvlIdx; 886 COLORREF clrBlend; 887 BOOL bImage; /* draw image ? */ 888 BOOL bImageTrans; /* draw image transparent ? */ 889 BOOL bMask; /* draw mask ? */ 890 BOOL bMaskTrans; /* draw mask transparent ? */ 891 BOOL bBlend25; 892 BOOL bBlend50; 893 1233 /* 1234 Do some Error Checking 1235 */ 894 1236 if (pimldp == NULL) 895 1237 return FALSE; … … 900 1242 if ((pimldp->i < 0) || (pimldp->i > pimldp->himl->cCurImage)) 901 1243 return FALSE; 902 903 himlLocal = pimldp->himl; 904 905 cx = (pimldp->cx == 0) ? himlLocal->cx : pimldp->cx; 906 cy = (pimldp->cy == 0) ? himlLocal->cy : pimldp->cy; 907 908 /* ILD_NORMAL state */ 909 bImage = TRUE; 910 bImageTrans = FALSE; 911 bMask = FALSE; 912 bMaskTrans = FALSE; 913 bBlend25 = FALSE; 914 bBlend50 = FALSE; 915 if ((himlLocal->clrBk == CLR_NONE) && (himlLocal->hbmMask)) 1244 /* 1245 Get the Height and Width to display 1246 */ 1247 cx = (pimldp->cx == 0) ? pimldp->himl->cx : pimldp->cx; 1248 cy = (pimldp->cy == 0) ? pimldp->himl->cy : pimldp->cy; 1249 /* 1250 Draw the image 1251 */ 1252 if(pimldp->himl->hbmMask != 0) 916 1253 { 917 bImageTrans = TRUE; 918 bMask = TRUE; 919 bMaskTrans = TRUE; 920 } 921 922 /* ILD_IMAGE state (changes) */ 923 if (pimldp->fStyle & ILD_IMAGE) 1254 IMAGELIST_InternalDrawMask(pimldp, cx, cy); 1255 } 1256 else 924 1257 { 925 bMask = FALSE;926 bImage = TRUE;927 bImageTrans = FALSE;928 }929 930 /* ILD_MASK state (changes) */931 if ((pimldp->fStyle & ILD_MASK) && (himlLocal->hbmMask))1258 IMAGELIST_InternalDraw(pimldp, cx, cy); 1259 } 1260 /* 1261 Apply the blend if needed to the Image 1262 */ 1263 if((pimldp->fStyle & ILD_BLEND50) 1264 || (pimldp->fStyle & ILD_BLEND25)) 932 1265 { 933 bMask = TRUE; 934 bMaskTrans = FALSE; 935 bImage = FALSE; 936 } 937 if ((pimldp->fStyle & ILD_TRANSPARENT) && (himlLocal->hbmMask)) 1266 IMAGELIST_InternalDrawBlend(pimldp, cx, cy); 1267 } 1268 /* 1269 Apply the Overlay if needed 1270 */ 1271 if (pimldp->fStyle & 0x0700) 938 1272 { 939 bMaskTrans = TRUE; 940 bImageTrans = TRUE; 941 } 942 if ((himlLocal->clrBk == CLR_NONE) && (himlLocal->hbmMask)) 943 bMaskTrans = TRUE; 944 945 if (pimldp->fStyle & ILD_BLEND50) 946 bBlend50 = TRUE; 947 else if (pimldp->fStyle & ILD_BLEND25) 948 bBlend25 = TRUE; 949 950 hdcImageList = CreateCompatibleDC (0); 951 952 if (bMask) 953 { 954 /* draw the mask */ 955 SelectObject (hdcImageList, himlLocal->hbmMask); 956 SetBkColor (hdcImageList, RGB(255, 255, 255)); 957 SetTextColor (hdcImageList, RGB(0, 0, 0)); 958 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 959 hdcImageList, himlLocal->cx * pimldp->i, 0, 960 bMaskTrans ? SRCAND : SRCCOPY); 961 } 962 963 if (bImage) 964 { 965 /* draw the image */ 966 SelectObject (hdcImageList, himlLocal->hbmImage); 967 968 if (!bImageTrans) 969 { 970 hBrush = CreateSolidBrush (himlLocal->clrBk); 971 hOldBrush = SelectObject (pimldp->hdcDst, hBrush); 972 PatBlt (pimldp->hdcDst, pimldp->x, pimldp->y, 973 cx, cy, PATCOPY); 974 DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush)); 975 } 976 977 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 978 hdcImageList, himlLocal->cx * pimldp->i, 0, SRCPAINT); 979 980 if (bBlend25 || bBlend50) 981 { 982 if (pimldp->rgbFg == CLR_DEFAULT) 983 clrBlend = GetSysColor (COLOR_HIGHLIGHT); 984 else 985 clrBlend = pimldp->rgbFg; 986 987 hdcTempImage = CreateCompatibleDC (0); 988 hbmTempImage = CreateBitmap (himlLocal->cx, himlLocal->cy, 989 1, himlLocal->uBitsPixel, NULL); 990 SelectObject (hdcTempImage, hbmTempImage); 991 992 993 /* mask */ 994 SelectObject (hdcTempImage, 995 bBlend50 ? himlLocal->hbrBlend50 : himlLocal->hbrBlend25); 996 PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, PATCOPY); 997 998 SelectObject (hdcImageList, himlLocal->hbmMask); 999 BitBlt (hdcTempImage, 0, 0, himlLocal->cx, 1000 himlLocal->cy, hdcImageList, 1001 pimldp->i * himlLocal->cx, 0, SRCPAINT); 1002 1003 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 1004 hdcTempImage, 0, 0, SRCAND); 1005 1006 /* fill */ 1007 hBrush = CreateSolidBrush (clrBlend); 1008 SelectObject (hdcTempImage, hBrush); 1009 PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, PATCOPY); 1010 DeleteObject (hBrush); 1011 1012 SelectObject (hdcTempImage, 1013 bBlend50 ? himlLocal->hbrBlend50 : himlLocal->hbrBlend25); 1014 PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, 0x0A0329); 1015 1016 SelectObject (hdcImageList, himlLocal->hbmMask); 1017 BitBlt (hdcTempImage, 0, 0, himlLocal->cx, 1018 himlLocal->cy, hdcImageList, 1019 pimldp->i * himlLocal->cx, 0, SRCPAINT); 1020 1021 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 1022 hdcTempImage, 0, 0, SRCPAINT); 1023 1024 DeleteObject (hbmTempImage); 1025 DeleteDC (hdcTempImage); 1026 } 1027 } 1028 1029 /* Draw overlay image */ 1030 if (pimldp->fStyle & 0x0700) { 1031 nOvlIdx = (pimldp->fStyle & 0x0700) >> 8; 1032 if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) { 1033 nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1]; 1034 if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage)) { 1035 if (pimldp->himl->hbmMask) { 1036 SelectObject (hdcImageList, pimldp->himl->hbmMask); 1037 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 1038 hdcImageList, pimldp->himl->cx * nOvlIdx, 0, 1039 SRCAND); 1040 } 1041 SelectObject (hdcImageList, pimldp->himl->hbmImage); 1042 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, 1043 cx, cy, hdcImageList, 1044 pimldp->himl->cx * nOvlIdx, 0, SRCPAINT); 1045 } 1046 } 1047 } 1048 1049 DeleteDC (hdcImageList); 1273 IMAGELIST_InternalDrawOverlay(pimldp, cx, cy); 1274 } 1050 1275 1051 1276 return TRUE; … … 1211 1436 ICONINFO ii; 1212 1437 HICON hIcon; 1438 HBITMAP hOldSrcBitmap,hOldDstBitmap; 1213 1439 HDC hdcSrc, hdcDst; 1214 1440 1215 1441 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) 1216 1442 return 0; 1217 1443 1218 1444 hdcSrc = CreateCompatibleDC(0); … … 1221 1447 ii.fIcon = TRUE; 1222 1448 ii.hbmMask = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); 1223 ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy);1224 1225 1449 1226 1450 /* draw mask*/ 1227 SelectObject (hdcDst, ii.hbmMask);1451 hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask); 1228 1452 if (himl->hbmMask) { 1229 1230 1231 1453 SelectObject (hdcSrc, himl->hbmMask); 1454 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1455 hdcSrc, i * himl->cx, 0, SRCCOPY); 1232 1456 } 1233 1457 else 1234 1458 PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); 1235 1459 1236 1460 /* draw image*/ 1461 hOldSrcBitmap = (HBITMAP)SelectObject (hdcSrc, himl->hbmImage); 1462 ii.hbmColor = CreateCompatibleBitmap (hdcSrc, himl->cx, himl->cy); 1237 1463 SelectObject (hdcDst, ii.hbmColor); 1238 SelectObject (hdcSrc, himl->hbmImage);1239 1464 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1240 hdcSrc, i * himl->cx, 0, SRCCOPY); 1465 hdcSrc, i * himl->cx, 0, SRCCOPY); 1466 1467 /* 1468 * CreateIconIndirect requires us to deselect the bitmaps from 1469 * the DCs before calling 1470 */ 1471 SelectObject(hdcSrc, hOldSrcBitmap); 1472 SelectObject(hdcDst, hOldDstBitmap); 1241 1473 1242 1474 hIcon = CreateIconIndirect (&ii); -
TabularUnified trunk/src/comctl32/ipaddress.c ¶
r295 r496 1 /* $Id: ipaddress.c,v 1. 6 1999-07-12 15:58:47cbratschi Exp $ */1 /* $Id: ipaddress.c,v 1.7 1999-08-14 16:13:11 cbratschi Exp $ */ 2 2 /* 3 3 * IP Address control … … 597 597 } 598 598 599 LRESULT WINAPI599 static LRESULT WINAPI 600 600 IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 601 601 { -
TabularUnified trunk/src/comctl32/listview.c ¶
r295 r496 2 2 * Listview control 3 3 * 4 * Copyright 1998 Eric Kohl4 * Copyright 1998, 1999 Eric Kohl 5 5 * Copyright 1999 Luc Tourangeau 6 6 * Copyright 1999 Achim Hasenmueller … … 13 13 * 1. No horizontal scrolling when header is larger than the client area. 14 14 * 2. Drawing optimizations. 15 * 3. Hot item handling. 15 16 * 16 17 * Notifications: … … 21 22 * 22 23 * Unicode: 23 * LISTVIEW_SetItem 32W : no unicode support24 * LISTVIEW_InsertItem 32W : no unicode support25 * LISTVIEW_InsertColumn 32W : no unicode support24 * LISTVIEW_SetItemW : no unicode support 25 * LISTVIEW_InsertItemW : no unicode support 26 * LISTVIEW_InsertColumnW : no unicode support 26 27 * LISTVIEW_GetColumnW : no unicode support 28 * LISTVIEW_SetColumnW : no unicode support 27 29 * 28 30 * Advanced functionality: 29 31 * LISTVIEW_GetNumberOfWorkAreas : not implemented 30 32 * LISTVIEW_GetHotCursor : not implemented 31 * LISTVIEW_GetHotItem : not implemented32 33 * LISTVIEW_GetHoverTime : not implemented 33 34 * LISTVIEW_GetISearchString : not implemented … … 35 36 * LISTVIEW_EditLabel : REPORT (need to implement a timer) 36 37 * LISTVIEW_GetColumnOrderArray : not implemented 38 * LISTVIEW_SetColumnOrderArray : not implemented 37 39 * LISTVIEW_Arrange : empty stub 38 40 * LISTVIEW_ApproximateViewRect : incomplete … … 3157 3159 3158 3160 /* LISTVIEW_GetEditControl */ 3159 /* LISTVIEW_GetExtendedListViewStyle */ 3161 3162 /*** 3163 * DESCRIPTION: 3164 * Retrieves the extended listview style. 3165 * 3166 * PARAMETERS: 3167 * [I] HWND : window handle 3168 * 3169 * RETURN: 3170 * SUCCESS : previous style 3171 * FAILURE : 0 3172 */ 3173 static LRESULT LISTVIEW_GetExtendedListViewStyle(HWND hwnd) 3174 { 3175 LISTVIEW_INFO *infoPtr; 3176 /* make sure we can get the listview info */ 3177 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 3178 return (0); 3179 return (infoPtr->dwExStyle); 3180 } 3160 3181 3161 3182 /*** … … 3412 3433 /* LISTVIEW_GetItemW */ 3413 3434 /* LISTVIEW_GetHotCursor */ 3414 /* LISTVIEW_GetHotItem */ 3415 /* LISTVIEW_GetHoverTime> */ 3435 3436 /*** 3437 * DESCRIPTION: 3438 * Retrieves the index of the hot item. 3439 * 3440 * PARAMETERS: 3441 * [I] HWND : window handle 3442 * 3443 * RETURN: 3444 * SUCCESS : hot item index 3445 * FAILURE : -1 (no hot item) 3446 */ 3447 static LRESULT LISTVIEW_GetHotItem(HWND hwnd) 3448 { 3449 LISTVIEW_INFO *infoPtr; 3450 /* make sure we can get the listview info */ 3451 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 3452 return (-1); 3453 return (infoPtr->nHotItem); 3454 } 3455 3456 /* LISTVIEW_GetHoverTime */ 3416 3457 3417 3458 /*** … … 4628 4669 } 4629 4670 4671 /* LISTVIEW_SetBkImage */ 4672 4630 4673 /*** 4631 4674 * DESCRIPTION: … … 4758 4801 } 4759 4802 4803 /* LISTVIEW_SetColumnW */ 4804 /* LISTVIEW_SetColumnOrderArray */ 4805 4760 4806 /*** 4761 4807 * DESCRIPTION: … … 4809 4855 /*** 4810 4856 * DESCRIPTION: 4857 * Sets the extended listview style. 4858 * 4859 * PARAMETERS: 4860 * [I] HWND : window handle 4861 * [I] DWORD : mask 4862 * [I] DWORD : style 4863 * 4864 * RETURN: 4865 * SUCCESS : previous style 4866 * FAILURE : 0 4867 */ 4868 static LRESULT LISTVIEW_SetExtendedListViewStyle(HWND hwnd, DWORD dwMask, DWORD dwStyle) 4869 { 4870 LISTVIEW_INFO *infoPtr; 4871 DWORD dwOldStyle; 4872 /* make sure we can get the listview info */ 4873 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 4874 return (0); 4875 /* store previous style */ 4876 dwOldStyle = infoPtr->dwExStyle; 4877 /* set new style */ 4878 infoPtr->dwExStyle = (dwOldStyle & ~dwMask) | (dwStyle & dwMask); 4879 return (dwOldStyle); 4880 } 4881 4882 /* LISTVIEW_SetHotCursor */ 4883 4884 /*** 4885 * DESCRIPTION: 4886 * Sets the hot item index. 4887 * 4888 * PARAMETERS: 4889 * [I] HWND : window handle 4890 * [I] INT : index 4891 * 4892 * RETURN: 4893 * SUCCESS : previous hot item index 4894 * FAILURE : -1 (no hot item) 4895 */ 4896 static LRESULT LISTVIEW_SetHotItem(HWND hwnd, INT iIndex) 4897 { 4898 LISTVIEW_INFO *infoPtr; 4899 INT iOldIndex; 4900 /* make sure we can get the listview info */ 4901 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 4902 return (-1); 4903 /* store previous index */ 4904 iOldIndex = infoPtr->nHotItem; 4905 /* set new style */ 4906 infoPtr->nHotItem = iIndex; 4907 return (iOldIndex); 4908 } 4909 4910 /* LISTVIEW_SetIconSpacing */ 4911 4912 /*** 4913 * DESCRIPTION: 4811 4914 * Sets image lists. 4812 4915 * … … 4893 4996 * [I] HWND : window handle 4894 4997 * [I] INT : item count (prjected number of items) 4895 * 4896 * RETURN: 4897 * None 4898 */ 4899 static VOID LISTVIEW_SetItemCount(HWND hwnd, INT nItemCount) 4900 { 4901 FIXME("empty stub!\n"); 4998 * [I] DWORD : update flags 4999 * 5000 * RETURN: 5001 * SUCCESS : TRUE 5002 * FAILURE : FALSE 5003 */ 5004 static BOOL LISTVIEW_SetItemCount(HWND hwnd, INT nItems, DWORD dwFlags) 5005 { 5006 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0); 5007 FIXME("(%d %08lx)empty stub!\n", nItems, dwFlags); 5008 if (nItems == 0) 5009 return LISTVIEW_DeleteAllItems (hwnd); 5010 if (nItems > GETITEMCOUNT(infoPtr)) 5011 { 5012 /* append items */ 5013 FIXME("append items\n"); 5014 } 5015 else if (nItems < GETITEMCOUNT(infoPtr)) 5016 { 5017 /* remove items */ 5018 FIXME("remove items\n"); 5019 } 5020 return TRUE; 4902 5021 } 4903 5022 … … 4947 5066 return bResult; 4948 5067 } 5068 5069 /* LISTVIEW_SetItemPosition32 */ 4949 5070 4950 5071 /*** … … 5031 5152 } 5032 5153 5154 /* LISTVIEW_SetItemTextW */ 5155 5156 /*** 5157 * DESCRIPTION: 5158 * Set item index that marks the start of a multiple selection. 5159 * 5160 * PARAMETER(S): 5161 * [I] HWND : window handle 5162 * [I] INT : index 5163 * 5164 * RETURN: 5165 * Index number or -1 if there is no selection mark. 5166 */ 5167 static LRESULT LISTVIEW_SetSelectionMark(HWND hwnd, INT nIndex) 5168 { 5169 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5170 INT nOldIndex = infoPtr->nSelectionMark; 5171 infoPtr->nSelectionMark = nIndex; 5172 return nOldIndex; 5173 } 5174 5033 5175 /*** 5034 5176 * DESCRIPTION: … … 5075 5217 } 5076 5218 5219 /* LISTVIEW_SetToolTips */ 5220 /* LISTVIEW_SetUnicodeFormat */ 5221 /* LISTVIEW_SetWorkAreas */ 5077 5222 5078 5223 /*** … … 5163 5308 } 5164 5309 5310 /* LISTVIEW_SubItemHitTest */ 5311 5165 5312 /*** 5166 5313 * DESCRIPTION: … … 5241 5388 infoPtr->nFocusedItem = -1; 5242 5389 infoPtr->nSelectionMark = -1; 5390 infoPtr->nHotItem = -1; 5243 5391 infoPtr->iconSpacing.cx = GetSystemMetrics(SM_CXICONSPACING); 5244 5392 infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING); … … 6433 6581 * 6434 6582 */ 6435 LRESULT WINAPI LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,6583 static LRESULT WINAPI LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, 6436 6584 LPARAM lParam) 6437 6585 { … … 6475 6623 6476 6624 /* case LVM_GETCOLUMNW: */ 6477 /* case LVM_GETCOLUMNORDERARRAY: */ 6625 6626 case LVM_GETCOLUMNORDERARRAY: 6627 //FIXME("Unimplemented msg LVM_GETCOLUMNORDERARRAY\n"); 6628 return 0; 6629 6478 6630 6479 6631 case LVM_GETCOLUMNWIDTH: … … 6484 6636 6485 6637 /* case LVM_GETEDITCONTROL: */ 6486 /* case LVM_GETEXTENDEDLISTVIEWSTYLE: */ 6638 case LVM_GETEXTENDEDLISTVIEWSTYLE: 6639 return LISTVIEW_GetExtendedListViewStyle(hwnd); 6487 6640 6488 6641 case LVM_GETHEADER: … … 6490 6643 6491 6644 /* case LVM_GETHOTCURSOR: */ 6492 /* case LVM_GETHOTITEM: */ 6645 6646 case LVM_GETHOTITEM: 6647 return LISTVIEW_GetHotItem(hwnd); 6648 6493 6649 /* case LVM_GETHOVERTIME: */ 6494 6650 … … 6593 6749 return LISTVIEW_SetColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam); 6594 6750 6595 /* case LVM_SETCOLUMNW: */ 6596 /* case LVM_SETCOLUMNORDERARRAY: */ 6751 case LVM_SETCOLUMNW: 6752 //FIXME("Unimplemented msg LVM_SETCOLUMNW\n"); 6753 return 0; 6754 6755 case LVM_SETCOLUMNORDERARRAY: 6756 //FIXME("Unimplemented msg LVM_SETCOLUMNORDERARRAY\n"); 6757 return 0; 6597 6758 6598 6759 case LVM_SETCOLUMNWIDTH: 6599 6760 return LISTVIEW_SetColumnWidth(hwnd, (INT)wParam, (INT)lParam); 6600 6761 6601 /* case LVM_SETEXTENDEDLISTVIEWSTYLE: */ 6762 case LVM_SETEXTENDEDLISTVIEWSTYLE: 6763 return LISTVIEW_SetExtendedListViewStyle(hwnd, (DWORD)wParam, (DWORD)lParam); 6764 6602 6765 /* case LVM_SETHOTCURSOR: */ 6603 /* case LVM_SETHOTITEM: */ 6766 6767 case LVM_SETHOTITEM: 6768 return LISTVIEW_SetHotItem(hwnd, (INT)wParam); 6769 6604 6770 /* case LVM_SETHOVERTIME: */ 6605 6771 /* case LVM_SETICONSPACING: */ … … 6614 6780 6615 6781 case LVM_SETITEMCOUNT: 6616 LISTVIEW_SetItemCount(hwnd, (INT)wParam); 6617 break; 6782 return LISTVIEW_SetItemCount(hwnd, (INT)wParam, (DWORD)lParam); 6618 6783 6619 6784 case LVM_SETITEMPOSITION: … … 6621 6786 (INT)HIWORD(lParam)); 6622 6787 6623 /* case LVM_SETITEMPOSITION : */6788 /* case LVM_SETITEMPOSITION32: */ 6624 6789 6625 6790 case LVM_SETITEMSTATE: … … 6629 6794 return LISTVIEW_SetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam); 6630 6795 6631 /* case LVM_SETSELECTIONMARK: */ 6796 /* case LVM_SETITEMTEXTW: */ 6797 6798 case LVM_SETSELECTIONMARK: 6799 return LISTVIEW_SetSelectionMark(hwnd, (INT)lParam); 6632 6800 6633 6801 case LVM_SETTEXTBKCOLOR: -
TabularUnified trunk/src/comctl32/monthcal.c ¶
r94 r496 1 /* $Id: monthcal.c,v 1.3 1999-06-10 16:22:01 achimha Exp $ */ 2 /* 3 * Month calendar control 1 2 /* Month calendar control 3 4 4 5 * 5 * Copyright 1998, 1999 Eric Kohl 6 * Copyright 1999 Achim Hasenmueller 7 * 8 * NOTES 9 * This is just a dummy control. An author is needed! Any volunteers? 10 * I will only improve this control once in a while. 11 * Eric <ekohl@abo.rhein-zeitung.de> 6 * Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de) 7 * Copyright 1999 Alex Priem (alexp@sci.kun.nl) 8 * Copyright 1999 Christoph Bratschi 12 9 * 13 10 * TODO: 14 * - All messages. 15 * - All notifications. 11 * - Notifications. 16 12 * 13 * 14 * FIXME: refresh should ask for rect of required length. (?) 15 * FIXME: we refresh to often; especially in LButtonDown/MouseMove. 16 * FIXME: handle resources better (doesn't work now); also take care 17 of internationalization. 18 * FIXME: keyboard handling. 17 19 */ 18 20 19 21 #include "winbase.h" 22 #include "win.h" 20 23 #include "commctrl.h" 24 #include "comctl32.h" 21 25 #include "monthcal.h" 22 26 #include "winnls.h" 27 #include <stdio.h> 28 #include <string.h> 29 #include <stdlib.h> 30 31 //DEFAULT_DEBUG_CHANNEL(monthcal) 32 33 /* take #days/month from ole/parsedt.c; 34 * we want full month-names, and abbreviated weekdays, so these are 35 * defined here */ 23 36 24 37 #define MONTHCAL_GetInfoPtr(hwnd) ((MONTHCAL_INFO *)GetWindowLongA (hwnd, 0)) 25 38 26 27 28 39 /* helper functions 40 * MONTHCAL_ValidateTime: is time a valid date/time combo? 41 */ 42 43 int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}; 44 45 int DayOfWeekTable[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; 46 47 static char *daytxt[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; 48 49 static char *monthtxt[] = {"January", "February", "March", "April", "May", 50 "June", "July", "August", "September", "October", 51 "November", "December"}; 52 53 /* CHECKME: all these validations OK? */ 54 55 static int MONTHCAL_ValidateTime (SYSTEMTIME time) 56 57 { 58 if (time.wMonth > 12) return FALSE; 59 if (time.wDayOfWeek > 6) return FALSE; 60 if (time.wDay > mdays[time.wMonth]) return FALSE; 61 if (time.wMonth > 23) return FALSE; 62 if (time.wMinute > 60) return FALSE; 63 if (time.wSecond > 60) return FALSE; 64 if (time.wMilliseconds > 100) return FALSE; 65 return TRUE; 66 } 67 68 void MONTHCAL_CopyTime (const SYSTEMTIME *from, SYSTEMTIME *to) 69 70 { 71 to->wYear=from->wYear; 72 to->wMonth=from->wMonth; 73 to->wDayOfWeek=from->wDayOfWeek; 74 to->wDay=from->wDay; 75 to->wHour=from->wHour; 76 to->wMinute=from->wMinute; 77 to->wSecond=from->wSecond; 78 to->wMilliseconds=from->wMilliseconds; 79 } 80 81 82 /* Note:Depending on DST, this may be offset by a day. 83 Need to find out if we're on a DST place & adjust the clock accordingly. 84 Above function assumes we have a valid data. 85 Valid for year>1752; d <= 1 <= 31, 1 <= m <= 12. 86 0=Monday. 87 */ 88 89 90 int MONTHCAL_CalculateDayOfWeek (DWORD day, DWORD month, DWORD year) 91 92 { 93 year -= month < 3; 94 return (year + year/4 - year/100 + year/400 + 95 DayOfWeekTable[month-1] + day - 1 ) % 7; 96 } 97 98 99 static int MONTHCAL_CalcDayFromPos (MONTHCAL_INFO *infoPtr, int x, int y) 100 101 { 102 int daypos,weekpos,retval,firstDay; 103 104 daypos=(x - infoPtr->prevmonth.left) / infoPtr->textWidth ; 105 weekpos=(y - infoPtr->days.bottom - infoPtr->rcClient.top) / 106 (infoPtr->textHeight*1.25); 107 firstDay=MONTHCAL_CalculateDayOfWeek (1,infoPtr->currentMonth,infoPtr->currentYear); 108 retval=daypos + 7*weekpos - firstDay; 109 //TRACE ("%d %d %d\n",daypos,weekpos,retval); 110 return retval; 111 } 112 113 114 static void MONTHCAL_CalcDayXY (MONTHCAL_INFO *infoPtr, int day, int month, 115 int *x, int *y) 116 117 { 118 int firstDay,prevMonth; 119 120 firstDay=MONTHCAL_CalculateDayOfWeek (1,infoPtr->currentMonth,infoPtr->currentYear); 121 122 if (month==infoPtr->currentMonth) { 123 *x=(day+firstDay) & 7; 124 *y=(day+firstDay-*x) / 7; 125 return; 126 } 127 if (month < infoPtr->currentMonth) { 128 prevMonth=month - 1; 129 if (prevMonth==0) prevMonth=11; 130 *x=(mdays[prevMonth]-firstDay) & 7; 131 *y=0; 132 } 133 134 *y=mdays[month] / 7; 135 *x=(day+firstDay+mdays[month]) & 7; 136 } 137 138 139 static void MONTHCAL_CalcDayRect (MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 140 { 141 r->left = infoPtr->prevmonth.left + x * infoPtr->textWidth; 142 r->right = r->left + infoPtr->textWidth; 143 r->top = infoPtr->rcClient.top + y * 1.25 * infoPtr->textHeight 144 + infoPtr->days.bottom; 145 r->bottom = r->top + infoPtr->textHeight; 146 147 } 148 149 static void MONTHCAL_CalcPosFromDay (MONTHCAL_INFO *infoPtr, 150 int day, int month, RECT *r) 151 152 { 153 int x,y; 154 155 MONTHCAL_CalcDayXY (infoPtr, day, month, &x, &y); 156 MONTHCAL_CalcDayRect (infoPtr, r, x, y); 157 } 158 159 160 161 162 static void MONTHCAL_CircleDay (HDC hdc, MONTHCAL_INFO *infoPtr, int i, int j) 163 164 { 165 HPEN hRedPen = CreatePen(PS_SOLID, 2, RGB (255,0,0) ); 166 HPEN hOldPen2 = SelectObject( hdc, hRedPen ); 167 POINT points[7]; 168 int x,y; 169 170 /* use prevmonth to calculate position because it contains the extra width 171 * from MCS_WEEKNUMBERS 172 */ 173 174 x=infoPtr->prevmonth.left + (i+0.5)*infoPtr->textWidth; 175 y=infoPtr->rcClient.top + 1.25*(j+0.5)*infoPtr->textHeight + infoPtr->days.bottom; 176 points[0].x = x; 177 points[0].y = y-0.25*infoPtr->textHeight; 178 points[1].x = x-1.0*infoPtr->textWidth; 179 points[1].y = y; 180 points[2].x = x; 181 points[2].y = y+0.6*infoPtr->textHeight; 182 points[3].x = x+0.5*infoPtr->textWidth; 183 points[3].y = y; 184 points[4].x = x+0.3*infoPtr->textWidth; 185 points[4].y = y-0.5*infoPtr->textHeight; 186 points[5].x = x-0.25*infoPtr->textWidth; 187 points[5].y = y-0.5*infoPtr->textHeight; 188 points[6].x = x-0.5*infoPtr->textWidth; 189 points[6].y = y-0.45*infoPtr->textHeight; 190 191 PolyBezier (hdc,points,4); 192 PolyBezier (hdc,points+3,4); 193 DeleteObject (hRedPen); 194 SelectObject (hdc, hOldPen2); 195 } 196 197 198 199 200 201 static void MONTHCAL_DrawDay (HDC hdc, MONTHCAL_INFO *infoPtr, 202 int day, int month, int x, int y, int bold) 203 204 { 205 char buf[10]; 206 RECT r; 207 static int haveBoldFont,haveSelectedDay=FALSE; 208 HBRUSH hbr; 209 COLORREF oldCol,oldBk; 210 211 sprintf (buf,"%d",day); 212 213 214 215 /* No need to check styles: when selection is not valid, it is set to zero. 216 * 1<day<31, so evertyhing's OK. 217 */ 218 219 MONTHCAL_CalcDayRect (infoPtr, &r, x, y); 220 221 if ((day>=infoPtr->minSel.wDay) && (day<=infoPtr->maxSel.wDay) 222 && (month==infoPtr->currentMonth)) { 223 HRGN hrgn; 224 RECT r2; 225 226 //TRACE ("%d %d %d\n",day,infoPtr->minSel.wDay,infoPtr->maxSel.wDay); 227 //TRACE ("%d %d %d %d\n", r.left, r.top, r.right, r.bottom); 228 oldCol=SetTextColor (hdc, infoPtr->monthbk); 229 oldBk=SetBkColor (hdc,infoPtr->trailingtxt); 230 hbr= GetSysColorBrush (COLOR_GRAYTEXT); 231 hrgn=CreateEllipticRgn (r.left,r.top, r.right,r.bottom); 232 FillRgn (hdc,hrgn,hbr); 233 234 r2.left = r.left-0.25*infoPtr->textWidth; 235 r2.top = r.top; 236 r2.right = r.left+0.5*infoPtr->textWidth; 237 r2.bottom = r.bottom; 238 if (haveSelectedDay) FillRect (hdc,&r2,hbr); 239 haveSelectedDay=TRUE; 240 } else { 241 haveSelectedDay=FALSE; 242 } 243 244 245 246 /* need to add some code for multiple selections */ 247 248 if ((bold) && (!haveBoldFont)) { 249 SelectObject (hdc, infoPtr->hBoldFont); 250 haveBoldFont=TRUE; 251 } 252 if ((!bold) && (haveBoldFont)) { 253 SelectObject (hdc, infoPtr->hFont); 254 haveBoldFont=FALSE; 255 } 256 257 258 259 DrawTextA ( hdc, buf, lstrlenA(buf), &r, 260 DT_CENTER | DT_VCENTER | DT_SINGLELINE ); 261 if (haveSelectedDay) { 262 SetTextColor(hdc, oldCol); 263 SetBkColor (hdc, oldBk); 264 } 265 266 if ((day==infoPtr->curSelDay) && (month==infoPtr->currentMonth)) { 267 HPEN hNewPen, hOldPen; 268 269 hNewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) ); 270 hbr= GetSysColorBrush (COLOR_WINDOWTEXT); 271 hOldPen = SelectObject( hdc, hNewPen ); 272 r.left+=2; 273 r.right-=2; 274 r.top-=1; 275 r.bottom+=1; 276 FrameRect (hdc, &r, hbr); 277 SelectObject( hdc, hOldPen ); 278 } 279 } 280 281 282 /* CHECKME: For `todays date', do we need to check the locale?*/ 283 /* CHECKME: For `todays date', how do is Y2K handled?*/ 284 /* FIXME: todays date circle */ 285 286 static void MONTHCAL_Refresh (HWND hwnd, HDC hdc) 287 288 { 289 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 290 RECT *rcClient=&infoPtr->rcClient; 291 RECT *title=&infoPtr->title; 292 RECT *prev=&infoPtr->titlebtnprev; 293 RECT *next=&infoPtr->titlebtnnext; 294 RECT *titlemonth=&infoPtr->titlemonth; 295 RECT *titleyear=&infoPtr->titleyear; 296 RECT *prevmonth=&infoPtr->prevmonth; 297 RECT *nextmonth=&infoPtr->nextmonth; 298 RECT *days=&infoPtr->days; 299 RECT *weeknums=&infoPtr->weeknums; 300 RECT *rtoday=&infoPtr->today; 301 int i,j,m,mask,day,firstDay, weeknum,prevMonth; 302 int textHeight,textWidth; 303 SIZE size; 304 HBRUSH hbr; 305 HFONT currentFont; 306 TEXTMETRICA tm; 307 /* LOGFONTA logFont; */ 308 char buf[20],*thisMonthtxt; 309 COLORREF oldTextColor,oldBkColor; 310 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 311 BOOL prssed; 312 313 314 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT)); 315 316 currentFont = SelectObject (hdc, infoPtr->hFont); 317 318 /* FIXME: need a way to determine current font, without setting it */ 319 /* 320 if (infoPtr->hFont!=currentFont) { 321 SelectObject (hdc, currentFont); 322 infoPtr->hFont=currentFont; 323 GetObjectA (currentFont, sizeof (LOGFONTA), &logFont); 324 logFont.lfWeight=FW_BOLD; 325 infoPtr->hBoldFont = CreateFontIndirectA (&logFont); 326 } 327 */ 328 329 GetTextMetricsA (hdc, &tm); 330 infoPtr->textHeight=textHeight=tm.tmHeight + tm.tmExternalLeading; 331 GetTextExtentPoint32A (hdc, "Sun",3, &size); 332 infoPtr->textWidth=textWidth=size.cx+2; 333 334 GetClientRect (hwnd, rcClient); 335 hbr = CreateSolidBrush (RGB(255,255,255)); 336 DrawEdge (hdc, rcClient, EDGE_SUNKEN, BF_RECT | BF_ADJUST); 337 FillRect (hdc, rcClient, hbr); 338 DeleteObject (hbr); 339 340 /* calculate whole client area & title area */ 341 342 infoPtr->rcClient.right=7*infoPtr->textWidth; 343 if (dwStyle & MCS_WEEKNUMBERS) 344 infoPtr->rcClient.right+=infoPtr->textWidth; 345 346 title->top = rcClient->top + 1; 347 title->bottom = title->top + 2*textHeight + 4; 348 title->left = rcClient->left + 1; 349 title->right = rcClient->right - 1; 350 infoPtr->rcClient.bottom=title->bottom + 6*textHeight; 351 352 353 /* draw header */ 354 355 hbr = CreateSolidBrush (infoPtr->titlebk); 356 FillRect (hdc, title, hbr); 357 358 prev->top = next->top = title->top + 6; 359 prev->bottom = next->bottom = title->top + 2*textHeight - 3; 360 prev->right = title->left + 28; 361 prev->left = title->left + 4; 362 next->left = title->right - 28; 363 next->right = title->right - 4; 364 titlemonth->bottom= titleyear->bottom = prev->top + 2*textHeight - 3; 365 titlemonth->top = titleyear->top = title->top + 6; 366 titlemonth->left = title->left; 367 titlemonth->right = title->right; 368 prssed=FALSE; 369 370 if (!(infoPtr->status & MC_PREVPRESSED)) 371 DrawFrameControl(hdc, prev, DFC_SCROLL, 372 DFCS_SCROLLLEFT | (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); 373 374 if (!(infoPtr->status & MC_NEXTPRESSED)) 375 DrawFrameControl(hdc, next, DFC_SCROLL, 376 DFCS_SCROLLRIGHT | (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); 377 378 oldBkColor=SetBkColor (hdc,infoPtr->titlebk); 379 SetTextColor(hdc, infoPtr->titletxt); 380 SelectObject (hdc, infoPtr->hBoldFont); 381 382 thisMonthtxt=monthtxt[infoPtr->currentMonth - 1]; 383 sprintf (buf,"%s %ld",thisMonthtxt,infoPtr->currentYear); 384 DrawTextA ( hdc, buf, strlen(buf), titlemonth, 385 DT_CENTER | DT_VCENTER | DT_SINGLELINE ); 386 SelectObject (hdc, infoPtr->hFont); 387 388 /* titlemonth left/right contained rect for whole titletxt ('June 1999') 389 * MCM_HitTestInfo wants month & year rects, so prepare these now. 390 * (no, we can't draw them separately; the whole text is centered) 391 */ 392 393 GetTextExtentPoint32A (hdc, buf,lstrlenA (buf), &size); 394 titlemonth->left = title->right/2 - size.cx/2; 395 titleyear->right = title->right/2 + size.cx/2; 396 GetTextExtentPoint32A (hdc, thisMonthtxt,lstrlenA (thisMonthtxt), &size); 397 titlemonth->right= titlemonth->left+size.cx; 398 titleyear->right = titlemonth->right; 399 400 /* draw line under day abbreviatons */ 401 402 if (dwStyle & MCS_WEEKNUMBERS) 403 MoveToEx (hdc, rcClient->left+textWidth+3, 404 title->bottom + textHeight + 2, NULL); 405 else 406 MoveToEx (hdc, rcClient->left+3, title->bottom + textHeight + 2, NULL); 407 LineTo (hdc, rcClient->right-3, title->bottom + textHeight + 2); 408 409 /* draw day abbreviations */ 410 411 SetBkColor (hdc, infoPtr->monthbk); 412 SetTextColor(hdc, infoPtr->trailingtxt); 413 414 days->left = rcClient->left; 415 if (dwStyle & MCS_WEEKNUMBERS) days->left+=textWidth; 416 days->right = days->left + textWidth; 417 days->top = title->bottom + 2; 418 days->bottom = title->bottom + textHeight + 2; 419 i=infoPtr->firstDay; 420 421 for (j=0; j<7; j++) { 422 DrawTextA ( hdc, daytxt[i], strlen(daytxt[i]), days, 423 DT_CENTER | DT_VCENTER | DT_SINGLELINE ); 424 i++; 425 if (i>7) i-=7; 426 days->left+=textWidth; 427 days->right+=textWidth; 428 } 429 430 days->left = rcClient->left + j; 431 if (dwStyle & MCS_WEEKNUMBERS) days->left+=textWidth; 432 days->right = rcClient->left + (j+1)*textWidth-2; 433 434 /* draw day numbers; first, the previous month */ 435 436 prevmonth->left=0; 437 if (dwStyle & MCS_WEEKNUMBERS) prevmonth->left=textWidth; 438 439 firstDay=MONTHCAL_CalculateDayOfWeek (1,infoPtr->currentMonth,infoPtr->currentYear); 440 prevMonth=infoPtr->currentMonth-1; 441 if (prevMonth==0) prevMonth=11; 442 day=mdays[prevMonth]-firstDay; 443 mask=1<<(day-1); 444 445 i=0; 446 m=0; 447 while (day<=mdays[prevMonth]) { 448 MONTHCAL_DrawDay (hdc, infoPtr, day, prevMonth, i, 0, 449 infoPtr->monthdayState[m] & mask); 450 mask<<=1; 451 day++; 452 i++; 453 } 454 455 prevmonth->right = prevmonth->left+i*textWidth; 456 prevmonth->top = days->bottom; 457 prevmonth->bottom= prevmonth->top + textHeight; 458 459 /* draw `current' month */ 460 461 day=1; 462 infoPtr->firstDayplace=i; 463 SetTextColor(hdc, infoPtr->txt); 464 m++; 465 mask=1; 466 while (i<7) { 467 MONTHCAL_DrawDay (hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 468 infoPtr->monthdayState[m] & mask); 469 if ((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) && 470 (day==infoPtr->todaysDate.wDay)) 471 MONTHCAL_CircleDay (hdc, infoPtr, i,j); 472 mask<<=1; 473 day++; 474 i++; 475 } 476 477 j=1; 478 i=0; 479 while (day<=mdays[infoPtr->currentMonth]) { 480 MONTHCAL_DrawDay (hdc, infoPtr, day, infoPtr->currentMonth, i, j, 481 infoPtr->monthdayState[m] & mask); 482 if ((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) && 483 (day==infoPtr->todaysDate.wDay)) 484 MONTHCAL_CircleDay (hdc, infoPtr, i,j); 485 mask<<=1; 486 day++; 487 i++; 488 if (i>6) { 489 i=0; 490 j++; 491 } 492 } 493 494 /* draw `next' month */ 495 496 /* note: the nextmonth rect only hints for the `half-week' that needs to be 497 * drawn to complete the current week. An eventual next week that needs to 498 * be drawn to complete the month calendar is not taken into account in 499 * this rect -- HitTest knows about this.*/ 500 501 502 503 nextmonth->left = prevmonth->left+i*textWidth; 504 nextmonth->right = rcClient->right; 505 nextmonth->top = days->bottom+(j+1)*textHeight; 506 nextmonth->bottom = nextmonth->top + textHeight; 507 508 day=1; 509 m++; 510 mask=1; 511 SetTextColor(hdc, infoPtr->trailingtxt); 512 while ((i<7) && (j<6)) { 513 MONTHCAL_DrawDay (hdc, infoPtr, day, infoPtr->currentMonth+1, i, j, 514 infoPtr->monthdayState[m] & mask); 515 mask<<=1; 516 day++; 517 i++; 518 if (i==7) { 519 i=0; 520 j++; 521 } 522 } 523 SetTextColor(hdc, infoPtr->txt); 524 525 526 527 /* draw `today' date if style allows it, and draw a circle before today's 528 * date if necessairy */ 529 530 if (!( dwStyle & MCS_NOTODAY)) { 531 int offset=0; 532 if (!( dwStyle & MCS_NOTODAYCIRCLE)) { 533 MONTHCAL_CircleDay (hdc, infoPtr, 0, 6); 534 offset+=textWidth; 535 } 536 537 MONTHCAL_CalcDayRect (infoPtr, rtoday, offset==textWidth, 6); 538 sprintf (buf,"Today: %d/%d/%d",infoPtr->todaysDate.wMonth, 539 infoPtr->todaysDate.wDay, infoPtr->todaysDate.wYear-1900); 540 rtoday->right = rcClient->right; 541 SelectObject (hdc, infoPtr->hBoldFont); 542 DrawTextA ( hdc, buf, lstrlenA(buf), rtoday, 543 DT_LEFT | DT_VCENTER | DT_SINGLELINE ); 544 SelectObject (hdc, infoPtr->hFont); 545 } 546 547 if (dwStyle & MCS_WEEKNUMBERS) { 548 /* display weeknumbers*/ 549 550 weeknums->left = 0; 551 weeknums->right = textWidth; 552 weeknums->top = days->bottom + 2; 553 weeknums->bottom = days->bottom + 2 + textHeight; 554 555 weeknum=0; 556 for (i=0; i<infoPtr->currentMonth-1; i++) 557 weeknum+=mdays[i]; 558 559 weeknum/=7; 560 for (i=0; i<6; i++) { 561 sprintf (buf,"%d",weeknum+i); 562 DrawTextA ( hdc, buf, lstrlenA(buf), weeknums, 563 DT_CENTER | DT_BOTTOM | DT_SINGLELINE ); 564 weeknums->top+=textHeight*1.25; 565 weeknums->bottom+=textHeight*1.25; 566 } 567 568 MoveToEx (hdc, weeknums->right, days->bottom+5 , NULL); 569 LineTo (hdc, weeknums->right, weeknums->bottom-1.25*textHeight-5); 570 571 } 572 573 /* currentFont was font at entering Refresh */ 574 575 SetBkColor (hdc, oldBkColor); 576 SelectObject (hdc, currentFont); 577 SetTextColor (hdc, oldTextColor); 578 } 579 580 581 static LRESULT 582 MONTHCAL_GetMinReqRect (HWND hwnd, WPARAM wParam, LPARAM lParam) 583 584 { 585 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 586 LPRECT lpRect=(LPRECT) lParam; 587 //TRACE ("%x %lx\n",wParam,lParam); 588 589 /* validate parameters */ 590 591 if ( (infoPtr==NULL) || (lpRect == NULL) ) return FALSE; 592 593 lpRect->left=infoPtr->rcClient.left; 594 lpRect->right=infoPtr->rcClient.right; 595 lpRect->top=infoPtr->rcClient.top; 596 lpRect->bottom=infoPtr->rcClient.bottom; 597 return TRUE; 598 } 599 600 static LRESULT 601 MONTHCAL_GetColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 602 603 { 604 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 605 606 //TRACE ("%x %lx\n",wParam,lParam); 607 608 switch ((int)wParam) { 609 case MCSC_BACKGROUND: 610 return infoPtr->bk; 611 case MCSC_TEXT: 612 return infoPtr->txt; 613 case MCSC_TITLEBK: 614 return infoPtr->titlebk; 615 case MCSC_TITLETEXT: 616 return infoPtr->titletxt; 617 case MCSC_MONTHBK: 618 return infoPtr->monthbk; 619 case MCSC_TRAILINGTEXT: 620 return infoPtr->trailingtxt; 621 } 622 623 return -1; 624 } 625 626 static LRESULT 627 MONTHCAL_SetColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 628 629 { 630 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 631 int prev=-1; 632 633 //TRACE ("%x %lx\n",wParam,lParam); 634 635 switch ((int)wParam) { 636 case MCSC_BACKGROUND: 637 prev=infoPtr->bk; 638 infoPtr->bk=(COLORREF) lParam; 639 break; 640 case MCSC_TEXT: 641 prev=infoPtr->txt; 642 infoPtr->txt=(COLORREF) lParam; 643 break; 644 case MCSC_TITLEBK: 645 prev=infoPtr->titlebk; 646 infoPtr->titlebk=(COLORREF) lParam; 647 break; 648 case MCSC_TITLETEXT: 649 prev=infoPtr->titletxt; 650 infoPtr->titletxt=(COLORREF) lParam; 651 break; 652 case MCSC_MONTHBK: 653 prev=infoPtr->monthbk; 654 infoPtr->monthbk=(COLORREF) lParam; 655 break; 656 case MCSC_TRAILINGTEXT: 657 prev=infoPtr->trailingtxt; 658 infoPtr->trailingtxt=(COLORREF) lParam; 659 break; 660 } 661 662 return prev; 663 } 664 665 static LRESULT 666 MONTHCAL_GetMonthDelta (HWND hwnd, WPARAM wParam, LPARAM lParam) 667 668 { 669 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 670 671 //TRACE ("%x %lx\n",wParam,lParam); 672 673 if (infoPtr->delta) return infoPtr->delta; 674 else return infoPtr->visible; 675 } 676 677 static LRESULT 678 MONTHCAL_SetMonthDelta (HWND hwnd, WPARAM wParam, LPARAM lParam) 679 680 { 681 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 682 int prev=infoPtr->delta; 683 684 //TRACE ("%x %lx\n",wParam,lParam); 685 686 infoPtr->delta=(int) wParam; 687 return prev; 688 } 689 690 691 692 static LRESULT 693 MONTHCAL_GetFirstDayOfWeek (HWND hwnd, WPARAM wParam, LPARAM lParam) 694 { 695 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 696 697 return infoPtr->firstDay; 698 } 699 700 /* FIXME: we need more error checking here */ 701 702 static LRESULT 703 MONTHCAL_SetFirstDayOfWeek (HWND hwnd, WPARAM wParam, LPARAM lParam) 704 705 { 706 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 707 int prev=infoPtr->firstDay; 708 char buf[40]; 709 int day; 710 711 //TRACE ("%x %lx\n",wParam,lParam); 712 713 if ((lParam>=0) && (lParam<7)) { 714 infoPtr->firstDay=(int) lParam; 715 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, 716 buf, sizeof(buf)); 717 //TRACE ("%s %d\n",buf,strlen(buf)); 718 if ((sscanf(buf,"%d",&day)==1) && (infoPtr->firstDay!=day)) 719 infoPtr->firstDay|=HIWORD(TRUE); 720 721 } 722 return prev; 723 } 724 725 726 727 /* FIXME: fill this in */ 728 729 static LRESULT 730 MONTHCAL_GetMonthRange (HWND hwnd, WPARAM wParam, LPARAM lParam) 731 { 732 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 733 734 //TRACE ("%x %lx\n",wParam,lParam); 735 736 return infoPtr->monthRange; 737 } 738 739 static LRESULT 740 MONTHCAL_GetMaxTodayWidth (HWND hwnd) 741 742 { 743 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 744 745 return (infoPtr->today.right-infoPtr->today.left); 746 } 747 748 /* FIXME: are validated times taken from current date/time or simply 749 * copied? 750 * FIXME: check whether MCM_GETMONTHRANGE shows correct result after 751 * adjusting range with MCM_SETRANGE 752 */ 753 754 static LRESULT 755 MONTHCAL_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam) 756 { 757 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 758 SYSTEMTIME lprgSysTimeArray[1]; 759 int prev; 760 761 //TRACE ("%x %lx\n",wParam,lParam); 762 763 if (wParam & GDTR_MAX) { 764 if (MONTHCAL_ValidateTime(lprgSysTimeArray[1])){ 765 MONTHCAL_CopyTime (&lprgSysTimeArray[1],&infoPtr->maxDate); 766 infoPtr->rangeValid|=GDTR_MAX; 767 } else { 768 GetSystemTime (&infoPtr->todaysDate); 769 MONTHCAL_CopyTime (&infoPtr->todaysDate,&infoPtr->maxDate); 770 } 771 } 772 if (wParam & GDTR_MIN) { 773 if (MONTHCAL_ValidateTime(lprgSysTimeArray[0])) { 774 MONTHCAL_CopyTime (&lprgSysTimeArray[0],&infoPtr->maxDate); 775 infoPtr->rangeValid|=GDTR_MIN; 776 } else { 777 GetSystemTime (&infoPtr->todaysDate); 778 MONTHCAL_CopyTime (&infoPtr->todaysDate,&infoPtr->maxDate); 779 } 780 } 781 782 prev=infoPtr->monthRange; 783 infoPtr->monthRange=infoPtr->maxDate.wMonth-infoPtr->minDate.wMonth; 784 if (infoPtr->monthRange!=prev) 785 COMCTL32_ReAlloc (infoPtr->monthdayState, 786 infoPtr->monthRange*sizeof(MONTHDAYSTATE)); 787 788 return 1; 789 } 790 791 792 /* CHECKME: At the moment, we copy ranges anyway,regardless of 793 * infoPtr->rangeValid; a invalid range is simply filled with zeros in 794 * SetRange. Is this the right behavior? 795 */ 796 797 static LRESULT 798 MONTHCAL_GetRange (HWND hwnd, WPARAM wParam, LPARAM lParam) 799 { 800 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 801 SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam; 802 803 /* validate parameters */ 804 805 if ( (infoPtr==NULL) || (lprgSysTimeArray==NULL) ) return FALSE; 806 807 MONTHCAL_CopyTime (&infoPtr->maxDate,&lprgSysTimeArray[1]); 808 MONTHCAL_CopyTime (&infoPtr->minDate,&lprgSysTimeArray[0]); 809 810 return infoPtr->rangeValid; 811 } 812 813 static LRESULT 814 MONTHCAL_SetDayState (HWND hwnd, WPARAM wParam, LPARAM lParam) 815 816 { 817 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 818 int i,iMonths=(int) wParam; 819 MONTHDAYSTATE *dayStates=(LPMONTHDAYSTATE) lParam; 820 821 //TRACE ("%x %lx\n",wParam,lParam); 822 if (iMonths!=infoPtr->monthRange) return 0; 823 824 for (i=0; i<iMonths; i++) 825 infoPtr->monthdayState[i]=dayStates[i]; 826 return 1; 827 } 828 829 static LRESULT 830 MONTHCAL_GetCurSel (HWND hwnd, WPARAM wParam, LPARAM lParam) 831 { 832 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 833 SYSTEMTIME *lpSel=(SYSTEMTIME *) lParam; 834 835 //TRACE ("%x %lx\n",wParam,lParam); 836 if ( (infoPtr==NULL) || (lpSel==NULL) ) return FALSE; 837 if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE; 838 839 MONTHCAL_CopyTime (&infoPtr->minSel,lpSel); 840 return TRUE; 841 } 842 843 844 /* FIXME: if the specified date is not visible, make it visible */ 845 /* FIXME: redraw? */ 846 847 static LRESULT 848 MONTHCAL_SetCurSel (HWND hwnd, WPARAM wParam, LPARAM lParam) 849 { 850 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 851 SYSTEMTIME *lpSel=(SYSTEMTIME *) lParam; 852 853 //TRACE ("%x %lx\n",wParam,lParam); 854 if ( (infoPtr==NULL) || (lpSel==NULL) ) return FALSE; 855 if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE; 856 857 //TRACE ("%d %d\n",lpSel->wMonth,lpSel->wDay); 858 859 MONTHCAL_CopyTime (lpSel,&infoPtr->minSel); 860 MONTHCAL_CopyTime (lpSel,&infoPtr->maxSel); 861 862 return TRUE; 863 } 864 865 static LRESULT 866 MONTHCAL_GetMaxSelCount (HWND hwnd, WPARAM wParam, LPARAM lParam) 867 { 868 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 869 870 //TRACE ("%x %lx\n",wParam,lParam); 871 return infoPtr->maxSelCount; 872 } 873 874 static LRESULT 875 MONTHCAL_SetMaxSelCount (HWND hwnd, WPARAM wParam, LPARAM lParam) 876 { 877 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 878 879 //TRACE ("%x %lx\n",wParam,lParam); 880 if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) { 881 infoPtr->maxSelCount=wParam; 882 } 883 884 return TRUE; 885 } 886 887 888 static LRESULT 889 MONTHCAL_GetSelRange (HWND hwnd, WPARAM wParam, LPARAM lParam) 890 { 891 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 892 SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam; 893 894 //TRACE ("%x %lx\n",wParam,lParam); 895 896 /* validate parameters */ 897 898 if ( (infoPtr==NULL) || (lprgSysTimeArray==NULL) ) return FALSE; 899 900 if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) { 901 MONTHCAL_CopyTime (&infoPtr->maxSel,&lprgSysTimeArray[1]); 902 MONTHCAL_CopyTime (&infoPtr->minSel,&lprgSysTimeArray[0]); 903 //TRACE ("[min,max]=[%d %d]\n",infoPtr->minSel.wDay,infoPtr->maxSel.wDay); 904 return TRUE; 905 } 906 907 return FALSE; 908 } 909 910 static LRESULT 911 MONTHCAL_SetSelRange (HWND hwnd, WPARAM wParam, LPARAM lParam) 912 { 913 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 914 SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam; 915 916 //TRACE ("%x %lx\n",wParam,lParam); 917 918 /* validate parameters */ 919 920 if ( (infoPtr==NULL) || (lprgSysTimeArray==NULL) ) return FALSE; 921 922 if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) { 923 MONTHCAL_CopyTime (&lprgSysTimeArray[1],&infoPtr->maxSel); 924 MONTHCAL_CopyTime (&lprgSysTimeArray[0],&infoPtr->minSel); 925 //TRACE ("[min,max]=[%d %d]\n",infoPtr->minSel.wDay,infoPtr->maxSel.wDay); 926 return TRUE; 927 } 928 929 return FALSE; 930 } 931 932 933 934 935 static LRESULT 936 MONTHCAL_GetToday (HWND hwnd, WPARAM wParam, LPARAM lParam) 937 { 938 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 939 SYSTEMTIME *lpToday=(SYSTEMTIME *) lParam; 940 941 //TRACE ("%x %lx\n",wParam,lParam); 942 943 /* validate parameters */ 944 945 if ( (infoPtr==NULL) || (lpToday==NULL) ) return FALSE; 946 MONTHCAL_CopyTime (&infoPtr->todaysDate,lpToday); 947 return TRUE; 948 } 949 950 951 static LRESULT 952 MONTHCAL_SetToday (HWND hwnd, WPARAM wParam, LPARAM lParam) 953 { 954 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 955 SYSTEMTIME *lpToday=(SYSTEMTIME *) lParam; 956 957 //TRACE ("%x %lx\n",wParam,lParam); 958 959 /* validate parameters */ 960 961 if ( (infoPtr==NULL) || (lpToday==NULL) ) return FALSE; 962 MONTHCAL_CopyTime (lpToday, &infoPtr->todaysDate); 963 return TRUE; 964 } 965 966 967 968 969 static LRESULT 970 MONTHCAL_HitTest (HWND hwnd, LPARAM lParam) 971 { 972 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); 973 PMCHITTESTINFO lpht=(PMCHITTESTINFO) lParam; 974 UINT x,y; 975 DWORD retval; 976 977 x=lpht->pt.x; 978 y=lpht->pt.y; 979 retval=MCHT_NOWHERE; 980 981 982 /* are we in the header? */ 983 984 if (PtInRect (&infoPtr->title, lpht->pt)) { 985 986 if (PtInRect (&infoPtr->titlebtnprev, lpht->pt)) { 987 retval=MCHT_TITLEBTNPREV; 988 goto done; 989 } 990 if (PtInRect (&infoPtr->titlebtnnext, lpht->pt)) { 991 retval=MCHT_TITLEBTNNEXT; 992 goto done; 993 } 994 if (PtInRect (&infoPtr->titlemonth, lpht->pt)) { 995 retval=MCHT_TITLEMONTH; 996 goto done; 997 } 998 if (PtInRect (&infoPtr->titleyear, lpht->pt)) { 999 retval=MCHT_TITLEYEAR; 1000 goto done; 1001 } 1002 retval=MCHT_TITLE; 1003 goto done; 1004 } 1005 1006 if (PtInRect (&infoPtr->days, lpht->pt)) { 1007 retval=MCHT_CALENDARDAY; /* FIXME: find out which day we're on */ 1008 goto done; 1009 } 1010 if (PtInRect (&infoPtr->weeknums, lpht->pt)) { 1011 retval=MCHT_CALENDARWEEKNUM;/* FIXME: find out which day we're on */ 1012 goto done; 1013 } 1014 if (PtInRect (&infoPtr->prevmonth, lpht->pt)) { 1015 retval=MCHT_CALENDARDATEPREV; 1016 goto done; 1017 } 1018 if (PtInRect (&infoPtr->nextmonth, lpht->pt) || 1019 ((x>infoPtr->nextmonth.left) && (x<infoPtr->nextmonth.right) && 1020 (y>infoPtr->nextmonth.bottom) && (y<infoPtr->today.top ))) { 1021 retval=MCHT_CALENDARDATENEXT; 1022 goto done; 1023 } 1024 1025 1026 if (PtInRect (&infoPtr->today, lpht->pt)) { 1027 retval=MCHT_TODAYLINK; 1028 goto done; 1029 } 1030 1031 /* MCHT_CALENDARDATE determination: since the next & previous month have 1032 * been handled already (MCHT_CALENDARDATEPREV/NEXT), we only have to check 1033 * whether we're in the calendar area. infoPtr->prevMonth.left handles the 1034 * MCS_WEEKNUMBERS style nicely. 1035 */ 1036 1037 1038 //TRACE ("%d %d [%d %d %d %d] [%d %d %d %d]\n",x,y, 1039 // infoPtr->prevmonth.left, infoPtr->prevmonth.right, 1040 // infoPtr->prevmonth.top, infoPtr->prevmonth.bottom, 1041 // infoPtr->nextmonth.left, infoPtr->nextmonth.right, 1042 // infoPtr->nextmonth.top, infoPtr->nextmonth.bottom); 1043 1044 if ((x>infoPtr->prevmonth.left) && (x<infoPtr->nextmonth.right) && 1045 (y>infoPtr->prevmonth.top) && (y<infoPtr->nextmonth.bottom)) { 1046 lpht->st.wYear=infoPtr->currentYear; 1047 lpht->st.wMonth=infoPtr->currentMonth; 1048 1049 lpht->st.wDay=MONTHCAL_CalcDayFromPos (infoPtr,x,y); 1050 1051 //TRACE ("day hit: %d\n",lpht->st.wDay); 1052 retval=MCHT_CALENDARDATE; 1053 goto done; 1054 1055 } 1056 1057 /* Hit nothing special? What's left must be background :-) */ 1058 1059 retval=MCHT_CALENDARBK; 1060 done: 1061 lpht->uHit=retval; 1062 return retval; 1063 } 1064 1065 1066 1067 static void MONTHCAL_GoToNextMonth (HWND hwnd, MONTHCAL_INFO *infoPtr) 1068 { 1069 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 1070 1071 //TRACE ("\n"); 1072 1073 infoPtr->currentMonth++; 1074 if (infoPtr->currentMonth>12) { 1075 infoPtr->currentYear++; 1076 infoPtr->currentMonth=1; 1077 } 1078 1079 if (dwStyle & MCS_DAYSTATE) { 1080 NMDAYSTATE nmds; 1081 int i; 1082 1083 nmds.nmhdr.hwndFrom = hwnd; 1084 nmds.nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 1085 nmds.nmhdr.code = MCN_GETDAYSTATE; 1086 nmds.cDayState = infoPtr->monthRange; 1087 nmds.prgDayState = COMCTL32_Alloc 1088 (infoPtr->monthRange*sizeof(MONTHDAYSTATE)); 1089 1090 SendMessageA (GetParent (hwnd), WM_NOTIFY, 1091 (WPARAM)nmds.nmhdr.idFrom, (LPARAM)&nmds); 1092 for (i=0; i<infoPtr->monthRange; i++) 1093 infoPtr->monthdayState[i]=nmds.prgDayState[i]; 1094 } 1095 1096 } 1097 1098 1099 static void MONTHCAL_GoToPrevMonth (HWND hwnd, MONTHCAL_INFO *infoPtr) 1100 { 1101 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 1102 1103 //TRACE ("\n"); 1104 1105 infoPtr->currentMonth--; 1106 if (infoPtr->currentMonth<1) { 1107 infoPtr->currentYear--; 1108 infoPtr->currentMonth=12; 1109 } 1110 1111 if (dwStyle & MCS_DAYSTATE) { 1112 NMDAYSTATE nmds; 1113 int i; 1114 1115 nmds.nmhdr.hwndFrom = hwnd; 1116 nmds.nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 1117 nmds.nmhdr.code = MCN_GETDAYSTATE; 1118 nmds.cDayState = infoPtr->monthRange; 1119 nmds.prgDayState = COMCTL32_Alloc 1120 (infoPtr->monthRange*sizeof(MONTHDAYSTATE)); 1121 1122 SendMessageA (GetParent (hwnd), WM_NOTIFY, 1123 (WPARAM)nmds.nmhdr.idFrom, (LPARAM)&nmds); 1124 for (i=0; i<infoPtr->monthRange; i++) 1125 infoPtr->monthdayState[i]=nmds.prgDayState[i]; 1126 } 1127 } 1128 1129 1130 static LRESULT 1131 MONTHCAL_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 1132 1133 { 1134 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd); 1135 MCHITTESTINFO ht; 1136 HDC hdc; 1137 DWORD hit; 1138 HMENU hMenu; 1139 HWND retval; 1140 1141 1142 //TRACE ("%x %lx\n",wParam,lParam); 1143 1144 ht.pt.x = (INT)LOWORD(lParam); 1145 ht.pt.y = (INT)HIWORD(lParam); 1146 hit=MONTHCAL_HitTest (hwnd, (LPARAM) &ht); 1147 1148 hdc=GetDC (hwnd); 1149 1150 if (hit & MCHT_NEXT){ 1151 MONTHCAL_GoToNextMonth (hwnd, infoPtr); 1152 infoPtr->status=MC_NEXTPRESSED; 1153 SetTimer (hwnd, MC_NEXTMONTHTIMER, MC_NEXTMONTHDELAY,0); 1154 } 1155 if (hit & MCHT_PREV) { 1156 MONTHCAL_GoToPrevMonth (hwnd, infoPtr); 1157 infoPtr->status=MC_PREVPRESSED; 1158 SetTimer (hwnd, MC_PREVMONTHTIMER, MC_NEXTMONTHDELAY,0); 1159 } 1160 1161 if (hit == MCHT_TITLEMONTH) { 1162 /* 1163 HRSRC hrsrc = FindResourceA( COMCTL32_hModule, MAKEINTRESOURCEA(IDD_MCMONTHMENU), RT_MENUA ); 1164 if (!hrsrc) { 1165 TRACE ("returning zero\n"); 1166 return 0; 1167 } 1168 TRACE ("resource is:%x\n",hrsrc); 1169 hMenu=LoadMenuIndirectA( (LPCVOID)LoadResource( COMCTL32_hModule, hrsrc )); 1170 1171 TRACE ("menu is:%x\n",hMenu); 1172 */ 1173 1174 hMenu=CreateMenu (); 1175 AppendMenuA (hMenu,MF_STRING,IDM_JAN,"January"); 1176 AppendMenuA (hMenu,MF_STRING,IDM_FEB,"February"); 1177 AppendMenuA (hMenu,MF_STRING,IDM_MAR,"March"); 1178 1179 retval=CreateWindowA (POPUPMENU_CLASS_ATOM, NULL, 1180 WS_CHILD | WS_VISIBLE, 1181 0,0,100,220, 1182 hwnd, hMenu, GetWindowLongA (hwnd, GWL_HINSTANCE), NULL); 1183 //TRACE ("hwnd returned:%x\n",retval); 1184 1185 } 1186 if (hit == MCHT_TITLEYEAR) { 1187 //FIXME ("create updown for yearselection\n"); 1188 } 1189 if (hit == MCHT_TODAYLINK) { 1190 //FIXME ("set currentday\n"); 1191 } 1192 if (hit == MCHT_CALENDARDATE) { 1193 SYSTEMTIME selArray[2]; 1194 NMSELCHANGE nmsc; 1195 1196 //TRACE ("\n"); 1197 nmsc.nmhdr.hwndFrom = hwnd; 1198 nmsc.nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 1199 nmsc.nmhdr.code = MCN_SELCHANGE; 1200 MONTHCAL_CopyTime (&nmsc.stSelStart, &infoPtr->minSel); 1201 MONTHCAL_CopyTime (&nmsc.stSelEnd, &infoPtr->maxSel); 1202 1203 SendMessageA (GetParent (hwnd), WM_NOTIFY, 1204 (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc); 1205 1206 MONTHCAL_CopyTime (&ht.st, &selArray[0]); 1207 MONTHCAL_CopyTime (&ht.st, &selArray[1]); 1208 MONTHCAL_SetSelRange (hwnd,0,(LPARAM) &selArray); 1209 1210 infoPtr->firstSelDay=ht.st.wDay; 1211 infoPtr->curSelDay=ht.st.wDay; 1212 infoPtr->status=MC_SEL_LBUTDOWN; 1213 } 1214 1215 MONTHCAL_Refresh (hwnd,hdc); 1216 ReleaseDC (hwnd,hdc); 1217 return 0; 1218 } 1219 1220 static LRESULT 1221 MONTHCAL_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) 1222 1223 { 1224 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd); 1225 NMSELCHANGE nmsc; 1226 NMHDR nmhdr; 1227 HDC hdc; 1228 1229 //TRACE ("\n"); 1230 1231 if (infoPtr->status & MC_NEXTPRESSED) 1232 KillTimer (hwnd, MC_NEXTMONTHTIMER); 1233 if (infoPtr->status & MC_PREVPRESSED) 1234 KillTimer (hwnd, MC_PREVMONTHTIMER); 1235 infoPtr->status=MC_SEL_LBUTUP; 1236 infoPtr->curSelDay=0; 1237 1238 nmhdr.hwndFrom = hwnd; 1239 nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 1240 nmhdr.code = NM_RELEASEDCAPTURE; 1241 //TRACE ("Sent notification from %x to %x\n", hwnd, GetParent (hwnd)); 1242 1243 SendMessageA (GetParent (hwnd), WM_NOTIFY, 1244 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 1245 1246 nmsc.nmhdr.hwndFrom = hwnd; 1247 nmsc.nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 1248 nmsc.nmhdr.code = MCN_SELECT; 1249 MONTHCAL_CopyTime (&nmsc.stSelStart, &infoPtr->minSel); 1250 MONTHCAL_CopyTime (&nmsc.stSelEnd, &infoPtr->maxSel); 1251 1252 SendMessageA (GetParent (hwnd), WM_NOTIFY, 1253 (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc); 1254 1255 hdc=GetDC (hwnd); 1256 MONTHCAL_Refresh (hwnd,hdc); 1257 ReleaseDC (hwnd,hdc); 1258 1259 return 0; 1260 } 1261 1262 static LRESULT 1263 MONTHCAL_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam) 1264 1265 { 1266 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd); 1267 HDC hdc; 1268 1269 //TRACE(" %d\n",wParam); 1270 if (!infoPtr) return FALSE; 1271 1272 hdc=GetDC (hwnd); 1273 switch (wParam) { 1274 case MC_NEXTMONTHTIMER: 1275 MONTHCAL_GoToNextMonth (hwnd, infoPtr); 1276 break; 1277 case MC_PREVMONTHTIMER: 1278 MONTHCAL_GoToPrevMonth (hwnd, infoPtr); 1279 break; 1280 //default: 1281 //ERR("got unknown timer\n"); 1282 } 1283 1284 MONTHCAL_Refresh (hwnd,hdc); 1285 ReleaseDC (hwnd,hdc); 1286 return 0; 1287 } 1288 1289 1290 1291 static LRESULT 1292 MONTHCAL_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) 1293 { 1294 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd); 1295 MCHITTESTINFO ht; 1296 HDC hdc; 1297 int selday,hit; 1298 RECT r; 1299 1300 if (!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0; 1301 1302 ht.pt.x=LOWORD(lParam); 1303 ht.pt.y=HIWORD(lParam); 1304 1305 hit=MONTHCAL_HitTest (hwnd, (LPARAM) &ht); 1306 1307 /* not on the calendar date numbers? bail out */ 1308 //TRACE ("hit:%x\n",hit); 1309 if ((hit & MCHT_CALENDARDATE) !=MCHT_CALENDARDATE) return 0; 1310 1311 selday=ht.st.wDay; 1312 infoPtr->curSelDay=selday; 1313 MONTHCAL_CalcPosFromDay (infoPtr,selday,ht.st.wMonth,&r); 1314 1315 if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) { 1316 SYSTEMTIME selArray[2]; 1317 int i; 1318 1319 MONTHCAL_GetSelRange (hwnd,0,(LPARAM) &selArray); 1320 i=0; 1321 if (infoPtr->firstSelDay==selArray[0].wDay) i=1; 1322 //TRACE ("oldRange:%d %d %d %d\n",infoPtr->firstSelDay,selArray[0].wDay,selArray[1].wDay,i); 1323 if (infoPtr->firstSelDay==selArray[1].wDay) { 1324 /* 1st time we get here: selArray[0]=selArray[1]) */ 1325 /* if we're still at the first selected date, return */ 1326 if (infoPtr->firstSelDay==selday) goto done; 1327 1328 if (selday<infoPtr->firstSelDay) i=0; 1329 } 1330 1331 if (abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) { 1332 if (selday>infoPtr->firstSelDay) 1333 selday=infoPtr->firstSelDay+infoPtr->maxSelCount; 1334 else 1335 selday=infoPtr->firstSelDay-infoPtr->maxSelCount; 1336 } 1337 1338 if (selArray[i].wDay!=selday) { 1339 1340 //TRACE ("newRange:%d %d %d %d\n",infoPtr->firstSelDay,selArray[0].wDay,selArray[1].wDay,i); 1341 1342 selArray[i].wDay=selday; 1343 1344 1345 if (selArray[0].wDay>selArray[1].wDay) { 1346 DWORD tempday; 1347 tempday=selArray[1].wDay; 1348 selArray[1].wDay=selArray[0].wDay; 1349 selArray[0].wDay=tempday; 1350 } 1351 1352 MONTHCAL_SetSelRange (hwnd,0,(LPARAM) &selArray); 1353 } 1354 } 1355 1356 done: 1357 1358 hdc=GetDC (hwnd); 1359 MONTHCAL_Refresh (hwnd, hdc); 1360 ReleaseDC (hwnd, hdc); 1361 1362 return 0; 1363 } 1364 1365 static LRESULT 1366 MONTHCAL_Paint (HWND hwnd, WPARAM wParam) 1367 { 1368 HDC hdc; 1369 PAINTSTRUCT ps; 1370 1371 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; 1372 MONTHCAL_Refresh (hwnd, hdc); 1373 if(!wParam) 1374 EndPaint (hwnd, &ps); 1375 return 0; 1376 } 1377 1378 static LRESULT 1379 MONTHCAL_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 1380 { 1381 HDC hdc; 1382 1383 //TRACE ("\n"); 1384 1385 hdc = GetDC (hwnd); 1386 MONTHCAL_Refresh (hwnd, hdc); 1387 ReleaseDC (hwnd, hdc); 1388 InvalidateRect (hwnd, NULL, TRUE); 1389 1390 return 0; 1391 } 1392 1393 1394 static LRESULT 1395 MONTHCAL_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 1396 { 1397 HDC hdc; 1398 1399 //TRACE ("\n"); 1400 1401 hdc = GetDC (hwnd); 1402 MONTHCAL_Refresh (hwnd, hdc); 1403 ReleaseDC (hwnd, hdc); 1404 1405 return 0; 1406 } 1407 1408 1409 /* FIXME: check whether dateMin/dateMax need to be adjusted. */ 29 1410 30 1411 … … 33 1414 { 34 1415 MONTHCAL_INFO *infoPtr; 1416 LOGFONTA logFont; 35 1417 36 1418 /* allocate memory for info structure */ … … 38 1420 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); 39 1421 1422 if (infoPtr == NULL) { 1423 //ERR ( "could not allocate info memory!\n"); 1424 return 0; 1425 } 1426 if ((MONTHCAL_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) { 1427 //ERR ( "pointer assignment error!\n"); 1428 return 0; 1429 } 1430 1431 1432 infoPtr->hFont=GetStockObject(DEFAULT_GUI_FONT); 1433 GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont); 1434 logFont.lfWeight=FW_BOLD; 1435 infoPtr->hBoldFont = CreateFontIndirectA (&logFont); 40 1436 41 1437 /* initialize info structure */ 42 43 1438 /* FIXME: calculate systemtime ->> localtime (substract timezoneinfo) */ 1439 1440 GetSystemTime (&infoPtr->todaysDate); 1441 infoPtr->firstDay = 0; 1442 infoPtr->currentMonth = infoPtr->todaysDate.wMonth; 1443 infoPtr->currentYear= infoPtr->todaysDate.wYear; 1444 MONTHCAL_CopyTime (&infoPtr->todaysDate,&infoPtr->minDate); 1445 MONTHCAL_CopyTime (&infoPtr->todaysDate,&infoPtr->maxDate); 1446 infoPtr->maxSelCount=6; 1447 infoPtr->monthRange=3; 1448 infoPtr->monthdayState=COMCTL32_Alloc 1449 (infoPtr->monthRange*sizeof(MONTHDAYSTATE)); 1450 infoPtr->titlebk = GetSysColor (COLOR_GRAYTEXT); 1451 infoPtr->titletxt = GetSysColor (COLOR_WINDOW); 1452 infoPtr->monthbk = GetSysColor (COLOR_WINDOW); 1453 infoPtr->trailingtxt = GetSysColor (COLOR_GRAYTEXT); 1454 infoPtr->bk = GetSysColor (COLOR_WINDOW); 1455 infoPtr->txt = GetSysColor (COLOR_WINDOWTEXT); 44 1456 45 1457 return 0; … … 52 1464 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd); 53 1465 54 55 56 57 58 59 /* free ipaddress info data */ 1466 /* free month calendar info data */ 60 1467 COMCTL32_Free (infoPtr); 61 1468 … … 65 1472 66 1473 67 68 LRESULT WINAPI 1474 static LRESULT WINAPI 69 1475 MONTHCAL_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 70 1476 { 1477 71 1478 switch (uMsg) 72 1479 { 73 1480 74 75 case WM_CREATE: 76 return MONTHCAL_Create (hwnd, wParam, lParam); 77 78 case WM_DESTROY: 79 return MONTHCAL_Destroy (hwnd, wParam, lParam); 80 81 default: 82 // if (uMsg >= WM_USER) 83 // ERR (monthcal, "unknown msg %04x wp=%08x lp=%08lx\n", 84 // uMsg, wParam, lParam); 85 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 1481 case MCM_GETCURSEL: 1482 return MONTHCAL_GetCurSel (hwnd, wParam, lParam); 1483 1484 case MCM_SETCURSEL: 1485 return MONTHCAL_SetCurSel (hwnd, wParam, lParam); 1486 1487 case MCM_GETMAXSELCOUNT: 1488 return MONTHCAL_GetMaxSelCount (hwnd, wParam, lParam); 1489 1490 case MCM_SETMAXSELCOUNT: 1491 return MONTHCAL_SetMaxSelCount (hwnd, wParam, lParam); 1492 1493 case MCM_GETSELRANGE: 1494 return MONTHCAL_GetSelRange (hwnd, wParam, lParam); 1495 1496 case MCM_SETSELRANGE: 1497 return MONTHCAL_SetSelRange (hwnd, wParam, lParam); 1498 1499 case MCM_GETMONTHRANGE: 1500 return MONTHCAL_GetMonthRange (hwnd, wParam, lParam); 1501 1502 case MCM_SETDAYSTATE: 1503 return MONTHCAL_SetDayState (hwnd, wParam, lParam); 1504 1505 case MCM_GETMINREQRECT: 1506 return MONTHCAL_GetMinReqRect (hwnd, wParam, lParam); 1507 1508 case MCM_GETCOLOR: 1509 return MONTHCAL_GetColor (hwnd, wParam, lParam); 1510 1511 case MCM_SETCOLOR: 1512 return MONTHCAL_SetColor (hwnd, wParam, lParam); 1513 1514 case MCM_GETTODAY: 1515 return MONTHCAL_GetToday (hwnd, wParam, lParam); 1516 1517 case MCM_SETTODAY: 1518 return MONTHCAL_SetToday (hwnd, wParam, lParam); 1519 1520 case MCM_HITTEST: 1521 return MONTHCAL_HitTest (hwnd,lParam); 1522 1523 case MCM_GETFIRSTDAYOFWEEK: 1524 return MONTHCAL_GetFirstDayOfWeek (hwnd, wParam, lParam); 1525 1526 case MCM_SETFIRSTDAYOFWEEK: 1527 return MONTHCAL_SetFirstDayOfWeek (hwnd, wParam, lParam); 1528 1529 case MCM_GETRANGE: 1530 return MONTHCAL_GetRange (hwnd, wParam, lParam); 1531 1532 case MCM_SETRANGE: 1533 return MONTHCAL_SetRange (hwnd, wParam, lParam); 1534 1535 case MCM_GETMONTHDELTA: 1536 return MONTHCAL_GetMonthDelta (hwnd, wParam, lParam); 1537 1538 case MCM_SETMONTHDELTA: 1539 return MONTHCAL_SetMonthDelta (hwnd, wParam, lParam); 1540 1541 case MCM_GETMAXTODAYWIDTH: 1542 return MONTHCAL_GetMaxTodayWidth (hwnd); 1543 1544 case WM_GETDLGCODE: 1545 return DLGC_WANTARROWS | DLGC_WANTCHARS; 1546 1547 case WM_KILLFOCUS: 1548 return MONTHCAL_KillFocus (hwnd, wParam, lParam); 1549 1550 case WM_LBUTTONDOWN: 1551 return MONTHCAL_LButtonDown (hwnd, wParam, lParam); 1552 1553 case WM_MOUSEMOVE: 1554 return MONTHCAL_MouseMove (hwnd, wParam, lParam); 1555 1556 case WM_LBUTTONUP: 1557 return MONTHCAL_LButtonUp (hwnd, wParam, lParam); 1558 1559 case WM_PAINT: 1560 return MONTHCAL_Paint (hwnd, wParam); 1561 1562 case WM_SETFOCUS: 1563 return MONTHCAL_SetFocus (hwnd, wParam, lParam); 1564 1565 case WM_CREATE: 1566 return MONTHCAL_Create (hwnd, wParam, lParam); 1567 1568 case WM_TIMER: 1569 return MONTHCAL_Timer (hwnd, wParam, lParam); 1570 1571 case WM_DESTROY: 1572 return MONTHCAL_Destroy (hwnd, wParam, lParam); 1573 1574 default: 1575 //if (uMsg >= WM_USER) 1576 // ERR ( "unknown msg %04x wp=%08x lp=%08lx\n", 1577 // uMsg, wParam, lParam); 1578 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 86 1579 } 87 1580 return 0; … … 89 1582 90 1583 91 VOID 92 MONTHCAL_Register ( VOID)1584 void 1585 MONTHCAL_Register (void) 93 1586 { 94 1587 WNDCLASSA wndClass; … … 104 1597 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 105 1598 wndClass.lpszClassName = MONTHCAL_CLASSA; 106 1599 107 1600 RegisterClassA (&wndClass); 108 1601 } 109 1602 110 1603 111 VOID 112 MONTHCAL_Unregister ( VOID)1604 void 1605 MONTHCAL_Unregister (void) 113 1606 { 114 1607 if (GlobalFindAtomA (MONTHCAL_CLASSA)) 115 116 } 117 1608 UnregisterClassA (MONTHCAL_CLASSA, (HINSTANCE)NULL); 1609 } 1610 -
TabularUnified trunk/src/comctl32/nativefont.c ¶
r94 r496 1 /* $Id: nativefont.c,v 1. 3 1999-06-10 16:22:01 achimhaExp $ */1 /* $Id: nativefont.c,v 1.4 1999-08-14 16:13:12 cbratschi Exp $ */ 2 2 /* 3 3 * Native Font control … … 60 60 61 61 62 LRESULT WINAPI62 static LRESULT WINAPI 63 63 NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 64 64 { … … 66 66 { 67 67 68 69 68 case WM_CREATE: 69 return NATIVEFONT_Create (hwnd, wParam, lParam); 70 70 71 72 71 case WM_DESTROY: 72 return NATIVEFONT_Destroy (hwnd, wParam, lParam); 73 73 74 75 // 76 // 77 74 default: 75 // ERR (nativefont, "unknown msg %04x wp=%08x lp=%08lx\n", 76 // uMsg, wParam, lParam); 77 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 78 78 } 79 79 return 0; … … 96 96 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 97 97 wndClass.lpszClassName = WC_NATIVEFONTCTLA; 98 98 99 99 RegisterClassA (&wndClass); 100 100 } … … 105 105 { 106 106 if (GlobalFindAtomA (WC_NATIVEFONTCTLA)) 107 107 UnregisterClassA (WC_NATIVEFONTCTLA, (HINSTANCE)NULL); 108 108 } 109 109 -
TabularUnified trunk/src/comctl32/pager.c ¶
r94 r496 1 /* $Id: pager.c,v 1. 3 1999-06-10 16:22:01 achimhaExp $ */1 /* $Id: pager.c,v 1.4 1999-08-14 16:13:12 cbratschi Exp $ */ 2 2 /* 3 3 * Pager control … … 93 93 94 94 if (infoPtr->hwndChild) { 95 96 97 98 99 100 101 102 103 95 ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE)); 96 nmpgcs.hdr.hwndFrom = hwnd; 97 nmpgcs.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 98 nmpgcs.hdr.code = PGN_CALCSIZE; 99 nmpgcs.dwFlag = (dwStyle & PGS_HORZ) ? PGF_CALCWIDTH : PGF_CALCHEIGHT; 100 SendMessageA (GetParent (hwnd), WM_NOTIFY, 101 (WPARAM)nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs); 102 103 infoPtr->nChildSize = (dwStyle & PGS_HORZ) ? nmpgcs.iWidth : nmpgcs.iHeight; 104 104 105 105 … … 168 168 /* FIXME: redraw */ 169 169 if (infoPtr->hwndChild) { 170 SetParent (infoPtr->hwndChild, hwnd); 171 SetWindowPos (infoPtr->hwndChild, HWND_TOP, 172 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE); 170 RECT rect; 171 172 GetClientRect(hwnd,&rect); 173 SetParent (infoPtr->hwndChild, hwnd); 174 SetWindowPos (infoPtr->hwndChild, HWND_TOP, 175 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE); 176 177 MoveWindow (infoPtr->hwndChild, 0, 0, rect.right, rect.bottom, TRUE); 173 178 } 174 179 … … 188 193 /* FIXME: redraw */ 189 194 SetWindowPos (infoPtr->hwndChild, HWND_TOP, 190 195 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE); 191 196 192 197 return 0; … … 268 273 GetClientRect (hwnd, &rect); 269 274 if (infoPtr->hwndChild) { 270 271 272 273 /* MoveWindow32(infoPtr->hwndChild, 1, 1, rect.right - 2, rect.bottom-2, TRUE); */274 /* UpdateWindow32(infoPtr->hwndChild); */275 SetWindowPos (infoPtr->hwndChild, HWND_TOP, rect.left, rect.top, 276 rect.right - rect.left, rect.bottom - rect.top, 277 SWP_SHOWWINDOW); 278 /* MoveWindow (infoPtr->hwndChild, 1, 1, rect.right - 2, rect.bottom-2, TRUE); */ 279 /* UpdateWindow (infoPtr->hwndChild); */ 275 280 276 281 } 277 /* FillRect 32 ((HDC32)wParam, &rect, hBrush); */278 /* DeleteObject 32(hBrush); */282 /* FillRect ((HDC)wParam, &rect, hBrush); */ 283 /* DeleteObject (hBrush); */ 279 284 return TRUE; 280 285 } … … 282 287 283 288 284 LRESULT WINAPI289 static LRESULT WINAPI 285 290 PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 286 291 { 287 292 switch (uMsg) 288 293 { 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 /* 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 /* 344 /* 345 346 347 348 349 350 // 351 // 352 // 353 294 case PGM_FORWARDMOUSE: 295 return PAGER_ForwardMouse (hwnd, wParam); 296 297 case PGM_GETBKCOLOR: 298 return PAGER_GetBkColor (hwnd, wParam, lParam); 299 300 case PGM_GETBORDER: 301 return PAGER_GetBorder (hwnd, wParam, lParam); 302 303 case PGM_GETBUTTONSIZE: 304 return PAGER_GetButtonSize (hwnd, wParam, lParam); 305 306 case PGM_GETBUTTONSTATE: 307 return PAGER_GetButtonState (hwnd, wParam, lParam); 308 309 /* case PGM_GETDROPTARGET: */ 310 311 case PGM_GETPOS: 312 return PAGER_SetPos (hwnd, wParam, lParam); 313 314 case PGM_RECALCSIZE: 315 return PAGER_RecalcSize (hwnd, wParam, lParam); 316 317 case PGM_SETBKCOLOR: 318 return PAGER_SetBkColor (hwnd, wParam, lParam); 319 320 case PGM_SETBORDER: 321 return PAGER_SetBorder (hwnd, wParam, lParam); 322 323 case PGM_SETBUTTONSIZE: 324 return PAGER_SetButtonSize (hwnd, wParam, lParam); 325 326 case PGM_SETCHILD: 327 return PAGER_SetChild (hwnd, wParam, lParam); 328 329 case PGM_SETPOS: 330 return PAGER_SetPos (hwnd, wParam, lParam); 331 332 case WM_CREATE: 333 return PAGER_Create (hwnd, wParam, lParam); 334 335 case WM_DESTROY: 336 return PAGER_Destroy (hwnd, wParam, lParam); 337 338 case WM_ERASEBKGND: 339 return PAGER_EraseBackground (hwnd, wParam, lParam); 340 341 case WM_MOUSEMOVE: 342 return PAGER_MouseMove (hwnd, wParam, lParam); 343 344 case WM_NOTIFY: 345 case WM_COMMAND: 346 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); 347 348 /* case WM_PAINT: */ 349 /* return PAGER_Paint (hwnd, wParam); */ 350 351 case WM_SIZE: 352 return PAGER_Size (hwnd, wParam, lParam); 353 354 default: 355 // if (uMsg >= WM_USER) 356 // ERR (pager, "unknown msg %04x wp=%08x lp=%08lx\n", 357 // uMsg, wParam, lParam); 358 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 354 359 } 355 360 return 0; … … 372 377 wndClass.hbrBackground = 0; 373 378 wndClass.lpszClassName = WC_PAGESCROLLERA; 374 379 375 380 RegisterClassA (&wndClass); 376 381 } … … 381 386 { 382 387 if (GlobalFindAtomA (WC_PAGESCROLLERA)) 383 384 } 385 388 UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL); 389 } 390 -
TabularUnified trunk/src/comctl32/progress.c ¶
r236 r496 1 /* $Id: progress.c,v 1. 7 1999-06-28 15:46:25cbratschi Exp $ */1 /* $Id: progress.c,v 1.8 1999-08-14 16:13:12 cbratschi Exp $ */ 2 2 /* 3 3 * Progress control … … 493 493 * ProgressWindowProc 494 494 */ 495 LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,495 static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, 496 496 WPARAM wParam, LPARAM lParam) 497 497 { -
TabularUnified trunk/src/comctl32/propsheet.c ¶
r295 r496 1 /* $Id: propsheet.c,v 1. 6 1999-07-12 15:58:48cbratschi Exp $ */1 /* $Id: propsheet.c,v 1.7 1999-08-14 16:13:12 cbratschi Exp $ */ 2 2 /* 3 3 * Property Sheets … … 627 627 ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_SYSMENU; 628 628 ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_POPUP; 629 ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_DISABLED; 629 630 } 630 631 else … … 635 636 pTemplate->style &= ~WS_SYSMENU; 636 637 pTemplate->style &= ~WS_POPUP; 638 pTemplate->style &= ~WS_DISABLED; 639 637 640 } 638 641 … … 668 671 669 672 if (showPage) 673 { 674 NMHDR hdr; 675 676 hdr.hwndFrom = hwndParent; 677 hdr.code = PSN_SETACTIVE; 678 679 /* 680 * Send the notification before showing the page. 681 */ 682 SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr); 683 670 684 ShowWindow(hwndPage, SW_SHOW); 685 } 671 686 else 672 687 ShowWindow(hwndPage, SW_HIDE); … … 899 914 return FALSE; 900 915 901 // if (hpage != NULL) 902 // FIXME(propsheet, "Implement HPROPSHEETPAGE!\n"); 903 // else 904 hwndPage = psInfo->proppage[index].hwndPage; 905 906 /* 907 * Notify the new page. 908 */ 909 hdr.code = PSN_SETACTIVE; 910 911 SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr); 916 /* 917 * hpage takes precedence over index. 918 */ 919 if (hpage != NULL) 920 { 921 index = PROPSHEET_GetPageIndex(hpage, psInfo); 922 923 if (index == -1) 924 { 925 //TRACE("Could not find page to remove!\n"); 926 return FALSE; 927 } 928 } 929 930 hwndPage = psInfo->proppage[index].hwndPage; 931 932 /* 933 * Notify the new page if it's already created. 934 * If not it will get created and notified in PROPSHEET_ShowPage. 935 */ 936 if (hwndPage) 937 { 938 int result; 939 hdr.code = PSN_SETACTIVE; 940 941 result = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr); 942 /* 943 * TODO: check return value. 944 */ 945 } 912 946 913 947 /* … … 1340 1374 if (pnmh->code == TCN_SELCHANGE) 1341 1375 { 1342 PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,1343 PropSheetInfoStr);1344 1376 int index = SendMessageA(pnmh->hwndFrom, TCM_GETCURSEL, 0, 0); 1345 HWND hwndHelp = GetDlgItem(hwnd, IDHELP); 1346 1347 PROPSHEET_ShowPage(hwnd, index, psInfo); 1348 1349 if (psInfo->proppage[index].hasHelp) 1350 EnableWindow(hwndHelp, TRUE); 1351 else 1352 EnableWindow(hwndHelp, FALSE); 1377 PROPSHEET_SetCurSel(hwnd, index, 0); 1353 1378 } 1354 1379 -
TabularUnified trunk/src/comctl32/rebar.c ¶
r295 r496 1 /* $Id: rebar.c,v 1. 7 1999-07-12 15:58:48cbratschi Exp $ */1 /* $Id: rebar.c,v 1.8 1999-08-14 16:13:12 cbratschi Exp $ */ 2 2 /* 3 3 * Rebar control … … 1861 1861 1862 1862 1863 LRESULT WINAPI1863 static LRESULT WINAPI 1864 1864 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 1865 1865 { -
TabularUnified trunk/src/comctl32/status.c ¶
r295 r496 1 /* $Id: status.c,v 1. 9 1999-07-12 15:58:48cbratschi Exp $ */1 /* $Id: status.c,v 1.10 1999-08-14 16:13:12 cbratschi Exp $ */ 2 2 /* 3 3 * Interface code to StatusWindow widget/control … … 1154 1154 1155 1155 1156 LRESULT WINAPI1156 static LRESULT WINAPI 1157 1157 StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1158 1158 { -
TabularUnified trunk/src/comctl32/tab.c ¶
r295 r496 1 /* $Id: tab.c,v 1. 9 1999-07-12 15:58:48cbratschi Exp $ */1 /* $Id: tab.c,v 1.10 1999-08-14 16:13:13 cbratschi Exp $ */ 2 2 /* 3 3 * Tab control … … 800 800 */ 801 801 if (!(lStyle & TCS_OWNERDRAWFIXED)) 802 { 803 DeleteObject(hbr); 802 804 hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT)); 805 } 803 806 804 807 /* … … 849 852 * Background color. 850 853 */ 854 DeleteObject(hbr); 851 855 hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); 852 856 … … 963 967 SetBkMode(hdc, oldBkMode); 964 968 SelectObject(hdc, holdPen); 969 DeleteObject(hfocusPen); 970 DeleteObject(hbr); 965 971 } 966 972 } … … 1098 1104 if (givenDC==0) 1099 1105 ReleaseDC(hwnd, hdc); 1106 1107 DeleteObject(brush); 1100 1108 1101 1109 return 0; … … 1420 1428 if (len>wineItem->cchTextMax) 1421 1429 wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, (len+1)*sizeof(WCHAR)); 1422 lstrcpy nAtoW (wineItem->pszText, tabItem->pszText, len+1);1430 lstrcpyAtoW (wineItem->pszText, tabItem->pszText); 1423 1431 } 1424 1432 … … 1456 1464 if (len>wineItem->cchTextMax) 1457 1465 wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, (len+1)*sizeof(WCHAR)); 1458 lstrcpy nW (wineItem->pszText, tabItem->pszText, len+1);1466 lstrcpyW (wineItem->pszText, tabItem->pszText); 1459 1467 } 1460 1468 … … 1784 1792 } 1785 1793 1786 LRESULT WINAPI1794 static LRESULT WINAPI 1787 1795 TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 1788 1796 { -
TabularUnified trunk/src/comctl32/toolbar.c ¶
r295 r496 1 /* $Id: toolbar.c,v 1.1 1 1999-07-12 15:58:49cbratschi Exp $ */1 /* $Id: toolbar.c,v 1.12 1999-08-14 16:13:13 cbratschi Exp $ */ 2 2 /* 3 3 * Toolbar control … … 14 14 * - Fix TB_SETROWS. 15 15 * - Tooltip support (almost complete). 16 * - Internal COMMCTL32 bitmaps.17 16 * - Fix TOOLBAR_SetButtonInfo32A. 18 17 * - Drag & drop of buttons … … 45 44 #define BOTTOM_BORDER 2 46 45 47 #define TOOLBAR_GetInfoPtr( wndPtr) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))46 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0)) 48 47 49 48 … … 130 129 internals directly */ 131 130 132 HDC hdcImageList = CreateCompatibleDC (0);133 HDC hdcMask = CreateCompatibleDC (0);134 131 HIMAGELIST himl = infoPtr->himlDef; 135 132 HBITMAP hbmMask; 133 HDC hdcImageList; 134 HDC hdcMask; 135 136 if (!himl) 137 return; 138 139 /* create new dc's */ 140 hdcImageList = CreateCompatibleDC (0); 141 hdcMask = CreateCompatibleDC (0); 136 142 137 143 /* create new bitmap */ … … 179 185 180 186 rc = btnPtr->rect; 187 188 /* separator */ 181 189 if (btnPtr->fsStyle & TBSTYLE_SEP) 182 190 { 183 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->i dCommand== 0))191 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0)) 184 192 TOOLBAR_DrawFlatSeparator (&rc, hdc); 185 193 return; … … 1544 1552 * This function implements the toolbar customization dialog. 1545 1553 */ 1546 BOOL WINAPI1554 static BOOL WINAPI 1547 1555 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 1548 1556 { … … 1585 1593 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam; 1586 1594 INT nIndex = 0,nButtons; 1595 HBITMAP hbmLoad; 1587 1596 1588 1597 if (!lpAddBmp) … … 1602 1611 // TRACE ("adding %d internal bitmaps!\n", nButtons); 1603 1612 1604 /* Windows resize all the buttons to the size of a newly added STandard Image*/1613 /* Windows resize all the buttons to the size of a newly added standard Image*/ 1605 1614 if (lpAddBmp->nID & 1) 1606 1615 { … … 1650 1659 else if (lpAddBmp->hInst == HINST_COMMCTRL) 1651 1660 { 1652 /* add internal bitmaps */ 1653 // FIXME ("internal bitmaps not supported!\n"); 1654 1655 /* Hack to "add" some reserved images within the image list 1656 to get the right image indices */ 1657 nIndex = ImageList_GetImageCount (infoPtr->himlDef); 1658 ImageList_SetImageCount (infoPtr->himlDef, nIndex + nButtons); 1661 /* Add system bitmaps */ 1662 switch (lpAddBmp->nID) 1663 { 1664 case IDB_STD_SMALL_COLOR: 1665 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1666 MAKEINTRESOURCEA(IDB_STD_SMALL)); 1667 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1668 hbmLoad, CLR_DEFAULT); 1669 DeleteObject (hbmLoad); 1670 break; 1671 1672 case IDB_STD_LARGE_COLOR: 1673 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1674 MAKEINTRESOURCEA(IDB_STD_LARGE)); 1675 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1676 hbmLoad, CLR_DEFAULT); 1677 DeleteObject (hbmLoad); 1678 break; 1679 1680 case IDB_VIEW_SMALL_COLOR: 1681 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1682 MAKEINTRESOURCEA(IDB_VIEW_SMALL)); 1683 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1684 hbmLoad, CLR_DEFAULT); 1685 DeleteObject (hbmLoad); 1686 break; 1687 1688 case IDB_VIEW_LARGE_COLOR: 1689 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1690 MAKEINTRESOURCEA(IDB_VIEW_LARGE)); 1691 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1692 hbmLoad, CLR_DEFAULT); 1693 DeleteObject (hbmLoad); 1694 break; 1695 1696 case IDB_HIST_SMALL_COLOR: 1697 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1698 MAKEINTRESOURCEA(IDB_HIST_SMALL)); 1699 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1700 hbmLoad, CLR_DEFAULT); 1701 DeleteObject (hbmLoad); 1702 break; 1703 1704 case IDB_HIST_LARGE_COLOR: 1705 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1706 MAKEINTRESOURCEA(IDB_HIST_LARGE)); 1707 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1708 hbmLoad, CLR_DEFAULT); 1709 DeleteObject (hbmLoad); 1710 break; 1711 1712 default: 1713 nIndex = ImageList_GetImageCount (infoPtr->himlDef); 1714 //ERR ("invalid imagelist!\n"); 1715 break; 1716 } 1659 1717 } 1660 1718 else 1661 1719 { 1662 HBITMAP hBmp = 1663 LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1664 nIndex = ImageList_AddMasked (infoPtr->himlDef, hBmp, CLR_DEFAULT); 1665 1666 DeleteObject (hBmp); 1720 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1721 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT); 1722 DeleteObject (hbmLoad); 1667 1723 } 1668 1724 … … 3825 3881 3826 3882 3827 LRESULT WINAPI3883 static LRESULT WINAPI 3828 3884 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 3829 3885 { -
TabularUnified trunk/src/comctl32/tooltips.c ¶
r295 r496 1 /* $Id: tooltips.c,v 1.1 2 1999-07-12 15:58:49cbratschi Exp $ */1 /* $Id: tooltips.c,v 1.13 1999-08-14 16:13:15 cbratschi Exp $ */ 2 2 /* 3 3 * Tool tip control … … 2175 2175 2176 2176 2177 LRESULT CALLBACK2177 static LRESULT CALLBACK 2178 2178 TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 2179 2179 { -
TabularUnified trunk/src/comctl32/trackbar.c ¶
r267 r496 1 /* $Id: trackbar.c,v 1.1 1 1999-07-04 21:06:00cbratschi Exp $ */1 /* $Id: trackbar.c,v 1.12 1999-08-14 16:13:15 cbratschi Exp $ */ 2 2 /* 3 3 * Trackbar control … … 74 74 static BOOL TRACKBAR_SendNotify (HWND hwnd, UINT code); 75 75 76 void TRACKBAR_RecalculateTics (HWND hwnd,TRACKBAR_INFO *infoPtr,BOOL restoreOld)76 static void TRACKBAR_RecalculateTics (HWND hwnd,TRACKBAR_INFO *infoPtr,BOOL restoreOld) 77 77 { 78 78 INT i,tic,nrTics; … … 2032 2032 2033 2033 2034 LRESULT WINAPI2034 static LRESULT WINAPI 2035 2035 TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 2036 2036 { -
TabularUnified trunk/src/comctl32/treeview.c ¶
r371 r496 1 /* $Id: treeview.c,v 1. 9 1999-07-23 15:54:34cbratschi Exp $ */1 /* $Id: treeview.c,v 1.10 1999-08-14 16:13:16 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 46 46 #include "wingdi.h" 47 47 #include "commctrl.h" 48 #include "comctl32.h" 48 49 #include "treeview.h" 49 50 … … 460 461 461 462 static LRESULT 463 TREEVIEW_GetLineColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 464 { 465 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 466 467 //TRACE("\n"); 468 return (LRESULT) infoPtr->clrLine; 469 } 470 471 static LRESULT 472 TREEVIEW_SetLineColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 473 { 474 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 475 COLORREF prevColor=infoPtr->clrLine; 476 477 //TRACE("\n"); 478 infoPtr->clrLine=(COLORREF) lParam; 479 return (LRESULT) prevColor; 480 } 481 482 static LRESULT 462 483 TREEVIEW_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 463 484 { … … 510 531 { 511 532 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 512 533 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 513 534 INT center,xpos,cx,cy, cditem, drawmode; 514 535 HFONT hOldFont; … … 523 544 524 545 cditem=0; 546 //TRACE ("cdmode:%x\n",infoPtr->cdmode); 525 547 if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) { 526 548 drawmode=CDDS_ITEMPREPAINT; 527 549 528 550 if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW) 529 drawmode|=CDDS_SUBITEM;551 drawmode|=CDDS_SUBITEM; 530 552 531 553 cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode); … … 547 569 * Display the tree hierarchy 548 570 */ 549 if ( GetWindowLongA( hwnd, GWL_STYLE)& TVS_HASLINES)571 if ( dwStyle & TVS_HASLINES) 550 572 { 551 573 /* … … 557 579 * points[2] is attached to the parent or the up sibling 558 580 */ 559 if ( GetWindowLongA( hwnd, GWL_STYLE)& TVS_LINESATROOT)581 if ( dwStyle & TVS_LINESATROOT) 560 582 { 561 583 TREEVIEW_ITEM *upNode = NULL; … … 598 620 599 621 /* 600 * Get a dot ed pen622 * Get a dotted pen 601 623 */ 602 hnewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT));624 hnewPen = CreatePen(PS_DOT, 0, infoPtr->clrLine); 603 625 hOldPen = SelectObject( hdc, hnewPen ); 604 626 … … 619 641 xpos+=(5*wineItem->iLevel); 620 642 621 if (( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASBUTTONS) && 622 ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES)) 643 if (( dwStyle & TVS_HASBUTTONS) && ( dwStyle & TVS_HASLINES)) 623 644 { 624 645 if ( (wineItem->cChildren) || … … 876 897 if (tvItem->mask & TVIF_INTEGRAL) { 877 898 wineItem->iIntegral=tvItem->iIntegral; 878 // FIXME (treeview," TVIF_INTEGRAL not supported yet\n");879 899 } 880 900 … … 909 929 } 910 930 911 912 913 931 static LRESULT 932 TREEVIEW_GetItemState (HWND hwnd, WPARAM wParam, LPARAM lParam) 933 934 { 935 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 936 TREEVIEW_ITEM *wineItem; 937 938 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)wParam); 939 if (!wineItem) return 0; 940 941 return (wineItem->state & lParam); 942 } 914 943 915 944 static void … … 1144 1173 if (tvItem->mask & TVIF_INTEGRAL) { 1145 1174 tvItem->iIntegral=wineItem->iIntegral; 1146 // FIXME (treeview," TVIF_INTEGRAL not supported yet\n");1147 1175 } 1148 1176 … … 1382 1410 1383 1411 /*************************************************************************** 1412 * Treeview native sort routine: sort on item text. 1413 */ 1414 static INT WINAPI TREEVIEW_SortOnName ( 1415 LPVOID first, 1416 LPVOID second, 1417 LPARAM tvInfoPtr) 1418 { 1419 HWND hwnd=(HWND) tvInfoPtr; 1420 char *txt1, *txt2; 1421 TREEVIEW_ITEM *item; 1422 1423 1424 item=(TREEVIEW_ITEM *) first; 1425 if (item->pszText==LPSTR_TEXTCALLBACKA) { 1426 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1427 } 1428 txt1=item->pszText; 1429 1430 item=(TREEVIEW_ITEM *) second; 1431 if (item->pszText==LPSTR_TEXTCALLBACKA) { 1432 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1433 } 1434 txt2=item->pszText; 1435 1436 return -strcmp (txt1,txt2); 1437 } 1438 1439 /*************************************************************************** 1384 1440 * Setup the treeview structure with regards of the sort method 1385 1441 * and sort the children of the TV item specified in lParam 1442 * fRecurse: currently unused. Should be zero. 1443 * parent: if pSort!=NULL, should equal pSort->hParent. 1444 * otherwise, item which child items are to be sorted. 1445 * pSort: sort method info. if NULL, sort on item text. 1446 * if non-NULL, sort on item's lParam content, and let the 1447 * application decide what that means. See also TVM_SORTCHILDRENCB. 1386 1448 */ 1387 LRESULT WINAPI TREEVIEW_SortChildrenCB( 1449 1450 static LRESULT WINAPI TREEVIEW_Sort ( 1388 1451 HWND hwnd, 1389 WPARAM wParam, 1390 LPARAM lParam) 1452 BOOL fRecurse, 1453 HTREEITEM parent, 1454 LPTVSORTCB pSort 1455 ) 1391 1456 { 1392 1457 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 1394 1459 1395 1460 /* Obtain the TVSORTBC struct */ 1396 infoPtr->pCallBackSort = (LPTVSORTCB)lParam; 1461 infoPtr->pCallBackSort = pSort; 1462 1463 /* undocumented feature: TVI_ROOT means `sort the whole tree' */ 1464 1465 if (parent==TVI_ROOT) 1466 parent=infoPtr->TopRootItem; 1397 1467 1398 1468 /* Check for a valid handle to the parent item */ 1399 if (!TREEVIEW_ValidItem(infoPtr, infoPtr->pCallBackSort->hParent))1469 if (!TREEVIEW_ValidItem(infoPtr, parent)) 1400 1470 { 1401 // ERR ("invalid item hParent=%d\n", (INT)infoPtr->pCallBackSort->hParent);1471 ERR ("invalid item hParent=%x\n", (INT)parent); 1402 1472 return FALSE; 1403 1473 } 1404 1474 1405 1475 /* Obtain the parent node to sort */ 1406 sortMe = &infoPtr->items[ (INT) infoPtr->pCallBackSort->hParent ];1476 sortMe = &infoPtr->items[ (INT)parent ]; 1407 1477 1408 1478 /* Make sure there is something to sort */ … … 1434 1504 1435 1505 /* let DPA perform the sort activity */ 1436 DPA_Sort( 1437 sortList, /* what */ 1438 TREEVIEW_CallBackCompare, /* how */ 1439 hwnd); /* owner */ 1506 if (pSort) 1507 DPA_Sort( 1508 sortList, /* what */ 1509 TREEVIEW_CallBackCompare, /* how */ 1510 hwnd); /* owner */ 1511 else 1512 DPA_Sort ( 1513 sortList, /* what */ 1514 TREEVIEW_SortOnName, /* how */ 1515 hwnd); /* owner */ 1440 1516 1441 1517 /* … … 1476 1552 return FALSE; 1477 1553 } 1554 1555 /*************************************************************************** 1556 * Setup the treeview structure with regards of the sort method 1557 * and sort the children of the TV item specified in lParam 1558 */ 1559 static LRESULT WINAPI TREEVIEW_SortChildrenCB( 1560 HWND hwnd, 1561 WPARAM wParam, 1562 LPARAM lParam 1563 ) 1564 { 1565 LPTVSORTCB pSort=(LPTVSORTCB) lParam; 1566 1567 return TREEVIEW_Sort (hwnd, wParam, pSort->hParent, pSort); 1568 } 1569 1570 1571 /*************************************************************************** 1572 * Sort the children of the TV item specified in lParam. 1573 */ 1574 static LRESULT WINAPI TREEVIEW_SortChildren ( 1575 HWND hwnd, 1576 WPARAM wParam, 1577 LPARAM lParam) 1578 { 1579 return TREEVIEW_Sort (hwnd, (BOOL) wParam, (HTREEITEM) lParam, NULL); 1580 } 1581 1478 1582 1479 1583 int ffs(int mask) … … 1779 1883 1780 1884 1781 1885 static LRESULT 1886 TREEVIEW_InsertItemW(HWND hwnd, WPARAM wParam, LPARAM lParam) 1887 { 1888 TVINSERTSTRUCTW *tvisW; 1889 TVINSERTSTRUCTA tvisA; 1890 LRESULT lRes; 1891 1892 tvisW = (LPTVINSERTSTRUCTW)lParam; 1893 1894 tvisA.hParent = tvisW->hParent; 1895 tvisA.hInsertAfter = tvisW->hInsertAfter; 1896 1897 tvisA.DUMMYUNIONNAME.item.mask = tvisW->DUMMYUNIONNAME.item.mask; 1898 tvisA.DUMMYUNIONNAME.item.hItem = tvisW->DUMMYUNIONNAME.item.hItem; 1899 tvisA.DUMMYUNIONNAME.item.state = tvisW->DUMMYUNIONNAME.item.state; 1900 tvisA.DUMMYUNIONNAME.item.stateMask = tvisW->DUMMYUNIONNAME.item.stateMask; 1901 tvisA.DUMMYUNIONNAME.item.cchTextMax = tvisW->DUMMYUNIONNAME.item.cchTextMax; 1902 1903 if(tvisW->DUMMYUNIONNAME.item.pszText) 1904 { 1905 if (tvisW->DUMMYUNIONNAME.item.pszText!=LPSTR_TEXTCALLBACKW) 1906 { 1907 int len = lstrlenW (tvisW->DUMMYUNIONNAME.item.pszText)+1; 1908 tvisA.DUMMYUNIONNAME.item.pszText = COMCTL32_Alloc (len); 1909 lstrcpyWtoA (tvisA.DUMMYUNIONNAME.item.pszText, 1910 tvisW->DUMMYUNIONNAME.item.pszText ); 1911 } 1912 else 1913 { 1914 tvisA.DUMMYUNIONNAME.item.pszText = LPSTR_TEXTCALLBACKA; 1915 tvisA.DUMMYUNIONNAME.item.cchTextMax = 0; 1916 } 1917 } 1918 1919 tvisA.DUMMYUNIONNAME.item.iImage = tvisW->DUMMYUNIONNAME.item.iImage; 1920 tvisA.DUMMYUNIONNAME.item.iSelectedImage = tvisW->DUMMYUNIONNAME.item.iSelectedImage; 1921 tvisA.DUMMYUNIONNAME.item.cChildren = tvisW->DUMMYUNIONNAME.item.cChildren; 1922 tvisA.DUMMYUNIONNAME.item.lParam = tvisW->DUMMYUNIONNAME.item.lParam; 1923 1924 lRes = TREEVIEW_InsertItemA(hwnd,wParam,(LPARAM)&tvisA); 1925 1926 if (tvisA.DUMMYUNIONNAME.item.pszText!=LPSTR_TEXTCALLBACKA) 1927 { 1928 COMCTL32_Free(tvisA.DUMMYUNIONNAME.item.pszText); 1929 } 1930 1931 return lRes; 1932 1933 } 1782 1934 1783 1935 … … 1858 2010 1859 2011 1860 LRESULT CALLBACK2012 static LRESULT CALLBACK 1861 2013 TREEVIEW_GetEditControl (HWND hwnd) 1862 2014 … … 1979 2131 TREEVIEW_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam) 1980 2132 { 1981 LPSTYLESTRUCT lpss=(LPSTYLESTRUCT) lParam;1982 1983 2133 // TRACE (treeview,"(%x %lx)\n",wParam,lParam); 1984 2134 1985 if (wParam & (GWL_STYLE)) 1986 SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew); 1987 if (wParam & (GWL_EXSTYLE)) 1988 SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew); 2135 TREEVIEW_Refresh(hwnd); 1989 2136 1990 2137 return 0; … … 2022 2169 infoPtr->clrBk = GetSysColor (COLOR_WINDOW); 2023 2170 infoPtr->clrText = GetSysColor (COLOR_BTNTEXT); 2171 infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT); 2024 2172 infoPtr->cy = 0; 2025 2173 infoPtr->cx = 0; … … 2039 2187 infoPtr->dropItem=0; 2040 2188 infoPtr->pCallBackSort=NULL; 2189 infoPtr->uScrollTime = 300; /* milliseconds */ 2041 2190 2042 2191 /* … … 2696 2845 2697 2846 2698 LRESULT2847 static LRESULT 2699 2848 TREEVIEW_LButtonDoubleClick (HWND hwnd, WPARAM wParam, LPARAM lParam) 2700 2849 { … … 3358 3507 } 3359 3508 3360 3361 LRESULT WINAPI 3509 static LRESULT 3510 TREEVIEW_GetScrollTime (HWND hwnd) 3511 { 3512 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3513 return infoPtr->uScrollTime; 3514 } 3515 3516 static LRESULT 3517 TREEVIEW_SetScrollTime (HWND hwnd, UINT uScrollTime) 3518 { 3519 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3520 UINT uOldScrollTime = infoPtr->uScrollTime; 3521 infoPtr->uScrollTime = min (uScrollTime, 100); 3522 return uOldScrollTime; 3523 } 3524 3525 static LRESULT WINAPI 3362 3526 TREEVIEW_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 3363 3527 { … … 3367 3531 3368 3532 case TVM_INSERTITEMW: 3369 // FIXME (treeview, "Unimplemented msg TVM_INSERTITEM32W\n"); 3370 return 0; 3533 return TREEVIEW_InsertItemW(hwnd,wParam,lParam); 3371 3534 3372 3535 case TVM_DELETEITEM: … … 3404 3567 3405 3568 case TVM_GETITEMW: 3406 // FIXME (treeview, "Unimplemented msg TVM_GETITEM 32W\n");3569 // FIXME (treeview, "Unimplemented msg TVM_GETITEMW\n"); 3407 3570 return 0; 3408 3571 … … 3415 3578 3416 3579 case TVM_EDITLABELA: 3417 // FIXME (treeview, "Unimplemented msg TVM_EDITLABEL 32A \n");3580 // FIXME (treeview, "Unimplemented msg TVM_EDITLABELA \n"); 3418 3581 return 0; 3419 3582 3420 3583 case TVM_EDITLABELW: 3421 // FIXME (treeview, "Unimplemented msg TVM_EDITLABEL 32W \n");3584 // FIXME (treeview, "Unimplemented msg TVM_EDITLABELW \n"); 3422 3585 return 0; 3423 3586 … … 3435 3598 3436 3599 case TVM_SORTCHILDREN: 3437 // FIXME (treeview, "Unimplemented msg TVM_SORTCHILDREN\n"); 3438 return 0; 3600 return TREEVIEW_SortChildrenCB(hwnd, wParam, lParam); 3439 3601 3440 3602 case TVM_ENSUREVISIBLE: … … 3449 3611 3450 3612 case TVM_GETISEARCHSTRINGA: 3451 // FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING 32A\n");3613 // FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRINGA\n"); 3452 3614 return 0; 3453 3615 3454 3616 case TVM_GETISEARCHSTRINGW: 3455 // FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING 32W\n");3617 // FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRINGW\n"); 3456 3618 return 0; 3457 3619 … … 3485 3647 3486 3648 case TVM_SETSCROLLTIME: 3487 // FIXME (treeview, "Unimplemented msg TVM_SETSCROLLTIME\n"); 3488 return 0; 3649 return TREEVIEW_SetScrollTime (hwnd, (UINT)wParam); 3489 3650 3490 3651 case TVM_GETSCROLLTIME: 3491 // FIXME (treeview, "Unimplemented msg TVM_GETSCROLLTIME\n"); 3492 return 0; 3652 return TREEVIEW_GetScrollTime (hwnd); 3653 3654 case TVM_GETITEMSTATE: 3655 return TREEVIEW_GetItemState (hwnd,wParam, lParam); 3656 3657 case TVM_GETLINECOLOR: 3658 return TREEVIEW_GetLineColor (hwnd,wParam, lParam); 3659 3660 case TVM_SETLINECOLOR: 3661 return TREEVIEW_SetLineColor (hwnd,wParam, lParam); 3493 3662 3494 3663 case TVM_SETINSERTMARKCOLOR: … … 3504 3673 return 0; 3505 3674 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 /* 3516 3517 3518 3519 3520 3675 case WM_COMMAND: 3676 return TREEVIEW_Command (hwnd, wParam, lParam); 3677 3678 case WM_CREATE: 3679 return TREEVIEW_Create (hwnd, wParam, lParam); 3680 3681 case WM_DESTROY: 3682 return TREEVIEW_Destroy (hwnd); 3683 3684 /* case WM_ENABLE: */ 3685 3686 case WM_ERASEBKGND: 3687 return TREEVIEW_EraseBackground (hwnd, wParam, lParam); 3688 3689 case WM_GETDLGCODE: 3521 3690 return DLGC_WANTARROWS | DLGC_WANTCHARS; 3522 3691 3523 3692 case WM_PAINT: 3524 3693 return TREEVIEW_Paint (hwnd, wParam, lParam); 3525 3694 3526 3695 case WM_GETFONT: 3527 3696 return TREEVIEW_GetFont (hwnd, wParam, lParam); 3528 3697 3529 3698 case WM_SETFONT: 3530 3699 return TREEVIEW_SetFont (hwnd, wParam, lParam); 3531 3700 3532 case WM_KEYDOWN: 3533 return TREEVIEW_KeyDown (hwnd, wParam, lParam); 3534 3535 3536 case WM_SETFOCUS: 3537 return TREEVIEW_SetFocus (hwnd, wParam, lParam); 3538 3539 case WM_KILLFOCUS: 3540 return TREEVIEW_KillFocus (hwnd, wParam, lParam); 3541 3542 3543 case WM_LBUTTONDOWN: 3544 return TREEVIEW_LButtonDown (hwnd, wParam, lParam); 3545 3546 case WM_LBUTTONUP: 3547 return TREEVIEW_LButtonUp (hwnd, wParam, lParam); 3548 3549 case WM_LBUTTONDBLCLK: 3550 return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam); 3551 3552 case WM_RBUTTONDOWN: 3553 return TREEVIEW_RButtonDown (hwnd, wParam, lParam); 3554 3555 case WM_RBUTTONUP: 3556 return TREEVIEW_RButtonUp (hwnd, wParam, lParam); 3557 3558 case WM_MOUSEMOVE: 3559 return TREEVIEW_MouseMove (hwnd, wParam, lParam); 3560 3561 3562 /* case WM_SYSCOLORCHANGE: */ 3563 case WM_STYLECHANGED: 3564 return TREEVIEW_StyleChanged (hwnd, wParam, lParam); 3565 3566 /* case WM_SETREDRAW: */ 3567 3568 case WM_TIMER: 3569 return TREEVIEW_HandleTimer (hwnd, wParam, lParam); 3570 3571 case WM_SIZE: 3572 return TREEVIEW_Size (hwnd, wParam,lParam); 3573 3574 case WM_HSCROLL: 3575 return TREEVIEW_HScroll (hwnd, wParam, lParam); 3576 case WM_VSCROLL: 3577 return TREEVIEW_VScroll (hwnd, wParam, lParam); 3578 3579 case WM_DRAWITEM: 3580 // printf ("drawItem\n"); 3581 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 3582 3583 default: 3584 // if (uMsg >= WM_USER) 3585 // FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n", 3701 case WM_KEYDOWN: 3702 return TREEVIEW_KeyDown (hwnd, wParam, lParam); 3703 3704 case WM_SETFOCUS: 3705 return TREEVIEW_SetFocus (hwnd, wParam, lParam); 3706 3707 case WM_KILLFOCUS: 3708 return TREEVIEW_KillFocus (hwnd, wParam, lParam); 3709 3710 case WM_LBUTTONDOWN: 3711 return TREEVIEW_LButtonDown (hwnd, wParam, lParam); 3712 3713 case WM_LBUTTONUP: 3714 return TREEVIEW_LButtonUp (hwnd, wParam, lParam); 3715 3716 case WM_LBUTTONDBLCLK: 3717 return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam); 3718 3719 case WM_RBUTTONDOWN: 3720 return TREEVIEW_RButtonDown (hwnd, wParam, lParam); 3721 3722 case WM_RBUTTONUP: 3723 return TREEVIEW_RButtonUp (hwnd, wParam, lParam); 3724 3725 case WM_MOUSEMOVE: 3726 return TREEVIEW_MouseMove (hwnd, wParam, lParam); 3727 3728 case WM_STYLECHANGED: 3729 return TREEVIEW_StyleChanged (hwnd, wParam, lParam); 3730 3731 /* case WM_SYSCOLORCHANGE: */ 3732 /* case WM_SETREDRAW: */ 3733 3734 case WM_TIMER: 3735 return TREEVIEW_HandleTimer (hwnd, wParam, lParam); 3736 3737 case WM_SIZE: 3738 return TREEVIEW_Size (hwnd, wParam,lParam); 3739 3740 case WM_HSCROLL: 3741 return TREEVIEW_HScroll (hwnd, wParam, lParam); 3742 3743 case WM_VSCROLL: 3744 return TREEVIEW_VScroll (hwnd, wParam, lParam); 3745 3746 case WM_DRAWITEM: 3747 // printf ("drawItem\n"); 3748 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 3749 3750 default: 3751 // if (uMsg >= WM_USER) 3752 // FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n", 3586 3753 // uMsg, wParam, lParam); 3587 3754 return DefWindowProcA (hwnd, uMsg, wParam, lParam); -
TabularUnified trunk/src/comctl32/updown.c ¶
r295 r496 1 /* $Id: updown.c,v 1. 6 1999-07-12 15:58:51cbratschi Exp $ */1 /* $Id: updown.c,v 1.7 1999-08-14 16:13:16 cbratschi Exp $ */ 2 2 /* 3 3 * Updown control … … 8 8 * 9 9 * TODO: 10 * - subclass the buddy window (in UPDOWN_SetBuddyHandle) to process the11 * arrow keys12 10 * - I am not sure about the default values for the Min, Max, Pos 13 11 * (in the UPDOWN_INFO the fields: MinVal, MaxVal, CurVal) … … 56 54 #define DEFAULT_ADDTOP 0 /* amount to extend above the buddy window */ 57 55 #define DEFAULT_ADDBOT 0 /* amount to extend below the buddy window */ 56 #define DEFAULT_BUDDYBORDER 2 /* Width/height of the buddy border */ 58 57 59 58 … … 67 66 #define TIMERID1 1 68 67 #define TIMERID2 2 68 #define BUDDY_UPDOWN_HWND "buddyUpDownHWND" 69 #define BUDDY_SUPERCLASS_WNDPROC "buddySupperClassWndProc" 69 70 70 71 static int accelIndex = -1; … … 77 78 #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongA(hwnd,0)) 78 79 80 static LRESULT CALLBACK 81 UPDOWN_Buddy_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 79 82 80 83 /*********************************************************************** … … 119 122 120 123 /*********************************************************************** 124 * UPDOWN_HasBuddyBorder [Internal] 125 * 126 * When we have a buddy set and that we are aligned on our buddy, we 127 * want to draw a sunken edge to make like we are part of that control. 128 */ 129 static BOOL UPDOWN_HasBuddyBorder(HWND hwnd) 130 { 131 UPDOWN_INFO* infoPtr = UPDOWN_GetInfoPtr (hwnd); 132 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 133 134 return ( ((dwStyle & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT)) != 0) && 135 (SendMessageA(hwnd, UDM_GETBUDDY, 0, 0) != 0) && 136 (lstrcmpiA(infoPtr->szBuddyClass, "EDIT") == 0 ) ); 137 } 138 139 /*********************************************************************** 121 140 * UPDOWN_GetArrowRect 122 141 * wndPtr - pointer to the up-down wnd … … 128 147 static void UPDOWN_GetArrowRect (HWND hwnd, RECT *rect, BOOL incr) 129 148 { 130 int len; /* will hold the width or height */ 149 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 150 int len; /* will hold the width or height */ 131 151 132 152 GetClientRect (hwnd, rect); 133 153 134 if (GetWindowLongA(hwnd, GWL_STYLE) & UDS_HORZ) 154 /* 155 * Make sure we calculate the rectangle to fit even if we draw the 156 * border. 157 */ 158 if (UPDOWN_HasBuddyBorder(hwnd)) 135 159 { 136 len = rect->right-rect->left; /* compute the width */ 137 if (incr) rect->left = len/2+1; 138 else rect->right = len/2; 139 } else 140 { 141 len = rect->bottom-rect->top; /* compute the height */ 142 if (incr) rect->bottom = len/2; 143 else rect->top = len/2+1; 160 if (dwStyle & UDS_ALIGNLEFT) 161 rect->left+=DEFAULT_BUDDYBORDER; 162 else 163 rect->right-=DEFAULT_BUDDYBORDER; 164 165 InflateRect(rect, 0, -DEFAULT_BUDDYBORDER); 166 } 167 168 /* 169 * We're calculating the midpoint to figure-out where the 170 * separation between the buttons will lay. We make sure that we 171 * round the uneven numbers by adding 1. 172 */ 173 if (dwStyle & UDS_HORZ) { 174 len = rect->right - rect->left + 1; /* compute the width */ 175 if (incr) 176 rect->left = rect->left + len/2; 177 else 178 rect->right = rect->left + len/2; 179 } 180 else { 181 len = rect->bottom - rect->top + 1; /* compute the height */ 182 if (incr) 183 rect->bottom = rect->top + len/2; 184 else 185 rect->top = rect->top + len/2; 144 186 } 145 187 } … … 277 319 278 320 /*********************************************************************** 321 * UPDOWN_DrawBuddyBorder [Internal] 322 * 323 * When we have a buddy set and that we are aligned on our buddy, we 324 * want to draw a sunken edge to make like we are part of that control. 325 */ 326 static void UPDOWN_DrawBuddyBorder (HWND hwnd, HDC hdc) 327 { 328 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 329 RECT clientRect; 330 331 GetClientRect(hwnd, &clientRect); 332 333 if (dwStyle & UDS_ALIGNLEFT) 334 DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_BOTTOM | BF_LEFT | BF_TOP); 335 else 336 DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_BOTTOM | BF_RIGHT | BF_TOP); 337 } 338 339 /*********************************************************************** 279 340 * UPDOWN_Draw [Internal] 280 341 * … … 287 348 BOOL prssed; 288 349 RECT rect; 350 351 /* 352 * Draw the common border between ourselves and our buddy. 353 */ 354 if (UPDOWN_HasBuddyBorder(hwnd)) 355 UPDOWN_DrawBuddyBorder(hwnd, hdc); 289 356 290 357 /* Draw the incr button */ … … 332 399 * Calls UPDOWN_Draw. 333 400 */ 334 static void UPDOWN_Paint (HWND hwnd )401 static void UPDOWN_Paint (HWND hwnd, HDC passedDC) 335 402 { 336 403 PAINTSTRUCT ps; 337 HDC hdc; 338 339 hdc = BeginPaint (hwnd, &ps); 404 HDC hdc = passedDC; 405 406 if (passedDC == 0) 407 hdc = BeginPaint (hwnd, &ps); 408 340 409 UPDOWN_Draw (hwnd, hdc); 341 EndPaint (hwnd, &ps); 410 411 if (passedDC == 0) 412 EndPaint (hwnd, &ps); 342 413 } 343 414 344 415 /*********************************************************************** 345 416 * UPDOWN_SetBuddyHandle 417 * CB: UPDOWN_SetBuddy == message handler 346 418 * Tests if 'hwndBud' is a valid window handle. If not, returns FALSE. 347 419 * Else, sets it as a new Buddy. … … 354 426 static BOOL UPDOWN_SetBuddyHandle (HWND hwnd, HWND hwndBud) 355 427 { 356 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); 357 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 358 RECT budRect; /* new coord for the buddy */ 359 int x; /* new x position and width for the up-down */ 360 361 *infoPtr->szBuddyClass = '\0'; 362 363 /* Is is a valid bud? */ 428 UPDOWN_INFO* infoPtr = UPDOWN_GetInfoPtr (hwnd); 429 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 430 RECT budRect; /* new coord for the buddy */ 431 int x,width; /* new x position and width for the up-down */ 432 433 /* Is it a valid bud? */ 364 434 if(!IsWindow(hwndBud)) 365 435 return FALSE; 366 436 367 /* Store buddy wundow handle */ 437 /* there is already a body assigned */ 438 if ( infoPtr->Buddy ) 439 RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND); 440 441 /* Store buddy window handle */ 368 442 infoPtr->Buddy = hwndBud; 369 443 444 /* keep upDown ctrl hwnd in a buddy property */ 445 SetPropA( hwndBud, BUDDY_UPDOWN_HWND, hwnd); 446 370 447 /* Store buddy window clas name */ 371 GetClassNameA (hwndBud, infoPtr->szBuddyClass, 40); 448 memset(infoPtr->szBuddyClass, 0, UPDOWN_BUDDYCLASSNAMELEN); 449 GetClassNameA (hwndBud, infoPtr->szBuddyClass, UPDOWN_BUDDYCLASSNAMELEN-1); 372 450 373 451 if(dwStyle & UDS_ARROWKEYS){ 374 // FIXME(updown, "we need to subclass the buddy to process the arrow keys.\n"); 452 /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property 453 when we reset the upDown ctrl buddy to another buddy because it is not 454 good to break the window proc chain. */ 455 456 /* keep buddy supperclass wndproc in prop instead of in ptr struct 457 to prevent accessing freed memory */ 458 SetPropA( 459 hwndBud, 460 BUDDY_SUPERCLASS_WNDPROC, 461 (LONG)GetWindowLongA(hwndBud, GWL_WNDPROC) ); 462 463 /* Assign the buddy wndproc to local wndproc in order to override 464 keyboard's up and down arrow */ 465 SetWindowLongA( 466 hwndBud, 467 GWL_WNDPROC, 468 (LONG)UPDOWN_Buddy_SubclassProc); 375 469 } 376 470 … … 379 473 return TRUE; 380 474 381 infoPtr->Buddy = hwndBud;382 383 475 /* Get the rect of the buddy relative to its parent */ 384 476 GetWindowRect(infoPtr->Buddy, &budRect); 385 477 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), 386 478 (POINT *)(&budRect.left), 2); 387 479 388 480 /* now do the positioning */ … … 398 490 /* first adjust the buddy to accomodate the up/down */ 399 491 SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top, 400 401 492 budRect.right - budRect.left, budRect.bottom - budRect.top, 493 SWP_NOACTIVATE|SWP_NOZORDER); 402 494 403 495 /* now position the up/down */ 404 496 /* Since the UDS_ALIGN* flags were used, */ 405 497 /* we will pick the position and size of the window. */ 406 407 SetWindowPos (hwnd, 0, x, budRect.top-DEFAULT_ADDTOP,DEFAULT_WIDTH, 408 (budRect.bottom-budRect.top)+DEFAULT_ADDTOP+DEFAULT_ADDBOT, 409 SWP_NOACTIVATE|SWP_NOZORDER); 498 width = DEFAULT_WIDTH; 499 500 /* 501 * If the updown has a buddy border, it has to overlap with the buddy 502 * to look as if it is integrated with the buddy control. 503 * We nudge the control or change it size to overlap. 504 */ 505 if (UPDOWN_HasBuddyBorder(hwnd)) 506 { 507 if(dwStyle & UDS_ALIGNRIGHT) 508 x-=DEFAULT_BUDDYBORDER; 509 else 510 width+=DEFAULT_BUDDYBORDER; 511 } 512 513 SetWindowPos (hwnd, infoPtr->Buddy, 514 x, budRect.top-DEFAULT_ADDTOP, 515 width, (budRect.bottom-budRect.top)+DEFAULT_ADDTOP+DEFAULT_ADDBOT, 516 SWP_NOACTIVATE); 410 517 411 518 return TRUE; 412 } 519 } 413 520 414 521 /*********************************************************************** … … 640 747 if(infoPtr->AccelVect) COMCTL32_Free(infoPtr->AccelVect); 641 748 749 if ( IsWindow(infoPtr->Buddy) ) /* Cleanup */ 750 RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND); 751 642 752 COMCTL32_Free (infoPtr); 643 753 … … 652 762 653 763 if (dwStyle & WS_DISABLED) UPDOWN_CancelMode(hwnd); 654 UPDOWN_Paint(hwnd); 764 765 UPDOWN_Refresh(hwnd); 655 766 656 767 return 0; … … 811 922 if (lParam) UNKNOWN_PARAM(UDM_SETBUDDY,wParam,lParam); 812 923 temp = infoPtr->Buddy; 813 infoPtr->Buddy = wParam;814 924 UPDOWN_SetBuddyHandle(hwnd,wParam); 815 925 // TRACE(updown, "UpDown Ctrl new buddy(%04x), hwnd=%04x\n", … … 901 1011 * UpDownWndProc 902 1012 */ 903 LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,1013 static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, 904 1014 LPARAM lParam) 905 1015 { … … 942 1052 943 1053 case WM_PAINT: 944 UPDOWN_Paint(hwnd );1054 UPDOWN_Paint(hwnd,(HDC)wParam); 945 1055 break; 946 1056 … … 991 1101 } 992 1102 1103 /*********************************************************************** 1104 * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy 1105 * control. 1106 */ 1107 LRESULT CALLBACK 1108 UPDOWN_Buddy_SubclassProc ( 1109 HWND hwnd, 1110 UINT uMsg, 1111 WPARAM wParam, 1112 LPARAM lParam) 1113 { 1114 LONG superClassWndProc = GetPropA(hwnd, BUDDY_SUPERCLASS_WNDPROC); 1115 //TRACE("hwnd=%04x, wndProc=%d, uMsg=%04x, wParam=%d, lParam=%d\n", 1116 // hwnd, (INT)superClassWndProc, uMsg, wParam, (UINT)lParam); 1117 1118 switch (uMsg) 1119 { 1120 case WM_KEYDOWN: 1121 { 1122 if ( ((int)wParam == VK_UP ) || ((int)wParam == VK_DOWN ) ) 1123 { 1124 HWND upDownHwnd = GetPropA(hwnd, BUDDY_UPDOWN_HWND); 1125 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(upDownHwnd); 1126 1127 if (!lstrcmpA (infoPtr->szBuddyClass, "ListBox")) 1128 { 1129 /* if the buddy is a list window, we must update curr index */ 1130 INT oldVal = SendMessageA(hwnd, LB_GETCURSEL, 0, 0); 1131 SendMessageA(hwnd, LB_SETCURSEL, oldVal+1, 0); 1132 } 1133 else 1134 { 1135 UPDOWN_GetBuddyInt(upDownHwnd); 1136 UPDOWN_DoAction(upDownHwnd, 1, wParam==VK_UP); 1137 } 1138 1139 break; 1140 } 1141 /* else Fall Through */ 1142 } 1143 1144 default: 1145 return CallWindowProcA( (WNDPROC)superClassWndProc, hwnd, uMsg, wParam, lParam); 1146 } 1147 1148 return 0; 1149 } 993 1150 994 1151 /***********************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.