Changeset 243 for trunk/src/helpers/comctl.c
- Timestamp:
- Jan 29, 2003, 7:41:39 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/comctl.c
r242 r243 178 178 * given window. This must be called in WM_CREATE 179 179 * of a window proc if it intends to use 180 * ctlDefWindowProc as its default window procedure. 180 * ctlDefWindowProc as its default window procedure 181 * for generic message handling. 182 * 183 * Parameter remarks: 184 * 185 * -- For hwnd and mp2, pass in what you get in WM_CREATE. 186 * 187 * -- pdwd must point to a static DEFWINDATA which will 188 * maintain instance data for this control. It is 189 * recommended to have a DEFWINDATA struct in your 190 * window's instance data, which you must allocate 191 * in WM_CREATE anyway. So just pass the address of 192 * that struct within your instance buffer. 193 * 194 * -- pDefWindowProc is called by ctlDefWindowProc 195 * after its own message processing. In most cases, 196 * pass in WinDefWindowProc, unless you're superclassing 197 * a standard PM control. 198 * 199 * -- flCtl fine-tunes the behavior of ctlDefWindowProc: 200 * 201 * -- If CCS_NOSENDCTLPTR, we do not send WM_CONTROLPOINTER 202 * on every mouse move, but force the system "arrow" 203 * pointer over the control. 204 * 205 * -- paCtlColors must point to a CCTLCOLOR array. This 206 * enables automatic presparams and syscolor caching 207 * within ctlDefWindowProc so your window gets invalidated 208 * automatically. If you always use ctlQueryColor() in your 209 * WM_PAINT handler to determine the colors to be used for 210 * painting, you have full presparams support. 181 211 * 182 212 *@@added V1.0.1 (2002-11-30) [umoeller] … … 184 214 185 215 VOID ctlInitDWD(HWND hwnd, 186 MPARAM mp2, 216 MPARAM mp2, // in: mp2 of WM_CREATE 187 217 PDEFWINDATA pdwd, 188 PFNWP pDefWindowProc, 189 const SYSCOLORSET *pSysColorSet) 218 PFNWP pDefWindowProc, // in: parent window proc 219 ULONG flCtl, // in: CTL_* flags 220 const CCTLCOLOR *paCtlColors, 221 ULONG cCtlColors) 190 222 { 191 223 pdwd->hwnd = hwnd; 224 pdwd->hab = WinQueryAnchorBlock(hwnd); 225 pdwd->pDefWindowProc = pDefWindowProc; 226 pdwd->flCtl = flCtl; 192 227 pdwd->szlWin.cx = ((PCREATESTRUCT)mp2)->cx; 193 228 pdwd->szlWin.cy = ((PCREATESTRUCT)mp2)->cy; 194 pdwd->hab = WinQueryAnchorBlock(hwnd); 195 pdwd->pDefWindowProc = pDefWindowProc; 196 pdwd->pSysColorSet = pSysColorSet; 229 pdwd->paCtlColors = paCtlColors; 230 pdwd->cCtlColors = cCtlColors; 231 232 pdwd->palColorValues = (PLONG)malloc(sizeof(LONG) * cCtlColors); 197 233 198 234 ctlRefreshColors(pdwd); … … 207 243 VOID ctlRefreshColors(PDEFWINDATA pdwd) 208 244 { 209 pdwd->lcolBackground = winhQueryPresColor2(pdwd->hwnd, 210 PP_BACKGROUNDCOLOR, 211 PP_BACKGROUNDCOLORINDEX, 212 pdwd->pSysColorSet->fInheritPP, 213 pdwd->pSysColorSet->lBackIndex); 214 pdwd->lcolForeground = winhQueryPresColor2(pdwd->hwnd, 215 PP_FOREGROUNDCOLOR, 216 PP_FOREGROUNDCOLORINDEX, 217 pdwd->pSysColorSet->fInheritPP, 218 pdwd->pSysColorSet->lForeIndex); 245 ULONG ul; 246 for (ul = 0; 247 ul < pdwd->cCtlColors; 248 ++ul) 249 { 250 pdwd->palColorValues[ul] = winhQueryPresColor2(pdwd->hwnd, 251 pdwd->paCtlColors[ul].ulPP, 252 0, 253 pdwd->paCtlColors[ul].fInheritPP, 254 pdwd->paCtlColors[ul].ulSysColor); 255 } 256 } 257 258 /* 259 *@@ ctlQueryColor: 260 * returns the color value corresponding to the given 261 * color index. The color index is interpreted according 262 * to the CCTLCOLOR array that was given to ctlInitDWD 263 * and must not be larger than the number of colors in 264 * that array minus 1. 265 * 266 *@@added V1.0.1 (2003-01-22) [umoeller] 267 */ 268 269 LONG ctlQueryColor(PDEFWINDATA pdwd, ULONG ulIndex) 270 { 271 if (ulIndex < pdwd->cCtlColors) 272 return pdwd->palColorValues[ulIndex]; 273 274 return 0; 219 275 } 220 276 … … 238 294 { 239 295 MRESULT mrc = 0; 296 BOOL fCallDefault = TRUE; 297 HWND hwndOwner; 240 298 241 299 switch (msg) 242 300 { 301 case WM_MOUSEMOVE: 302 if ( (!(pdwd->flCtl & CCS_NOSENDCTLPTR)) 303 && (hwndOwner = WinQueryWindow(pdwd->hwnd, QW_OWNER)) 304 ) 305 { 306 HPOINTER hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE); 307 WinSetPointer(HWND_DESKTOP, 308 (HPOINTER)WinSendMsg(hwndOwner, 309 WM_CONTROLPOINTER, 310 (MPARAM)WinQueryWindowUShort(pdwd->hwnd, QWS_ID), 311 (MPARAM)hptrArrow)); 312 fCallDefault = FALSE; 313 } 314 break; 315 243 316 case WM_SYSCOLORCHANGE: 244 317 case WM_PRESPARAMCHANGED: … … 258 331 break; 259 332 260 default: 261 mrc = pdwd->pDefWindowProc(pdwd->hwnd, msg, mp1, mp2); 333 case WM_DESTROY: 334 FREE(pdwd->palColorValues); 335 break; 262 336 } 337 338 if (fCallDefault) 339 mrc = pdwd->pDefWindowProc(pdwd->hwnd, msg, mp1, mp2); 263 340 264 341 return mrc;
Note:
See TracChangeset
for help on using the changeset viewer.