|
|
1.1 ! root 1: #include "windows.h" ! 2: #include <windowsx.h> ! 3: #include "fontedit.h" ! 4: #include "fcntl.h" ! 5: #include "stdio.h" ! 6: ! 7: #define ATTRDIRLIST 0x4010 /* Include directories and drives in listbox */ ! 8: ! 9: /****************************************************************************/ ! 10: /* Shared Variables */ ! 11: /****************************************************************************/ ! 12: extern LONG lSizeOfOldFontHeader; /* Old font header type. */ ! 13: extern FontHeaderType font; /* Structure of Font File Header */ ! 14: extern FontHeaderType fontBuffer; /* temp structure of font file header */ ! 15: CHAR szFontFileFull[FILENAMEMAX] = {"*.FNT"}; /* Name of Font File */ ! 16: CHAR szFontFile[FILENAMEMAX] = {"*.FNT"}; /* Name of Font File */ ! 17: CHAR szNewFile[FILENAMEMAX] = {"*.FNT"}; /* Name of New File */ ! 18: extern CHAR szFaceName[]; /* Face Name of Font */ ! 19: extern BOOL NewFile; /* flag indicating if file was opened ! 20: by selecting NEW on menu */ ! 21: extern CHAR *vrgsz[CSTRINGS]; /* string table */ ! 22: extern BOOL fChanged; /* Note if we did anything */ ! 23: extern INT swH; ! 24: extern BYTE iChar, jChar; ! 25: ! 26: extern HWND hFont; /* Handle to Show window */ ! 27: extern HWND hBox; /* Handle to Edit Window */ ! 28: extern HDC hMemDC; /* Handle to Memory Display Context */ ! 29: ! 30: extern CHAR szAppName[]; ! 31: extern INT iFontFormat; /* format of font currently being edited */ ! 32: extern DWORD cTable; /* offset table size */ ! 33: /****************************************************************************/ ! 34: /* Local Variables */ ! 35: /****************************************************************************/ ! 36: WORD newCharSet; /* Temporary value of font.CharSet */ ! 37: WORD newFamily; /* Temporary value of font.Family << 4 */ ! 38: BOOL newFV; /* Temporay value of Fixed/Variable flag */ ! 39: WORD newItalic, newUnderline, newStrikeOut; ! 40: WORD newWeight; /* Temporary value of font.Weight */ ! 41: BOOL fMsgBoxUp; /* Bug Fix Hack explained in ReSizeProc */ ! 42: /****************************************************************************/ ! 43: /* Local Functions */ ! 44: /****************************************************************************/ ! 45: ! 46: VOID SetCharSet(HWND hDial); ! 47: VOID SetFamily(HWND hDial); ! 48: VOID SetFixed(HWND hDial, BOOL fFV); ! 49: VOID SetWeight(HWND hDial); ! 50: ! 51: /**************************************************************************** ! 52: * BOOL APIENTRY HeaderProc(hDial, message, wParam, lParam) ! 53: * ! 54: * purpose : Dialog function which verifies and accepts inputs which may ! 55: * alter font's header information (font attributes) ! 56: * ! 57: * params : Same as for all dialog functions ! 58: * ! 59: * side effects: may alter font attributes ! 60: * ! 61: ***************************************************************************/ ! 62: BOOL APIENTRY ! 63: HeaderProc( ! 64: HWND hDial, ! 65: WORD message, ! 66: WPARAM wParam, ! 67: LPARAM lParam ! 68: ) ! 69: { ! 70: FontHeaderType FAR * lpFont; ! 71: BOOL fOk; /* for GetDlgItemInt errors! */ ! 72: UINT i; ! 73: ! 74: UNREFERENCED_PARAMETER(lParam); ! 75: ! 76: lpFont = (FontHeaderType FAR *)&font; ! 77: switch (message) ! 78: { ! 79: default: ! 80: return FALSE; ! 81: case WM_INITDIALOG: ! 82: newCharSet = font.CharSet; ! 83: SetCharSet(hDial); /* Set OEM/ANSI buttons */ ! 84: ! 85: newFamily = (WORD) (font.Family >> 4); /* Working value */ ! 86: SetFamily(hDial); /* Set Font Family */ ! 87: ! 88: CheckDlgButton(hDial, ID_ITALIC, newItalic = font.Italic); ! 89: CheckDlgButton(hDial, ID_UNDERLINE, newUnderline = font.Underline); ! 90: CheckDlgButton(hDial, ID_STRIKEOUT, newStrikeOut = font.StrikeOut); ! 91: ! 92: SetDlgItemInt(hDial, ID_POINTS, lpFont->Points, FALSE); ! 93: SetDlgItemInt(hDial, ID_VERT_RES, lpFont->VertRes, FALSE); ! 94: SetDlgItemInt(hDial, ID_HORIZ_RES, lpFont->HorizRes, FALSE); ! 95: SetDlgItemInt(hDial, ID_ASCENT, lpFont->Ascent, FALSE); ! 96: SetDlgItemInt(hDial, ID_EXT_LEADING, lpFont->ExtLeading, FALSE); ! 97: SetDlgItemInt(hDial, ID_INT_LEADING, lpFont->IntLeading, FALSE); ! 98: SetDlgItemInt(hDial, ID_DEFAULT_CHAR,lpFont->DefaultChar , FALSE); ! 99: SetDlgItemInt(hDial, ID_BREAK_CHAR, lpFont->BreakChar, FALSE); ! 100: ! 101: SetDlgItemText(hDial, ID_COPYRIGHT, lpFont->Copyright); ! 102: SetDlgItemText(hDial, ID_FACE_NAME, (LPSTR)szFaceName); ! 103: SetDlgItemText(hDial, ID_FONT_NAME, (LPSTR)szFontFile); ! 104: break; ! 105: case WM_COMMAND: ! 106: switch (LOWORD(wParam)) ! 107: { ! 108: case ID_ANSI: ! 109: newCharSet = ANSI_CHARSET; ! 110: SetCharSet(hDial); /* Set OEM/ANSI buttons */ ! 111: break; ! 112: case ID_SYMBOL: ! 113: newCharSet = SYMBOL_CHARSET; ! 114: SetCharSet(hDial); /* Set OEM/ANSI buttons */ ! 115: break; ! 116: case ID_OEM: ! 117: newCharSet = OEM_CHARSET; ! 118: SetCharSet(hDial); /* Set OEM/ANSI buttons */ ! 119: break; ! 120: case ID_UNKNOWN: ! 121: newFamily = 0; ! 122: SetFamily(hDial); ! 123: break; ! 124: case ID_ROMAN: ! 125: newFamily = 1; ! 126: SetFamily(hDial); ! 127: break; ! 128: case ID_SWISS: ! 129: newFamily = 2; ! 130: SetFamily(hDial); ! 131: break; ! 132: case ID_MODERN: ! 133: newFamily = 3; ! 134: SetFamily(hDial); ! 135: break; ! 136: case ID_SCRIPT: ! 137: newFamily = 4; ! 138: SetFamily(hDial); ! 139: break; ! 140: case ID_DECORATIVE: ! 141: newFamily = 5; ! 142: SetFamily(hDial); ! 143: break; ! 144: case ID_ITALIC: ! 145: newItalic = (WORD) !newItalic; ! 146: CheckDlgButton(hDial, ID_ITALIC, newItalic); ! 147: break; ! 148: case ID_UNDERLINE: ! 149: newUnderline = (WORD) !newUnderline; ! 150: CheckDlgButton(hDial, ID_UNDERLINE, newUnderline); ! 151: break; ! 152: case ID_STRIKEOUT: ! 153: newStrikeOut = (WORD) !newStrikeOut; ! 154: CheckDlgButton(hDial, ID_STRIKEOUT, newStrikeOut); ! 155: break; ! 156: case ID_CHAR_SET : ! 157: i = GetDlgItemInt(hDial, ID_CHAR_SET, (LPBOOL)&fOk, FALSE); ! 158: if (fOk && (i < 256)) ! 159: { ! 160: font.CharSet = (BYTE) (newCharSet = (WORD) i); ! 161: CheckDlgButton(hDial, ID_ANSI, (WORD) (i == ANSI_CHARSET)); ! 162: CheckDlgButton(hDial, ID_SYMBOL, (WORD) (i == SYMBOL_CHARSET)); ! 163: CheckDlgButton(hDial, ID_OEM, (WORD) (i == OEM_CHARSET)); ! 164: } ! 165: break; ! 166: ! 167: case IDOK: ! 168: font.CharSet = (BYTE) newCharSet; ! 169: font.Family = (BYTE) ((newFamily << 4) | (font.Family & 1)); ! 170: font.Italic = (BYTE) newItalic; ! 171: font.Underline = (BYTE) newUnderline; ! 172: font.StrikeOut = (BYTE) newStrikeOut; ! 173: fChanged = TRUE; ! 174: ! 175: /* nominal point size */ ! 176: i = GetDlgItemInt(hDial, ID_POINTS, (LPBOOL)&fOk, FALSE); ! 177: if (fOk) ! 178: lpFont->Points = (WORD) i; ! 179: else{ ! 180: ErrorBox(hDial, vszNomPtSizeNotOk); ! 181: SetFocus(GetDlgItem(hDial, ID_POINTS)); ! 182: break; ! 183: } ! 184: /* nominal vertical resolution */ ! 185: i = GetDlgItemInt(hDial, ID_VERT_RES, (LPBOOL)&fOk, FALSE); ! 186: if (fOk) ! 187: lpFont->VertRes = (WORD) i; ! 188: else{ ! 189: ErrorBox(hDial, vszNomVertResNotOk); ! 190: SetFocus(GetDlgItem(hDial, ID_VERT_RES)); ! 191: break; ! 192: } ! 193: /* nominal horizontal resolution */ ! 194: i = GetDlgItemInt(hDial, ID_HORIZ_RES, (LPBOOL)&fOk, FALSE); ! 195: if (fOk) ! 196: lpFont->HorizRes = (WORD) i; ! 197: else{ ! 198: ErrorBox(hDial, vszNomHorResNotOk); ! 199: SetFocus(GetDlgItem(hDial, ID_HORIZ_RES)); ! 200: break; ! 201: } ! 202: /* font ascent */ ! 203: i = GetDlgItemInt(hDial, ID_ASCENT, (LPBOOL)&fOk, FALSE); ! 204: if (fOk) ! 205: { ! 206: if (i <= font.PixHeight) ! 207: lpFont->Ascent = (WORD) i; ! 208: else{ ! 209: ErrorBox(hDial, vszAscentTooBig); ! 210: SetFocus(GetDlgItem(hDial, ID_ASCENT)); ! 211: break; ! 212: } ! 213: } ! 214: else{ ! 215: ErrorBox(hDial, vszAscentNotOk); ! 216: SetFocus(GetDlgItem(hDial, ID_ASCENT)); ! 217: break; ! 218: } ! 219: /* font external leading */ ! 220: i = GetDlgItemInt(hDial, ID_EXT_LEADING, (LPBOOL)&fOk, FALSE); ! 221: if (fOk) ! 222: lpFont->ExtLeading = (WORD) i; ! 223: else{ ! 224: ErrorBox(hDial, vszExtLeadNotOk); ! 225: SetFocus(GetDlgItem(hDial, ID_EXT_LEADING)); ! 226: break; ! 227: } ! 228: /* font internal leading */ ! 229: i = GetDlgItemInt(hDial, ID_INT_LEADING, (LPBOOL)&fOk, FALSE); ! 230: if (fOk) ! 231: { ! 232: if (i <= font.Ascent) ! 233: lpFont->IntLeading = (WORD) i; ! 234: else{ ! 235: ErrorBox(hDial, vszIntLeadTooBig); ! 236: SetFocus(GetDlgItem(hDial, ID_INT_LEADING)); ! 237: break; ! 238: } ! 239: } ! 240: else{ ! 241: ErrorBox(hDial, vszIntLeadNotOk); ! 242: SetFocus(GetDlgItem(hDial, ID_INT_LEADING)); ! 243: break; ! 244: } ! 245: /* font character set */ ! 246: i = GetDlgItemInt(hDial, ID_CHAR_SET, (LPBOOL)&fOk, FALSE); ! 247: if (fOk && i < 256) ! 248: { ! 249: font.CharSet = (BYTE) i; ! 250: SetCharSet(hDial); ! 251: } ! 252: else{ ! 253: ErrorBox(hDial, vszCharSetOutOfBounds); ! 254: SetFocus(GetDlgItem(hDial, ID_CHAR_SET)); ! 255: break; ! 256: } ! 257: /* font default char number */ ! 258: i = GetDlgItemInt(hDial, ID_DEFAULT_CHAR, (LPBOOL)&fOk, FALSE); ! 259: ! 260: if (fOk) ! 261: { ! 262: if ((i >= font.FirstChar) && (i <= font.LastChar)) ! 263: lpFont->DefaultChar = (BYTE) i; ! 264: else{ ! 265: ErrorBox(hDial, vszDefCharOutsideFont); ! 266: SetFocus(GetDlgItem(hDial, ID_DEFAULT_CHAR)); ! 267: break; ! 268: } ! 269: } ! 270: else{ ! 271: ErrorBox(hDial, vszDefCharNotOk); ! 272: SetFocus(GetDlgItem(hDial, ID_DEFAULT_CHAR)); ! 273: break; ! 274: } ! 275: /* break char number */ ! 276: i = GetDlgItemInt(hDial, ID_BREAK_CHAR, (LPBOOL)&fOk, FALSE); ! 277: if (fOk) ! 278: { ! 279: if ((BYTE)i <= (font.LastChar - font.FirstChar)) ! 280: lpFont->BreakChar = (BYTE) i; ! 281: else{ ! 282: ErrorBox(hDial, vszBreakCharOutsideFont); ! 283: SetFocus(GetDlgItem(hDial, ID_BREAK_CHAR)); ! 284: break; ! 285: } ! 286: } ! 287: else{ ! 288: ErrorBox(hDial, vszBreakCharNotOk); ! 289: SetFocus(GetDlgItem(hDial, ID_BREAK_CHAR)); ! 290: break; ! 291: } ! 292: /* facename string */ ! 293: GetDlgItemText(hDial, ID_COPYRIGHT, lpFont->Copyright, 60); ! 294: GetDlgItemText(hDial, ID_FACE_NAME, (LPSTR)szFaceName, szNamesMax); ! 295: if (!lstrlen((LPSTR)szFaceName)) ! 296: { ! 297: lstrcpy((LPSTR)szFaceName, (LPSTR)vszUnknown); ! 298: ErrorBox(hDial, vszUnknownFace); ! 299: } ! 300: /* fall thru to enddialog */ ! 301: ! 302: ! 303: case IDCANCEL: ! 304: EndDialog(hDial, wParam != IDCANCEL); ! 305: break; ! 306: ! 307: default: ! 308: break; ! 309: } ! 310: } ! 311: return TRUE; ! 312: } ! 313: ! 314: /**************************************************************************** ! 315: * char * VerifyHeaderContents() ! 316: * ! 317: * purpose: Checks if the Header information of the file just read makes ! 318: * sense. If not, returns an error message string to FontLoad ! 319: * ! 320: * params : none ! 321: * ! 322: * returns :char *szError : ptr to error string if error occurs ! 323: * NULL otherwise ! 324: * ! 325: * side effects: none ! 326: * ! 327: ***************************************************************************/ ! 328: CHAR * PASCAL ! 329: VerifyHeaderContents( ! 330: VOID ! 331: ) ! 332: { ! 333: if (fontBuffer.Points > 999) ! 334: return vszNomPtSizeNotOk; ! 335: if (fontBuffer.VertRes > 999) ! 336: return vszNomVertResNotOk; ! 337: if (fontBuffer.HorizRes > 999) ! 338: return vszNomHorResNotOk; ! 339: if (fontBuffer.Ascent > fontBuffer.PixHeight) ! 340: return vszAscentTooBig; ! 341: if (fontBuffer.Ascent > 999) ! 342: return vszAscentNotOk; ! 343: if (fontBuffer.ExtLeading > 999) ! 344: return vszExtLeadNotOk; ! 345: if (fontBuffer.IntLeading > fontBuffer.Ascent) ! 346: return vszIntLeadTooBig; ! 347: if (fontBuffer.IntLeading > 999) ! 348: return vszIntLeadNotOk; ! 349: if (fontBuffer.LastChar > 255) ! 350: return vszCharSetOutOfBounds; ! 351: if (fontBuffer.DefaultChar > fontBuffer.FirstChar + (fontBuffer.LastChar - fontBuffer.FirstChar)) ! 352: #if 0 ! 353: fontBuffer.DefaultChar = 0; ! 354: #else ! 355: return vszDefCharOutsideFont; ! 356: #endif ! 357: if (fontBuffer.DefaultChar > 255) ! 358: return vszDefCharNotOk; ! 359: if (fontBuffer.BreakChar > (fontBuffer.LastChar - fontBuffer.FirstChar)) ! 360: return vszBreakCharOutsideFont; ! 361: if (fontBuffer.BreakChar > 255) ! 362: return vszBreakCharNotOk; ! 363: if (fontBuffer.PixHeight > 64) ! 364: return vszHeightOutOfBounds; ! 365: if (fontBuffer.MaxWidth > 64) ! 366: return vszMaxWidthOutOfBounds; ! 367: if (fontBuffer.AvgWidth > 64) ! 368: return vszAvgWidthOutOfBounds; ! 369: if (iFontFormat == ID_FORMAT2) ! 370: if (fontBuffer.BitsOffset > (DWORD)SEGMENT_SIZE) ! 371: return vszBitsOffsetNotOk; ! 372: return NULL; ! 373: } ! 374: ! 375: /**************************************************************************** ! 376: * BOOL PASCAL Format20FileTooBig(iHeight, iWidth) ! 377: * ! 378: * purpose: Checks if the 2.0 font file size is within the 64k ! 379: * limit imposed by the 2.0 format offset table.( if file over ! 380: * size limit is saved in 2.0 format, loss of information will ! 381: * result) ! 382: * ! 383: * params: WORD iHeight : current height of font in pixels ! 384: * WORD iWidth : current width of font in pixels ! 385: * ! 386: * returns: TRUE : file too large ! 387: * FALSE : ok to save ! 388: * ! 389: * side effects: none ! 390: * ! 391: ***************************************************************************/ ! 392: BOOL PASCAL ! 393: Format20FileTooBig( ! 394: WORD iHeight, ! 395: WORD iWidth ! 396: ) ! 397: { ! 398: if ((DWORD)lSizeOfOldFontHeader + (DWORD)cTable ! 399: + (font.LastChar - font.FirstChar +1) ! 400: * (((DWORD)iHeight * (DWORD)iWidth ) >> 3) >= WORD_LIMIT) ! 401: return TRUE; ! 402: return FALSE; ! 403: } ! 404: ! 405: /**************************************************************************** ! 406: * BOOL APIENTRY ReSizeProc(hDial, message, wParam, lParam) ! 407: * ! 408: * purpose : dialog fn. which verifies and accepts font resize (stretch, ! 409: * shrink...) input and calls the appropriate routine to perform ! 410: * the function. Also alters font weight attributes (bold, light, ! 411: * extra light...) ! 412: * ! 413: * params : same as for all dialog functions ! 414: * ! 415: * side effects: alters header information regarding font dimensions and font ! 416: * weight ! 417: * ! 418: ***************************************************************************/ ! 419: BOOL APIENTRY ! 420: ReSizeProc( ! 421: HWND hDial, ! 422: WORD message, ! 423: WPARAM wParam, ! 424: LPARAM lParam ! 425: ) ! 426: { ! 427: FontHeaderType FAR * lpFont; ! 428: BOOL fOk; /* for GetDlgItemInt errors! */ ! 429: UINT i; ! 430: HMENU hMenu; ! 431: static BOOL fFV; /* temporary fixed/var width flag */ ! 432: ! 433: UNREFERENCED_PARAMETER(lParam); ! 434: ! 435: lpFont = (FontHeaderType FAR *)&font; ! 436: switch (message) ! 437: { ! 438: case WM_INITDIALOG: ! 439: fMsgBoxUp = FALSE; ! 440: newWeight = (WORD) font.Weight; ! 441: newFV = (BOOL) (font.Family & 1); ! 442: fFV = newFV; ! 443: SetFixed(hDial, fFV); /* Set Fixed or Variable width */ ! 444: SetDlgItemInt(hDial, ID_PIX_HEIGHT, lpFont->PixHeight, FALSE); ! 445: SetDlgItemInt(hDial, ID_FIRST_CHAR, lpFont->FirstChar, FALSE); ! 446: SetDlgItemInt(hDial, ID_WIDTH, lpFont->MaxWidth, FALSE); ! 447: SetDlgItemInt(hDial, ID_AVERAGE, lpFont->AvgWidth, FALSE); ! 448: SetDlgItemInt(hDial, ID_LAST_CHAR, lpFont->LastChar, FALSE); ! 449: SetWeight(hDial); ! 450: SetFixed(hDial, fFV); ! 451: break; ! 452: ! 453: case WM_COMMAND: ! 454: switch (LOWORD(wParam)) ! 455: { ! 456: case ID_THIN: ! 457: newWeight = FW_THIN; ! 458: SetWeight(hDial); ! 459: break; ! 460: case ID_EXTRALIGHT: ! 461: newWeight = FW_EXTRALIGHT; ! 462: SetWeight(hDial); ! 463: break; ! 464: case ID_LIGHT: ! 465: newWeight = FW_LIGHT; ! 466: SetWeight(hDial); ! 467: break; ! 468: case ID_NORMAL: ! 469: newWeight = FW_NORMAL; ! 470: SetWeight(hDial); ! 471: break; ! 472: case ID_MEDIUM: ! 473: newWeight = FW_MEDIUM; ! 474: SetWeight(hDial); ! 475: break; ! 476: case ID_BOLD: ! 477: newWeight = FW_BOLD; ! 478: SetWeight(hDial); ! 479: break; ! 480: case ID_SEMIBOLD: ! 481: newWeight = FW_SEMIBOLD; ! 482: SetWeight(hDial); ! 483: break; ! 484: case ID_EXTRABOLD: ! 485: newWeight = FW_EXTRABOLD; ! 486: SetWeight(hDial); ! 487: break; ! 488: case ID_HEAVY: ! 489: newWeight = FW_HEAVY; ! 490: SetWeight(hDial); ! 491: break; ! 492: ! 493: case ID_FIXED: ! 494: fFV = 0; ! 495: SetFixed(hDial, fFV); ! 496: break; ! 497: case ID_VARIABLE: ! 498: fFV = 1; ! 499: SetFixed(hDial, fFV); ! 500: break; ! 501: ! 502: case IDOK: ! 503: fChanged = TRUE; ! 504: font.Weight = newWeight; ! 505: /* give warning if user attempts to change from variable to ! 506: fixed width */ ! 507: if ((fFV == 0) && (newFV != 0)) ! 508: { ! 509: fMsgBoxUp = TRUE; ! 510: ErrorBox(hDial, vszNoVarToFixChange); ! 511: fMsgBoxUp = FALSE; ! 512: SetFocus(GetDlgItem(hDial, ID_VARIABLE)); ! 513: break; ! 514: } ! 515: else ! 516: newFV = fFV; ! 517: ! 518: if (newFV && !(font.Family & 1)) ! 519: { ! 520: font.PixWidth = 0; /* All we need to do to make this */ ! 521: font.Family |= 1; /* .. font variable width */ ! 522: } ! 523: /* change height command */ ! 524: i = GetDlgItemInt(hDial, ID_PIX_HEIGHT, (LPBOOL)&fOk, FALSE); ! 525: if (fOk && i && i < kBoxLim && i>0 ) ! 526: { ! 527: if (i != font.PixHeight){ /* Same size ? */ ! 528: /* No: Resize body height */ ! 529: if (!ResizeBody(font.WidthBytes, i)){ ! 530: SetFocus(hDial); ! 531: break; ! 532: } ! 533: } ! 534: } ! 535: else{ ! 536: ErrorBox(hDial, vszHeightOutOfBounds); ! 537: SetFocus(GetDlgItem(hDial, ID_PIX_HEIGHT)); ! 538: break; ! 539: } ! 540: ! 541: /* change width command */ ! 542: i = GetDlgItemInt(hDial, ID_WIDTH, (LPBOOL)&fOk, FALSE); ! 543: if (fOk && i < wBoxLim && i > 0){ ! 544: if (i != font.MaxWidth){ ! 545: if (newFV){ ! 546: if (!SpreadWidths(i)){ ! 547: SetFocus(hDial); ! 548: break; /* New Variable Widths */ ! 549: } ! 550: } ! 551: else{ ! 552: if (!ResizeWidths(i)){ ! 553: SetFocus(hDial); ! 554: break; /* New Fixed Widths */ ! 555: } ! 556: } ! 557: } ! 558: } ! 559: else{ ! 560: ErrorBox(hDial, vszWidthOutOfBounds); ! 561: SetFocus(GetDlgItem(hDial, ID_WIDTH)); ! 562: break; ! 563: } ! 564: ! 565: /* new first char command */ ! 566: i = GetDlgItemInt(hDial, ID_FIRST_CHAR, (LPBOOL)&fOk, FALSE); ! 567: if (fOk) ! 568: { ! 569: if ((i <= font.LastChar) && (i <= font.DefaultChar)) ! 570: { ! 571: if (i != font.FirstChar) ! 572: { ! 573: if (!NewFirstChar(i)) ! 574: break; ! 575: iChar = jChar = (CHAR) i; ! 576: swH = 0; ! 577: ScrollFont(); /* Show front end */ ! 578: } ! 579: } ! 580: else{ ! 581: ErrorBox(hDial, vszChar1MoreThanDChar); ! 582: SetFocus(GetDlgItem(hDial, ID_FIRST_CHAR)); ! 583: break; ! 584: } ! 585: } ! 586: else{ ! 587: ErrorBox(hDial, vszChar1NotOk); ! 588: SetFocus(GetDlgItem(hDial, ID_FIRST_CHAR)); ! 589: break; ! 590: } ! 591: ! 592: ! 593: /* new last char command */ ! 594: i = GetDlgItemInt(hDial, ID_LAST_CHAR, (LPBOOL)&fOk, FALSE); ! 595: if (fOk && i < 256) ! 596: { ! 597: if ((i >= font.FirstChar) && ! 598: (i >= font.DefaultChar)) ! 599: { ! 600: if (i != font.LastChar) ! 601: { ! 602: if (!NewLastChar(i)) ! 603: break; ! 604: iChar = jChar = (CHAR) i; ! 605: swH = 100; ! 606: ScrollFont(); /* Show back end */ ! 607: } ! 608: } ! 609: else{ ! 610: ErrorBox(hDial, vszLastCharTooSmall); ! 611: SetFocus(GetDlgItem(hDial, ID_LAST_CHAR)); ! 612: break; ! 613: } ! 614: } ! 615: else{ ! 616: ErrorBox(hDial, vszLastCharNotOk); ! 617: SetFocus(GetDlgItem(hDial, ID_LAST_CHAR)); ! 618: break; ! 619: } ! 620: ! 621: /* this is moved from SetFixed, since it should only be done ! 622: * if idok pressed. */ ! 623: if (newFV) ! 624: { /* Enable "width" if variable-width font */ ! 625: hMenu = GetMenu(hBox); ! 626: EnableMenuItem(hMenu, 4, MF_BYPOSITION | MF_ENABLED); ! 627: DrawMenuBar(hBox); ! 628: } ! 629: ! 630: /* fall thru to enddialog...*/ ! 631: ! 632: case IDCANCEL: ! 633: EndDialog(hDial, wParam != IDCANCEL); ! 634: break; ! 635: ! 636: default: ! 637: return FALSE; ! 638: break; ! 639: } /* end switch wParam */ ! 640: ! 641: default: ! 642: return FALSE; ! 643: } /* end switch message */ ! 644: ! 645: return TRUE; ! 646: } ! 647: ! 648: VOID ! 649: ErrorBox( ! 650: HWND hWndparent, ! 651: CHAR * szMessage ! 652: ) ! 653: /* Show Message Box */ ! 654: { ! 655: MessageBox(hWndparent, (LPSTR)szMessage, (LPSTR)szAppName, ! 656: MB_OK | MB_ICONASTERISK | MB_APPLMODAL); ! 657: } ! 658: ! 659: /**************************************************************************** ! 660: * SetCharSet(hDial) ! 661: * ! 662: * purpose : Set ANSI/OEM dialog button and set the number in edit window ! 663: * ! 664: * param : HWND hDial : handle to dialog box window ! 665: * ! 666: * returns : none ! 667: * ! 668: ***************************************************************************/ ! 669: VOID ! 670: SetCharSet( ! 671: HWND hDial ! 672: ) ! 673: { ! 674: CheckDlgButton(hDial, ID_ANSI, (WORD) (newCharSet == ANSI_CHARSET)); ! 675: CheckDlgButton(hDial, ID_SYMBOL, (WORD) (newCharSet == SYMBOL_CHARSET)); ! 676: CheckDlgButton(hDial, ID_OEM, (WORD) (newCharSet == OEM_CHARSET)); ! 677: SetDlgItemInt(hDial, ID_CHAR_SET, newCharSet, FALSE); ! 678: } ! 679: ! 680: /**************************************************************************** ! 681: * SetFixed(hDial) ! 682: * ! 683: * purpose : Set fixed/variable dialog button ! 684: * ! 685: * params : HWND hDial : handle to dialog box window ! 686: * BOOL fFV : variable or fixed ! 687: * ! 688: * returns : none ! 689: * ! 690: ***************************************************************************/ ! 691: VOID ! 692: SetFixed( ! 693: HWND hDial, ! 694: BOOL fFV ! 695: ) ! 696: { ! 697: CheckDlgButton(hDial, ID_FIXED, (WORD)(fFV == 0)); ! 698: CheckDlgButton(hDial, ID_VARIABLE, (WORD)(fFV == 1)); ! 699: if (newFV) ! 700: SetDlgItemText(hDial, ID_WIDTH_TEXT, (LPSTR)vszMaxWidth); ! 701: else ! 702: SetDlgItemText(hDial, ID_WIDTH_TEXT, (LPSTR)vszCharPixelWidth); ! 703: } ! 704: ! 705: /**************************************************************************** ! 706: * SetWeight(hDial) ! 707: * ! 708: * purpose : Set font weight dialog button ! 709: * ! 710: * params : HWND hDial : handle to dialog box window ! 711: * ! 712: * returns : none ! 713: * ! 714: ****************************************************************************/ ! 715: VOID ! 716: SetWeight( ! 717: HWND hDial ! 718: ) ! 719: { ! 720: CheckDlgButton(hDial, ID_THIN, (WORD)(newWeight == FW_THIN)); ! 721: CheckDlgButton(hDial, ID_EXTRALIGHT, (WORD)(newWeight == FW_EXTRALIGHT)); ! 722: CheckDlgButton(hDial, ID_LIGHT, (WORD)(newWeight == FW_LIGHT)); ! 723: CheckDlgButton(hDial, ID_NORMAL, (WORD)(newWeight == FW_NORMAL)); ! 724: CheckDlgButton(hDial, ID_MEDIUM, (WORD)(newWeight == FW_MEDIUM)); ! 725: CheckDlgButton(hDial, ID_SEMIBOLD, (WORD)(newWeight == FW_SEMIBOLD)); ! 726: CheckDlgButton(hDial, ID_BOLD, (WORD)(newWeight == FW_BOLD)); ! 727: CheckDlgButton(hDial, ID_EXTRABOLD, (WORD)(newWeight == FW_EXTRABOLD)); ! 728: CheckDlgButton(hDial, ID_HEAVY, (WORD)(newWeight == FW_HEAVY)); ! 729: } ! 730: ! 731: /**************************************************************************** ! 732: * SetFamily(hDial) ! 733: * ! 734: * purpose : Set font family dialog button ! 735: * ! 736: * params : HWND hDial : handle to dialog box window ! 737: * ! 738: * returns : none ! 739: * ! 740: ***************************************************************************/ ! 741: VOID ! 742: SetFamily( ! 743: HWND hDial ! 744: ) ! 745: { ! 746: CheckDlgButton(hDial, ID_UNKNOWN, (WORD) (newFamily == 0)); ! 747: CheckDlgButton(hDial, ID_ROMAN, (WORD)(newFamily == 1)); ! 748: CheckDlgButton(hDial, ID_SWISS, (WORD)(newFamily == 2)); ! 749: CheckDlgButton(hDial, ID_MODERN, (WORD)(newFamily == 3)); ! 750: CheckDlgButton(hDial, ID_SCRIPT, (WORD)(newFamily == 4)); ! 751: CheckDlgButton(hDial, ID_DECORATIVE, (WORD) (newFamily == 5)); ! 752: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.