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

random.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: random.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * This file contains global function pointers that are called trough to get 00007 * to either a client or a server function depending on which side we are on 00008 * 00009 * History: 00010 * 10-Nov-1993 MikeKe Created 00011 \***************************************************************************/ 00012 00013 #include "precomp.h" 00014 #pragma hdrstop 00015 00016 /***************************************************************************\ 00017 * 00018 * 00019 * History: 00020 * 10-Nov-1993 MikeKe Created 00021 \***************************************************************************/ 00022 00023 HBRUSH ghbrWhite = NULL; 00024 HBRUSH ghbrBlack = NULL; 00025 00026 /***************************************************************************\ 00027 * GetSysColorBrush 00028 * 00029 * Retrieves the system-color-brush. 00030 * 00031 \***************************************************************************/ 00032 HBRUSH WINAPI GetSysColorBrush( 00033 int nIndex) 00034 { 00035 if ((nIndex < 0) || (nIndex >= COLOR_MAX)) 00036 return NULL; 00037 00038 return SYSHBRUSH(nIndex); 00039 } 00040 00041 /***************************************************************************\ 00042 * SetSysColorTemp 00043 * 00044 * Sets the global system colors all at once. Also remembers the old colors 00045 * so they can be reset. 00046 * 00047 * Sets/Resets the color and brush arrays for user USER drawing. 00048 * lpRGBs and lpBrushes are pointers to arrays paralleling the argbSystem and 00049 * gpsi->hbrSystem arrays. wCnt is a sanity check so that this does the "right" 00050 * thing in a future windows version. The current argbSystem and hbrSystem 00051 * arrays are saved off, and a handle to those saved arrays is returned. 00052 * 00053 * To reset the arrays, pass in NULL for lpRGBs, NULL for lpBrushes, and the 00054 * handle (from the first set) for wCnt. 00055 * 00056 * History: 00057 * 18-Sep-1995 JohnC Gave this miserable function a life 00058 \***************************************************************************/ 00059 00060 LPCOLORREF gpOriginalRGBs = NULL; 00061 UINT gcOriginalRGBs = 0; 00062 00063 WINUSERAPI HANDLE WINAPI SetSysColorsTemp( 00064 CONST COLORREF *lpRGBs, 00065 CONST HBRUSH *lpBrushes, 00066 UINT_PTR cBrushes) // Count of brushes or handle 00067 { 00068 UINT cbRGBSize; 00069 UINT i; 00070 UINT abElements[COLOR_MAX]; 00071 00072 /* 00073 * See if we are resetting the colors back to a saved state 00074 */ 00075 if (lpRGBs == NULL) { 00076 00077 /* 00078 * When restoring cBrushes is really a handle to the old global 00079 * handle. Make sure that is true. Also lpBrushes is unused 00080 */ 00081 UNREFERENCED_PARAMETER(lpBrushes); 00082 UserAssert(lpBrushes == NULL); 00083 UserAssert(cBrushes == (ULONG_PTR)gpOriginalRGBs); 00084 00085 if (gpOriginalRGBs == NULL) { 00086 RIPMSG0(RIP_ERROR, "SetSysColorsTemp: Can not restore if not saved"); 00087 return NULL; 00088 } 00089 00090 /* 00091 * reset the global Colors 00092 */ 00093 UserAssert((sizeof(abElements)/sizeof(abElements[0])) >= gcOriginalRGBs); 00094 for (i = 0; i < gcOriginalRGBs; i++) 00095 abElements[i] = i; 00096 00097 NtUserSetSysColors(gcOriginalRGBs, abElements, gpOriginalRGBs, 0); 00098 00099 UserLocalFree(gpOriginalRGBs); 00100 00101 gpOriginalRGBs = NULL; 00102 gcOriginalRGBs = 0; 00103 00104 return (HANDLE)TRUE; 00105 } 00106 00107 /* 00108 * Make sure we aren't trying to set too many colors 00109 * If we allow more then COLOR_MAX change the abElements array 00110 */ 00111 if (cBrushes > COLOR_MAX) { 00112 RIPMSG1(RIP_ERROR, "SetSysColorsTemp: trying to set too many colors %lX", cBrushes); 00113 return NULL; 00114 } 00115 00116 /* 00117 * If we have already a saved state then don't let them save it again 00118 */ 00119 if (gpOriginalRGBs != NULL) { 00120 RIPMSG0(RIP_ERROR, "SetSysColorsTemp: temp colors already set"); 00121 return NULL; 00122 } 00123 00124 /* 00125 * If we are here then we must be setting the new temp colors 00126 * 00127 * First save the old colors 00128 */ 00129 cbRGBSize = sizeof(COLORREF) * (UINT)cBrushes; 00130 00131 UserAssert(sizeof(COLORREF) == sizeof(int)); 00132 gpOriginalRGBs = UserLocalAlloc(HEAP_ZERO_MEMORY, cbRGBSize); 00133 00134 if (gpOriginalRGBs == NULL) { 00135 RIPMSG0(RIP_WARNING, "SetSysColorsTemp: unable to alloc temp colors buffer"); 00136 } 00137 00138 RtlCopyMemory(gpOriginalRGBs, gpsi->argbSystem, cbRGBSize); 00139 00140 /* 00141 * Now set the new colors. 00142 */ 00143 UserAssert( (sizeof(abElements)/sizeof(abElements[0])) >= cBrushes); 00144 00145 for (i = 0; i < cBrushes; i++) 00146 abElements[i] = i; 00147 00148 NtUserSetSysColors((UINT)cBrushes, abElements, lpRGBs, 0); 00149 00150 gcOriginalRGBs = (UINT)cBrushes; 00151 00152 return gpOriginalRGBs; 00153 } 00154 00155 /***************************************************************************\ 00156 * TextAlloc 00157 * 00158 * History: 00159 * 25-Oct-1990 MikeHar Wrote. 00160 * 09-Nov-1990 DarrinM Fixed. 00161 * 13-Jan-1992 GregoryW Neutralized. 00162 \***************************************************************************/ 00163 00164 LPWSTR TextAlloc( 00165 LPCWSTR lpszSrc) 00166 { 00167 LPWSTR pszT; 00168 DWORD cbString; 00169 00170 if (lpszSrc == NULL) 00171 return NULL; 00172 00173 cbString = (wcslen(lpszSrc) + 1) * sizeof(WCHAR); 00174 00175 if (pszT = (LPWSTR)UserLocalAlloc(HEAP_ZERO_MEMORY, cbString)) { 00176 00177 RtlCopyMemory(pszT, lpszSrc, cbString); 00178 } 00179 00180 return pszT; 00181 } 00182 00183 #if DBG 00184 /***************************************************************************\ 00185 * CheckCurrentDesktop 00186 * 00187 * Ensure that the pointer is valid for the current desktop. 00188 * 00189 * History: 00190 * 10-Apr-1995 JimA Created. 00191 \***************************************************************************/ 00192 00193 VOID CheckCurrentDesktop( 00194 PVOID p) 00195 { 00196 UserAssert(p >= GetClientInfo()->pDeskInfo->pvDesktopBase && 00197 p < GetClientInfo()->pDeskInfo->pvDesktopLimit); 00198 } 00199 #endif 00200 00201 00202 /***************************************************************************\ 00203 * SetLastErrorEx 00204 * 00205 * Sets the last error, ignoring dwtype. 00206 \***************************************************************************/ 00207 00208 VOID WINAPI SetLastErrorEx( 00209 DWORD dwErrCode, 00210 DWORD dwType 00211 ) 00212 { 00213 UNREFERENCED_PARAMETER(dwType); 00214 00215 SetLastError(dwErrCode); 00216 } 00217 00218 #if defined(_X86_) 00219 /***************************************************************************\ 00220 * InitializeWin32EntryTable 00221 * 00222 * Initializes a Win32 entry table so our test apps will know which entry 00223 * points to avoid. This should be removed before we ship. 00224 \***************************************************************************/ 00225 00226 static CONST PROC FunctionsToSkip[] = { 00227 NtUserWaitMessage, 00228 NtUserLockWorkStation, 00229 }; 00230 00231 UINT InitializeWin32EntryTable( 00232 PBOOLEAN pbEntryTable) 00233 { 00234 #if DBG 00235 // We'll only define this on free systems for now. Checked systems 00236 // will hit too many asserts. 00237 UNREFERENCED_PARAMETER(pbEntryTable); 00238 return 0; 00239 #else 00240 UINT i; 00241 PBYTE pb; 00242 00243 if (pbEntryTable) { 00244 for (i = 0; i < ARRAY_SIZE(FunctionsToSkip); i++) { 00245 pb = (PBYTE)FunctionsToSkip[i]; 00246 pbEntryTable[*((WORD *)(pb+1)) - 0x1000] = TRUE; 00247 } 00248 00249 } 00250 00251 return gDispatchTableValues; 00252 #endif 00253 } 00254 #endif 00255 /***************************************************************************\ 00256 * GetLastInputInfo 00257 * 00258 * Retrieves information about the last input event 00259 * 00260 * 05/30/07 GerardoB Created 00261 \***************************************************************************/ 00262 BOOL GetLastInputInfo (PLASTINPUTINFO plii) 00263 { 00264 VALIDATIONFNNAME(GetLastInputInfo); 00265 00266 if (plii->cbSize != sizeof(LASTINPUTINFO)) { 00267 VALIDATIONFAIL(plii->cbSize); 00268 } 00269 00270 plii->dwTime = gpsi->dwLastRITEventTickCount; 00271 00272 return TRUE; 00273 VALIDATIONERROR(FALSE); 00274 } 00275

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