Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

955 lines
32 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. #define NOVIRTUALKEYCODES
  5. #define NOKEYSTATE
  6. #define NOCREATESTRUCT
  7. #define NOICON
  8. //#define NOATOM
  9. //#define NOMEMMGR
  10. #define NOPEN
  11. #define NOREGION
  12. #define NODRAWTEXT
  13. #define NOMB
  14. #define NOWINOFFSETS
  15. #define NOOPENFILE
  16. #define NOMETAFILE
  17. #define NOWH
  18. //#define NOCLIPBOARD
  19. #define NOSYSCOMMANDS
  20. #define NOWINMESSAGES
  21. #define NOSOUND
  22. #define NOCOMM
  23. #include <windows.h>
  24. #include "mw.h"
  25. #define NOUAC
  26. #include "cmddefs.h"
  27. #include "dispdefs.h"
  28. #include "wwdefs.h"
  29. #include "menudefs.h"
  30. #include "str.h"
  31. #include "fontdefs.h"
  32. #include "printdef.h"
  33. #if defined(OLE)
  34. #include "obj.h"
  35. #endif
  36. #include <commdlg.h>
  37. #ifdef DEBUG
  38. #define STATIC
  39. #else
  40. #define STATIC static
  41. #endif
  42. /* static string arrays found in mglobals.c */
  43. extern CHAR szMw_acctb[];
  44. extern CHAR szNullPort[];
  45. extern CHAR szNone[15];
  46. extern CHAR szMwlores[];
  47. extern CHAR szMwhires[];
  48. extern CHAR szMw_icon[];
  49. extern CHAR szMw_menu[];
  50. extern CHAR szScrollBar[];
  51. extern CHAR szIntl[];
  52. extern CHAR szsDecimal[];
  53. extern CHAR szsDecimalDefault[];
  54. #ifdef INTL /* International version */
  55. extern CHAR sziCountry[];
  56. extern CHAR sziCountryDefault[5];
  57. #endif /* International version */
  58. extern CHAR vchDecimal; /* decimal point character */
  59. extern int viDigits; /* digits after decimal point */
  60. extern BOOL vbLZero; /* leading zero before decimal */
  61. extern struct WWD rgwwd[];
  62. extern CHAR stBuf[256];
  63. extern int vifceMac;
  64. extern union FCID vfcidScreen;
  65. extern union FCID vfcidPrint;
  66. extern struct FCE rgfce[ifceMax];
  67. extern struct FCE *vpfceMru;
  68. extern HCURSOR vhcHourGlass;
  69. #ifdef PENWIN // for PenWindows (5/21/91) patlam
  70. #include <penwin.h>
  71. extern HCURSOR vhcPen;
  72. extern int (FAR PASCAL *lpfnProcessWriting)(HWND, LPRC);
  73. extern VOID (FAR PASCAL *lpfnPostVirtualKeyEvent)(WORD, BOOL);
  74. extern VOID (FAR PASCAL *lpfnTPtoDP)(LPPOINT, int);
  75. extern BOOL (FAR PASCAL *lpfnCorrectWriting)(HWND, LPSTR, int, LPRC, DWORD, DWORD);
  76. extern BOOL (FAR PASCAL *lpfnSymbolToCharacter)(LPSYV, int, LPSTR, LPINT);
  77. #endif
  78. extern WORD fPrintOnly;
  79. extern HCURSOR vhcIBeam;
  80. extern HCURSOR vhcArrow;
  81. extern HCURSOR vhcBarCur;
  82. extern HANDLE hMmwModInstance;
  83. extern HWND hParentWw;
  84. extern HWND vhWndSizeBox;
  85. extern HWND vhWndPageInfo;
  86. extern HWND vhWnd;
  87. extern HMENU vhMenu;
  88. extern HANDLE vhAccel;
  89. extern long rgbBkgrnd;
  90. extern long rgbText;
  91. extern HBRUSH hbrBkgrnd;
  92. extern HDC vhMDC;
  93. extern int vfInitializing;
  94. extern int vfMouseExist;
  95. extern int ferror;
  96. extern CHAR szWindows[];
  97. extern CHAR szNul[];
  98. extern CHAR szWriteProduct[];
  99. extern CHAR szBackup[];
  100. extern int vfBackupSave;
  101. #if defined(JAPAN) || defined(KOREA) //Win3.1J
  102. extern CHAR szWordWrap[];
  103. extern int vfWordWrap; /*t-Yoshio WordWrap flag*/
  104. #endif
  105. //IME3.1J
  106. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  107. extern CHAR szImeHidden[];
  108. extern int vfImeHidden; /*T-HIROYN ImeHidden Mode flag*/
  109. #endif
  110. #ifdef JAPAN //01/21/93
  111. extern HANDLE hszNoMemorySel;
  112. #endif
  113. extern HANDLE hszNoMemory;
  114. extern HANDLE hszDirtyDoc;
  115. extern HANDLE hszCantPrint;
  116. extern HANDLE hszPRFAIL;
  117. extern HANDLE hszCantRunM;
  118. extern HANDLE hszCantRunF;
  119. extern HANDLE hszWinFailure;
  120. extern HDC vhDCPrinter;
  121. int vkMinus;
  122. extern int utCur;
  123. /* Regrettably, we are not permitted to signal in WM_CREATE message
  124. handlers that we have failed -- instead, we resort to
  125. ugly global communication via this variable */
  126. #ifdef WIN30
  127. /* Note that we now CAN return a -1L from MmwCreate and cause the
  128. CreateWindow to fail, but changing this now wouldn't accomplish us
  129. very much (besides saving a bunch of checks of a global) ..pault */
  130. #endif
  131. STATIC int fMessageInzFailed = FALSE;
  132. STATIC BOOL NEAR FRegisterWnd( HANDLE );
  133. #ifdef INEFFLOCKDOWN
  134. STATIC int NEAR FInitFarprocs( HANDLE );
  135. #endif
  136. STATIC HANDLE NEAR HszCreateIdpmt( int );
  137. BOOL InitIntlStrings( HANDLE );
  138. #define cchCmdLineMax 64 /* Longest command line accepted */
  139. /* FInitWinInfo */
  140. /* Main MS-WINDOWS initialization entry point for write */
  141. /* Actions:
  142. Loads all mouse cursors & sets global handles to cursors (vhc's)
  143. Loads the menu key accelerator table vhAccel
  144. Registers all of WRITE's myriad window classes
  145. Sets up global hMmwModInstance, our instance handle
  146. Puts "DOC = WRITE.EXE ^.DOC" into WIN.INI if not already there
  147. Generates thunks for all exported procedures
  148. Creates a parent window for this instance (the menu window, NOT
  149. the document window)
  150. Sets the right colors for the window
  151. */
  152. /* Returns FALSE if the initailization failed, TRUE if it succeeded */
  153. int FInitWinInfo( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  154. HANDLE hInstance, hPrevInstance;
  155. LPSTR lpszCmdLine;
  156. int cmdShow;
  157. {
  158. extern VOID (FAR PASCAL *lpfnRegisterPenApp)(WORD, BOOL);
  159. extern CHAR szParentClass[];
  160. extern int vfDiskError, vfDiskFull, vfSysFull;
  161. extern PRINTDLG PD;
  162. CHAR rgchCmdLine[ cchCmdLineMax ];
  163. CHAR bufT[3]; /* to hold decimal point string */
  164. CHAR *pch = bufT;
  165. BOOL fRetVal;
  166. #if defined(OLE)
  167. /*
  168. The only place I'm worrying about this is when we open a file which
  169. contains objects. Probably thats not enough, but its something.
  170. Alas for users of real mode.
  171. */
  172. fOleEnabled = GetWinFlags() & WF_PMODE; /* Are we in real mode today? */
  173. #endif
  174. /* Save the command line in a DS variable so we can pass a NEAR pointer */
  175. bltszx( lpszCmdLine, (LPSTR)rgchCmdLine );
  176. /* First thing, put up the hourglass cursor. */
  177. if ((vhcHourGlass = LoadCursor( NULL, IDC_WAIT )) == NULL)
  178. {
  179. /* We don't even have enough memory to tell the user we don't have
  180. enough memory. */
  181. return (FALSE);
  182. }
  183. vfMouseExist = GetSystemMetrics(SM_MOUSEPRESENT);
  184. /* Next, save the out of memory messages. */
  185. hMmwModInstance = hInstance;
  186. if ((hszCantRunM = HszCreateIdpmt( IDPMTCantRunM )) == NULL ||
  187. (hszCantRunF = HszCreateIdpmt( IDPMTCantRunF )) == NULL ||
  188. (hszWinFailure = HszCreateIdpmt( IDPMTWinFailure )) == NULL ||
  189. #ifdef JAPAN //01/21/93
  190. (hszNoMemorySel = HszCreateIdpmt( IDPMTNoMemorySel )) == NULL ||
  191. #endif
  192. (hszNoMemory = HszCreateIdpmt( IDPMTNoMemory )) == NULL ||
  193. (hszDirtyDoc = HszCreateIdpmt( IDPMTDirtyDoc )) == NULL ||
  194. (hszCantPrint = HszCreateIdpmt( IDPMTCantPrint )) == NULL ||
  195. (hszPRFAIL = HszCreateIdpmt( IDPMTPRFAIL )) == NULL)
  196. {
  197. goto InzFailed;
  198. }
  199. #if defined(INTL) && defined(WIN30)
  200. /* Initializaton of multi/intl strings. This is done before anything
  201. else because many are defaults used for GetProfileString, etc. */
  202. if (!FInitIntlStrings(hInstance))
  203. goto InzFailed;
  204. #endif
  205. /* Set up the standard cursors. */
  206. if ( ((vhcIBeam = LoadCursor( NULL, IDC_IBEAM )) == NULL) ||
  207. ((vhcArrow = LoadCursor( NULL, IDC_ARROW )) == NULL))
  208. goto InzFailed;
  209. #ifdef PENWIN // for PenWindows (5/21/91) patlam
  210. vhcPen =vhcIBeam;
  211. #endif
  212. /* Set up the menu accelerator key table. */
  213. if ((vhAccel = LoadAccelerators( hMmwModInstance, (LPSTR)szMw_acctb )) ==
  214. NULL)
  215. goto InzFailed;
  216. /* Get whether to make backups during save from the user profile. */
  217. vfBackupSave = GetProfileInt((LPSTR)szWriteProduct, (LPSTR)szBackup, 0) == 0
  218. ? FALSE : TRUE;
  219. /* Get the name of the null port from the user profile. */
  220. GetProfileString((LPSTR)szWindows, (LPSTR)szNullPort, (LPSTR)szNone,
  221. (LPSTR)szNul, cchMaxIDSTR);
  222. #ifdef INTL /* International version */
  223. /* Get the country code. If US or UK, set utCur to be inches, else set
  224. to cm */
  225. {
  226. #if 0
  227. /* codes from MSDOS country codes */
  228. #define USA (1)
  229. #define UK (44)
  230. int iCountry;
  231. GetProfileString((LPSTR)szIntl, (LPSTR)sziCountry, (LPSTR)sziCountryDefault,
  232. (LPSTR)bufT, 4);
  233. iCountry = WFromSzNumber (&pch);
  234. if ((iCountry == USA) || (iCountry == UK))
  235. utCur = utInch;
  236. #else
  237. if (GetProfileInt((LPSTR)szIntl, (LPSTR)"iMeasure", 1) == 1)
  238. utCur = utInch;
  239. else
  240. utCur = utCm;
  241. #endif
  242. }
  243. #endif /* International version */
  244. /* Get the decimal point character from the user profile. */
  245. GetProfileString((LPSTR)szIntl, (LPSTR)szsDecimal, (LPSTR)szsDecimalDefault,
  246. (LPSTR)bufT, 2);
  247. vchDecimal = *bufT;
  248. viDigits = GetProfileInt((LPSTR)szIntl, (LPSTR)"iDigits", 2);
  249. vbLZero = GetProfileInt((LPSTR)szIntl, (LPSTR)"iLZero", 0);
  250. MergeInit(); /* get message merge characters from resource file */
  251. #if defined(JAPAN) || defined(KOREA) /*t-Yoshio*/
  252. /*
  253. * Get WordWrap switch
  254. * case 1 WordWrap ON(default)
  255. * case 0 WordWrap OFF
  256. */
  257. vfWordWrap = GetProfileInt((LPSTR)szWriteProduct, (LPSTR)szWordWrap, 1);
  258. #endif
  259. #if defined(JAPAN) & defined(IME_HIDDEN) //IME3.1J
  260. //IR_UNDETERMINE
  261. /*
  262. * Get ImeHidden switch
  263. * case 1 Ime Conversion Window MCW_HIDDEN SET
  264. * case 0 Ime Conversion Window MCW_WINDOW SET (default)
  265. */
  266. if (3 == (vfImeHidden =
  267. GetProfileInt((LPSTR)szWriteProduct, (LPSTR)szImeHidden, 3))) {
  268. // insert machine power get routine someday
  269. vfImeHidden = 0;
  270. }
  271. GetImeHiddenTextColors();
  272. #endif
  273. #ifdef FONT_KLUDGE
  274. AddFontResource( (LPSTR)"helv.fon" );
  275. #endif /* FONT_KLUDGE */
  276. if (!hPrevInstance)
  277. {
  278. /* First time loaded; register the Write Windows. */
  279. if (!FRegisterWnd( hMmwModInstance ))
  280. {
  281. return ( FALSE );
  282. }
  283. /* Get the Memo specific cursor. */
  284. if ((vhcBarCur = LoadCursor( hMmwModInstance,
  285. (GetSystemMetrics( SM_CXICON ) < 32) ||
  286. (GetSystemMetrics( SM_CYICON ) < 32) ?
  287. (LPSTR) szMwlores : (LPSTR) szMwhires )) == NULL)
  288. goto InzFailed;
  289. }
  290. else /* not first time loaded; get data from previous instance */
  291. {
  292. if (!GetInstanceData( hPrevInstance,
  293. (PSTR)&vhcBarCur, sizeof( vhcBarCur ) ))
  294. goto InzFailed;
  295. }
  296. #ifdef INEFFLOCKDOWN
  297. /* Now initialize the pointers to far procedures (thunks). */
  298. if (!FInitFarprocs( hMmwModInstance ))
  299. goto InzFailed;
  300. #endif
  301. /* Create our parent (tiled) window */
  302. /* CreateWindow call generates a call to MmwCreate via message */
  303. {
  304. int cxFrame = GetSystemMetrics( SM_CXFRAME );
  305. int cxBorder = GetSystemMetrics( SM_CXBORDER );
  306. int cyBorder = GetSystemMetrics( SM_CYBORDER );
  307. int x = ((cxFrame + 7) & 0xfff8) - cxFrame;
  308. if ( CreateWindow(
  309. (LPSTR)szParentClass,
  310. (LPSTR)rgchCmdLine, /* don't pass lpszCmdLine; it will change! ..pault 2/22/90 */
  311. WS_TILEDWINDOW,
  312. #ifdef WIN30
  313. /* This makes for nicer cascading of Write.exe invocations ..pault */
  314. CW_USEDEFAULT, /* x */
  315. CW_USEDEFAULT, /* y */
  316. CW_USEDEFAULT, /* dx */
  317. CW_USEDEFAULT, /* dy */
  318. #else
  319. x, /* x */
  320. x * cyBorder / cxBorder, /* y */
  321. CW_USEDEFAULT, /* dx */
  322. NULL, /* dy */
  323. #endif
  324. (HWND)NULL, /* no parent */
  325. (HMENU)NULL, /* use class menu */
  326. (HANDLE)hInstance, /* handle to window instance */
  327. (LPSTR)NULL /* no params to pass on */
  328. ) == NULL)
  329. /* Could not create window */
  330. goto InzFailed;
  331. }
  332. if (fMessageInzFailed)
  333. /* The create itself did not fail, but something in MmwCreate did
  334. and it signals us via this global */
  335. goto InzFailed;
  336. Assert( hParentWw != NULL ); /* MmwCreate should have assured this */
  337. #if WINVER >= 0x300
  338. vkMinus = VkKeyScan('-');
  339. #endif
  340. /* Record the window foreground and background colors. */
  341. #ifdef DEBUG
  342. {
  343. int f =
  344. #endif
  345. FSetWindowColors();
  346. #ifdef DEBUG
  347. Assert (f);
  348. }
  349. #endif
  350. /* Select the background brush into the parent window. */
  351. SelectObject( GetDC( hParentWw ), hbrBkgrnd );
  352. /* Commdlg stuff (3.7.91) D. Kent */
  353. if (InitCommDlg(0))
  354. goto InzFailed;
  355. #ifdef PENWIN
  356. if (lpfnRegisterPenApp = GetProcAddress(GetSystemMetrics(SM_PENWINDOWS),
  357. "RegisterPenApp"))
  358. {
  359. (*lpfnRegisterPenApp)((WORD)1, fTrue); // be Pen-Enhanced
  360. }
  361. {
  362. // This assumes no edit controls created in FInitWinInfo
  363. HANDLE hLib;
  364. if (lpfnProcessWriting = GetProcAddress(hLib = GetSystemMetrics(SM_PENWINDOWS),
  365. "ProcessWriting"))
  366. {
  367. lpfnPostVirtualKeyEvent = GetProcAddress(hLib, "PostVirtualKeyEvent");
  368. lpfnTPtoDP = GetProcAddress(hLib, "TPtoDP");
  369. lpfnCorrectWriting = GetProcAddress(hLib, "CorrectWriting");
  370. lpfnSymbolToCharacter = GetProcAddress(hLib, "SymbolToCharacter");
  371. if ((vhcPen = LoadCursor( NULL, IDC_PEN )) == NULL)
  372. goto InzFailed;
  373. }
  374. }
  375. #endif
  376. /* init fields of the PRINTDLG structure (not used yet) */
  377. PD.lStructSize = sizeof(PRINTDLG);
  378. PD.hwndOwner = hParentWw;
  379. // PD.hDevMode is already initialized
  380. PD.hDevNames = NULL;
  381. PD.hDC = NULL;
  382. PD.Flags = PD_ALLPAGES; /* disable "pages" and "Selection" radiobuttons */
  383. PD.nFromPage = 1;
  384. PD.nToPage = 1;
  385. PD.nMinPage = pgnMin; /* constant 1 */
  386. PD.nMaxPage = pgnMax; /* largest integer */
  387. PD.nCopies = 1;
  388. /* initialize OLE stuff (1-23-91 dougk) */
  389. if (!ObjInit(hInstance))
  390. goto InzFailed;
  391. /* Parse command line; load document & create an "mdoc" child window */
  392. if (!FInitArgs(rgchCmdLine) || fMessageInzFailed)
  393. /* Serious error -- bail out */
  394. goto InzFailed;
  395. /* Create a memory DC for the child window, to test that it works */
  396. ValidateMemoryDC();
  397. if (vhMDC == NULL)
  398. goto InzFailed;
  399. /* Make parent window visible after the child gets created; the order is
  400. important and that the parent window is created without the visible bit on,
  401. so that no size message is sent before child gets created */
  402. //if (!fPrintOnly)
  403. ShowWindow(hParentWw, cmdShow);
  404. Diag(CommSz("---------------------------------------------------------------------------\n\r"));
  405. vfInitializing = FALSE;
  406. fRetVal = TRUE;
  407. FreeMsgs:
  408. if (hszCantRunM != NULL)
  409. GlobalFree( hszCantRunM );
  410. if (hszCantRunF != NULL)
  411. GlobalFree( hszCantRunF );
  412. return fRetVal;
  413. InzFailed:
  414. FreeMemoryDC( TRUE );
  415. if (vhDCPrinter != NULL)
  416. DeleteDC( vhDCPrinter);
  417. if (hszWinFailure != NULL)
  418. GlobalFree( hszWinFailure );
  419. #ifdef JAPAN //01/21/93
  420. if (hszNoMemorySel != NULL)
  421. GlobalFree( hszNoMemorySel );
  422. #endif
  423. if (hszNoMemory != NULL)
  424. GlobalFree( hszNoMemory );
  425. if (hszDirtyDoc != NULL)
  426. GlobalFree( hszDirtyDoc );
  427. if (hszCantPrint != NULL)
  428. GlobalFree( hszCantPrint );
  429. if (hszPRFAIL != NULL)
  430. GlobalFree( hszPRFAIL );
  431. ferror = vfInitializing = FALSE; /* So the error report is not suppressed */
  432. if (vfDiskFull || vfSysFull || vfDiskError)
  433. Error(IDPMTCantRunF);
  434. else
  435. Error(IDPMTCantRunM);
  436. fRetVal = FALSE;
  437. goto FreeMsgs;
  438. }
  439. STATIC BOOL NEAR FRegisterWnd(hInstance)
  440. HANDLE hInstance;
  441. {
  442. /* This routine registers all of the window classes. TRUE is returned if
  443. all of the windows classes were successfully registered; FALSE otherwise. */
  444. extern CHAR szParentClass[];
  445. extern CHAR szDocClass[];
  446. extern CHAR szRulerClass[];
  447. extern CHAR szPageInfoClass[];
  448. #ifdef ONLINEHELP
  449. extern CHAR szHelpDocClass[];
  450. #endif
  451. extern long FAR PASCAL MmwWndProc(HWND, unsigned, WORD, LONG);
  452. extern long FAR PASCAL MdocWndProc(HWND, unsigned, WORD, LONG);
  453. extern long FAR PASCAL RulerWndProc(HWND, unsigned, WORD, LONG);
  454. extern long FAR PASCAL PageInfoWndProc(HWND, unsigned, WORD, LONG);
  455. #ifdef ONLINEHELP
  456. extern long FAR PASCAL HelpDocWndProc(HWND, unsigned, WORD, LONG);
  457. #endif /* ONLINEHELP */
  458. WNDCLASS Class;
  459. /* Register our Window Proc */
  460. bltbc( (PCH)&Class, 0, sizeof( WNDCLASS ) );
  461. Class.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNCLIENT;
  462. Class.lpfnWndProc = MmwWndProc;
  463. Class.hInstance = hInstance;
  464. Class.hCursor = vhcArrow;
  465. Class.hIcon = LoadIcon( hInstance, (LPSTR)szMw_icon );
  466. Class.lpszMenuName = (LPSTR)szMw_menu;
  467. Class.lpszClassName = (LPSTR)szParentClass;
  468. Class.hbrBackground = COLOR_WINDOW+1;
  469. /* register the parent menu class with WINDOWS */
  470. if (!RegisterClass( (LPWNDCLASS)&Class ) )
  471. return FALSE; /* Initialization failed */
  472. /* register memo document child window class */
  473. bltbc( (PCH)&Class, 0, sizeof( WNDCLASS ) );
  474. Class.style = CS_OWNDC | CS_DBLCLKS;
  475. Class.lpfnWndProc = MdocWndProc;
  476. Class.hInstance = hInstance;
  477. Class.lpszClassName = (LPSTR)szDocClass;
  478. if (!RegisterClass( (LPWNDCLASS)&Class ) )
  479. return FALSE; /* Initialization failed */
  480. /* register ruler child window class */
  481. bltbc( (PCH)&Class, 0, sizeof( WNDCLASS ) );
  482. Class.style = CS_OWNDC | CS_DBLCLKS;
  483. Class.lpfnWndProc = RulerWndProc;
  484. Class.hInstance = hInstance;
  485. Class.hCursor = vhcArrow;
  486. Class.lpszClassName = (LPSTR)szRulerClass;
  487. if (!RegisterClass( (LPWNDCLASS)&Class ) )
  488. return FALSE; /* Initialization failed */
  489. #ifdef ONLINEHELP
  490. /* register Help document child window class */
  491. bltbc( (PCH)&Class, 0, sizeof( WNDCLASS ) );
  492. Class.style = CS_OWNDC;
  493. Class.lpfnWndProc = HelpDocWndProc;
  494. Class.hInstance = hInstance;
  495. Class.lpszClassName = (LPSTR)szHelpDocClass;
  496. if (!RegisterClass( (LPWNDCLASS)&Class ) )
  497. return FALSE; /* Initialization failed */
  498. #endif /* ONLINE HELP */
  499. /* register page info child window class */
  500. bltbc( (PCH)&Class, 0, sizeof( WNDCLASS ) );
  501. Class.style = CS_OWNDC;
  502. Class.lpfnWndProc = PageInfoWndProc;
  503. Class.hInstance = hInstance;
  504. Class.hCursor = vhcArrow;
  505. Class.lpszClassName = (LPSTR)szPageInfoClass;
  506. if (!RegisterClass( (LPWNDCLASS)&Class ) )
  507. return FALSE; /* Initialization failed */
  508. return TRUE;
  509. }
  510. #ifdef INEFFLOCKDOWN
  511. /* I've removed this for Windows 3.0 because (unless reasons come up
  512. proving otherwise) it is inefficient for a Win program to lock-down
  513. so many procedures like this for the entire time the app is running.
  514. Originally thought to lock down the entire procedure; now understood only
  515. to lock down the thunk. The principle still applies..pault 10/26/89 */
  516. STATIC int NEAR FInitFarprocs( hInstance )
  517. HANDLE hInstance;
  518. {
  519. /* This routine initializes all of the far pointer to procedures. */
  520. extern FARPROC lpDialogOpen;
  521. extern FARPROC lpDialogSaveAs;
  522. extern FARPROC lpDialogConfirm;
  523. extern FARPROC lpDialogPrinterSetup;
  524. extern FARPROC lpDialogPrint;
  525. extern FARPROC lpDialogRepaginate;
  526. extern FARPROC lpDialogSetPage;
  527. extern FARPROC lpDialogPageMark;
  528. extern FARPROC lpDialogCancelPrint;
  529. extern FARPROC lpDialogHelp;
  530. #ifdef ONLINEHELP
  531. extern FARPROC lpDialogHelpInner;
  532. #endif /* ONLINEHELP */
  533. extern FARPROC lpDialogGoTo;
  534. extern FARPROC lpDialogFind;
  535. extern FARPROC lpDialogChange;
  536. extern FARPROC lpDialogCharFormats;
  537. extern FARPROC lpDialogParaFormats;
  538. extern FARPROC lpDialogRunningHead;
  539. extern FARPROC lpDialogTabs;
  540. extern FARPROC lpDialogDivision;
  541. extern FARPROC lpDialogBadMargins;
  542. extern FARPROC lpFontFaceEnum;
  543. extern FARPROC lpFPrContinue;
  544. #ifdef INTL /* International version */
  545. extern FARPROC lpDialogWordCvt;
  546. extern BOOL far PASCAL DialogWordCvt(HWND, unsigned, WORD, LONG);
  547. #endif /* International version */
  548. extern BOOL far PASCAL DialogOpen(HWND, unsigned, WORD, LONG);
  549. extern BOOL far PASCAL DialogSaveAs(HWND, unsigned, WORD, LONG);
  550. extern BOOL far PASCAL DialogPrinterSetup(HWND, unsigned, WORD, LONG);
  551. extern BOOL far PASCAL DialogPrint(HWND, unsigned, WORD, LONG);
  552. extern BOOL far PASCAL DialogCancelPrint(HWND, unsigned, WORD, LONG);
  553. extern BOOL far PASCAL DialogRepaginate(HWND, unsigned, WORD, LONG);
  554. extern BOOL far PASCAL DialogSetPage(HWND, unsigned, WORD, LONG);
  555. extern BOOL far PASCAL DialogPageMark(HWND, unsigned, WORD, LONG);
  556. extern BOOL far PASCAL DialogHelp(HWND, unsigned, WORD, LONG);
  557. #ifdef ONLINEHELP
  558. extern BOOL far PASCAL DialogHelpInner(HWND, unsigned, WORD, LONG);
  559. #endif /* ONLINEHELP */
  560. extern BOOL far PASCAL DialogGoTo(HWND, unsigned, WORD, LONG);
  561. extern BOOL far PASCAL DialogFind(HWND, unsigned, WORD, LONG);
  562. extern BOOL far PASCAL DialogChange(HWND, unsigned, WORD, LONG);
  563. extern BOOL far PASCAL DialogCharFormats(HWND, unsigned, WORD, LONG);
  564. extern BOOL far PASCAL DialogParaFormats(HWND, unsigned, WORD, LONG);
  565. extern BOOL far PASCAL DialogRunningHead(HWND, unsigned, WORD, LONG);
  566. extern BOOL far PASCAL DialogTabs(HWND, unsigned, WORD, LONG);
  567. extern BOOL far PASCAL DialogDivision(HWND, unsigned, WORD, LONG);
  568. extern BOOL far PASCAL DialogConfirm(HWND, unsigned, WORD, LONG);
  569. extern BOOL far PASCAL DialogBadMargins(HWND, unsigned, WORD, LONG);
  570. extern BOOL far PASCAL FontFaceEnum(LPLOGFONT, LPTEXTMETRIC, int, long);
  571. extern BOOL far PASCAL FPrContinue(HDC, int);
  572. if (
  573. ((lpDialogPrinterSetup = MakeProcInstance(DialogPrinterSetup, hInstance))
  574. == NULL) ||
  575. ((lpDialogPrint = MakeProcInstance(DialogPrint, hInstance)) == NULL) ||
  576. ((lpDialogSetPage = MakeProcInstance(DialogSetPage, hInstance)) == NULL)||
  577. ((lpDialogRepaginate = MakeProcInstance(DialogRepaginate, hInstance))
  578. == NULL) ||
  579. ((lpDialogPageMark = MakeProcInstance(DialogPageMark, hInstance))
  580. == NULL) ||
  581. ((lpDialogCancelPrint = MakeProcInstance(DialogCancelPrint, hInstance))
  582. == NULL) ||
  583. ((lpDialogHelp = MakeProcInstance(DialogHelp, hInstance)) == NULL) ||
  584. #ifdef ONLINEHELP
  585. ((lpDialogHelpInner = MakeProcInstance(DialogHelpInner, hInstance))
  586. == NULL) ||
  587. #endif /* ONLINEHELP */
  588. ((lpDialogGoTo = MakeProcInstance(DialogGoTo, hInstance)) == NULL) ||
  589. ((lpDialogFind = MakeProcInstance(DialogFind, hInstance)) == NULL) ||
  590. ((lpDialogChange = MakeProcInstance(DialogChange, hInstance)) == NULL) ||
  591. ((lpDialogCharFormats = MakeProcInstance(DialogCharFormats, hInstance))
  592. == NULL) ||
  593. ((lpDialogParaFormats = MakeProcInstance(DialogParaFormats, hInstance))
  594. == NULL) ||
  595. ((lpDialogRunningHead = MakeProcInstance(DialogRunningHead, hInstance))
  596. == NULL) ||
  597. ((lpDialogTabs = MakeProcInstance(DialogTabs, hInstance)) == NULL) ||
  598. ((lpDialogDivision = MakeProcInstance(DialogDivision, hInstance))
  599. == NULL) ||
  600. ((lpDialogConfirm = MakeProcInstance(DialogConfirm, hInstance)) == NULL)||
  601. ((lpDialogBadMargins = MakeProcInstance(DialogBadMargins, hInstance))
  602. == NULL) ||
  603. ((lpFontFaceEnum = MakeProcInstance(FontFaceEnum, hInstance)) == NULL) ||
  604. ((lpFPrContinue = MakeProcInstance(FPrContinue, hInstance)) == NULL)
  605. #ifdef INTL /* International version */
  606. || ((lpDialogWordCvt = MakeProcInstance(DialogWordCvt, hInstance)) == NULL)
  607. #endif /* International version */
  608. )
  609. return FALSE;
  610. return TRUE;
  611. }
  612. #endif /* ifdef-INEFFLOCKDOWN */
  613. void MmwCreate(hWnd, lParam)
  614. HWND hWnd;
  615. LONG lParam;
  616. {
  617. extern CHAR szPageInfoClass[];
  618. HANDLE hSysMenu;
  619. HDC hDC;
  620. HBRUSH hbr;
  621. Assert( hMmwModInstance != NULL ); /* Should have set up instance handle */
  622. hParentWw = hWnd;
  623. if ((vhMenu = GetMenu(hWnd)) == NULL)
  624. goto Error;
  625. /* set up font cache */
  626. /* RgfceInit() placed in line for speed */
  627. {
  628. int ifce;
  629. struct FCE *pfce;
  630. for (ifce = 0; ifce < vifceMac; ifce++)
  631. {
  632. pfce = &rgfce[ifce];
  633. pfce->pfceNext = &rgfce[(ifce + 1) % vifceMac];
  634. pfce->pfcePrev = &rgfce[(ifce + vifceMac - 1) % vifceMac];
  635. pfce->fmi.mpchdxp = pfce->rgdxp - chFmiMin;
  636. pfce->fcidRequest.lFcid = fcidNil;
  637. }
  638. Assert(sizeof(rgfce[0].fcidRequest.lFcid)
  639. == sizeof(rgfce[0].fcidRequest.strFcid));
  640. vpfceMru = &rgfce[0];
  641. vfcidScreen.lFcid = vfcidPrint.lFcid = fcidNil;
  642. }
  643. /* set up page buffer, internal data structures, heap etc. */
  644. if (!FInitMemory())
  645. goto Error;
  646. /* Create the horizontal scroll bar. The size is initialized to zero
  647. because it will be reset later. */
  648. if ((wwdCurrentDoc.hHScrBar = CreateWindow((LPSTR)szScrollBar, (LPSTR)NULL,
  649. WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_HORZ, 0, 0, 0, 0, hWnd,
  650. NULL, hMmwModInstance, (LPSTR)NULL)) == NULL)
  651. {
  652. goto Error;
  653. }
  654. wwdCurrentDoc.sbHbar = SB_CTL;
  655. /* Create the vertical scroll bar. The size is initialized to zero
  656. because again it will be reset later. */
  657. if ((wwdCurrentDoc.hVScrBar = CreateWindow((LPSTR)szScrollBar, (LPSTR)NULL,
  658. WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_VERT, 0, 0, 0, 0, hWnd,
  659. NULL, hMmwModInstance, (LPSTR)NULL)) == NULL)
  660. {
  661. goto Error;
  662. }
  663. wwdCurrentDoc.sbVbar = SB_CTL;
  664. #ifndef NOMORESIZEBOX
  665. /* Create the size box. The size is initialized to zero because again it
  666. will be reset later. */
  667. if ((vhWndSizeBox = CreateWindow((LPSTR)szScrollBar, (LPSTR)NULL,
  668. WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBS_SIZEBOX,
  669. CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hWnd, NULL,
  670. hMmwModInstance, (LPSTR)NULL)) == NULL)
  671. {
  672. goto Error;
  673. }
  674. #endif
  675. /* Create the page info window. Again, we'll worry about the sizing later.
  676. */
  677. if ((vhWndPageInfo = CreateWindow((LPSTR)szPageInfoClass, (LPSTR)NULL,
  678. WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 0, 0, 0, 0, hWnd, NULL,
  679. hMmwModInstance, (LPSTR)NULL)) == NULL)
  680. {
  681. goto Error;
  682. }
  683. /* Initialize the page info window. */
  684. if ((hDC = GetDC(vhWndPageInfo)) == NULL || (hbr =
  685. CreateSolidBrush(GetSysColor(COLOR_WINDOWFRAME))) == NULL)
  686. {
  687. goto Error;
  688. }
  689. if (SelectObject(hDC, hbr) == NULL)
  690. {
  691. DeleteObject(hbr);
  692. goto Error;
  693. }
  694. SetBkMode(hDC, TRANSPARENT);
  695. #ifdef WIN30
  696. /* If the user has their colors set with a TextCaption color of
  697. black then this becomes hard to read! We just hardcode this
  698. to be white since the background defaults to being black */
  699. SetTextColor(hDC, (DWORD) -1);
  700. #else
  701. SetTextColor(hDC, GetSysColor(COLOR_CAPTIONTEXT));
  702. #endif
  703. /* Get the height and width of the scroll bars. */
  704. dypScrlBar = GetSystemMetrics(SM_CYHSCROLL);
  705. dxpScrlBar = GetSystemMetrics(SM_CXVSCROLL);
  706. /* Set the ranges of the horizontal and vertical scroll bars. */
  707. SetScrollRange(wwdCurrentDoc.hHScrBar, SB_CTL, 0, xpRightLim, TRUE);
  708. SetScrollRange(wwdCurrentDoc.hVScrBar, SB_CTL, 0, drMax - 1, TRUE);
  709. return;
  710. Error:
  711. fMessageInzFailed = TRUE;
  712. }
  713. void MdocCreate(hWnd, lParam)
  714. register HWND hWnd;
  715. LONG lParam;
  716. {
  717. vhWnd = wwdCurrentDoc.wwptr = hWnd;
  718. wwdCurrentDoc.hDC = GetDC( hWnd );
  719. if ( wwdCurrentDoc.hDC == NULL )
  720. {
  721. fMessageInzFailed = TRUE;
  722. return;
  723. }
  724. /* Set the DC to transparent mode. */
  725. SetBkMode( wwdCurrentDoc.hDC, TRANSPARENT );
  726. /* Set the background and foreground colors. */
  727. SetBkColor( wwdCurrentDoc.hDC, rgbBkgrnd );
  728. SetTextColor( wwdCurrentDoc.hDC, rgbText );
  729. /* Set the background brush. */
  730. SelectObject( wwdCurrentDoc.hDC, hbrBkgrnd );
  731. }
  732. STATIC HANDLE NEAR HszCreateIdpmt(idpmt)
  733. int idpmt;
  734. {
  735. /* Create a heap string and fill it with a string from the resource file. */
  736. char szTmp[cchMaxSz];
  737. return (LoadString(hMmwModInstance, idpmt, (LPSTR)szTmp, sizeof(szTmp)) == 0 ? NULL :
  738. HszGlobalCreate(szTmp));
  739. }
  740. #if defined(INTL) && defined(WIN30)
  741. /* Routine to load some strings from write.rc. These strings
  742. used to be placed in globdefs.h. fernandd 10/20/89 */
  743. BOOL FInitIntlStrings(hInstance)
  744. HANDLE hInstance;
  745. {
  746. extern CHAR szMode[30];
  747. extern CHAR szWriteDocPrompt[25];
  748. extern CHAR szScratchFilePrompt[25];
  749. extern CHAR szSaveFilePrompt[25];
  750. #if defined(KOREA) // jinwoo : 10/16/92
  751. extern CHAR szAppName[13];
  752. #else
  753. extern CHAR szAppName[10];
  754. #endif
  755. extern CHAR szUntitled[20];
  756. extern CHAR sziCountryDefault[5];
  757. extern CHAR szWRITEText[30];
  758. extern CHAR szFree[15];
  759. extern CHAR szNone[15];
  760. extern CHAR szHeader[15];
  761. extern CHAR szFooter[15];
  762. extern CHAR szLoadFile[25];
  763. extern CHAR szCvtLoadFile[45];
  764. extern CHAR szAltBS[15];
  765. extern CHAR *mputsz[];
  766. #ifdef JAPAN /*t-Yoshio T-HIROYN Win3.1 */
  767. extern CHAR Zenstr1[256];
  768. extern CHAR Zenstr2[256];
  769. // default Font Face Name . We use this FInitFontEnum()
  770. extern CHAR szDefFFN0[10];
  771. extern CHAR szDefFFN1[10];
  772. LoadString(hInstance, IDSTRZen1,(LPSTR)Zenstr1,sizeof(Zenstr1));
  773. LoadString(hInstance, IDSTRZen2,(LPSTR)Zenstr2,sizeof(Zenstr2));
  774. LoadString(hInstance, IDSdefaultFFN0, (LPSTR)szDefFFN0,sizeof(szDefFFN0));
  775. LoadString(hInstance, IDSdefaultFFN1, (LPSTR)szDefFFN1,sizeof(szDefFFN1));
  776. #elif defined(KOREA)
  777. extern CHAR Zenstr1[256];
  778. LoadString(hInstance, IDSTRZen1,(LPSTR)Zenstr1,sizeof(Zenstr1));
  779. #endif
  780. if (LoadString(hInstance, IDSTRModeDef, (LPSTR)szMode, sizeof(szMode)) &&
  781. LoadString(hInstance, IDSTRWriteDocPromptDef, (LPSTR)szWriteDocPrompt, sizeof(szWriteDocPrompt)) &&
  782. LoadString(hInstance, IDSTRScratchFilePromptDef, (LPSTR)szScratchFilePrompt, sizeof(szScratchFilePrompt)) &&
  783. LoadString(hInstance, IDSTRSaveFilePromptDef, (LPSTR)szSaveFilePrompt, sizeof(szSaveFilePrompt)) &&
  784. LoadString(hInstance, IDSTRAppNameDef, (LPSTR)szAppName, sizeof(szAppName)) &&
  785. LoadString(hInstance, IDSTRUntitledDef, (LPSTR)szUntitled, sizeof(szUntitled)) &&
  786. LoadString(hInstance, IDSTRiCountryDefaultDef, (LPSTR)sziCountryDefault, sizeof(sziCountryDefault)) &&
  787. LoadString(hInstance, IDSTRWRITETextDef, (LPSTR)szWRITEText, sizeof(szWRITEText)) &&
  788. LoadString(hInstance, IDSTRFreeDef, (LPSTR)szFree, sizeof(szFree)) &&
  789. LoadString(hInstance, IDSTRNoneDef, (LPSTR)szNone, sizeof(szNone)) &&
  790. LoadString(hInstance, IDSTRHeaderDef, (LPSTR)szHeader, sizeof(szHeader)))
  791. {
  792. if (LoadString(hInstance, IDSTRFooterDef, (LPSTR)szFooter, sizeof(szFooter)) &&
  793. LoadString(hInstance, IDSTRLoadFileDef, (LPSTR)szLoadFile, sizeof(szLoadFile)) &&
  794. LoadString(hInstance, IDSTRCvtLoadFileDef, (LPSTR)szCvtLoadFile, sizeof(szCvtLoadFile)) &&
  795. LoadString(hInstance, IDSTRAltBSDef, (LPSTR)szAltBS, sizeof(szAltBS)) &&
  796. LoadString(hInstance, IDSTRInchDef, (LPSTR)mputsz[0], 6) &&
  797. LoadString(hInstance, IDSTRCmDef, (LPSTR)mputsz[1], 6) &&
  798. LoadString(hInstance, IDSTRP10Def, (LPSTR)mputsz[2], 6) &&
  799. LoadString(hInstance, IDSTRP12Def, (LPSTR)mputsz[3], 6) &&
  800. LoadString(hInstance, IDSTRPointDef, (LPSTR)mputsz[4], 6) &&
  801. LoadString(hInstance, IDSTRLineDef, (LPSTR)mputsz[5], 6))
  802. return(fTrue);
  803. }
  804. /* else */
  805. return(fFalse);
  806. }
  807. #endif