Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

sysmet.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: sysmet.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * System metrics APIs and support routines. 00007 * 00008 * History: 00009 * 24-Sep-1990 DarrinM Generated stubs. 00010 * 12-Feb-1991 JimA Added access checks 00011 \***************************************************************************/ 00012 00013 #include "precomp.h" 00014 #pragma hdrstop 00015 00016 /***************************************************************************\ 00017 * _SwapMouseButton (API) 00018 * 00019 * History: 00020 * 24-Sep-1990 DarrinM Generated stubs. 00021 * 25-Jan-1991 DavidPe Did the real thing. 00022 * 12-Feb-1991 JimA Added access check 00023 \***************************************************************************/ 00024 00025 BOOL APIENTRY _SwapMouseButton( 00026 BOOL fSwapButtons) 00027 { 00028 BOOL fSwapOld; 00029 PPROCESSINFO ppiCurrent = PpiCurrent(); 00030 00031 /* 00032 * Blow it off if the caller doesn't have the proper access rights 00033 */ 00034 RETURN_IF_ACCESS_DENIED(ppiCurrent->amwinsta, 00035 WINSTA_READATTRIBUTES | WINSTA_WRITEATTRIBUTES, 00036 FALSE); 00037 00038 if (!(ppiCurrent->W32PF_Flags & W32PF_IOWINSTA)) { 00039 RIPERR0(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION, 00040 RIP_WARNING, 00041 "SwapMouseButton invalid on a non-interactive WindowStation."); 00042 00043 return FALSE; 00044 } 00045 00046 fSwapOld = SYSMET(SWAPBUTTON); 00047 SYSMET(SWAPBUTTON) = fSwapButtons; 00048 00049 /* 00050 * Give xxxButtonEvent a hint that a mouse button event may have to be 00051 * left/right swapped to correspond with our current async key state. 00052 * Toggle the global since an even number of SwapMouseButtons has no effect. 00053 */ 00054 if (fSwapButtons != fSwapOld) { 00055 gbMouseButtonsRecentlySwapped = !gbMouseButtonsRecentlySwapped; 00056 } 00057 00058 /* 00059 * Return previous state 00060 */ 00061 return fSwapOld; 00062 } 00063 00064 /***************************************************************************\ 00065 * _SetDoubleClickTime (API) 00066 * 00067 * History: 00068 * 24-Sep-1990 DarrinM Generated stubs. 00069 * 25-Jan-1991 DavidPe Did the real thing. 00070 * 12-Feb-1991 JimA Added access check 00071 * 16-May-1991 MikeKe Changed to return BOOL 00072 \***************************************************************************/ 00073 00074 BOOL APIENTRY _SetDoubleClickTime( 00075 UINT dtTime) 00076 { 00077 PWINDOWSTATION pwinsta = PpiCurrent()->rpwinsta; 00078 00079 /* 00080 * Blow it off if the caller doesn't have the proper access rights 00081 */ 00082 if (!CheckWinstaWriteAttributesAccess()) { 00083 return FALSE; 00084 } 00085 00086 if (!dtTime) { 00087 dtTime = 500; 00088 } else if (dtTime > 5000) { 00089 dtTime = 5000; 00090 } 00091 00092 gdtDblClk = dtTime; 00093 gpsi->dtLBSearch = dtTime * 4; // dtLBSearch = 4 * gdtDblClk 00094 gpsi->dtScroll = gpsi->dtLBSearch / 5; // dtScroll = 4/5 * gdtDblClk 00095 /* 00096 * This value should be set through SPI_SETMENUSHOWDELAY 00097 * gdtMNDropDown = gpsi->dtScroll; // gdtMNDropDown = 4/5 * gdtDblClk 00098 */ 00099 00100 /* 00101 * Recalculate delays for tooltip windows on all desktops. 00102 */ 00103 if (pwinsta != NULL) { 00104 PDESKTOP pdesk; 00105 for (pdesk = pwinsta->rpdeskList; pdesk; pdesk = pdesk->rpdeskNext) { 00106 InitTooltipDelay((PTOOLTIPWND)pdesk->spwndTooltip); 00107 } 00108 } 00109 00110 return TRUE; 00111 } 00112 00113 /***************************************************************************\ 00114 * SetSysColor() 00115 * 00116 * Changes the value of a system color, and updates the brush. Tries to 00117 * recover in case of an error. 00118 * 00119 * History: 00120 \***************************************************************************/ 00121 VOID SetSysColor( 00122 UINT icol, 00123 DWORD rgb, 00124 UINT uOptions 00125 ) 00126 { 00127 00128 if ((uOptions & SSCF_SETMAGICCOLORS) && gpDispInfo->fAnyPalette) { 00129 union { 00130 DWORD rgb; 00131 PALETTEENTRY pe; 00132 } peMagic; 00133 00134 peMagic.rgb = rgb; 00135 00136 /* 00137 * when any of the 3D colors are changing, call GDI to 00138 * set the apropiate "magic" color 00139 * 00140 * the four magic colors are reserved like so 00141 * 00142 * 8 - UI color (3D shadow) 00143 * 9 - UI color (3D face) 00144 * 00145 * F6 - UI color (3D hilight) 00146 * F7 - UI color (desktop) 00147 * 00148 * NOTE (3D hilight) inverts to (3D shadow) 00149 * (3D face) inverts to sys gray 00150 * 00151 */ 00152 00153 switch (icol) 00154 { 00155 case COLOR_3DSHADOW: 00156 GreSetMagicColors(gpDispInfo->hdcScreen, peMagic.pe, 8); 00157 break; 00158 00159 case COLOR_3DFACE: 00160 GreSetMagicColors(gpDispInfo->hdcScreen, peMagic.pe, 9); 00161 break; 00162 00163 case COLOR_3DHILIGHT: 00164 GreSetMagicColors(gpDispInfo->hdcScreen, peMagic.pe, 246); 00165 break; 00166 00167 case COLOR_DESKTOP: 00168 GreSetMagicColors(gpDispInfo->hdcScreen, peMagic.pe, 247); 00169 break; 00170 } 00171 } 00172 00173 if (uOptions & SSCF_16COLORS) { 00174 /* 00175 * Force solid colors for all elements in 16 color or less modes. 00176 */ 00177 rgb = GreGetNearestColor(gpDispInfo->hdcScreen, rgb); 00178 } else if (uOptions & SSCF_FORCESOLIDCOLOR) { 00179 /* 00180 * Force solid colors for certain window elements. 00181 */ 00182 switch (icol) { 00183 00184 /* 00185 * These can be dithers 00186 */ 00187 case COLOR_DESKTOP: 00188 case COLOR_ACTIVEBORDER: 00189 case COLOR_INACTIVEBORDER: 00190 case COLOR_APPWORKSPACE: 00191 case COLOR_INFOBK: 00192 case COLOR_GRADIENTACTIVECAPTION: 00193 case COLOR_GRADIENTINACTIVECAPTION: 00194 break; 00195 00196 default: 00197 rgb = GreGetNearestColor(gpDispInfo->hdcScreen, rgb); 00198 break; 00199 } 00200 } 00201 00202 gpsi->argbSystem[icol] = rgb; 00203 if (SYSHBRUSH(icol) == NULL) { 00204 /* 00205 * This is the first time we're setting up the system colors. 00206 * We need to create the brush 00207 */ 00208 SYSHBRUSH(icol) = GreCreateSolidBrush(rgb); 00209 GreMarkUndeletableBrush(SYSHBRUSH(icol)); 00210 GreSetBrushOwnerPublic(SYSHBRUSH(icol)); 00211 } else { 00212 GreSetSolidBrush(SYSHBRUSH(icol), rgb); 00213 } 00214 } 00215 00216 /***************************************************************************\ 00217 * xxxSetSysColors (API) 00218 * 00219 * 00220 * History: 00221 * 12-Feb-1991 JimA Created stub and added access check 00222 * 22-Apr-1991 DarrinM Ported from Win 3.1 sources. 00223 * 16-May-1991 MikeKe Changed to return BOOL 00224 \***************************************************************************/ 00225 BOOL APIENTRY xxxSetSysColors(PUNICODE_STRING pProfileUserName, 00226 int cicol, 00227 PUINT picolor, 00228 COLORREF *prgb, 00229 UINT uOptions 00230 ) 00231 { 00232 int i; 00233 UINT icol; 00234 COLORREF rgb; 00235 00236 /* 00237 * Blow it off if the caller doesn't have the proper access rights 00238 */ 00239 if ((uOptions & SSCF_NOTIFY) && !CheckWinstaWriteAttributesAccess()) { 00240 return FALSE; 00241 } 00242 00243 if (GreGetDeviceCaps(gpDispInfo->hdcScreen, NUMCOLORS) <= 16) { 00244 uOptions |= SSCF_16COLORS; 00245 } 00246 00247 if (uOptions & SSCF_SETMAGICCOLORS) { 00248 /* 00249 * Set the Magic colors first 00250 */ 00251 for(i = 0; i < cicol; i++) { 00252 icol = picolor[i]; 00253 rgb = prgb[i]; 00254 if ( icol == COLOR_3DFACE || 00255 icol == COLOR_3DSHADOW || 00256 icol == COLOR_3DHILIGHT || 00257 icol == COLOR_DESKTOP) { 00258 00259 SetSysColor(icol, rgb, uOptions); 00260 } 00261 } 00262 } 00263 00264 for (i = 0; i < cicol; i++) { 00265 00266 icol = *picolor++; 00267 rgb = *prgb++; 00268 00269 if (icol >= COLOR_MAX) 00270 continue; 00271 00272 if ((uOptions & SSCF_SETMAGICCOLORS) && 00273 (icol == COLOR_3DFACE || 00274 icol == COLOR_3DSHADOW || 00275 icol == COLOR_3DHIGHLIGHT || 00276 icol == COLOR_DESKTOP)) { 00277 continue; 00278 } 00279 00280 SetSysColor(icol, rgb, uOptions); 00281 } 00282 00283 if (uOptions & SSCF_NOTIFY) { 00284 00285 /* 00286 * Recolor all the current desktop 00287 */ 00288 RecolorDeskPattern(); 00289 00290 /* 00291 * Render the system bitmaps in new colors before we broadcast 00292 */ 00293 00294 xxxSetWindowNCMetrics(pProfileUserName,NULL, FALSE, -1); 00295 00296 00297 /* 00298 * Notify everyone that the colors have changed. 00299 */ 00300 xxxSendNotifyMessage(PWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0L); 00301 00302 /* 00303 * Just redraw the entire screen. Trying to just draw the parts 00304 * that were changed isn't worth it, since Control Panel always 00305 * resets every color anyway. 00306 * 00307 * Anyway, it could get messy, sending apps NCPAINT messages without 00308 * accumulating update regions too. 00309 */ 00310 xxxRedrawScreen(); 00311 } 00312 00313 return TRUE; 00314 }

Generated on Sat May 15 19:41:56 2004 for test by doxygen 1.3.7