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

inctlpan.c

Go to the documentation of this file.
00001 /***************************************************************************\ 00002 * 00003 * INCTLPAN.C 00004 * 00005 * Copyright (c) 1985 - 1999, Microsoft Corporation 00006 * 00007 * Init Routines which are also used by Control Panel 00008 * 00009 * -- Scalable Window Frame Support 00010 * 00011 * exports from this module: 00012 * > SetCaretBlinkTime -- API called internally (kinda) by control panel 00013 * > SetKeyboardSpeed -- called by LoadWindows & SystemParametersInfo 00014 * > SetMinMaxInfo -- called by LoadWindows & SystemParemetersInfo 00015 * > SetWindowMetrics -- called by LoadWindows & SystemParametersInfo 00016 * 00017 \***************************************************************************/ 00018 00019 #include "precomp.h" 00020 #pragma hdrstop 00021 00022 __inline int 00023 MetricGetID( 00024 PUNICODE_STRING pProfileUserName, 00025 UINT idStr, 00026 int defValue 00027 ) 00028 { 00029 return FastGetProfileIntFromID( 00030 pProfileUserName, PMAP_METRICS, idStr, defValue); 00031 } 00032 00033 static CONST WORD sysBmpStyles[OBI_COUNT][2] = { 00034 00035 DFC_CAPTION, DFCS_CAPTIONCLOSE, // OBI_CLOSE 00036 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_PUSHED, // OBI_CLOSE_D 00037 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_HOT, // OBI_CLOSE_H 00038 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INACTIVE, // OBI_CLOSE_I 00039 DFC_CAPTION, DFCS_CAPTIONMIN, // OBI_REDUCE 00040 DFC_CAPTION, DFCS_CAPTIONMIN | DFCS_PUSHED, // OBI_REDUCE_D 00041 DFC_CAPTION, DFCS_CAPTIONMIN | DFCS_HOT, // OBI_REDUCE_H 00042 DFC_CAPTION, DFCS_CAPTIONMIN | DFCS_INACTIVE, // OBI_REDUCE_I 00043 DFC_CAPTION, DFCS_CAPTIONRESTORE, // OBI_RESTORE 00044 DFC_CAPTION, DFCS_CAPTIONRESTORE | DFCS_PUSHED, // OBI_RESTORE_D 00045 DFC_CAPTION, DFCS_CAPTIONRESTORE | DFCS_HOT, // OBI_RESTORE_H 00046 DFC_CAPTION, DFCS_CAPTIONHELP, // OBI_HELP 00047 DFC_CAPTION, DFCS_CAPTIONHELP | DFCS_PUSHED, // OBI_HELP_D 00048 DFC_CAPTION, DFCS_CAPTIONHELP | DFCS_HOT, // OBI_HELP_H 00049 DFC_CAPTION, DFCS_CAPTIONMAX, // OBI_ZOOM 00050 DFC_CAPTION, DFCS_CAPTIONMAX | DFCS_PUSHED, // OBI_ZOOM_D 00051 DFC_CAPTION, DFCS_CAPTIONMAX | DFCS_HOT, // OBI_ZOOM_H 00052 DFC_CAPTION, DFCS_CAPTIONMAX | DFCS_INACTIVE, // OBI_ZOOM_I 00053 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INMENU, // OBI_CLOSE_MBAR 00054 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INMENU | DFCS_PUSHED, // OBI_CLOSE_MBAR_D 00055 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INMENU | DFCS_HOT, // OBI_CLOSE_MBAR_H 00056 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INMENU | DFCS_INACTIVE, // OBI_CLOSE_MBAR_I 00057 DFC_CAPTION, DFCS_CAPTIONMIN | DFCS_INMENU, // OBI_REDUCE_MBAR 00058 DFC_CAPTION, DFCS_CAPTIONMIN | DFCS_INMENU | DFCS_PUSHED, // OBI_REDUCE_MBAR_D 00059 DFC_CAPTION, DFCS_CAPTIONMIN | DFCS_INMENU | DFCS_HOT, // OBI_REDUCE_MBAR_H 00060 DFC_CAPTION, DFCS_CAPTIONMIN | DFCS_INMENU | DFCS_INACTIVE, // OBI_REDUCE_MBAR_I 00061 DFC_CAPTION, DFCS_CAPTIONRESTORE | DFCS_INMENU, // OBI_RESTORE_MBAR 00062 DFC_CAPTION, DFCS_CAPTIONRESTORE | DFCS_INMENU | DFCS_PUSHED, // OBI_RESTORE_MBAR_D 00063 DFC_CAPTION, DFCS_CAPTIONRESTORE | DFCS_INMENU | DFCS_HOT, // OBI_RESTORE_MBAR_H 00064 DFC_CACHE, DFCS_CACHEICON, // OBI_CAPICON1 00065 DFC_CACHE, DFCS_CACHEICON | DFCS_INACTIVE, // OBI_CAPICON1_I 00066 DFC_CACHE, DFCS_CACHEICON, // OBI_CAPICON2 00067 DFC_CACHE, DFCS_CACHEICON | DFCS_INACTIVE, // OBI_CAPICON2_I 00068 DFC_CACHE, DFCS_CACHEICON, // OBI_CAPICON3 00069 DFC_CACHE, DFCS_CACHEICON | DFCS_INACTIVE, // OBI_CAPICON3_I 00070 DFC_CACHE, DFCS_CACHEICON, // OBI_CAPICON4 00071 DFC_CACHE, DFCS_CACHEICON | DFCS_INACTIVE, // OBI_CAPICON4_I 00072 DFC_CACHE, DFCS_CACHEICON, // OBI_CAPICON5 00073 DFC_CACHE, DFCS_CACHEICON | DFCS_INACTIVE, // OBI_CAPICON5_I 00074 DFC_CACHE, DFCS_CACHEBUTTONS, // OBI_CAPBTNS 00075 DFC_CACHE, DFCS_CACHEBUTTONS | DFCS_INACTIVE, // OBI_CAPBTNS_I 00076 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INSMALL, // OBI_CLOSE_PAL 00077 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INSMALL | DFCS_PUSHED, // OBI_CLOSE_PAL_D 00078 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INSMALL | DFCS_HOT, // OBI_CLOSE_PAL_H 00079 DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_INSMALL | DFCS_INACTIVE,// OBI_CLOSE_PAL_I 00080 DFC_SCROLL, DFCS_SCROLLSIZEGRIP, // OBI_NCGRIP 00081 DFC_SCROLL, DFCS_SCROLLUP, // OBI_UPARROW 00082 DFC_SCROLL, DFCS_SCROLLUP | DFCS_PUSHED | DFCS_FLAT, // OBI_UPARROW_D 00083 DFC_SCROLL, DFCS_SCROLLUP | DFCS_HOT, // OBI_UPARROW_H 00084 DFC_SCROLL, DFCS_SCROLLUP | DFCS_INACTIVE, // OBI_UPARROW_I 00085 DFC_SCROLL, DFCS_SCROLLDOWN, // OBI_DNARROW 00086 DFC_SCROLL, DFCS_SCROLLDOWN | DFCS_PUSHED | DFCS_FLAT, // OBI_DNARROW_D 00087 DFC_SCROLL, DFCS_SCROLLDOWN | DFCS_HOT, // OBI_DNARROW_H 00088 DFC_SCROLL, DFCS_SCROLLDOWN | DFCS_INACTIVE, // OBI_DNARROW_I 00089 DFC_SCROLL, DFCS_SCROLLRIGHT, // OBI_RGARROW 00090 DFC_SCROLL, DFCS_SCROLLRIGHT | DFCS_PUSHED | DFCS_FLAT, // OBI_RGARROW_D 00091 DFC_SCROLL, DFCS_SCROLLRIGHT | DFCS_HOT, // OBI_RGARROW_H 00092 DFC_SCROLL, DFCS_SCROLLRIGHT | DFCS_INACTIVE, // OBI_RGARROW_I 00093 DFC_SCROLL, DFCS_SCROLLLEFT, // OBI_LFARROW 00094 DFC_SCROLL, DFCS_SCROLLLEFT | DFCS_PUSHED | DFCS_FLAT, // OBI_LFARROW_D 00095 DFC_SCROLL, DFCS_SCROLLLEFT | DFCS_HOT, // OBI_LFARROW_H 00096 DFC_SCROLL, DFCS_SCROLLLEFT | DFCS_INACTIVE, // OBI_LFARROW_I 00097 DFC_MENU, DFCS_MENUARROW, // OBI_MENUARROW 00098 DFC_MENU, DFCS_MENUCHECK, // OBI_MENUCHECK 00099 DFC_MENU, DFCS_MENUBULLET, // OBI_MENUBULLET 00100 DFC_MENU, DFCS_MENUARROWUP, // OBI_MENUARROWUP 00101 DFC_MENU, DFCS_MENUARROWUP | DFCS_HOT, // OBI_MENUARROWUP_H 00102 DFC_MENU, DFCS_MENUARROWUP | DFCS_INACTIVE, // OBI_MENUARROWUP_I 00103 DFC_MENU, DFCS_MENUARROWDOWN, // OBI_MENUARROWDOWN 00104 DFC_MENU, DFCS_MENUARROWDOWN | DFCS_HOT, // OBI_MENUARROWDOWN_H 00105 DFC_MENU, DFCS_MENUARROWDOWN | DFCS_INACTIVE, // OBI_MENUARROWDOWN_I 00106 DFC_BUTTON, DFCS_BUTTONRADIOMASK, // OBI_RADIOMASK 00107 DFC_BUTTON, DFCS_BUTTONCHECK, // OBI_CHECK 00108 DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED, // OBI_CHECK_C 00109 DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_PUSHED, // OBI_CHECK_D 00110 DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_PUSHED, // OBI_CHECK_CD 00111 DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE, // OBI_CHECK_CDI 00112 DFC_BUTTON, DFCS_BUTTONRADIOIMAGE, // OBI_RADIO 00113 DFC_BUTTON, DFCS_BUTTONRADIOIMAGE | DFCS_CHECKED, // OBI_RADIO_C 00114 DFC_BUTTON, DFCS_BUTTONRADIOIMAGE | DFCS_PUSHED, // OBI_RADIO_D 00115 DFC_BUTTON, DFCS_BUTTONRADIOIMAGE | DFCS_CHECKED | DFCS_PUSHED, // OBI_RADIO_CD 00116 DFC_BUTTON, DFCS_BUTTONRADIOIMAGE | DFCS_CHECKED | DFCS_INACTIVE, // OBI_RADIO_CDI 00117 DFC_BUTTON, DFCS_BUTTON3STATE, // OBI_3STATE 00118 DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED, // OBI_3STATE_C 00119 DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_PUSHED, // OBI_3STATE_D 00120 DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_PUSHED, // OBI_3STATE_CD 00121 DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE, // OBI_3STATE_CDI 00122 DFC_POPUPMENU, DFCS_CAPTIONCLOSE | DFCS_INMENU, // OBI_CLOSE_POPUP 00123 DFC_POPUPMENU, DFCS_CAPTIONRESTORE | DFCS_INMENU, // OBI_RESTORE_POPUP 00124 DFC_POPUPMENU, DFCS_CAPTIONMAX | DFCS_INMENU, // OBI_ZOOM_POPUP 00125 DFC_POPUPMENU, DFCS_CAPTIONMIN | DFCS_INMENU, // OBI_REDUCE_POPUP 00126 DFC_SCROLL, DFCS_SCROLLSIZEGRIPRIGHT, // OBI_NCGRIP_L 00127 DFC_MENU, DFCS_MENUARROWRIGHT // OBI_MENUARROW_L 00128 }; 00129 00130 #define DIVISOR 72 00131 #define DU_BTNWIDTH 50 // D.U. of minimum button width in a message box 00132 00133 UINT xxxMB_FindLongestString(HDC hdc); 00134 00135 #ifdef LATER 00136 /***************************************************************************\ 00137 \***************************************************************************/ 00138 00139 WCHAR NibbleToChar( 00140 BYTE x) 00141 { 00142 WCHAR static N2C[] = 00143 { 00144 '0', '1', '2', '3', '4', '5', '6', '7', 00145 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 00146 }; 00147 00148 return N2C[x]; 00149 } 00150 00151 BYTE CharToNibble( 00152 WCHAR ch) 00153 { 00154 BYTE x = (BYTE)ch; 00155 00156 return x >= '0' && x <= '9' ? 00157 x - '0' : 00158 ((10 + x - 'A' ) & 0x0f); 00159 } 00160 00161 /***************************************************************************\ 00162 \***************************************************************************/ 00163 00164 BOOL TextToBinary( 00165 LPBYTE pbyte, 00166 LPWSTR pwstr, 00167 int length) 00168 { 00169 BYTE checksum = 0; 00170 00171 while (TRUE) { 00172 BYTE byte; 00173 00174 byte = (CharToNibble(pwstr[0]) << 4) | CharToNibble(pwstr[1]); 00175 00176 if (length == 0) { 00177 return checksum == byte; 00178 } 00179 00180 checksum += byte; 00181 *pbyte = byte; 00182 00183 pwstr += 2; 00184 length--; 00185 pbyte++; 00186 } 00187 } 00188 00189 void BinaryToText( 00190 LPWSTR pwstr, 00191 LPBYTE pbyte, 00192 int length) 00193 { 00194 BYTE checksum = 0; 00195 00196 while (length > 0) { 00197 checksum += *pbyte; 00198 00199 pwstr[0] = NibbleToChar((BYTE)((*pbyte >> 4) & 0x0f)); 00200 pwstr[1] = NibbleToChar((BYTE)(*pbyte & 0x0f)); 00201 00202 pbyte++; 00203 pwstr += 2; 00204 length--; 00205 } 00206 00207 pwstr[0] = NibbleToChar((BYTE)((checksum >> 4) & 0x0f)); 00208 pwstr[1] = NibbleToChar((BYTE)(checksum & 0x0f)); 00209 pwstr[2] = '\0'; 00210 } 00211 00212 /***************************************************************************\ 00213 \***************************************************************************/ 00214 00215 // these are the exported apis. The User* versions are for server use only 00216 // I didn't get them to work since no one calls them yet. 00217 00218 BOOL GetPrivateProfileStruct( 00219 LPWSTR szSection, 00220 LPWSTR szKey, 00221 LPWSTR lpStruct, 00222 DWORD uSizeStruct, 00223 LPWSTR szFile) 00224 { 00225 WCHAR szBuf[256]; 00226 BOOL fAlloc = FALSE; 00227 LPSTR lpBuf, lpBufTemp; 00228 int nLen; 00229 BOOL fError = FALSE; 00230 00231 nLen = uSizeStruct * 4 + 10; 00232 if (nLen > (WORD)sizeof(szBuf)) { 00233 fAlloc = TRUE; 00234 lpBuf = (LPSTR)UserAllocPoolWithQuota(nLen, TAG_PROFILE); 00235 if (lpBuf == NULL) 00236 return FALSE; 00237 } else { 00238 lpBuf = (LPSTR)szBuf; 00239 } 00240 00241 if (szFile && *szFile) { 00242 nLen = GetPrivateProfileString(szSection, szKey, NULL, lpBuf, nLen, szFile); 00243 } else { 00244 nLen = GetProfileString(szSection, szKey, NULL, lpBuf, nLen); 00245 } 00246 00247 if (nLen == (int)(uSizeStruct * 4 + 4)) { 00248 /* 00249 * decode the string 00250 */ 00251 fError = TextToBinary(lpStruct, lpBufTemp, uSizeStruct); 00252 } 00253 00254 if (fAlloc) 00255 UserFreePool(lpBuf); 00256 00257 return fError; 00258 } 00259 00260 BOOL WritePrivateProfileStruct( 00261 LPWSTR szSection, 00262 LPWSTR szKey, 00263 LPWSTR lpStruct, 00264 WORD uSizeStruct, 00265 LPWSTR szFile) 00266 { 00267 LPWSTR lpBuf; 00268 BOOL bRet; 00269 BOOL fAlloc; 00270 WCHAR szBuf[256]; 00271 BYTE checksum=0; 00272 int allocsize = (uSizeStruct * 2 + 3) * sizeof(WCHAR); 00273 00274 /* NULL lpStruct erases the the key */ 00275 00276 if (lpStruct == NULL) { 00277 if (szFile && *szFile) { 00278 return WritePrivateProfileString(szSection, szKey, (LPSTR)NULL, szFile); 00279 } else { 00280 return WriteProfileString(szSection, szKey, (LPSTR)NULL); 00281 } 00282 } 00283 00284 fAlloc = (allocsize > sizeof(szBuf)); 00285 if (fAlloc) { 00286 lpBuf = (LPSTR)UserAllocPoolWithQuota(allocsize, TAG_PROFILE); 00287 if (!lpBuf) 00288 return FALSE; 00289 } else { 00290 lpBuf = (LPSTR)szBuf; 00291 } 00292 00293 BinaryToText(lpBuf, lpStruct, uSizeStruct); 00294 00295 if (szFile && *szFile) { 00296 bRet = WritePrivateProfileString(szSection, szKey, lpBuf, szFile); 00297 } else { 00298 bRet = WriteProfileString(szSection, szKey, lpBuf); 00299 } 00300 00301 if (fAlloc) 00302 UserFreePool(lpBuf); 00303 00304 return bRet; 00305 } 00306 #endif 00307 00308 /***************************************************************************\ 00309 * 00310 * GetFrameControlMetrics 00311 * 00312 * (cx = 0) is a code meaning cy is the obi of the "shared" bitmap 00313 * 00314 \***************************************************************************/ 00315 int GetFrameControlMetrics( 00316 UINT obi, 00317 int cxMax ) 00318 { 00319 int cx, cy; 00320 UINT wType = sysBmpStyles[obi][0]; 00321 UINT wState = sysBmpStyles[obi][1]; 00322 POEMBITMAPINFO pOem = gpsi->oembmi + obi; 00323 00324 switch (wType) { 00325 case DFC_SCROLL: 00326 if (wState & DFCS_SCROLLSIZEGRIP) { 00327 cx = SYSMET(CXVSCROLL); 00328 cy = SYSMET(CYHSCROLL); 00329 break; 00330 } else if (wState & DFCS_SCROLLHORZ) { 00331 cx = SYSMET(CXHSCROLL); 00332 cy = SYSMET(CYHSCROLL); 00333 } else { 00334 cx = SYSMET(CXVSCROLL); 00335 cy = SYSMET(CYVSCROLL); 00336 } 00337 break; 00338 00339 case DFC_MENU: 00340 case DFC_POPUPMENU: 00341 if (wState & (DFCS_MENUARROWUP | DFCS_MENUARROWDOWN)) { 00342 cy = gcyMenuScrollArrow; 00343 } else { 00344 /* 00345 * Add on proper space for space above underscore. 00346 * the 0xFFFE and -1 are to insure an ODD height 00347 */ 00348 cy = ((gcyMenuFontChar + gcyMenuFontExternLeading + SYSMET(CYBORDER)) & 0xFFFE) - 1; 00349 } 00350 cx = cy; 00351 break; 00352 00353 case DFC_CAPTION: 00354 if (wState & DFCS_INSMALL) { 00355 cx = SYSMET(CXSMSIZE); 00356 cy = SYSMET(CYSMSIZE); 00357 } else if (wState & DFCS_INMENU) { 00358 if ((SYSMET(CXSIZE) == SYSMET(CXMENUSIZE)) && 00359 (SYSMET(CYSIZE) == SYSMET(CYMENUSIZE))) { 00360 cx = 0; 00361 cy = obi - DOBI_MBAR; 00362 break; 00363 } else { 00364 cx = SYSMET(CXMENUSIZE); 00365 cy = SYSMET(CYMENUSIZE); 00366 } 00367 } else { 00368 cx = SYSMET(CXSIZE); 00369 cy = SYSMET(CYSIZE); 00370 } 00371 00372 cx -= SYSMET(CXEDGE); 00373 cy -= 2 * SYSMET(CYEDGE); 00374 break; 00375 00376 case DFC_CACHE: 00377 if (wState & DFCS_CACHEBUTTONS) { 00378 cx = SYSMET(CXSIZE) * 4; 00379 cy = SYSMET(CYSIZE); 00380 } else 00381 cx = cy = SYSMET(CYSIZE); 00382 break; 00383 00384 case DFC_BUTTON: 00385 if (((wState & 0x00FF) & DFCS_BUTTON3STATE) && !(wState & DFCS_CHECKED)) { 00386 cx = 0; 00387 cy = obi - DOBI_3STATE; 00388 } else { 00389 cx = 13; 00390 cy = 13; 00391 } 00392 break; 00393 } 00394 00395 pOem->cx = cx; 00396 pOem->cy = cy; 00397 00398 return((cx > cxMax) ? cx : cxMax); 00399 } 00400 00401 00402 /***************************************************************************\ 00403 * 00404 * PackFrameControls 00405 * 00406 * Given the dimensions that GetFrameControlMetrics has calculated, this 00407 * arranges all the system bitmaps to fit within a bitmap of the given width 00408 * 00409 \***************************************************************************/ 00410 00411 int PackFrameControls(int cxMax, BOOL fRecord) { 00412 UINT obi; 00413 int cy = 0; 00414 int x = 0; 00415 int y = 0; 00416 00417 00418 POEMBITMAPINFO pOem = gpsi->oembmi; 00419 00420 for (obi = 0; obi < OBI_COUNT; obi++, pOem++) { 00421 if (pOem->cx) { 00422 if ((x + pOem->cx) > cxMax) { 00423 y += cy; 00424 cy = 0; 00425 x = 0; 00426 } 00427 00428 if (fRecord) { 00429 pOem->x = x; 00430 pOem->y = y; 00431 } 00432 00433 if (cy < pOem->cy) 00434 cy = pOem->cy; 00435 00436 x += pOem->cx; 00437 } 00438 } 00439 00440 return(y + cy); 00441 } 00442 00443 00444 void DrawCaptionButtons( 00445 int x, 00446 int y 00447 ) 00448 { 00449 x += SYSMET(CXEDGE); 00450 y += SYSMET(CYEDGE); 00451 00452 BitBltSysBmp(HDCBITS(), x, y, OBI_REDUCE); 00453 x += SYSMET(CXSIZE) - SYSMET(CXEDGE); 00454 BitBltSysBmp(HDCBITS(), x, y, OBI_ZOOM); 00455 x += SYSMET(CXSIZE); 00456 BitBltSysBmp(HDCBITS(), x, y, OBI_CLOSE); 00457 x += SYSMET(CXSIZE); 00458 BitBltSysBmp(HDCBITS(), x, y, OBI_HELP); 00459 } 00460 00461 /***************************************************************************\ 00462 * CreateCaptionStrip 00463 * 00464 * 00465 \***************************************************************************/ 00466 HBITMAP CreateCaptionStrip(VOID) 00467 { 00468 HBITMAP hbm; 00469 00470 hbm = GreCreateCompatibleBitmap(gpDispInfo->hdcScreen, 00471 SYSMET(CXVIRTUALSCREEN), 00472 (SYSMET(CYCAPTION) - 1) * 2); 00473 00474 if (hbm) 00475 GreSetBitmapOwner(hbm, OBJECT_OWNER_PUBLIC); 00476 00477 return hbm; 00478 } 00479 00480 int cy[5]; 00481 00482 /***************************************************************************\ 00483 * 00484 * CreateBitmapStrip 00485 * 00486 * This routine sets up either the color or monochrome strip bitmap -- a 00487 * large horizontal bitmap which contains all of the system bitmaps. By 00488 * having all of these bitmaps in one long bitmap, we can have that one 00489 * bitmap always selected in, speeding up paint time by not having to do 00490 * a SelectBitmap() everytime we need to Blt one of the system bitmaps. 00491 * 00492 \***************************************************************************/ 00493 00494 BOOL CreateBitmapStrip(VOID) 00495 { 00496 int cxBmp = 0; 00497 int cyBmp = 0; 00498 int iCache = 0; 00499 HBITMAP hOldBitmap; 00500 HBITMAP hNewBmp; 00501 UINT iType; 00502 RECT rc; 00503 UINT wBmpType; 00504 UINT wBmpStyle; 00505 POEMBITMAPINFO pOem; 00506 00507 /* 00508 * Each OBI_ must have an entry in sysBmpStyles 00509 */ 00510 UserAssert(OBI_COUNT == sizeof(sysBmpStyles) / sizeof(*sysBmpStyles)); 00511 UserAssert(OBI_COUNT == sizeof(gpsi->oembmi) / sizeof(*(gpsi->oembmi))); 00512 00513 /* 00514 * load all the bitmap dimensions into the OEMBITMAPINFO array oemInfo.bm 00515 */ 00516 for (iType = 0; iType < OBI_COUNT; iType++) 00517 cxBmp = GetFrameControlMetrics(iType, cxBmp); 00518 00519 for (iType = 0; iType < 5; iType++) 00520 cy[iType] = PackFrameControls(cxBmp * (iType + 1), FALSE) * (iType + 1); 00521 00522 cyBmp = min(cy[0], min(cy[1], min(cy[2], min(cy[3], cy[4])))); 00523 for (iType = 0; cyBmp != cy[iType]; iType++); 00524 00525 cxBmp *= iType + 1; 00526 cyBmp = PackFrameControls(cxBmp, TRUE); 00527 00528 hNewBmp = GreCreateCompatibleBitmap(gpDispInfo->hdcScreen, cxBmp, cyBmp); 00529 00530 if (hNewBmp == NULL) { 00531 RIPMSG0(RIP_WARNING, "CreateBitmapStrip: failed to create bitmap"); 00532 return FALSE; 00533 } 00534 00535 GreSetBitmapOwner(hNewBmp, OBJECT_OWNER_PUBLIC); 00536 00537 /* 00538 * Select in Bitmap Strip -- then delete old one if it exists 00539 * Yanked for Chicago since these can now be paged 00540 * GDIMoveBitmap(hNewBmp); 00541 */ 00542 hOldBitmap = GreSelectBitmap(HDCBITS(), hNewBmp); 00543 00544 if (ghbmBits) { 00545 #if DBG 00546 /* 00547 * Don't assert if we're out of memory 00548 */ 00549 if (hOldBitmap != NULL) { 00550 UserAssert(ghbmBits == hOldBitmap); 00551 } 00552 #endif 00553 GreDeleteObject(ghbmCaption); 00554 GreDeleteObject(hOldBitmap); 00555 } else { 00556 /* 00557 * hack to clear out display driver's font cache 00558 */ 00559 GreExtTextOutW(HDCBITS(), 0, 0, 0, NULL, (PWSTR)szOneChar, 1, NULL); 00560 } 00561 00562 ghbmBits = hNewBmp; 00563 00564 ghbmCaption = CreateCaptionStrip(); 00565 00566 if (ghbmCaption == NULL) { 00567 RIPMSG0(RIP_WARNING, "CreateBitmapStrip: failed to create bitmap for caption"); 00568 return FALSE; 00569 } 00570 00571 /* 00572 * draw individual bitmaps into the strip bitmap and record the offsets 00573 */ 00574 for (pOem = gpsi->oembmi, iType = 0; iType < OBI_COUNT; iType++, pOem++) { 00575 if (!pOem->cx) { 00576 *pOem = gpsi->oembmi[pOem->cy]; 00577 } else { 00578 rc.left = pOem->x; 00579 rc.top = pOem->y; 00580 rc.right = rc.left + pOem->cx; 00581 rc.bottom = rc.top + pOem->cy; 00582 00583 wBmpType = sysBmpStyles[iType][0]; 00584 wBmpStyle = sysBmpStyles[iType][1]; 00585 00586 if (wBmpType == DFC_CACHE) { 00587 if (wBmpStyle & DFCS_CACHEBUTTONS) { 00588 HBRUSH hbr; 00589 if (TestALPHA(GRADIENTCAPTIONS)) { 00590 hbr = (wBmpStyle & DFCS_INACTIVE) ? SYSHBR(GRADIENTINACTIVECAPTION) : SYSHBR(GRADIENTACTIVECAPTION); 00591 } else { 00592 hbr = (wBmpStyle & DFCS_INACTIVE) ? SYSHBR(INACTIVECAPTION) : SYSHBR(ACTIVECAPTION); 00593 } 00594 FillRect(HDCBITS(), &rc, hbr); 00595 DrawCaptionButtons(rc.left, rc.top); 00596 } else if (!(wBmpStyle & DFCS_INACTIVE)) { 00597 /* 00598 * Setup Caption Cache Entry 00599 */ 00600 UserAssert(iCache < CCACHEDCAPTIONS); 00601 if (gcachedCaptions[iCache].spcursor) { 00602 Unlock(&(gcachedCaptions[iCache].spcursor)); 00603 } 00604 gcachedCaptions[iCache++].pOem = pOem; 00605 } 00606 } else { 00607 DrawFrameControl(HDCBITS(), &rc, wBmpType, wBmpStyle); 00608 } 00609 } 00610 } 00611 00612 /* 00613 * Setup other frame metric dependent values. 00614 */ 00615 SYSMET(CXMENUCHECK) = gpsi->oembmi[OBI_MENUCHECK].cx; 00616 SYSMET(CYMENUCHECK) = gpsi->oembmi[OBI_MENUCHECK].cy; 00617 00618 return TRUE; 00619 } 00620 00621 void 00622 SetNCMetrics( 00623 LPNONCLIENTMETRICS lpnc 00624 ) 00625 { 00626 int nMin; 00627 00628 /* 00629 * Scroll metrics 00630 */ 00631 SYSMET(CXVSCROLL) = SYSMET(CYHSCROLL) = (int) lpnc->iScrollWidth; 00632 SYSMET(CYVSCROLL) = SYSMET(CXHSCROLL) = (int) lpnc->iScrollHeight; 00633 SYSMET(CYVTHUMB) = SYSMET(CXHTHUMB) = (int) lpnc->iScrollHeight; 00634 00635 /* 00636 * Caption metrics 00637 */ 00638 SYSMET(CXSIZE) = (int) lpnc->iCaptionWidth; 00639 SYSMET(CYSIZE) = (int) lpnc->iCaptionHeight; 00640 SYSMET(CYCAPTION) = SYSMET(CYSIZE) + SYSMET(CYBORDER); 00641 00642 /* 00643 * Keep small icon square? 00644 * ?? Should we allow rectangles? 00645 */ 00646 SYSMET(CXSMICON) = (SYSMET(CXSIZE) - SYSMET(CXEDGE)) & ~1; 00647 SYSMET(CYSMICON) = (SYSMET(CYSIZE) - SYSMET(CYEDGE)) & ~1; 00648 nMin = min(SYSMET(CXSMICON), SYSMET(CYSMICON)); 00649 SYSMET(CXSMICON) = nMin; 00650 SYSMET(CYSMICON) = nMin; 00651 00652 /* 00653 * Small Caption metrics 00654 */ 00655 SYSMET(CXSMSIZE) = (int) lpnc->iSmCaptionWidth; 00656 SYSMET(CYSMSIZE) = (int) lpnc->iSmCaptionHeight; 00657 SYSMET(CYSMCAPTION) = SYSMET(CYSMSIZE) + SYSMET(CYBORDER); 00658 00659 /* 00660 * Menu metrics 00661 */ 00662 SYSMET(CXMENUSIZE) = (int) lpnc->iMenuWidth; 00663 SYSMET(CYMENUSIZE) = (int) lpnc->iMenuHeight; 00664 SYSMET(CYMENU) = SYSMET(CYMENUSIZE) + SYSMET(CYBORDER); 00665 00666 /* 00667 * Border metrics 00668 */ 00669 gpsi->gclBorder = (int) lpnc->iBorderWidth; 00670 00671 SYSMET(CXFRAME) = SYSMET(CXEDGE) + (gpsi->gclBorder+1)*SYSMET(CXBORDER); 00672 SYSMET(CYFRAME) = SYSMET(CYEDGE) + (gpsi->gclBorder+1)*SYSMET(CYBORDER); 00673 00674 /* 00675 * Minimium tracking size is 00676 * Across: Space for small icon, 4 chars & space + 3 buttons + borders 00677 * Down: Space for caption + borders 00678 * Yes, we use CYSIZE. This is because the width of any small icon 00679 * is the same as the height, and the height is CYSIZE. 00680 */ 00681 SYSMET(CXMINTRACK) = SYSMET(CYSIZE) + (gcxCaptionFontChar * 4) + 2 * SYSMET(CXEDGE) + 00682 (SYSMET(CXSIZE) * 3) + (SYSMET(CXSIZEFRAME) * 2); 00683 SYSMET(CYMINTRACK) = SYSMET(CYCAPTION) + (SYSMET(CYSIZEFRAME) * 2); 00684 00685 /* 00686 * Max track size 00687 * Yeah, max track is bigger than maximized. The reason why is the DOS 00688 * box. It has a normal sizing border plus the sunken edge around the 00689 * client. We need to make this big enough to allow the dos box to grow. 00690 * When it hits its max size, it maximizes automatically. 00691 */ 00692 SYSMET(CXMAXTRACK) = SYSMET(CXVIRTUALSCREEN) + (2 * (SYSMET(CXSIZEFRAME) + SYSMET(CXEDGE))); 00693 SYSMET(CYMAXTRACK) = SYSMET(CYVIRTUALSCREEN) + (2 * (SYSMET(CYSIZEFRAME) + SYSMET(CYEDGE))); 00694 00695 SYSMET(CXMIN) = SYSMET(CXMINTRACK); 00696 SYSMET(CYMIN) = SYSMET(CYMINTRACK); 00697 00698 SYSMET(CYMINIMIZED) = 2*SYSMET(CYFIXEDFRAME) + SYSMET(CYSIZE); 00699 00700 /* 00701 * Desktop stuff--working area 00702 */ 00703 bSetDevDragWidth(gpDispInfo->hDev, 00704 gpsi->gclBorder + BORDER_EXTRA); 00705 00706 SetDesktopMetrics(); 00707 } 00708 00709 00710 00711 /***************************************************************************\ 00712 * 00713 * CreateFontFromWinIni() - 00714 * 00715 * If lplf is NULL, we do a first time, default initialization. 00716 * Otherwise, lplf is a pointer to the logfont we will use. 00717 * 00718 \***************************************************************************/ 00719 HFONT CreateFontFromWinIni( 00720 PUNICODE_STRING pProfileUserName, 00721 LPLOGFONTW lplf, 00722 UINT idFont) 00723 { 00724 LOGFONTW lf; 00725 HFONT hFont; 00726 00727 if (lplf == NULL) { 00728 static CONST WCHAR szDefFont[] = TEXT("MS Shell Dlg"); 00729 /* 00730 * Fill logfont w/ 0 so we can check if values were filled in. 00731 */ 00732 lplf = &lf; 00733 RtlZeroMemory(&lf, sizeof(lf)); 00734 lf.lfCharSet = gSystemCPCharSet; 00735 00736 FastGetProfileValue(pProfileUserName,PMAP_METRICS, (LPWSTR)UIntToPtr( idFont ), NULL, (LPBYTE)&lf, sizeof(lf)); 00737 00738 /* 00739 * Default font is MS Shell Dlg 00740 */ 00741 if (! lf.lfFaceName[0]) { 00742 RtlCopyMemory(lf.lfFaceName, szDefFont, sizeof(szDefFont)); 00743 } 00744 00745 /* 00746 * Warning! these values are different then Win 95. They did not have a True Type 00747 * font so they would round up when they asked for a 6 pt font. We have to ask 00748 * for an 8 point font ICONFONT to be the same. 00749 */ 00750 if (!lf.lfHeight) { 00751 switch (idFont) { 00752 case STR_SMCAPTIONFONT: 00753 case STR_MINFONT: 00754 case STR_ICONFONT: 00755 default: 00756 lf.lfHeight = 8; 00757 break; 00758 } 00759 } 00760 00761 /* 00762 * We need to convert the point size properly. GDI expects a 00763 * height in pixels, not points. 00764 */ 00765 if (lf.lfHeight > 0) { 00766 lf.lfHeight = -MultDiv(lf.lfHeight, gpsi->dmLogPixels, 72); 00767 } 00768 00769 if (! lf.lfWeight) { 00770 switch (idFont) { 00771 case STR_CAPTIONFONT: 00772 case STR_MINFONT: 00773 lf.lfWeight = FW_BOLD; 00774 break; 00775 00776 default: 00777 lf.lfWeight = FW_NORMAL; 00778 break; 00779 } 00780 } 00781 00782 lf.lfOutPrecision = OUT_DEFAULT_PRECIS; 00783 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; 00784 lf.lfQuality = DEFAULT_QUALITY; 00785 } 00786 00787 00788 hFont = GreCreateFontIndirectW(lplf); 00789 00790 if (hFont) { 00791 LOGFONTW lfT; 00792 00793 GreExtGetObjectW(hFont, sizeof(LOGFONTW), &lfT); 00794 if (lfT.lfHeight != lplf->lfHeight) { 00795 /* 00796 * Couldn't find a font with the height that we 00797 * wanted so use the system font instead. 00798 */ 00799 GreDeleteObject(hFont); 00800 hFont = NULL; 00801 } else { 00802 GreMarkUndeletableFont(hFont); 00803 GreSetLFONTOwner((HLFONT)hFont, OBJECT_OWNER_PUBLIC); 00804 } 00805 } 00806 00807 if (!hFont) { 00808 /* 00809 * We've tried to create the font from the app-supplied description. 00810 * If failure, return NULL so that we don't change the previous 00811 * font. 00812 */ 00813 if (lplf) 00814 hFont = NULL; 00815 else 00816 hFont = ghFontSys; 00817 } 00818 00819 return hFont; 00820 } 00821 00822 00823 /***************************************************************************\ 00824 * 00825 \***************************************************************************/ 00826 00827 BOOL UserSetFont( 00828 PUNICODE_STRING pProfileUserName, 00829 LPLOGFONTW lplf, 00830 UINT idFont, 00831 HFONT* phfont) 00832 { 00833 HFONT hNewFont; 00834 00835 if (hNewFont = CreateFontFromWinIni(pProfileUserName, lplf, idFont)) { 00836 if (*phfont != NULL && *phfont != ghFontSys) { 00837 GreMarkDeletableFont(*phfont); 00838 GreDeleteObject(*phfont); 00839 } 00840 00841 *phfont = hNewFont; 00842 return TRUE; 00843 } 00844 return FALSE; 00845 } 00846 00847 /***************************************************************************\ 00848 * 00849 * xxxSetNCFonts() - 00850 * 00851 * Creates fonts to be used in the frame components: 00852 * Caption 00853 * Small caption 00854 * Menu 00855 * Minimized 00856 * Icon 00857 * 00858 * 01-21-98 [SamerA] Renamed to xxxSetNCFonts since it may leave the 00859 * critical section when a client LPK is installed. 00860 \***************************************************************************/ 00861 BOOL xxxSetNCFonts( 00862 PUNICODE_STRING pProfileUserName, 00863 LPNONCLIENTMETRICS lpnc) 00864 { 00865 HFONT hOldFont; 00866 TEXTMETRIC tm; 00867 LOGFONTW lf; 00868 LPLOGFONTW lplf = (lpnc) ? &lf : 0; 00869 00870 /* 00871 * Caption font 00872 */ 00873 if (lplf) { 00874 *lplf = lpnc->lfCaptionFont; 00875 } 00876 00877 if (!UserSetFont(pProfileUserName,lplf, STR_CAPTIONFONT, &gpsi->hCaptionFont)) { 00878 RIPMSG0(RIP_WARNING, "xxxSetNCFonts failed for gpsi->hCaptionFont"); 00879 return FALSE; 00880 } 00881 00882 hOldFont = GreSelectFont(HDCBITS(), gpsi->hCaptionFont); 00883 gcxCaptionFontChar = GetCharDimensions( 00884 HDCBITS(), NULL, &gcyCaptionFontChar); 00885 00886 /* 00887 * Small caption font 00888 */ 00889 if (lplf) { 00890 *lplf = lpnc->lfSmCaptionFont; 00891 } 00892 00893 if (!UserSetFont(pProfileUserName,lplf, STR_SMCAPTIONFONT, &ghSmCaptionFont)) { 00894 RIPMSG0(RIP_WARNING, "xxxSetNCFonts failed for ghSmCaptionFont"); 00895 return FALSE; 00896 } 00897 00898 GreSelectFont(HDCBITS(), ghSmCaptionFont); 00899 gcxSmCaptionFontChar = GetCharDimensions( 00900 HDCBITS(), NULL, &gcySmCaptionFontChar); 00901 00902 /* 00903 * Menu font 00904 */ 00905 if (lplf) { 00906 *lplf = lpnc->lfMenuFont; 00907 } 00908 00909 if (!UserSetFont(pProfileUserName,lplf, STR_MENUFONT, &ghMenuFont)) { 00910 RIPMSG0(RIP_WARNING, "xxxSetNCFonts failed for ghMenuFont"); 00911 return FALSE; 00912 } 00913 00914 /* 00915 * if ghMenuFont is selected in cached animation DC, select the new one. 00916 */ 00917 if (gMenuState.hdcAni != NULL) { 00918 GreSelectFont(gMenuState.hdcAni, ghMenuFont); 00919 } 00920 00921 GreSelectFont(HDCBITS(), ghMenuFont); 00922 gcxMenuFontChar = GetCharDimensions( 00923 HDCBITS(), &tm, &gcyMenuFontChar); 00924 gcxMenuFontOverhang = tm.tmOverhang; 00925 00926 gcyMenuFontExternLeading = tm.tmExternalLeading; 00927 gcyMenuScrollArrow = gcyMenuFontChar + gcyMenuFontExternLeading + SYSMET(CYEDGE); 00928 gcyMenuFontAscent = tm.tmAscent; 00929 00930 /* 00931 * We only use gcyMenuFontAscent in mndraw.c once, and in U.S. we 00932 * always add on CYBORDER! So calculate gcyMenuFontAscent+CYBORDER 00933 * once only. 00934 * Legacy NT4: For Korean version, don't add it on; the underline would 00935 * be too low. 00936 * NT5: according to #254327, Korean version now sees underline is 00937 * too close to menu strings. Korean hack is pulled out so. 00938 */ 00939 gcyMenuFontAscent += SYSMET(CYBORDER); 00940 00941 /* 00942 * Default menu item font: bolder version of menu font 00943 */ 00944 00945 /* 00946 * Create default menu font by bolding hMenuFont. If this doesn't 00947 * work, then fall back to using simulation. 00948 */ 00949 if (ghMenuFontDef != NULL && ghMenuFontDef != ghFontSys) { 00950 GreMarkDeletableFont(ghMenuFontDef); 00951 GreDeleteObject(ghMenuFontDef); 00952 ghMenuFontDef = NULL; 00953 } 00954 00955 GreExtGetObjectW(ghMenuFont, sizeof(LOGFONTW), &lf); 00956 if (lf.lfWeight < FW_BOLD) { 00957 lf.lfWeight += 200; 00958 00959 ghMenuFontDef = GreCreateFontIndirectW(&lf); 00960 if (ghMenuFontDef) { 00961 GreMarkUndeletableFont(ghMenuFontDef); 00962 GreSetLFONTOwner((HLFONT)ghMenuFontDef, OBJECT_OWNER_PUBLIC); 00963 } 00964 } 00965 00966 /* 00967 * Status Bar font 00968 */ 00969 if (lplf) { 00970 *lplf = lpnc->lfStatusFont; 00971 } 00972 00973 if (!UserSetFont(pProfileUserName,lplf, STR_STATUSFONT, &ghStatusFont)) { 00974 RIPMSG0(RIP_WARNING, "xxxSetNCFonts failed for ghStatusFont"); 00975 return FALSE; 00976 } 00977 00978 /* 00979 * Message Box font 00980 */ 00981 if (lplf) { 00982 *lplf = lpnc->lfMessageFont; 00983 } 00984 00985 if (!UserSetFont(pProfileUserName,lplf, STR_MESSAGEFONT, &gpsi->hMsgFont)) { 00986 RIPMSG0(RIP_WARNING, "xxxSetNCFonts failed for gpsi->hMsgFont"); 00987 return FALSE; 00988 } 00989 00990 GreSelectFont(HDCBITS(), gpsi->hMsgFont); 00991 gpsi->cxMsgFontChar = GetCharDimensions( 00992 HDCBITS(), NULL, &gpsi->cyMsgFontChar); 00993 00994 /* 00995 * Recalculate length of the widest MessageBox button 00996 * Make sure the width is no less than DU_BTNWIDTH dialog units MCostea #170582 00997 */ 00998 gpsi->wMaxBtnSize = max((UINT)XPixFromXDU(DU_BTNWIDTH, gpsi->cxMsgFontChar), 00999 xxxMB_FindLongestString(HDCBITS())); 01000 GreSelectFont(HDCBITS(), hOldFont); 01001 01002 return TRUE; 01003 } 01004 01005 01006 BOOL 01007 SetIconFonts( 01008 PUNICODE_STRING pProfileUserName, 01009 LPICONMETRICS lpicon) 01010 { 01011 LOGFONTW lf; 01012 LPLOGFONTW lplf = 0; 01013 01014 if (lpicon) { 01015 lplf = &lf; 01016 lf = lpicon->lfFont; 01017 } 01018 01019 return UserSetFont(pProfileUserName, lplf, STR_ICONFONT, &ghIconFont); 01020 } 01021 01022 /***************************************************************************\ 01023 * GetWindowMetrics 01024 * 01025 * Retrieve the current NC metrics. 01026 * 01027 * 01028 \***************************************************************************/ 01029 01030 VOID GetWindowNCMetrics( 01031 LPNONCLIENTMETRICS lpnc) 01032 { 01033 lpnc->cbSize = sizeof(NONCLIENTMETRICS); 01034 lpnc->iBorderWidth = gpsi->gclBorder; 01035 lpnc->iScrollWidth = SYSMET(CXVSCROLL); 01036 lpnc->iScrollHeight = SYSMET(CYVSCROLL); 01037 lpnc->iCaptionWidth = SYSMET(CXSIZE); 01038 lpnc->iCaptionHeight = SYSMET(CYSIZE); 01039 lpnc->iSmCaptionWidth = SYSMET(CXSMSIZE); 01040 lpnc->iSmCaptionHeight = SYSMET(CYSMSIZE); 01041 lpnc->iMenuWidth = SYSMET(CXMENUSIZE); 01042 lpnc->iMenuHeight = SYSMET(CYMENUSIZE); 01043 01044 /* 01045 * Get the font info. 01046 */ 01047 GreExtGetObjectW(gpsi->hCaptionFont, 01048 sizeof(LOGFONTW), 01049 &(lpnc->lfCaptionFont)); 01050 01051 GreExtGetObjectW(ghSmCaptionFont, 01052 sizeof(LOGFONTW), 01053 &(lpnc->lfSmCaptionFont)); 01054 01055 GreExtGetObjectW(ghMenuFont, 01056 sizeof(LOGFONTW), 01057 &(lpnc->lfMenuFont)); 01058 01059 GreExtGetObjectW(ghStatusFont, 01060 sizeof(LOGFONTW), 01061 &(lpnc->lfStatusFont)); 01062 01063 GreExtGetObjectW(gpsi->hMsgFont, 01064 sizeof(LOGFONTW), 01065 &(lpnc->lfMessageFont)); 01066 } 01067 01068 /***************************************************************************\ 01069 * 01070 * xxxSetWindowMetrics() - 01071 * 01072 * creates system fonts and bitmaps and sets the system metrics based on the 01073 * values of the given FRAMEMETRICS struct. If NULL is passed in, the 01074 * default values (found in WIN.INI) are used instead. 01075 * 01076 * 01-21-98 [SamerA] Renamed to xxxSetWinowMetrics since it may leave the 01077 * critical section if an LPK is installed. 01078 \***************************************************************************/ 01079 01080 BOOL xxxSetWindowNCMetrics( 01081 PUNICODE_STRING pProfileUserName, 01082 LPNONCLIENTMETRICS lpnc, 01083 BOOL fSizeChange, 01084 int clNewBorder) 01085 { 01086 NONCLIENTMETRICS nc; 01087 int cxEdge4; 01088 01089 if (fSizeChange) { 01090 if (!xxxSetNCFonts(pProfileUserName, lpnc)) { 01091 RIPMSG0(RIP_WARNING, "xxxSetWindowNCMetrics failed in xxxSetNCFonts"); 01092 return FALSE; 01093 } 01094 01095 if (lpnc == NULL) { 01096 if (clNewBorder < 0) 01097 nc.iBorderWidth = MetricGetID(pProfileUserName,STR_BORDERWIDTH, 1); 01098 else 01099 nc.iBorderWidth = clNewBorder; 01100 01101 nc.iScrollWidth = MetricGetID(pProfileUserName,STR_SCROLLWIDTH, 16 ); 01102 nc.iScrollHeight = MetricGetID(pProfileUserName,STR_SCROLLHEIGHT, 16 ); 01103 nc.iCaptionWidth = MetricGetID(pProfileUserName,STR_CAPTIONWIDTH, 18 ); 01104 nc.iCaptionHeight = MetricGetID(pProfileUserName,STR_CAPTIONHEIGHT, 18 ); 01105 nc.iSmCaptionWidth = MetricGetID(pProfileUserName,STR_SMCAPTIONWIDTH, 13 ); 01106 nc.iSmCaptionHeight = MetricGetID(pProfileUserName,STR_SMCAPTIONHEIGHT, 13 ); 01107 nc.iMenuWidth = MetricGetID(pProfileUserName,STR_MENUWIDTH, 18 ); 01108 nc.iMenuHeight = MetricGetID(pProfileUserName,STR_MENUHEIGHT, 18 ); 01109 01110 lpnc = &nc; 01111 } 01112 01113 /* 01114 * SANITY CHECK for metric values 01115 */ 01116 cxEdge4 = 4 * SYSMET(CXEDGE); 01117 01118 /* 01119 * Border 01120 */ 01121 lpnc->iBorderWidth = max(lpnc->iBorderWidth, 1); 01122 lpnc->iBorderWidth = min(lpnc->iBorderWidth, 50); 01123 01124 /* 01125 * Scrollbar 01126 */ 01127 lpnc->iScrollWidth = max(lpnc->iScrollWidth, cxEdge4); 01128 lpnc->iScrollHeight = max(lpnc->iScrollHeight, 4 * SYSMET(CYEDGE)); 01129 01130 /* 01131 * Caption -- Buttons must be wide enough to draw edges, and text 01132 * area must be tall enough to fit caption font with a border above 01133 * and below. If we have to reset the caption height, should we 01134 * reset the button width as well? 01135 */ 01136 lpnc->iCaptionWidth = max(lpnc->iCaptionWidth, cxEdge4); 01137 lpnc->iCaptionHeight = max(lpnc->iCaptionHeight, gcyCaptionFontChar + SYSMET(CYEDGE)); 01138 01139 /* 01140 * Small caption -- Buttons must be wide enough to draw edges, and 01141 * text area must be tall enough to fit small caption font with a 01142 * border above and below. Again, if we have to reset the height, 01143 * reset the width as well? 01144 */ 01145 lpnc->iSmCaptionWidth = max(lpnc->iSmCaptionWidth, cxEdge4); 01146 lpnc->iSmCaptionHeight = max(lpnc->iSmCaptionHeight, gcySmCaptionFontChar + SYSMET(CYEDGE)); 01147 01148 /* 01149 * Menu -- Buttons must be wide enough to draw edges, and text 01150 * area must be tall enough to fit menu font with underscore. 01151 */ 01152 lpnc->iMenuWidth = max(lpnc->iMenuWidth, cxEdge4); 01153 lpnc->iMenuHeight = max(lpnc->iMenuHeight, gcyMenuFontChar + gcyMenuFontExternLeading + SYSMET(CYEDGE)); 01154 01155 /* 01156 * SET UP SYSTEM METRIC VALUES 01157 */ 01158 SetNCMetrics(lpnc); 01159 } 01160 01161 if (!CreateBitmapStrip()) { 01162 RIPMSG0(RIP_WARNING, "CreateBitmapStrip failed"); 01163 return FALSE; 01164 } 01165 01166 return TRUE; 01167 } 01168 01169 01170 VOID SetMinMetrics( 01171 PUNICODE_STRING pProfileUserName, 01172 LPMINIMIZEDMETRICS lpmin) 01173 { 01174 MINIMIZEDMETRICS min; 01175 01176 if (!lpmin) { 01177 01178 /* 01179 * Minimized 01180 */ 01181 min.iWidth = MetricGetID(pProfileUserName,STR_MINWIDTH, 154); 01182 min.iHorzGap = MetricGetID(pProfileUserName,STR_MINHORZGAP, 0); 01183 min.iVertGap = MetricGetID(pProfileUserName,STR_MINVERTGAP, 0); 01184 min.iArrange = MetricGetID(pProfileUserName,STR_MINARRANGE, ARW_BOTTOMLEFT | ARW_RIGHT); 01185 lpmin = &min; 01186 } 01187 01188 /* 01189 * SANITY CHECK for metric values 01190 */ 01191 01192 /* 01193 * Minimized window -- Text area must be >= 0, as must gap between 01194 * windows horizontally and vertically. 01195 */ 01196 lpmin->iWidth = max(lpmin->iWidth, 0); 01197 lpmin->iHorzGap = max(lpmin->iHorzGap, 0); 01198 lpmin->iVertGap = max(lpmin->iVertGap, 0); 01199 lpmin->iArrange &= ARW_VALID; 01200 01201 /* 01202 * Minimized size 01203 */ 01204 SYSMET(CXMINIMIZED) = 2*SYSMET(CXFIXEDFRAME) + (int) lpmin->iWidth; 01205 SYSMET(CYMINIMIZED) = 2*SYSMET(CYFIXEDFRAME) + SYSMET(CYSIZE); 01206 01207 SYSMET(CXMINSPACING) = SYSMET(CXMINIMIZED) + (int) lpmin->iHorzGap; 01208 SYSMET(CYMINSPACING) = SYSMET(CYMINIMIZED) + (int) lpmin->iVertGap; 01209 01210 SYSMET(ARRANGE) = (int) lpmin->iArrange; 01211 } 01212 01213 BOOL SetIconMetrics( 01214 PUNICODE_STRING pProfileUserName, 01215 LPICONMETRICS lpicon) 01216 { 01217 ICONMETRICS icon; 01218 01219 if (!SetIconFonts(pProfileUserName,lpicon)) { 01220 RIPMSG0(RIP_WARNING, "SetIconMetrics failed in SetIconFonts"); 01221 return FALSE; 01222 } 01223 01224 if (!lpicon) { 01225 01226 icon.iTitleWrap = MetricGetID(pProfileUserName, 01227 STR_ICONTITLEWRAP, TRUE); 01228 01229 icon.iHorzSpacing = MetricGetID(pProfileUserName, 01230 STR_ICONHORZSPACING, 01231 (GreGetDeviceCaps(HDCBITS(), LOGPIXELSX) * 75) / 96); 01232 01233 icon.iVertSpacing = MetricGetID(pProfileUserName, 01234 STR_ICONVERTSPACING, 01235 (GreGetDeviceCaps(HDCBITS(), LOGPIXELSY) * 75) / 96); 01236 01237 lpicon = &icon; 01238 } 01239 01240 /* 01241 * SANITY CHECK for metric values 01242 */ 01243 lpicon->iHorzSpacing = max(lpicon->iHorzSpacing, (int)SYSMET(CXICON)); 01244 lpicon->iVertSpacing = max(lpicon->iVertSpacing, (int)SYSMET(CYICON)); 01245 01246 SYSMET(CXICONSPACING) = (int) lpicon->iHorzSpacing; 01247 SYSMET(CYICONSPACING) = (int) lpicon->iVertSpacing; 01248 SET_OR_CLEAR_PUDF(PUDF_ICONTITLEWRAP, lpicon->iTitleWrap); 01249 01250 return TRUE; 01251 } 01252 01253 /***************************************************************************\ 01254 * xxxMB_FindLongestString 01255 * 01256 * History: 01257 * 10-23-90 DarrinM Ported from Win 3.0 sources. 01258 * 01-21-98 SamerA Renamed to xxx since it may leave the crit sec if 01259 * a client LPK is installed 01260 \***************************************************************************/ 01261 01262 UINT xxxMB_FindLongestString(HDC hdc) 01263 { 01264 UINT wRetVal; 01265 int i, iMaxLen = 0, iNewMaxLen; 01266 LPWSTR pszCurStr, szMaxStr; 01267 SIZE sizeOneChar; 01268 SIZE sizeMaxStr; 01269 PTHREADINFO ptiCurrent = PtiCurrentShared(); 01270 01271 for (i = 0; i < MAX_SEB_STYLES; i++) { 01272 pszCurStr = GETGPSIMBPSTR(i); 01273 if ((iNewMaxLen = wcslen(pszCurStr)) > iMaxLen) { 01274 iMaxLen = iNewMaxLen; 01275 szMaxStr = pszCurStr; 01276 } 01277 } 01278 01279 /* 01280 * Find the longest string 01281 */ 01282 if (CALL_LPK(ptiCurrent)) { 01283 xxxClientGetTextExtentPointW(hdc, (PWSTR)szOneChar, 1, &sizeOneChar); 01284 } else { 01285 GreGetTextExtentW(hdc, (PWSTR)szOneChar, 1, &sizeOneChar, GGTE_WIN3_EXTENT); 01286 } 01287 xxxPSMGetTextExtent(hdc, szMaxStr, iMaxLen, &sizeMaxStr); 01288 wRetVal = (UINT)(sizeMaxStr.cx + (sizeOneChar.cx * 2)); 01289 01290 return wRetVal; 01291 }

Generated on Sat May 15 19:40:21 2004 for test by doxygen 1.3.7