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.

2874 lines
87 KiB

  1. // INCLUSION PREVENTION DEFINITIONS
  2. #define NOMETAFILE
  3. #define NOMINMAX
  4. #define NOSOUND
  5. #define NOPROFILER
  6. #define NODEFERWINDOWPOS
  7. #define NODRIVERS
  8. #define NOCOMM
  9. #define NOBITMAP
  10. #define NOSCROLL
  11. #define NOWINOFFSETS
  12. #define NOWH
  13. #define NORASTEROPS
  14. #define NOOEMRESOURCE
  15. #define NOGDICAPMASKS
  16. #define NOKEYSTATES
  17. #define NOSYSCOMMANDS
  18. #define NOATOM
  19. #define NOLOGERROR
  20. #define NOSYSTEMPARAMSINFO
  21. #include <windows.h>
  22. #ifdef RLWIN32
  23. #include <windowsx.h>
  24. #endif
  25. #include <commdlg.h>
  26. #include <shellapi.h>
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include "windefs.h"
  30. #include "toklist.h"
  31. #include "RLADMIN.H"
  32. #include "RESTOK.H"
  33. #include "update.h"
  34. #include "custres.h"
  35. #include "exe2res.h"
  36. #include "commbase.h"
  37. #include "wincomon.h"
  38. #include "projdata.h"
  39. #include "showerrs.h"
  40. #include "resread.h"
  41. #include "langlist.h"
  42. #include "resource.h"
  43. // Global Variables:
  44. extern BOOL gbMaster;
  45. extern MSTRDATA gMstr;
  46. extern PROJDATA gProj;
  47. extern UCHAR szDHW[];
  48. extern BOOL bRLGui;
  49. #ifdef WIN32
  50. HINSTANCE hInst; // Instance of the main window
  51. #else
  52. HWND hInst; // Instance of the main window
  53. #endif
  54. int nUpdateMode = 0;
  55. BOOL fCodePageGiven = FALSE; //... Set to TRUE if -p arg given
  56. CHAR szFileTitle[14] = ""; // holds base name of latest opened file
  57. CHAR szCustFilterSpec[MAXCUSTFILTER]=""; // custom filter buffer
  58. HWND hMainWnd = NULL; // handle to main window
  59. HWND hListWnd = NULL; // handle to tok list window
  60. HWND hStatusWnd = NULL; // handle to status windows
  61. static int iLastBox = IDD_SOURCERES;
  62. static CHAR * gszHelpFile = "rltools.hlp";
  63. static TCHAR szSearchType[80] = TEXT("");
  64. static TCHAR szSearchText[4096] = TEXT("");
  65. static WORD wSearchStatus = 0;
  66. static WORD wSearchStatusMask = 0;
  67. static BOOL fSearchDirection;
  68. static BOOL fSearchStarted = FALSE;
  69. static BOOL fLanguageGiven = FALSE;
  70. static BOOL fLangSelected = FALSE;
  71. static void DrawLBItem( LPDRAWITEMSTRUCT lpdis);
  72. static void MakeStatusLine( TOKEN *pTok);
  73. static BOOL SaveMtkList( HWND hWnd, FILE *fpTokFile);
  74. static TOKENDELTAINFO FAR *InsertMtkList( FILE * fpTokFile);
  75. static void CleanDeltaList( void);
  76. static long lFilePointer[30];
  77. // File IO vars
  78. static OPENFILENAMEA ofn;
  79. static CHAR szFilterSpec [60] = "";
  80. static CHAR szExeFilterSpec [60] = "";
  81. static CHAR szDllFilterSpec [60] = "";
  82. static CHAR szResFilterSpec [60] = "";
  83. static CHAR szExeResFilterSpec [180] = "";
  84. static CHAR szMtkFilterSpec [60] = "";
  85. static CHAR szMPJFilterSpec [60] = "";
  86. static CHAR szRdfFilterSpec [60] = "";
  87. static CHAR szFileName[MAXFILENAME] = "";// holds full name of latest opened file
  88. static TCHAR tszAppName[100] = TEXT("");
  89. static CHAR szAppName[100] = "";
  90. static TCHAR szClassName[]=TEXT("RLAdminClass");
  91. static TCHAR szStatusClass[]=TEXT("RLAdminStatus");
  92. static BOOL fMtkChanges = FALSE; // set to true when toke file is out of date
  93. static BOOL fMtkFile = FALSE;
  94. static BOOL fMpjChanges = FALSE;
  95. static BOOL fMPJOutOfDate = FALSE;
  96. static BOOL fPRJOutOfDate = FALSE;
  97. static CHAR szOpenDlgTitle[80] = ""; // title of File open dialog
  98. static CHAR szSaveDlgTitle[80] = ""; // title of File saveas dialog
  99. static CHAR szNewFileName[MAXFILENAME] = "";
  100. static CHAR szPrompt[80] = "";
  101. static CHAR *szFSpec = NULL;
  102. static CHAR *szExt = NULL;
  103. static TOKENDELTAINFO FAR *pTokenDeltaInfo; // linked list of token deta info
  104. // Window vars
  105. static HCURSOR hHourGlass = NULL; // handle to hourglass cursor
  106. static HCURSOR hSaveCursor = NULL; // current cursor handle
  107. static HACCEL hAccTable = NULL;
  108. static RECT Rect = {0,0,0,0}; // dimension of the client window
  109. static UINT cyChildHeight = 0; // height of status windows
  110. // NOTIMPLEMENTED is a macro that displays a "Not implemented" dialog
  111. #define NOTIMPLEMENTED {\
  112. LoadString(hInst,IDS_NOT_IMPLEMENTED,szDHW, DHWSIZE);\
  113. MessageBox(hMainWnd,szDHW,tszAppName,MB_ICONEXCLAMATION | MB_OK);}
  114. // Edit Tok Dialog
  115. static FARPROC lpTokEditDlg = NULL;
  116. static HWND hTokEditDlgWnd = 0;
  117. /**
  118. *
  119. *
  120. * Function: InitApplication
  121. * Regsiters the main window, which is a list box composed of tokens
  122. * read from the token file. Also register the status window.
  123. *
  124. *
  125. * Arguments:
  126. * hInstance, instance handle of program in memory.
  127. *
  128. * Returns:
  129. *
  130. * Errors Codes:
  131. * TRUE, windows registered correctly.
  132. * FALSE, error during register of one of the windows.
  133. *
  134. * History:
  135. * 9/91, Implemented. TerryRu
  136. *
  137. *
  138. **/
  139. BOOL InitApplication(HINSTANCE hInstance)
  140. {
  141. WNDCLASS wc;
  142. CHAR sz[60] = "";
  143. CHAR sztFilterSpec[180] = "";
  144. gbMaster=TRUE;
  145. LoadStrIntoAnsiBuf(hInstance,IDS_RESSPEC,sz,sizeof(sz));
  146. szFilterSpecFromSz1Sz2(szResFilterSpec,sz,"*.RES");
  147. LoadStrIntoAnsiBuf(hInstance,IDS_EXESPEC,sz,sizeof(sz));
  148. szFilterSpecFromSz1Sz2(szExeFilterSpec,sz,"*.EXE");
  149. LoadStrIntoAnsiBuf(hInstance,IDS_DLLSPEC,sz,sizeof(sz));
  150. szFilterSpecFromSz1Sz2(szDllFilterSpec,sz,"*.DLL");
  151. CatSzFilterSpecs(sztFilterSpec,szExeFilterSpec,szDllFilterSpec);
  152. CatSzFilterSpecs(szExeResFilterSpec,sztFilterSpec,szResFilterSpec);
  153. LoadStrIntoAnsiBuf(hInstance,IDS_MTKSPEC,sz,sizeof(sz));
  154. szFilterSpecFromSz1Sz2(szMtkFilterSpec,sz,"*.MTK");
  155. LoadStrIntoAnsiBuf(hInstance,IDS_RDFSPEC,sz,sizeof(sz));
  156. szFilterSpecFromSz1Sz2(szRdfFilterSpec,sz,"*.RDF");
  157. LoadStrIntoAnsiBuf(hInstance,IDS_MPJSPEC,sz,sizeof(sz));
  158. szFilterSpecFromSz1Sz2(szMPJFilterSpec,sz,"*.MPJ");
  159. szFilterSpecFromSz1Sz2(szFilterSpec,sz,"*.MPJ");
  160. LoadStrIntoAnsiBuf(hInstance,
  161. IDS_OPENTITLE,
  162. szOpenDlgTitle,
  163. sizeof(szOpenDlgTitle));
  164. LoadStrIntoAnsiBuf(hInstance,
  165. IDS_SAVETITLE,
  166. szSaveDlgTitle,
  167. sizeof(szSaveDlgTitle));
  168. wc.style = 0;
  169. wc.lpfnWndProc = StatusWndProc;
  170. wc.cbClsExtra = 0;
  171. wc.cbWndExtra = 0;
  172. wc.hInstance = hInstance;
  173. wc.hIcon = LoadIcon((HINSTANCE) NULL, IDI_APPLICATION);
  174. wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
  175. wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
  176. wc.lpszMenuName = NULL;
  177. wc.lpszClassName = szStatusClass;
  178. if (! RegisterClass( (CONST WNDCLASS *)&wc))
  179. {
  180. return (FALSE);
  181. }
  182. wc.style = 0;
  183. wc.lpfnWndProc = MainWndProc;
  184. wc.cbClsExtra = 0;
  185. wc.cbWndExtra = 0;
  186. wc.hInstance = hInstance;
  187. wc.hIcon = LoadIcon(hInstance,TEXT("RLAdminIcon"));
  188. wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
  189. wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  190. wc.lpszMenuName = TEXT("RLAdmin");
  191. wc.lpszClassName = szClassName;
  192. return( RegisterClass( (CONST WNDCLASS *)&wc) ? TRUE : FALSE);
  193. }
  194. /**
  195. *
  196. *
  197. * Function: InitInstance
  198. * Creates the main, and status windows for the program.
  199. * The status window is sized according to the main window
  200. * size. InitInstance also loads the acclerator table, and prepares
  201. * the global openfilename structure for later use.
  202. *
  203. *
  204. * Errors Codes:
  205. * TRUE, windows created correctly.
  206. * FALSE, error on create windows calls.
  207. *
  208. * History:
  209. * 9/11, Implemented TerryRu
  210. *
  211. *
  212. **/
  213. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  214. {
  215. RECT Rect;
  216. hAccTable = LoadAccelerators(hInst, TEXT("RLAdmin"));
  217. hMainWnd = CreateWindow( szClassName,
  218. tszAppName,
  219. WS_OVERLAPPEDWINDOW,
  220. CW_USEDEFAULT,
  221. CW_USEDEFAULT,
  222. CW_USEDEFAULT,
  223. CW_USEDEFAULT,
  224. (HWND) NULL,
  225. (HMENU) NULL,
  226. (HINSTANCE)hInstance,
  227. (LPVOID) NULL);
  228. if ( ! hMainWnd )
  229. {
  230. return( FALSE);
  231. }
  232. DragAcceptFiles(hMainWnd, TRUE);
  233. GetClientRect(hMainWnd, (LPRECT) &Rect);
  234. // Create a child list box window
  235. hListWnd = CreateWindow( TEXT("LISTBOX"),
  236. NULL,
  237. WS_CHILD |
  238. LBS_WANTKEYBOARDINPUT |
  239. LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_OWNERDRAWFIXED |
  240. WS_VSCROLL | WS_HSCROLL | WS_BORDER ,
  241. 0,
  242. 0,
  243. (Rect.right-Rect.left),
  244. (Rect.bottom-Rect.top),
  245. hMainWnd,
  246. (HMENU)IDC_LIST, // Child control i.d.
  247. hInstance,
  248. NULL);
  249. if ( ! hListWnd )
  250. {
  251. DeleteObject((HGDIOBJ)hMainWnd);
  252. return( FALSE);
  253. }
  254. // Creat a child status window
  255. hStatusWnd = CreateWindow( szStatusClass,
  256. NULL,
  257. WS_CHILD | WS_BORDER | WS_VISIBLE,
  258. 0, 0, 0, 0,
  259. hMainWnd,
  260. NULL,
  261. hInst,
  262. NULL);
  263. if ( ! hStatusWnd )
  264. { // clean up after errors.
  265. DeleteObject((HGDIOBJ)hListWnd);
  266. DeleteObject((HGDIOBJ)hMainWnd);
  267. return( FALSE);
  268. }
  269. hHourGlass = LoadCursor( (HINSTANCE) NULL, IDC_WAIT);
  270. // Fill in non-variant fields of OPENFILENAMEA struct.
  271. ofn.lStructSize = sizeof( OPENFILENAMEA);
  272. ofn.hwndOwner = hMainWnd;
  273. ofn.lpstrFilter = szFilterSpec;
  274. ofn.lpstrCustomFilter = szCustFilterSpec;
  275. ofn.nMaxCustFilter = MAXCUSTFILTER;
  276. ofn.nFilterIndex = 1;
  277. ofn.lpstrFile = szFileName;
  278. ofn.nMaxFile = MAXFILENAME;
  279. ofn.lpstrInitialDir = NULL;
  280. ofn.lpstrFileTitle = szFileTitle;
  281. ofn.nMaxFileTitle = MAXFILENAME;
  282. ofn.lpstrTitle = NULL;
  283. ofn.lpstrDefExt = "MPJ";
  284. ofn.Flags = 0;
  285. GetLangList();
  286. ShowWindow(hMainWnd, nCmdShow);
  287. UpdateWindow(hMainWnd);
  288. return TRUE;
  289. }
  290. /**
  291. *
  292. *
  293. * Function: WinMain
  294. * Calls the intialization functions, to register, and create the
  295. * application windows. Once the windows are created, the program
  296. * enters the GetMessage loop.
  297. *
  298. *
  299. * Arguements:
  300. * hInstace, handle for this instance
  301. * hPrevInstanc, handle for possible previous instances
  302. * lpszCmdLine, long pointer to exec command line.
  303. * nCmdShow, code for main window display.
  304. *
  305. *
  306. * Errors Codes:
  307. * IDS_ERR_REGISTER_CLASS, error on windows register
  308. * IDS_ERR_CREATE_WINDOW, error on create windows
  309. * otherwise, status of last command.
  310. *
  311. * History:
  312. *
  313. *
  314. **/
  315. INT WINAPI WinMain(
  316. HINSTANCE hInstance,
  317. HINSTANCE hPrevInstance,
  318. LPSTR lpszCmdLine,
  319. int nCmdShow)
  320. {
  321. MSG msg;
  322. HWND FirstWnd = NULL;
  323. HWND FirstChildWnd = NULL;
  324. static TCHAR szString[256] = TEXT("");
  325. hInst = hInstance;
  326. bRLGui = TRUE;
  327. if ( FirstWnd = FindWindow( szClassName,NULL) )
  328. {
  329. // checking for previous instance
  330. FirstChildWnd = GetLastActivePopup( FirstWnd);
  331. BringWindowToTop( FirstWnd);
  332. ShowWindow( FirstWnd, SW_SHOWNORMAL);
  333. if ( FirstWnd != FirstChildWnd )
  334. {
  335. BringWindowToTop( FirstChildWnd);
  336. }
  337. return( FALSE);
  338. }
  339. GetModuleFileNameA( hInst, szDHW, DHWSIZE);
  340. GetInternalName( szDHW, szAppName, ACHARSIN( sizeof( szAppName)));
  341. szFileName[0] = '\0';
  342. lFilePointer[0] = (LONG)-1;
  343. #ifdef UNICODE
  344. _MBSTOWCS( tszAppName,
  345. szAppName,
  346. WCHARSIN( sizeof( tszAppName)),
  347. ACHARSIN( strlen( szAppName) + 1));
  348. #else
  349. strcpy( tszAppName, szAppName);
  350. #endif
  351. // register window classes if first instance of application
  352. if ( ! hPrevInstance )
  353. {
  354. if ( ! InitApplication( hInstance) )
  355. {
  356. /* Registering one of the windows failed */
  357. LoadString( hInst,
  358. IDS_ERR_REGISTER_CLASS,
  359. szString,
  360. TCHARSIN( sizeof( szString)));
  361. MessageBox( NULL, szString, NULL, MB_ICONEXCLAMATION);
  362. return( IDS_ERR_REGISTER_CLASS);
  363. }
  364. }
  365. // Create windows for this instance of application
  366. if ( ! InitInstance( hInstance, nCmdShow) )
  367. {
  368. LoadString( hInst,
  369. IDS_ERR_CREATE_WINDOW,
  370. szString,
  371. TCHARSIN( sizeof( szString)));
  372. MessageBox( NULL, szString, NULL, MB_ICONEXCLAMATION);
  373. return( IDS_ERR_CREATE_WINDOW);
  374. }
  375. // Main Message Loop
  376. while ( GetMessage( &msg, (HWND)NULL, 0, 0) )
  377. {
  378. if ( hTokEditDlgWnd )
  379. {
  380. if ( IsDialogMessage( hTokEditDlgWnd, &msg) )
  381. {
  382. continue;
  383. }
  384. }
  385. if ( TranslateAccelerator( hMainWnd, hAccTable, &msg) )
  386. {
  387. continue;
  388. }
  389. TranslateMessage( (CONST MSG *)&msg);
  390. DispatchMessage( (CONST MSG *)&msg);
  391. }
  392. return( (INT)msg.wParam);
  393. }
  394. /**
  395. *
  396. *
  397. * Function: MainWndProc
  398. * Process the windows messages for the main window of the application.
  399. * All user inputs go through this window procedure.
  400. * See cases in the switch table for a description of each message type.
  401. *
  402. *
  403. * Arguments:
  404. *
  405. * Returns:
  406. *
  407. * Errors Codes:
  408. *
  409. * History:
  410. *
  411. *
  412. **/
  413. INT_PTR APIENTRY MainWndProc(
  414. HWND hWnd,
  415. UINT wMsg,
  416. WPARAM wParam,
  417. LPARAM lParam)
  418. {
  419. DoListBoxCommand (hWnd, wMsg, wParam, lParam);
  420. switch (wMsg)
  421. {
  422. case WM_DROPFILES:
  423. {
  424. #ifndef CAIRO
  425. DragQueryFileA((HDROP)wParam, 0, szDHW, MAXFILENAME);
  426. #else
  427. DragQueryFile((HDROP)wParam, 0, szDHW, MAXFILENAME);
  428. #endif
  429. MessageBoxA( hWnd, szDHW, szAppName, MB_OK);
  430. if ( SendMessage( hWnd, WM_SAVEPROJECT, (WPARAM)0, (LPARAM)0) )
  431. {
  432. if ( GetMasterProjectData( gProj.szMpj,
  433. NULL,
  434. NULL,
  435. FALSE) == SUCCESS )
  436. {
  437. sprintf( szDHW, "%s - %s", szAppName, gProj.szMpj);
  438. SetWindowTextA( hMainWnd, szDHW);
  439. SendMessage( hMainWnd, WM_LOADTOKENS, (WPARAM)0, (LPARAM)0);
  440. }
  441. }
  442. DragFinish((HDROP)wParam);
  443. return( TRUE);
  444. }
  445. case WM_COMMAND:
  446. if ( DoMenuCommand( hWnd, wMsg, wParam, lParam) )
  447. {
  448. return( TRUE);
  449. }
  450. break;
  451. case WM_CLOSE:
  452. SendMessage( hWnd, WM_SAVEPROJECT, (WPARAM)0, (LPARAM)0);
  453. DestroyWindow( hMainWnd);
  454. DestroyWindow( hListWnd);
  455. DestroyWindow( hStatusWnd);
  456. _fcloseall();
  457. FreeLangList();
  458. #ifdef _DEBUG
  459. {
  460. FILE *pLeakList = fopen( "C:\\LEAKLIST.TXT", "wt");
  461. FreeMemList( pLeakList);
  462. fclose( pLeakList);
  463. }
  464. #endif // _DEBUG
  465. break;
  466. case WM_CREATE:
  467. {
  468. HDC hdc;
  469. int cyBorder;
  470. TEXTMETRIC tm;
  471. hdc = GetDC (hWnd);
  472. GetTextMetrics(hdc, &tm);
  473. ReleaseDC(hWnd, hdc);
  474. cyBorder = GetSystemMetrics(SM_CYBORDER);
  475. cyChildHeight = tm.tmHeight + 6 + cyBorder * 2;
  476. break;
  477. }
  478. case WM_DESTROY:
  479. WinHelpA( hWnd, gszHelpFile, HELP_QUIT, 0L);
  480. DragAcceptFiles( hMainWnd, FALSE);
  481. PostQuitMessage( 0);
  482. break;
  483. case WM_INITMENU:
  484. // Enable or Disable the Paste menu item
  485. // based on available Clipboard Text data
  486. if ( wParam == (WPARAM)GetMenu( hMainWnd) )
  487. {
  488. if ( OpenClipboard( hWnd))
  489. {
  490. #if defined(UNICODE)
  491. if ((IsClipboardFormatAvailable(CF_UNICODETEXT) ||
  492. IsClipboardFormatAvailable(CF_OEMTEXT)) &&
  493. fMtkFile)
  494. #else // not UNICODE
  495. if ((IsClipboardFormatAvailable(CF_TEXT) ||
  496. IsClipboardFormatAvailable(CF_OEMTEXT)) &&
  497. fMtkFile)
  498. #endif // UNICODE
  499. {
  500. EnableMenuItem((HMENU) wParam, IDM_E_PASTE, MF_ENABLED);
  501. }
  502. else
  503. {
  504. EnableMenuItem((HMENU) wParam, IDM_E_PASTE, MF_GRAYED);
  505. }
  506. CloseClipboard();
  507. return (TRUE);
  508. }
  509. }
  510. break;
  511. case WM_QUERYENDSESSION:
  512. /* message: to end the session? */
  513. if ( SendMessage( hWnd, WM_SAVEPROJECT, (WPARAM)0, (LPARAM)0) )
  514. {
  515. return TRUE;
  516. }
  517. else
  518. {
  519. return FALSE;
  520. }
  521. case WM_SETFOCUS:
  522. SetFocus (hListWnd);
  523. break;
  524. case WM_DRAWITEM:
  525. DrawLBItem((LPDRAWITEMSTRUCT) lParam);
  526. break;
  527. case WM_DELETEITEM:
  528. GlobalFree((HGLOBAL) ((LPDELETEITEMSTRUCT) lParam)->itemData);
  529. break;
  530. case WM_SIZE:
  531. {
  532. int cxWidth;
  533. int cyHeight;
  534. int xChild;
  535. int yChild;
  536. cxWidth = LOWORD(lParam);
  537. cyHeight = HIWORD(lParam);
  538. xChild = 0;
  539. yChild = cyHeight - cyChildHeight + 1;
  540. MoveWindow(hListWnd, 0, 0, cxWidth, yChild , TRUE);
  541. MoveWindow(hStatusWnd, xChild, yChild, cxWidth, cyChildHeight, TRUE);
  542. break;
  543. }
  544. case WM_LOADTOKENS:
  545. {
  546. HMENU hMenu = NULL;
  547. FILE *f = NULL;
  548. OFSTRUCT Of = { 0, 0, 0, 0, 0, ""};
  549. // Remove the current token list
  550. SendMessage( hListWnd, LB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
  551. CleanDeltaList();
  552. // Hide token list, while we add new tokens
  553. ShowWindow(hListWnd, SW_HIDE);
  554. if ( OpenFile( gMstr.szMtk, &Of, OF_EXIST) == HFILE_ERROR )
  555. {
  556. // file doesn't exist, create it
  557. BOOL bUpdate;
  558. HCURSOR hOldCursor;
  559. hOldCursor = SetCursor(hHourGlass);
  560. LoadCustResDescriptions(gMstr.szRdfs);
  561. GenerateTokFile(gMstr.szMtk,
  562. gMstr.szSrc,
  563. &bUpdate, 0);
  564. SetCursor(hOldCursor);
  565. ClearResourceDescriptions();
  566. SzDateFromFileName( gMstr.szSrcDate, gMstr.szSrc);
  567. SzDateFromFileName( gMstr.szMpjLastRealUpdate, gMstr.szMtk);
  568. fMpjChanges = TRUE;
  569. fMPJOutOfDate = FALSE;
  570. }
  571. SzDateFromFileName( szDHW, gMstr.szSrc);
  572. if ( lstrcmpA( szDHW, gMstr.szSrcDate) )
  573. {
  574. HCURSOR hOldCursor;
  575. BOOL bUpdate;
  576. // MPJ is not up to date
  577. fMPJOutOfDate = TRUE;
  578. hOldCursor = SetCursor( hHourGlass);
  579. LoadCustResDescriptions( gMstr.szRdfs);
  580. GenerateTokFile( gMstr.szMtk,
  581. gMstr.szSrc,
  582. &bUpdate, 0);
  583. if ( bUpdate )
  584. {
  585. SzDateFromFileName( gMstr.szMpjLastRealUpdate,
  586. gMstr.szMtk);
  587. }
  588. ClearResourceDescriptions();
  589. SzDateFromFileName(gMstr.szSrcDate,
  590. gMstr.szSrc);
  591. fMpjChanges = TRUE;
  592. fMPJOutOfDate = FALSE;
  593. SetCursor(hOldCursor);
  594. }
  595. else
  596. {
  597. fMPJOutOfDate = FALSE;
  598. }
  599. if ( f = fopen(gMstr.szMtk,"rt") )
  600. {
  601. HCURSOR hOldCursor;
  602. hOldCursor = SetCursor(hHourGlass);
  603. // Insert tokens from token file into the list box
  604. pTokenDeltaInfo = InsertMtkList(f);
  605. FCLOSE(f);
  606. // Make list box visible
  607. ShowWindow(hListWnd, SW_SHOW);
  608. hMenu=GetMenu(hWnd);
  609. EnableMenuItem(hMenu, IDM_P_CLOSE, MF_ENABLED|MF_BYCOMMAND);
  610. EnableMenuItem(hMenu, IDM_P_VIEW, MF_ENABLED|MF_BYCOMMAND);
  611. EnableMenuItem(hMenu, IDM_E_FIND, MF_ENABLED|MF_BYCOMMAND);
  612. EnableMenuItem(hMenu, IDM_E_FINDUP, MF_ENABLED|MF_BYCOMMAND);
  613. EnableMenuItem(hMenu, IDM_E_FINDDOWN, MF_ENABLED|MF_BYCOMMAND);
  614. EnableMenuItem(hMenu, IDM_E_REVIEW, MF_ENABLED|MF_BYCOMMAND);
  615. EnableMenuItem(hMenu, IDM_E_COPY, MF_ENABLED|MF_BYCOMMAND);
  616. EnableMenuItem(hMenu, IDM_E_COPYTOKEN, MF_ENABLED|MF_BYCOMMAND);
  617. EnableMenuItem(hMenu, IDM_E_PASTE, MF_ENABLED|MF_BYCOMMAND);
  618. fMtkFile = TRUE;
  619. fMtkChanges = FALSE;
  620. SetCursor(hOldCursor);
  621. }
  622. break;
  623. }
  624. case WM_SAVEPROJECT:
  625. {
  626. fMtkFile = FALSE;
  627. if ( fMtkChanges )
  628. {
  629. FILE *f = NULL;
  630. if ( (f = fopen( gMstr.szMtk, "wt")) )
  631. {
  632. SaveMtkList( hWnd,f);
  633. FCLOSE(f);
  634. SzDateFromFileName( gMstr.szMpjLastRealUpdate,
  635. gMstr.szMtk);
  636. fMtkChanges = FALSE;
  637. fMpjChanges = TRUE;
  638. }
  639. else
  640. {
  641. LoadStrIntoAnsiBuf(hInst, IDS_FILESAVEERR, szDHW, DHWSIZE);
  642. MessageBoxA( hWnd,
  643. szDHW,
  644. gMstr.szMtk,
  645. MB_ICONHAND | MB_OK);
  646. return FALSE;
  647. }
  648. }
  649. if ( fMpjChanges )
  650. {
  651. if ( PutMasterProjectData( gProj.szMpj) != SUCCESS )
  652. {
  653. LoadStrIntoAnsiBuf(hInst, IDS_FILESAVEERR, szDHW, DHWSIZE);
  654. MessageBoxA(hWnd, szDHW,gProj.szMpj, MB_ICONHAND | MB_OK);
  655. return FALSE;
  656. }
  657. fMpjChanges = FALSE;
  658. }
  659. return TRUE; // everything saved ok
  660. }
  661. default:
  662. break;
  663. }
  664. return (DefWindowProc(hWnd, wMsg, wParam, lParam));
  665. }
  666. /**
  667. *
  668. *
  669. * Function: DoListBoxCommand
  670. * Processes the messages sent to the list box. If the message is
  671. * not reconized as a list box message, it is ignored and not processed.
  672. * As the user scrolls through the tokens WM_UPDSTATLINE messages are
  673. * sent to the status window to indicate the current selected token.
  674. * The list box goes into Edit Mode by pressing the enter key, or
  675. * by double clicking on the list box. After the edit is done, a WM_TOKEDIT
  676. * message is sent back to the list box to update the token. The
  677. * list box uses control ID IDC_LIST.
  678. *
  679. *
  680. *
  681. * Arguments:
  682. * wMsg List Box message ID
  683. * wParam Either IDC_LIST, or VK_RETURN depending on wMsg
  684. * lParam LPTSTR to selected token during WM_TOKEDIT message.
  685. *
  686. * Returns:
  687. *
  688. *
  689. * Errors Codes:
  690. * TRUE. Message processed.
  691. * FALSE. Message not processed.
  692. *
  693. * History:
  694. * 01/92 Implemented. TerryRu.
  695. * 01/92 Fixed problem with DblClick, and Enter processing. TerryRu.
  696. *
  697. *
  698. **/
  699. INT_PTR DoListBoxCommand(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
  700. {
  701. TOKEN tok; // struct for token read from token list
  702. TCHAR szName[32] = TEXT(""); // buffer to hold token name
  703. CHAR szTmpBuf[64] = "";
  704. TCHAR szID[14] = TEXT(""); // buffer to hold token id
  705. TCHAR sz[512] = TEXT(""); // buffer to hold messages
  706. static UINT wIndex= 0;
  707. LONG lListParam = 0L;
  708. HWND hCtl = NULL;
  709. LPTSTR lpstrToken = NULL;
  710. HGLOBAL hMem = NULL;
  711. // this is the WM_COMMAND
  712. switch (wMsg)
  713. {
  714. case WM_TOKEDIT:
  715. {
  716. WORD wReservedOld;
  717. TCHAR *szBuffer;
  718. // Message sent by TokEditDlgProc to
  719. // indicate change in the token text.
  720. // Response to the message by inserting
  721. // new token text into list box
  722. // Insert the selected token into token struct
  723. hMem = (HGLOBAL)SendMessage( hListWnd,
  724. LB_GETITEMDATA,
  725. (WPARAM)wIndex,
  726. (LPARAM)0);
  727. lpstrToken = (LPTSTR)GlobalLock( hMem);
  728. szBuffer = (TCHAR *)FALLOC( MEMSIZE( lstrlen( lpstrToken) + 1));
  729. lstrcpy( szBuffer, lpstrToken);
  730. GlobalUnlock( hMem);
  731. ParseBufToTok(szBuffer, &tok);
  732. RLFREE( szBuffer);
  733. wReservedOld = tok.wReserved;
  734. switch (LOWORD(wParam))
  735. {
  736. case 0:
  737. tok.wReserved = 0;
  738. break;
  739. case 1:
  740. tok.wReserved = ST_CHANGED|ST_NEW;
  741. break;
  742. case 2:
  743. tok.wReserved = ST_NEW;
  744. break;
  745. case 3:
  746. tok.wReserved = ST_READONLY;
  747. break;
  748. }
  749. if (wReservedOld != tok.wReserved)
  750. {
  751. fMtkChanges = TRUE;
  752. }
  753. szBuffer = (TCHAR *)FALLOC( MEMSIZE( TokenToTextSize( &tok)));
  754. ParseTokToBuf( szBuffer, &tok);
  755. RLFREE( tok.szText);
  756. SendMessage( hListWnd, WM_SETREDRAW, (WPARAM)FALSE, (LPARAM)0);
  757. // Now remove old token
  758. SendMessage( hListWnd, LB_DELETESTRING, (WPARAM)wIndex, (LPARAM)0);
  759. // Replacing with the new token
  760. hMem = GlobalAlloc( GMEM_ZEROINIT, MEMSIZE( lstrlen( szBuffer) + 1));
  761. lpstrToken = (LPTSTR)GlobalLock( hMem);
  762. lstrcpy( lpstrToken, szBuffer);
  763. GlobalUnlock( hMem);
  764. SendMessage( hListWnd,
  765. LB_INSERTSTRING,
  766. (WPARAM)wIndex,
  767. (LPARAM)hMem);
  768. RLFREE( szBuffer);
  769. // Now put focus back on the current string
  770. SendMessage( hListWnd, LB_SETCURSEL, (WPARAM)wIndex, (LPARAM)0);
  771. SendMessage( hListWnd, WM_SETREDRAW, (WPARAM)TRUE, (LPARAM)0);
  772. InvalidateRect( hListWnd, NULL, TRUE);
  773. return TRUE;
  774. }
  775. case WM_CHARTOITEM:
  776. case WM_VKEYTOITEM:
  777. {
  778. #ifdef RLWIN16
  779. LONG lListParam = 0;
  780. #endif
  781. UINT wListParam = 0;
  782. // Messages sent to list box when keys are depressed.
  783. // Check for Return key pressed.
  784. switch(GET_WM_COMMAND_ID(wParam, lParam))
  785. {
  786. case VK_RETURN:
  787. #ifdef RLWIN16
  788. lListParam = (LONG) MAKELONG(NULL, LBN_DBLCLK);
  789. SendMessage( hMainWnd,
  790. WM_COMMAND,
  791. (WPARAM)IDC_LIST,
  792. (LPARAM)lListParam);
  793. #else
  794. SendMessage( hMainWnd,
  795. WM_COMMAND,
  796. MAKEWPARAM( IDC_LIST, LBN_DBLCLK),
  797. (LPARAM)0);
  798. #endif
  799. default:
  800. break;
  801. }
  802. break;
  803. }
  804. case WM_COMMAND:
  805. switch (GET_WM_COMMAND_ID(wParam, lParam))
  806. {
  807. case IDC_LIST:
  808. /*
  809. *
  810. * This is where we process the list box messages.
  811. * The TokEditDlgProc is used to
  812. * edit the token selected in LBS_DBLCLK message
  813. *
  814. */
  815. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  816. {
  817. case (UINT) LBN_ERRSPACE:
  818. LoadString( hInst,
  819. IDS_ERR_NO_MEMORY,
  820. sz,
  821. TCHARSIN( sizeof( sz)));
  822. MessageBox ( hWnd,
  823. sz,
  824. tszAppName,
  825. MB_ICONHAND | MB_OK);
  826. return TRUE;
  827. case LBN_DBLCLK:
  828. {
  829. TCHAR szResIDStr[20] = TEXT("");
  830. LPTSTR lpstrToken;
  831. TCHAR *szBuffer;
  832. wIndex = (UINT)SendMessage( hListWnd,
  833. LB_GETCURSEL,
  834. (WPARAM)0,
  835. (LPARAM)0);
  836. if (wIndex == (UINT) -1)
  837. {
  838. return TRUE;
  839. }
  840. // double click, or Return entered, go into token edit mode.
  841. if (!hTokEditDlgWnd)
  842. {
  843. // set up modaless dialog box to edit token
  844. #ifdef RLWIN32
  845. hTokEditDlgWnd = CreateDialog(hInst,
  846. TEXT("RLAdmin"),
  847. hWnd,
  848. TokEditDlgProc);
  849. #else
  850. lpTokEditDlg = (FARPROC) MakeProcInstance(TokEditDlgProc,
  851. hInst);
  852. hTokEditDlgWnd = CreateDialog(hInst,
  853. TEXT("RLAdmin"),
  854. hWnd,
  855. lpTokEditDlg);
  856. #endif
  857. }
  858. // Get token info from listbox, and place in token struct
  859. hMem = (HGLOBAL)SendMessage( hListWnd,
  860. LB_GETITEMDATA,
  861. (WPARAM)wIndex,
  862. (LPARAM)0);
  863. lpstrToken = (LPTSTR)GlobalLock( hMem);
  864. szBuffer = (LPTSTR)FALLOC( MEMSIZE( lstrlen( lpstrToken) + 1));
  865. lstrcpy( szBuffer, lpstrToken);
  866. GlobalUnlock( hMem);
  867. ParseBufToTok(szBuffer, &tok);
  868. RLFREE( szBuffer);
  869. // Now get the token name
  870. // Its either a string, or ordinal number
  871. if (tok.szName[0])
  872. {
  873. lstrcpy(szName, tok.szName);
  874. }
  875. else
  876. {
  877. #ifdef UNICODE
  878. _itoa( tok.wName, szTmpBuf, 10);
  879. _MBSTOWCS( szName,
  880. szTmpBuf,
  881. WCHARSIN( sizeof( szName)),
  882. ACHARSIN( strlen( szTmpBuf) + 1));
  883. #else
  884. _itoa(tok.wName, szName, 10);
  885. #endif
  886. }
  887. // Now get the token id
  888. #ifdef UNICODE
  889. _itoa( tok.wID, szTmpBuf, 10);
  890. _MBSTOWCS( szID,
  891. szTmpBuf,
  892. WCHARSIN( sizeof( szID)),
  893. ACHARSIN( strlen( szTmpBuf) + 1));
  894. #else
  895. _itoa( tok.wID, szID, 10);
  896. #endif
  897. if ( tok.wType <= 16 || tok.wType == ID_RT_DLGINIT )
  898. {
  899. LoadString( hInst,
  900. IDS_RESOURCENAMES+tok.wType,
  901. szResIDStr,
  902. TCHARSIN( sizeof( szResIDStr)));
  903. }
  904. else
  905. {
  906. #ifdef UNICODE
  907. _itoa( tok.wType, szTmpBuf, 10);
  908. _MBSTOWCS( szResIDStr,
  909. szTmpBuf,
  910. WCHARSIN( sizeof( szResIDStr)),
  911. ACHARSIN( strlen( szTmpBuf) + 1));
  912. #else
  913. _itoa( tok.wType, szResIDStr, 10);
  914. #endif
  915. }
  916. // Now insert token info in TokEdit Dialog Box
  917. SetDlgItemText(hTokEditDlgWnd,
  918. IDD_TOKTYPE,
  919. (LPTSTR) szResIDStr);
  920. SetDlgItemText(hTokEditDlgWnd,
  921. IDD_TOKNAME,
  922. (LPTSTR) szName);
  923. SetDlgItemText(hTokEditDlgWnd,
  924. IDD_TOKID,
  925. (LPTSTR) szID);
  926. SetDlgItemText(hTokEditDlgWnd,
  927. IDD_TOKCURTEXT,
  928. (LPTSTR) tok.szText);
  929. SetDlgItemText(hTokEditDlgWnd,
  930. IDD_TOKPREVTEXT,
  931. (LPTSTR) FindDeltaToken(tok,
  932. pTokenDeltaInfo,
  933. ST_CHANGED));
  934. hCtl = GetDlgItem(hTokEditDlgWnd,IDD_STATUS);
  935. {
  936. int i;
  937. if (tok.wReserved & ST_READONLY)
  938. {
  939. i = 3;
  940. }
  941. else if (tok.wReserved == ST_NEW)
  942. {
  943. i = 2;
  944. }
  945. else if (tok.wReserved & ST_CHANGED)
  946. {
  947. i = 1;
  948. }
  949. else
  950. {
  951. i = 0;
  952. }
  953. SendMessage( hCtl, CB_SETCURSEL, (WPARAM)i, (LPARAM)0);
  954. }
  955. SetActiveWindow(hTokEditDlgWnd);
  956. wIndex = (UINT)SendMessage( hListWnd,
  957. LB_GETCURSEL,
  958. (WPARAM)0,
  959. (LPARAM)0);
  960. RLFREE( tok.szText);
  961. return TRUE;
  962. }
  963. // let these messages fall through,
  964. default:
  965. break;
  966. }
  967. default:
  968. return FALSE;
  969. }
  970. break; // WM_COMMAND Case
  971. } // Main List Box Switch
  972. return FALSE;
  973. }
  974. /**
  975. *
  976. *
  977. * Function: DoMenuCommand.
  978. * Processes the Menu Command messages.
  979. *
  980. * Errors Codes:
  981. * TRUE. Message processed.
  982. * FALSE. Message not processed.
  983. *
  984. * History:
  985. * 01/92. Implemented. TerryRu.
  986. *
  987. *
  988. **/
  989. INT_PTR DoMenuCommand(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
  990. {
  991. static BOOL fListBox = FALSE;
  992. CHAR sz[256]="";
  993. TCHAR tsz[256] = TEXT("");
  994. #ifndef RLWIN32
  995. FARPROC lpNewDlg,lpViewDlg;
  996. #endif
  997. // Commands entered from the application menu, or child windows.
  998. switch (GET_WM_COMMAND_ID(wParam, lParam))
  999. {
  1000. case IDM_P_NEW:
  1001. if ( SendMessage( hWnd, WM_SAVEPROJECT, (WPARAM)0, (LPARAM)0) )
  1002. {
  1003. CHAR szOldFile[MAXFILENAME] = "";
  1004. strcpy( szOldFile, szFileName);
  1005. if ( ! GetFileNameFromBrowse( hWnd,
  1006. szFileName,
  1007. MAXFILENAME,
  1008. szSaveDlgTitle,
  1009. szFilterSpec,
  1010. "MPJ"))
  1011. {
  1012. break;
  1013. }
  1014. strcpy( gProj.szMpj, szFileName);
  1015. #ifdef RLWIN32
  1016. if (DialogBox(hInst, TEXT("PROJECT"), hWnd, NewDlgProc))
  1017. #else
  1018. lpNewDlg = MakeProcInstance( NewDlgProc, hInst);
  1019. if (DialogBox(hInst, TEXT("PROJECT"), hWnd, lpNewDlg))
  1020. #endif
  1021. {
  1022. sprintf( szDHW, "%s - %s", szAppName, gProj.szMpj);
  1023. SetWindowTextA( hWnd,szDHW);
  1024. gMstr.szSrcDate[0] = 0;
  1025. gMstr.szMpjLastRealUpdate[0] = 0;
  1026. SendMessage( hWnd, WM_LOADTOKENS, (WPARAM)0, (LPARAM)0);
  1027. }
  1028. else
  1029. {
  1030. strcpy( gProj.szMpj, szOldFile);
  1031. }
  1032. #ifndef RLWIN32
  1033. FreeProcInstance(lpTokEditDlg);
  1034. #endif
  1035. }
  1036. break;
  1037. case IDM_P_OPEN:
  1038. if ( SendMessage( hWnd, WM_SAVEPROJECT, (WPARAM)0, (LPARAM)0) )
  1039. {
  1040. if ( GetFileNameFromBrowse( hWnd,
  1041. gProj.szMpj,
  1042. MAXFILENAME,
  1043. szOpenDlgTitle,
  1044. szFilterSpec,
  1045. "MPJ"))
  1046. {
  1047. if ( GetMasterProjectData( gProj.szMpj, NULL, NULL, FALSE) == SUCCESS )
  1048. {
  1049. sprintf( szDHW, "%s - %s", szAppName, gProj.szMpj);
  1050. SetWindowTextA( hMainWnd, szDHW);
  1051. SendMessage( hMainWnd,
  1052. WM_LOADTOKENS,
  1053. (WPARAM)0,
  1054. (LPARAM)0);
  1055. }
  1056. }
  1057. }
  1058. break;
  1059. case IDM_P_VIEW:
  1060. #ifdef RLWIN32
  1061. DialogBox(hInst, TEXT("VIEWPROJECT"), hWnd, ViewDlgProc);
  1062. #else
  1063. lpViewDlg = MakeProcInstance(ViewDlgProc, hInst);
  1064. DialogBox(hInst, TEXT("VIEWPROJECT"), hWnd, lpViewDlg);
  1065. #endif
  1066. break;
  1067. case IDM_P_CLOSE:
  1068. {
  1069. HMENU hMenu;
  1070. hMenu = GetMenu(hWnd);
  1071. if ( SendMessage( hWnd, WM_SAVEPROJECT, (WPARAM)0, (LPARAM)0) )
  1072. {
  1073. // Remove file name from window title
  1074. SetWindowTextA(hMainWnd, szAppName);
  1075. // Hide token list since it's empty
  1076. ShowWindow(hListWnd, SW_HIDE);
  1077. // Remove the current token list
  1078. SendMessage( hListWnd, LB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
  1079. CleanDeltaList();
  1080. // Force Repaint of status Window
  1081. InvalidateRect(hStatusWnd, NULL, TRUE);
  1082. EnableMenuItem(hMenu,IDM_P_CLOSE,MF_GRAYED|MF_BYCOMMAND);
  1083. EnableMenuItem(hMenu,IDM_P_VIEW,MF_GRAYED|MF_BYCOMMAND);
  1084. EnableMenuItem(hMenu,IDM_E_FIND,MF_GRAYED|MF_BYCOMMAND);
  1085. EnableMenuItem(hMenu,IDM_E_FINDUP,MF_GRAYED|MF_BYCOMMAND);
  1086. EnableMenuItem(hMenu,IDM_E_FINDDOWN,MF_GRAYED|MF_BYCOMMAND);
  1087. EnableMenuItem(hMenu,IDM_E_REVIEW,MF_GRAYED|MF_BYCOMMAND);
  1088. EnableMenuItem(hMenu,IDM_E_COPY,MF_GRAYED|MF_BYCOMMAND);
  1089. EnableMenuItem(hMenu,IDM_E_COPYTOKEN,MF_GRAYED|MF_BYCOMMAND);
  1090. EnableMenuItem(hMenu,IDM_E_PASTE,MF_GRAYED|MF_BYCOMMAND);
  1091. }
  1092. break;
  1093. }
  1094. case IDM_P_EXIT:
  1095. // send wm_close message to main window
  1096. PostMessage(hMainWnd, WM_CLOSE, (WPARAM)0, (LPARAM)0);
  1097. break;
  1098. case IDM_E_COPYTOKEN:
  1099. {
  1100. HGLOBAL hStringMem = NULL;
  1101. LPTSTR lpString = NULL;
  1102. int nIndex = 0;
  1103. int nLength = 0;
  1104. LPTSTR lpstrToken = NULL;
  1105. // Is anything selected in the listbox
  1106. if ( (nIndex = (int)SendMessage( hListWnd,
  1107. LB_GETCURSEL,
  1108. (WPARAM)0,
  1109. (LPARAM)0)) != LB_ERR )
  1110. {
  1111. HGLOBAL hMem = (HGLOBAL)SendMessage( hListWnd,
  1112. LB_GETITEMDATA,
  1113. (WPARAM)nIndex,
  1114. (LPARAM)0);
  1115. lpstrToken = (LPTSTR)GlobalLock( hMem);
  1116. nLength = lstrlen( lpstrToken);
  1117. // Allocate memory for the string
  1118. if ( (hStringMem =
  1119. GlobalAlloc(GHND, (DWORD) MEMSIZE(nLength+1))) != NULL )
  1120. {
  1121. if ( (lpString = (LPTSTR)GlobalLock( hStringMem)) != NULL )
  1122. {
  1123. // Get the selected text
  1124. lstrcpy( lpString, lpstrToken);
  1125. GlobalUnlock( hMem);
  1126. // Unlock the block
  1127. GlobalUnlock( hStringMem);
  1128. // Open the Clipboard and clear its contents
  1129. OpenClipboard( hWnd);
  1130. EmptyClipboard();
  1131. // Give the Clipboard the text data
  1132. #if defined(UNICODE)
  1133. SetClipboardData(CF_UNICODETEXT, hStringMem);
  1134. #else // not UNICODE
  1135. SetClipboardData( CF_TEXT, hStringMem);
  1136. #endif // UNICODE
  1137. CloseClipboard();
  1138. hStringMem = NULL;
  1139. }
  1140. else
  1141. {
  1142. LoadString( hInst,
  1143. IDS_ERR_NO_MEMORY,
  1144. tsz,
  1145. TCHARSIN( sizeof( tsz)));
  1146. MessageBox( hWnd,
  1147. tsz,
  1148. tszAppName,
  1149. MB_ICONHAND | MB_OK);
  1150. }
  1151. }
  1152. else
  1153. {
  1154. LoadString( hInst,
  1155. IDS_ERR_NO_MEMORY,
  1156. tsz,
  1157. TCHARSIN( sizeof(tsz)));
  1158. MessageBox( hWnd,
  1159. tsz,
  1160. tszAppName,
  1161. MB_ICONHAND | MB_OK);
  1162. }
  1163. }
  1164. break;
  1165. }
  1166. case IDM_E_COPY:
  1167. {
  1168. HGLOBAL hStringMem = NULL;
  1169. HGLOBAL hMem = NULL;
  1170. LPTSTR lpString = NULL;
  1171. TCHAR *pszString = NULL;
  1172. int nIndex = 0;
  1173. int nLength = 0;
  1174. int nActual = 0;
  1175. TOKEN tok;
  1176. LPTSTR lpstrToken = NULL;
  1177. // Is anything selected in the listbox
  1178. if ( (nIndex = (int)SendMessage( hListWnd,
  1179. LB_GETCURSEL,
  1180. (WPARAM)0,
  1181. (LPARAM)0)) != LB_ERR )
  1182. {
  1183. hMem = (HGLOBAL)SendMessage( hListWnd,
  1184. LB_GETITEMDATA,
  1185. (WPARAM)nIndex,
  1186. (LPARAM)0);
  1187. lpstrToken = (LPTSTR)
  1188. pszString = (TCHAR *)FALLOC( MEMSIZE( lstrlen( lpstrToken) + 1 ));
  1189. lstrcpy( pszString, lpstrToken);
  1190. GlobalUnlock( hMem);
  1191. ParseBufToTok( pszString, &tok);
  1192. RLFREE( pszString);
  1193. nLength = lstrlen(tok.szText);
  1194. // Allocate memory for the string
  1195. if ((hStringMem =
  1196. GlobalAlloc(GHND, (DWORD)MEMSIZE( nLength + 1))) != NULL)
  1197. {
  1198. if ( (lpString = (LPTSTR)GlobalLock( hStringMem)) != NULL)
  1199. {
  1200. // Get the selected text
  1201. lstrcpy( lpString, tok.szText);
  1202. // Unlock the block
  1203. GlobalUnlock( hStringMem);
  1204. // Open the Clipboard and clear its contents
  1205. OpenClipboard(hWnd);
  1206. EmptyClipboard();
  1207. // Give the Clipboard the text data
  1208. #if defined(UNICODE)
  1209. SetClipboardData(CF_UNICODETEXT, hStringMem);
  1210. #else // not UNICODE
  1211. SetClipboardData(CF_TEXT, hStringMem);
  1212. #endif // UNICODE
  1213. CloseClipboard();
  1214. hStringMem = NULL;
  1215. }
  1216. else
  1217. {
  1218. LoadString( hInst,
  1219. IDS_ERR_NO_MEMORY,
  1220. tsz,
  1221. TCHARSIN( sizeof(tsz)));
  1222. MessageBox( hWnd,
  1223. tsz,
  1224. tszAppName,
  1225. MB_ICONHAND | MB_OK);
  1226. }
  1227. }
  1228. else
  1229. {
  1230. LoadString( hInst,
  1231. IDS_ERR_NO_MEMORY,
  1232. tsz,
  1233. TCHARSIN( sizeof( tsz)));
  1234. MessageBox( hWnd,
  1235. tsz,
  1236. tszAppName,
  1237. MB_ICONHAND | MB_OK);
  1238. }
  1239. RLFREE( tok.szText);
  1240. }
  1241. break;
  1242. }
  1243. case IDM_E_PASTE:
  1244. {
  1245. HGLOBAL hClipMem = NULL;
  1246. HGLOBAL hMem = NULL;
  1247. LPTSTR lpClipMem = NULL;
  1248. TCHAR *pszPasteString = NULL;
  1249. int nIndex = 0;
  1250. TOKEN tok;
  1251. LPTSTR lpstrToken = NULL;
  1252. if (OpenClipboard(hWnd))
  1253. {
  1254. #if defined(UNICODE)
  1255. if(IsClipboardFormatAvailable(CF_UNICODETEXT) ||
  1256. IsClipboardFormatAvailable(CF_OEMTEXT))
  1257. #else // not UNICODE
  1258. if(IsClipboardFormatAvailable(CF_TEXT) ||
  1259. IsClipboardFormatAvailable(CF_OEMTEXT))
  1260. #endif // UNICODE
  1261. {
  1262. // Check for current position and change that token's text
  1263. nIndex = (int) SendMessage( hListWnd,
  1264. LB_GETCURSEL,
  1265. (WPARAM)0,
  1266. (LPARAM)0);
  1267. if (nIndex == LB_ERR)
  1268. {
  1269. #if defined(UNICODE) // if no select, just ignore it.
  1270. break;
  1271. #else // not UNICODE
  1272. nIndex = -1;
  1273. #endif // UNICODE
  1274. }
  1275. #if defined(UNICODE) //enabled Paste command
  1276. hClipMem = GetClipboardData(CF_UNICODETEXT);
  1277. #else // not UNICODE
  1278. hClipMem = GetClipboardData(CF_TEXT);
  1279. #endif // UNICODE
  1280. lpClipMem = (LPTSTR)GlobalLock( hClipMem);
  1281. hMem = (HGLOBAL)SendMessage( hListWnd,
  1282. LB_GETITEMDATA,
  1283. (WPARAM)nIndex,
  1284. (LPARAM)0);
  1285. lpstrToken = (LPTSTR)GlobalLock( hMem);
  1286. pszPasteString = (LPTSTR)FALLOC( MEMSIZE( lstrlen( lpstrToken) + 1));
  1287. lstrcpy( pszPasteString, lpstrToken);
  1288. GlobalUnlock( hMem);
  1289. // copy the string to the token
  1290. ParseBufToTok( pszPasteString, &tok);
  1291. RLFREE( pszPasteString);
  1292. RLFREE( tok.szText);
  1293. tok.szText = (TCHAR *)FALLOC( MEMSIZE( lstrlen( lpClipMem) + 1));
  1294. lstrcpy( tok.szText, lpClipMem);
  1295. GlobalUnlock(hClipMem);
  1296. pszPasteString = (LPTSTR)FALLOC( MEMSIZE( TokenToTextSize( &tok) + 1));
  1297. ParseTokToBuf( pszPasteString, &tok);
  1298. RLFREE( tok.szText);
  1299. // Paste the text
  1300. SendMessage( hListWnd,
  1301. WM_SETREDRAW,
  1302. (WPARAM)FALSE,
  1303. (LPARAM)0);
  1304. SendMessage( hListWnd,
  1305. LB_DELETESTRING,
  1306. (WPARAM)nIndex,
  1307. (LPARAM)0);
  1308. hMem = GlobalAlloc( GMEM_ZEROINIT, MEMSIZE( lstrlen( pszPasteString)+1));
  1309. lpstrToken = (LPTSTR)GlobalLock( hMem);
  1310. lstrcpy( lpstrToken, pszPasteString);
  1311. GlobalUnlock( hMem);
  1312. SendMessage( hListWnd,
  1313. LB_INSERTSTRING,
  1314. (WPARAM)nIndex,
  1315. (LPARAM)hMem);
  1316. SendMessage( hListWnd,
  1317. LB_SETCURSEL,
  1318. (WPARAM)nIndex,
  1319. (LPARAM)0);
  1320. SendMessage( hListWnd,
  1321. WM_SETREDRAW,
  1322. (WPARAM)TRUE,
  1323. (LPARAM)0);
  1324. InvalidateRect(hListWnd,NULL,TRUE);
  1325. fMtkChanges = TRUE; // Set Dirty Flag
  1326. RLFREE( pszPasteString);
  1327. // Close the Clipboard
  1328. CloseClipboard();
  1329. SetFocus(hListWnd);
  1330. }
  1331. }
  1332. CloseClipboard();
  1333. break;
  1334. }
  1335. case IDM_E_FINDDOWN:
  1336. if (fSearchStarted)
  1337. {
  1338. if ( ! DoTokenSearch( szSearchType,
  1339. szSearchText,
  1340. wSearchStatus,
  1341. wSearchStatusMask,
  1342. 0,
  1343. TRUE) )
  1344. {
  1345. TCHAR sz1[80], sz2[80];
  1346. LoadString( hInst,
  1347. IDS_FIND_TOKEN,
  1348. sz1,
  1349. TCHARSIN( sizeof( sz1)));
  1350. LoadString( hInst,
  1351. IDS_TOKEN_NOT_FOUND,
  1352. sz2,
  1353. TCHARSIN( sizeof( sz2)));
  1354. MessageBox( hWnd, sz2, sz1, MB_ICONINFORMATION | MB_OK);
  1355. }
  1356. break;
  1357. } //... ELSE fall thru
  1358. case IDM_E_FINDUP:
  1359. if (fSearchStarted)
  1360. {
  1361. if ( ! DoTokenSearch( szSearchType,
  1362. szSearchText,
  1363. wSearchStatus,
  1364. wSearchStatusMask,
  1365. 1,
  1366. TRUE) )
  1367. {
  1368. TCHAR sz1[80], sz2[80];
  1369. LoadString( hInst,
  1370. IDS_FIND_TOKEN,
  1371. sz1,
  1372. TCHARSIN( sizeof( sz1)));
  1373. LoadString( hInst,
  1374. IDS_TOKEN_NOT_FOUND,
  1375. sz2,
  1376. TCHARSIN( sizeof( sz2)));
  1377. MessageBox( hWnd, sz2, sz1, MB_ICONINFORMATION | MB_OK);
  1378. }
  1379. break;
  1380. } //... ELSE fall thru
  1381. case IDM_E_FIND:
  1382. {
  1383. #ifndef RLWIN32
  1384. FARPROC lpfnTOKFINDMsgProc;
  1385. lpfnTOKFINDMsgProc = MakeProcInstance((FARPROC)TOKFINDMsgProc,
  1386. hInst);
  1387. if (!DialogBox( hInst, TEXT("TOKFIND"), hWnd, lpfnTOKFINDMsgProc))
  1388. #else
  1389. if (!DialogBox(hInst, TEXT("TOKFIND"), hWnd, TOKFINDMsgProc))
  1390. #endif
  1391. {
  1392. #ifndef DBCS
  1393. // 'Token Not Found' is strange because user selected cancel #3042
  1394. TCHAR sz1[80] = TEXT("");
  1395. TCHAR sz2[80] = TEXT("");
  1396. LoadString( hInst,
  1397. IDS_FIND_TOKEN,
  1398. sz1,
  1399. TCHARSIN( sizeof( sz1)));
  1400. LoadString( hInst,
  1401. IDS_TOKEN_NOT_FOUND,
  1402. sz2,
  1403. TCHARSIN( sizeof( sz2)));
  1404. MessageBox( hWnd, sz2, sz1, MB_ICONINFORMATION | MB_OK);
  1405. #endif //DBCS
  1406. }
  1407. #ifndef RLWIN32
  1408. FreeProcInstance( lpfnTOKFINDMsgProc);
  1409. #endif
  1410. return TRUE;
  1411. }
  1412. case IDM_E_REVIEW:
  1413. {
  1414. LRESULT lrSaveSelection = 0;
  1415. nUpdateMode = 1;
  1416. // set listbox selection to begining of the token list
  1417. lrSaveSelection = SendMessage( hListWnd,
  1418. LB_GETCURSEL,
  1419. (WPARAM)0,
  1420. (LPARAM)0);
  1421. SendMessage( hListWnd, LB_SETCURSEL, (WPARAM)0, (LPARAM)0);
  1422. if ( DoTokenSearch( NULL, NULL, ST_NEW, ST_NEW, FALSE, FALSE) )
  1423. {
  1424. #ifdef RLWIN32
  1425. SendMessage( hMainWnd,
  1426. WM_COMMAND,
  1427. MAKEWPARAM( IDC_LIST, LBN_DBLCLK),
  1428. (LPARAM)0);
  1429. #else
  1430. SendMessage( hMainWnd,
  1431. WM_COMMAND,
  1432. IDC_LIST,
  1433. MAKELONG( 0, LBN_DBLCLK));
  1434. #endif
  1435. }
  1436. }
  1437. break;
  1438. case IDM_H_CONTENTS:
  1439. {
  1440. OFSTRUCT Of = { 0, 0, 0, 0, 0, ""};
  1441. if ( OpenFile( gszHelpFile, &Of, OF_EXIST) == HFILE_ERROR)
  1442. {
  1443. LoadString( hInst,
  1444. IDS_ERR_NO_HELP ,
  1445. tsz,
  1446. TCHARSIN( sizeof( tsz)));
  1447. MessageBox( hWnd, tsz, NULL, MB_OK);
  1448. }
  1449. else
  1450. {
  1451. WinHelpA( hWnd, gszHelpFile, HELP_KEY,(DWORD_PTR)((LPSTR)"RLAdmin"));
  1452. }
  1453. break;
  1454. }
  1455. case IDM_H_ABOUT:
  1456. {
  1457. #ifndef RLWIN32
  1458. WNDPROC lpProcAbout;
  1459. lpProcAbout = MakeProcInstance(About, hInst);
  1460. DialogBox(hInst, TEXT("ABOUT"), hWnd, lpProcAbout);
  1461. FreeProcInstance(lpProcAbout);
  1462. #else
  1463. DialogBox(hInst, TEXT("ABOUT"), hWnd, About);
  1464. #endif
  1465. }
  1466. break;
  1467. default:
  1468. break;
  1469. } // WM_COMMAND switch
  1470. return FALSE;
  1471. }
  1472. /**
  1473. *
  1474. *
  1475. * Function: TokEditDlgProc
  1476. * Procedure for the edit mode dialog window. Loads the selected token
  1477. * info into the window, and allows the user to change the token text.
  1478. * Once the edit is complete, the procedure sends a message to the
  1479. * list box windows to update the current token info.
  1480. *
  1481. *
  1482. * Arguments:
  1483. *
  1484. * Returns: NA.
  1485. *
  1486. * Errors Codes:
  1487. * TRUE, carry out edit, and update token list box.
  1488. * FALSE, cancel edit.
  1489. *
  1490. * History:
  1491. *
  1492. *
  1493. **/
  1494. INT_PTR TokEditDlgProc(
  1495. HWND hDlg,
  1496. UINT wMsg,
  1497. WPARAM wParam,
  1498. LPARAM lParam)
  1499. {
  1500. HWND hCtl;
  1501. HWND hParentWnd;
  1502. UINT static wcTokens = 0;
  1503. UINT wIndex;
  1504. static BOOL fChanged = FALSE;
  1505. switch(wMsg)
  1506. {
  1507. case WM_INITDIALOG:
  1508. cwCenter(hDlg, 0);
  1509. wcTokens = (UINT)SendMessage( hListWnd,
  1510. LB_GETCOUNT,
  1511. (WPARAM)0,
  1512. (LPARAM)0);
  1513. wcTokens--;
  1514. hCtl = GetDlgItem(hDlg,IDD_STATUS);
  1515. {
  1516. TCHAR sz[80];
  1517. LoadString( hInst, IDS_UNCHANGED, sz, TCHARSIN( sizeof( sz)));
  1518. SendMessage( hCtl, CB_ADDSTRING, (WPARAM)0, (LPARAM)sz);
  1519. LoadString( hInst, IDS_CHANGED, sz, TCHARSIN( sizeof( sz)));
  1520. SendMessage( hCtl, CB_ADDSTRING, (WPARAM)0, (LPARAM)sz);
  1521. LoadString( hInst, IDS_NEW, sz, TCHARSIN( sizeof( sz)));
  1522. SendMessage( hCtl, CB_ADDSTRING, (WPARAM)0, (LPARAM)sz);
  1523. LoadString( hInst, IDS_READONLY, sz, TCHARSIN( sizeof( sz)));
  1524. SendMessage( hCtl, CB_ADDSTRING, (WPARAM)0, (LPARAM)sz);
  1525. }
  1526. if( ! nUpdateMode )
  1527. {
  1528. if (hCtl = GetDlgItem(hDlg, IDD_SKIP))
  1529. {
  1530. EnableWindow(hCtl, FALSE);
  1531. }
  1532. }
  1533. else
  1534. {
  1535. if (hCtl = GetDlgItem(hDlg, IDD_SKIP))
  1536. {
  1537. EnableWindow(hCtl, TRUE);
  1538. }
  1539. }
  1540. fChanged = FALSE;
  1541. return TRUE;
  1542. case WM_COMMAND:
  1543. switch (GET_WM_COMMAND_ID(wParam, lParam))
  1544. {
  1545. case IDD_SKIP:
  1546. wIndex = (UINT)SendMessage( hListWnd,
  1547. LB_GETCURSEL,
  1548. (WPARAM)0,
  1549. (LPARAM)0);
  1550. if ( nUpdateMode && wIndex < wcTokens )
  1551. {
  1552. wIndex ++;
  1553. SendMessage( hListWnd,
  1554. LB_SETCURSEL,
  1555. (WPARAM)wIndex,
  1556. (LPARAM)0);
  1557. if ( DoTokenSearch( NULL, NULL, ST_NEW, ST_NEW, FALSE, FALSE) )
  1558. {
  1559. wIndex = (UINT)SendMessage( hListWnd,
  1560. LB_GETCURSEL,
  1561. (WPARAM)0,
  1562. (LPARAM)0);
  1563. SendMessage( hMainWnd,
  1564. WM_COMMAND,
  1565. MAKEWPARAM( IDC_LIST, LBN_DBLCLK),
  1566. (LPARAM)0);
  1567. return TRUE;
  1568. }
  1569. }
  1570. nUpdateMode = 0;
  1571. DestroyWindow(hDlg);
  1572. #ifndef RLWIN32
  1573. FreeProcInstance(lpTokEditDlg);
  1574. #endif
  1575. hTokEditDlgWnd = 0;
  1576. break;
  1577. case IDD_STATUS:
  1578. fChanged = TRUE;
  1579. break;
  1580. case IDOK:
  1581. wIndex = (UINT)SendMessage( hListWnd,
  1582. LB_GETCURSEL,
  1583. (WPARAM)0,
  1584. (LPARAM)0);
  1585. if (fChanged)
  1586. {
  1587. int i;
  1588. fChanged = FALSE;
  1589. hCtl = GetDlgItem(hDlg, IDD_STATUS);
  1590. i = (int)SendMessage( hCtl,
  1591. CB_GETCURSEL,
  1592. (WPARAM)0,
  1593. (LPARAM)0);
  1594. hParentWnd = GetParent(hDlg);
  1595. SendMessage( hParentWnd, WM_TOKEDIT, (WPARAM)i, (LPARAM)0);
  1596. }
  1597. // Exit, or goto to next changed token if in update mode
  1598. if ( nUpdateMode && wIndex < wcTokens )
  1599. {
  1600. wIndex++;
  1601. SendMessage( hListWnd,
  1602. LB_SETCURSEL,
  1603. (WPARAM)wIndex,
  1604. (LPARAM)0);
  1605. if ( DoTokenSearch( NULL, NULL, ST_NEW, ST_NEW, FALSE, FALSE) )
  1606. {
  1607. // go into edit mode
  1608. SendMessage( hMainWnd,
  1609. WM_COMMAND,
  1610. MAKEWPARAM( IDC_LIST, LBN_DBLCLK),
  1611. (LPARAM)0);
  1612. return TRUE;
  1613. }
  1614. }
  1615. // fall through to IDCANCEL
  1616. case IDCANCEL:
  1617. nUpdateMode = 0;
  1618. // remove edit dialog box
  1619. DestroyWindow(hDlg);
  1620. #ifndef RLWIN32
  1621. FreeProcInstance(lpTokEditDlg);
  1622. #endif
  1623. hTokEditDlgWnd = 0;
  1624. break;
  1625. } // WM_COMMAND
  1626. return TRUE;
  1627. default:
  1628. if (hCtl = GetDlgItem(hDlg, IDOK))
  1629. {
  1630. EnableWindow(hCtl, TRUE);
  1631. }
  1632. return FALSE;
  1633. } // Main Switch
  1634. }
  1635. /**
  1636. *
  1637. *
  1638. * Function: TOKFINDMsgProc
  1639. *
  1640. * Arguments:
  1641. *
  1642. * Returns:
  1643. * NA.
  1644. *
  1645. * Errors Codes:
  1646. *
  1647. * History:
  1648. *
  1649. *
  1650. **/
  1651. INT_PTR TOKFINDMsgProc(HWND hWndDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
  1652. {
  1653. HWND hCtl;
  1654. int rgiTokenTypes[]=
  1655. {
  1656. ID_RT_MENU,
  1657. ID_RT_DIALOG,
  1658. ID_RT_STRING,
  1659. ID_RT_ACCELERATORS,
  1660. ID_RT_RCDATA,
  1661. ID_RT_ERRTABLE,
  1662. ID_RT_NAMETABLE,
  1663. ID_RT_VERSION,
  1664. ID_RT_DLGINIT
  1665. };
  1666. TCHAR szTokenType[40] = TEXT("");
  1667. UINT i;
  1668. switch(wMsg)
  1669. {
  1670. case WM_INITDIALOG:
  1671. CheckDlgButton(hWndDlg, IDD_READONLY, 2);
  1672. CheckDlgButton(hWndDlg, IDD_CHANGED, 2);
  1673. CheckDlgButton(hWndDlg, IDD_FINDDOWN, 1);
  1674. hCtl = GetDlgItem(hWndDlg, IDD_TYPELST);
  1675. for ( i = 0; i < sizeof( rgiTokenTypes) / 2; i++)
  1676. {
  1677. LoadString( hInst,
  1678. IDS_RESOURCENAMES + rgiTokenTypes[i],
  1679. szTokenType,
  1680. TCHARSIN( sizeof( szTokenType)));
  1681. SendMessage( hCtl,
  1682. CB_ADDSTRING,
  1683. (WPARAM)0,
  1684. (LPARAM)szTokenType);
  1685. }
  1686. return TRUE;
  1687. break;
  1688. case WM_COMMAND:
  1689. switch(wParam)
  1690. {
  1691. case IDOK: /* Button text: "Okay" */
  1692. fSearchStarted = TRUE;
  1693. GetDlgItemText( hWndDlg,
  1694. IDD_TYPELST,
  1695. szSearchType,
  1696. TCHARSIN( sizeof( szSearchType)));
  1697. GetDlgItemText( hWndDlg,
  1698. IDD_FINDTOK,
  1699. szSearchText,
  1700. TCHARSIN( sizeof( szSearchText)));
  1701. wSearchStatus = wSearchStatusMask = 0;
  1702. switch (IsDlgButtonChecked(hWndDlg, IDD_READONLY))
  1703. {
  1704. case 1:
  1705. wSearchStatus |= ST_READONLY;
  1706. case 0:
  1707. wSearchStatusMask |= ST_READONLY;
  1708. }
  1709. switch (IsDlgButtonChecked(hWndDlg, IDD_CHANGED))
  1710. {
  1711. case 1:
  1712. wSearchStatus |= ST_CHANGED;
  1713. case 0:
  1714. wSearchStatusMask |= ST_CHANGED;
  1715. }
  1716. fSearchDirection = IsDlgButtonChecked(hWndDlg, IDD_FINDUP);
  1717. if( DoTokenSearch(szSearchType,
  1718. szSearchText,
  1719. wSearchStatus,
  1720. wSearchStatusMask,
  1721. fSearchDirection,
  1722. FALSE) )
  1723. {
  1724. EndDialog( hWndDlg, TRUE );
  1725. }
  1726. else
  1727. {
  1728. TCHAR sz1[80], sz2[80];
  1729. LoadString( hInst,
  1730. IDS_FIND_TOKEN,
  1731. sz1,
  1732. TCHARSIN( sizeof( sz1)));
  1733. LoadString( hInst,
  1734. IDS_TOKEN_NOT_FOUND,
  1735. sz2,
  1736. TCHARSIN( sizeof( sz2)));
  1737. MessageBox( hWndDlg, sz2, sz1, MB_ICONINFORMATION | MB_OK);
  1738. EndDialog( hWndDlg, FALSE );
  1739. }
  1740. case IDCANCEL:
  1741. EndDialog( hWndDlg, FALSE);
  1742. return TRUE;
  1743. }
  1744. break; /* End of WM_COMMAND */
  1745. default:
  1746. return FALSE;
  1747. }
  1748. return FALSE;
  1749. }
  1750. /**
  1751. * Function: NewDlgProc
  1752. * Procedure for the new project dialog window.
  1753. *
  1754. * Arguments:
  1755. *
  1756. * Returns: NA.
  1757. *
  1758. * Errors Codes:
  1759. * TRUE, carry out edit, and update token list box.
  1760. * FALSE, cancel edit.
  1761. *
  1762. * History:
  1763. **/
  1764. INT_PTR APIENTRY NewDlgProc(
  1765. HWND hDlg,
  1766. UINT wMsg,
  1767. WPARAM wParam,
  1768. LPARAM lParam)
  1769. {
  1770. CHAR pszDrive[ _MAX_DRIVE] = "";
  1771. CHAR pszDir[ _MAX_DIR] = "";
  1772. CHAR pszName[ _MAX_FNAME] = "";
  1773. CHAR pszExt[ _MAX_EXT] = "";
  1774. switch ( wMsg )
  1775. {
  1776. case WM_INITDIALOG:
  1777. {
  1778. LPTSTR pszLangName = NULL;
  1779. OFSTRUCT Of = { 0, 0, 0, 0, 0, ""};
  1780. int nSel = 0;
  1781. iLastBox = IDD_SOURCERES;
  1782. fLangSelected = FALSE;
  1783. _splitpath( gProj.szMpj, pszDrive, pszDir, pszName, pszExt);
  1784. sprintf( szDHW, "%s%s%s.%s", pszDrive, pszDir, pszName, "EXE");
  1785. SetDlgItemTextA( hDlg, IDD_SOURCERES, szDHW);
  1786. sprintf( szDHW, "%s%s%s.%s", pszDrive, pszDir, pszName, "MTK");
  1787. SetDlgItemTextA( hDlg, IDD_MTK, szDHW);
  1788. sprintf( szDHW, "%s%s%s.%s", pszDrive, pszDir, pszName, "RDF");
  1789. if ( OpenFile( szDHW, &Of, OF_EXIST) != HFILE_ERROR )
  1790. SetDlgItemTextA( hDlg, IDD_RDFS, szDHW);
  1791. else
  1792. SetDlgItemText( hDlg, IDD_RDFS, TEXT(""));
  1793. if ( gMstr.uCodePage == CP_ACP )
  1794. gMstr.uCodePage = GetACP();
  1795. else if ( gMstr.uCodePage == CP_OEMCP )
  1796. gMstr.uCodePage = GetOEMCP();
  1797. if ( ! IsValidCodePage( gMstr.uCodePage) )
  1798. {
  1799. static TCHAR szMsg[ 256];
  1800. CHAR *pszCP[1];
  1801. pszCP[0] = UlongToPtr(gMstr.uCodePage);
  1802. LoadString( hInst, IDS_NOCPXTABLE, szMsg, 256);
  1803. FormatMessage( FORMAT_MESSAGE_FROM_STRING
  1804. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  1805. szMsg,
  1806. 0,
  1807. 0,
  1808. (LPTSTR)szDHW,
  1809. DHWSIZE/sizeof(TCHAR),
  1810. (va_list *)pszCP);
  1811. MessageBox( hDlg, (LPCTSTR)szDHW, tszAppName, MB_ICONHAND|MB_OK);
  1812. SetDlgItemInt( hDlg, IDD_TOK_CP, gMstr.uCodePage, FALSE);
  1813. return( TRUE);
  1814. }
  1815. SetDlgItemInt( hDlg, IDD_TOK_CP, gMstr.uCodePage, FALSE);
  1816. PostMessage( hDlg, WM_COMMAND, IDD_BROWSE, 0);
  1817. return TRUE;
  1818. }
  1819. case WM_COMMAND:
  1820. switch ( GET_WM_COMMAND_ID( wParam, lParam) )
  1821. {
  1822. case IDD_SOURCERES:
  1823. case IDD_MTK:
  1824. case IDD_RDFS:
  1825. iLastBox = GET_WM_COMMAND_ID(wParam, lParam);
  1826. break;
  1827. case IDD_BROWSE:
  1828. switch ( iLastBox )
  1829. {
  1830. case IDD_SOURCERES:
  1831. szFSpec = szExeResFilterSpec;
  1832. szExt = "EXE";
  1833. LoadStrIntoAnsiBuf( hInst,
  1834. IDS_RES_SRC,
  1835. szPrompt,
  1836. ACHARSIN( sizeof( szPrompt)));
  1837. fLangSelected = FALSE;
  1838. break;
  1839. case IDD_RDFS:
  1840. szFSpec = szRdfFilterSpec;
  1841. szExt = "RDF";
  1842. LoadStrIntoAnsiBuf( hInst,
  1843. IDS_RDF,
  1844. szPrompt,
  1845. ACHARSIN( sizeof( szPrompt)));
  1846. break;
  1847. case IDD_MTK:
  1848. szFSpec = szMtkFilterSpec;
  1849. szExt = "MTK";
  1850. LoadStrIntoAnsiBuf( hInst,
  1851. IDS_MTK,
  1852. szPrompt,
  1853. ACHARSIN( sizeof(szPrompt)));
  1854. break;
  1855. }
  1856. GetDlgItemTextA(hDlg, iLastBox, szNewFileName, MAXFILENAME);
  1857. if ( GetFileNameFromBrowse( hDlg,
  1858. szNewFileName,
  1859. MAXFILENAME,
  1860. szPrompt,
  1861. szFSpec,
  1862. szExt) )
  1863. {
  1864. SetDlgItemTextA( hDlg, iLastBox, szNewFileName);
  1865. if ( iLastBox == IDD_SOURCERES )
  1866. { // fill in suggested name for the MTK box
  1867. CHAR pszDrive[_MAX_DRIVE] = "";
  1868. CHAR pszDir[ _MAX_DIR] = "";
  1869. CHAR pszName[ _MAX_FNAME] = "";
  1870. CHAR pszExt[ _MAX_EXT] = "";
  1871. lstrcpyA( gMstr.szSrc, szNewFileName);
  1872. FillListAndSetLang( hDlg,
  1873. IDD_MSTR_LANG_NAME,
  1874. &gMstr.wLanguageID,
  1875. &fLangSelected);
  1876. _splitpath( szNewFileName, pszDrive, pszDir, pszName, pszExt);
  1877. GetDlgItemTextA(hDlg, IDD_MTK, szNewFileName, MAXFILENAME);
  1878. if ( ! szNewFileName[0] )
  1879. {
  1880. sprintf( szNewFileName,
  1881. "%s%s%s.%s",
  1882. pszDrive,
  1883. pszDir,
  1884. pszName,
  1885. "MTK");
  1886. SetDlgItemTextA( hDlg, IDD_MTK, szNewFileName);
  1887. }
  1888. }
  1889. }
  1890. break;
  1891. case IDD_MSTR_LANG_NAME:
  1892. if ( GET_WM_COMMAND_CMD( wParam, lParam) == CBN_SELENDOK )
  1893. {
  1894. fLangSelected = TRUE;
  1895. }
  1896. break;
  1897. case IDOK:
  1898. if ( fLangSelected )
  1899. {
  1900. MSTRDATA stProject =
  1901. { "", "", "", "", "",
  1902. MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US),
  1903. CP_ACP
  1904. };
  1905. BOOL fTranslated = FALSE;
  1906. UINT uCP = GetDlgItemInt( hDlg,
  1907. IDD_TOK_CP,
  1908. &fTranslated,
  1909. FALSE);
  1910. //... Get the selected language name
  1911. //... then set the appropriate lang id vals
  1912. INT_PTR nSel = SendDlgItemMessage( hDlg,
  1913. IDD_MSTR_LANG_NAME,
  1914. CB_GETCURSEL,
  1915. (WPARAM)0,
  1916. (LPARAM)0);
  1917. if ( nSel != CB_ERR
  1918. && SendDlgItemMessage( hDlg,
  1919. IDD_MSTR_LANG_NAME,
  1920. CB_GETLBTEXT,
  1921. (WPARAM)nSel,
  1922. (LPARAM)(LPTSTR)szDHW) != CB_ERR )
  1923. {
  1924. WORD wPri = 0;
  1925. WORD wSub = 0;
  1926. if ( GetLangIDs( (LPTSTR)szDHW, &wPri, &wSub) )
  1927. {
  1928. gMstr.wLanguageID = MAKELANGID( wPri, wSub);
  1929. }
  1930. else
  1931. {
  1932. fLangSelected = FALSE;
  1933. return( TRUE);
  1934. }
  1935. }
  1936. if ( uCP == CP_ACP )
  1937. uCP = GetACP();
  1938. else if ( uCP == CP_OEMCP )
  1939. uCP = GetOEMCP();
  1940. if ( IsValidCodePage( uCP) )
  1941. {
  1942. gMstr.uCodePage = uCP;
  1943. }
  1944. else
  1945. {
  1946. static TCHAR szMsg[ 256];
  1947. CHAR *pszCP[1];
  1948. pszCP[0] = UlongToPtr(uCP);
  1949. LoadString( hInst, IDS_NOCPXTABLE, szMsg, 256);
  1950. FormatMessage( FORMAT_MESSAGE_FROM_STRING
  1951. | FORMAT_MESSAGE_ARGUMENT_ARRAY,
  1952. szMsg,
  1953. 0,
  1954. 0,
  1955. (LPTSTR)szDHW,
  1956. DHWSIZE/sizeof(TCHAR),
  1957. (va_list *)pszCP);
  1958. MessageBox( hDlg, (LPCTSTR)szDHW, tszAppName, MB_ICONHAND|MB_OK);
  1959. SetDlgItemInt( hDlg, IDD_TOK_CP, gMstr.uCodePage, FALSE);
  1960. return( TRUE);
  1961. }
  1962. GetDlgItemTextA( hDlg,
  1963. IDD_SOURCERES,
  1964. stProject.szSrc,
  1965. MAXFILENAME);
  1966. GetDlgItemTextA( hDlg,
  1967. IDD_RDFS,
  1968. stProject.szRdfs,
  1969. MAXFILENAME);
  1970. GetDlgItemTextA( hDlg,
  1971. IDD_MTK,
  1972. stProject.szMtk,
  1973. MAXFILENAME);
  1974. if ( stProject.szSrc[0] && stProject.szMtk[0] )
  1975. {
  1976. _fullpath( gMstr.szSrc,
  1977. stProject.szSrc,
  1978. ACHARSIN( sizeof( gMstr.szSrc)));
  1979. _fullpath( gMstr.szMtk,
  1980. stProject.szMtk,
  1981. ACHARSIN( sizeof( gMstr.szMtk)));
  1982. if ( stProject.szRdfs[0] )
  1983. {
  1984. _fullpath( gMstr.szRdfs,
  1985. stProject.szRdfs,
  1986. ACHARSIN( sizeof( gMstr.szRdfs)));
  1987. }
  1988. else
  1989. {
  1990. gMstr.szRdfs[0] = '\0';
  1991. }
  1992. gProj.fSourceEXE = IsExe( gMstr.szSrc);
  1993. EndDialog( hDlg, TRUE);
  1994. return( TRUE);
  1995. }
  1996. else
  1997. {
  1998. break;
  1999. }
  2000. }
  2001. else
  2002. {
  2003. LoadString( hInst, IDS_SELECTLANG, (LPTSTR)szDHW, TCHARSIN( DHWSIZE));
  2004. MessageBox( hDlg, (LPTSTR)szDHW, tszAppName, MB_ICONHAND | MB_OK);
  2005. break;
  2006. }
  2007. case IDCANCEL:
  2008. EndDialog(hDlg, FALSE);
  2009. return( TRUE);
  2010. }
  2011. break;
  2012. }
  2013. return( FALSE);
  2014. }
  2015. /**
  2016. *
  2017. *
  2018. * Function: ViewDlgProc
  2019. * Procedure for the View project dialog window.
  2020. *
  2021. * Arguments:
  2022. *
  2023. * Returns: NA.
  2024. *
  2025. * Errors Codes:
  2026. * TRUE, carry out edit, and update token list box.
  2027. * FALSE, cancel edit.
  2028. *
  2029. * History:
  2030. *
  2031. *
  2032. **/
  2033. INT_PTR ViewDlgProc(
  2034. HWND hDlg,
  2035. UINT wMsg,
  2036. WPARAM wParam,
  2037. LPARAM lParam)
  2038. {
  2039. static int iLastBox = IDD_SOURCERES;
  2040. switch(wMsg)
  2041. {
  2042. case WM_INITDIALOG:
  2043. {
  2044. WORD wPri = PRIMARYLANGID( gMstr.wLanguageID);
  2045. WORD wSub = SUBLANGID( gMstr.wLanguageID);
  2046. LPTSTR pszName = GetLangName( wPri, wSub);
  2047. SetDlgItemTextA( hDlg, IDD_VIEW_SOURCERES, gMstr.szSrc);
  2048. SetDlgItemTextA( hDlg, IDD_VIEW_MTK, gMstr.szMtk);
  2049. SetDlgItemTextA( hDlg, IDD_VIEW_RDFS, gMstr.szRdfs);
  2050. SetDlgItemText( hDlg, IDD_MSTR_LANG_NAME, pszName);
  2051. SetDlgItemInt( hDlg, IDD_TOK_CP, gMstr.uCodePage, FALSE);
  2052. return TRUE;
  2053. }
  2054. case WM_COMMAND:
  2055. switch ( wParam )
  2056. {
  2057. case IDOK:
  2058. EndDialog( hDlg, TRUE);
  2059. return TRUE;
  2060. }
  2061. }
  2062. return FALSE;
  2063. }
  2064. void DrawLBItem(LPDRAWITEMSTRUCT lpdis)
  2065. {
  2066. LPRECT lprc = (LPRECT) &(lpdis->rcItem);
  2067. DWORD rgbOldText = 0;
  2068. DWORD rgbOldBack = 0;
  2069. HBRUSH hBrush;
  2070. static DWORD rgbHighlightText;
  2071. static DWORD rgbHighlightBack;
  2072. static HBRUSH hBrushHilite = NULL;
  2073. static HBRUSH hBrushNormal = NULL;
  2074. static DWORD rgbChangedText;
  2075. static DWORD rgbBackColor;
  2076. static DWORD rgbUnchangedText;
  2077. static DWORD rgbReadOnlyText;
  2078. static DWORD rgbNewText;
  2079. TCHAR *szToken = NULL;
  2080. TOKEN tok;
  2081. LPTSTR lpstrToken = NULL;
  2082. if (lpdis->itemAction & ODA_FOCUS)
  2083. {
  2084. DrawFocusRect(lpdis->hDC, (CONST RECT *)lprc);
  2085. }
  2086. else
  2087. {
  2088. HANDLE hMem = (HANDLE)SendMessage( lpdis->hwndItem,
  2089. LB_GETITEMDATA,
  2090. (WPARAM)lpdis->itemID,
  2091. (LPARAM)0);
  2092. lpstrToken = (LPTSTR)GlobalLock( hMem);
  2093. szToken = (LPTSTR)FALLOC( MEMSIZE( lstrlen( lpstrToken) + 1));
  2094. lstrcpy( szToken, lpstrToken);
  2095. GlobalUnlock( hMem);
  2096. ParseBufToTok(szToken, &tok);
  2097. RLFREE( szToken);
  2098. if (lpdis->itemState & ODS_SELECTED)
  2099. {
  2100. if (!hBrushHilite)
  2101. {
  2102. rgbHighlightText = GetSysColor(COLOR_HIGHLIGHTTEXT);
  2103. rgbHighlightBack = GetSysColor(COLOR_HIGHLIGHT);
  2104. hBrushHilite = CreateSolidBrush(rgbHighlightBack);
  2105. }
  2106. MakeStatusLine(&tok);
  2107. rgbOldText = SetTextColor(lpdis->hDC, rgbHighlightText);
  2108. rgbOldBack = SetBkColor(lpdis->hDC, rgbHighlightBack);
  2109. hBrush = hBrushHilite;
  2110. }
  2111. else
  2112. {
  2113. if (!hBrushNormal)
  2114. {
  2115. rgbChangedText = RGB(255, 0, 0);
  2116. rgbBackColor = RGB(192, 192, 192);
  2117. rgbUnchangedText = RGB(0, 0, 0);
  2118. rgbReadOnlyText = RGB(127, 127, 127);
  2119. rgbNewText = RGB(0, 0, 255);
  2120. hBrushNormal = CreateSolidBrush(rgbBackColor);
  2121. }
  2122. if (tok.wReserved & ST_READONLY)
  2123. {
  2124. rgbOldText = SetTextColor(lpdis->hDC, rgbReadOnlyText);
  2125. }
  2126. else if (tok.wReserved & ST_CHANGED)
  2127. {
  2128. rgbOldText = SetTextColor(lpdis->hDC, rgbChangedText);
  2129. }
  2130. else if (tok.wReserved & ST_NEW)
  2131. {
  2132. rgbOldText = SetTextColor(lpdis->hDC, rgbNewText);
  2133. }
  2134. else
  2135. {
  2136. rgbOldText = SetTextColor(lpdis->hDC, rgbUnchangedText);
  2137. }
  2138. rgbOldBack = SetBkColor(lpdis->hDC, rgbBackColor);
  2139. hBrush = hBrushNormal;
  2140. }
  2141. FillRect(lpdis->hDC, (CONST RECT *)lprc, hBrush);
  2142. DrawText(lpdis->hDC,
  2143. tok.szText,
  2144. STRINGSIZE(lstrlen(tok.szText)),
  2145. lprc,
  2146. DT_LEFT|DT_NOPREFIX);
  2147. RLFREE( tok.szText);
  2148. if (rgbOldText)
  2149. {
  2150. SetTextColor(lpdis->hDC, rgbOldText);
  2151. }
  2152. if (rgbOldBack)
  2153. {
  2154. SetBkColor(lpdis->hDC, rgbOldBack);
  2155. }
  2156. if (lpdis->itemState & ODS_FOCUS)
  2157. {
  2158. DrawFocusRect(lpdis->hDC, (CONST RECT *)lprc);
  2159. }
  2160. }
  2161. }
  2162. /*
  2163. * Function: Make Status Line
  2164. * Builds status line string from a token
  2165. *
  2166. * Inputs:
  2167. * pszStatusLine, buffer to hold string
  2168. * pTok, pointer to token structure
  2169. *
  2170. * History:
  2171. * 2/92, implemented SteveBl
  2172. * 7/92, changed to talk to new StatusWndProc t-GregTi
  2173. */
  2174. static void MakeStatusLine(TOKEN *pTok)
  2175. {
  2176. static BOOL fFirstCall = TRUE;
  2177. TCHAR szName[32] = TEXT("");
  2178. TCHAR szStatus[20] = TEXT("");
  2179. TCHAR szResIDStr[20] = TEXT("");
  2180. CHAR szTmpBuf[32] = "";
  2181. // now build status line
  2182. if (pTok->szName[0])
  2183. {
  2184. lstrcpy(szName, pTok->szName);
  2185. }
  2186. else
  2187. {
  2188. #ifdef UNICODE
  2189. _itoa(pTok->wName, szTmpBuf, 10);
  2190. _MBSTOWCS( szName,
  2191. szTmpBuf,
  2192. WCHARSIN( sizeof( szName)),
  2193. ACHARSIN( strlen( szTmpBuf) + 1));
  2194. #else
  2195. _itoa(pTok->wName, szName, 10);
  2196. #endif
  2197. }
  2198. if ( pTok->wReserved & ST_READONLY )
  2199. {
  2200. LoadString( hInst,
  2201. IDS_READONLY,
  2202. szStatus,
  2203. TCHARSIN( sizeof( szStatus)));
  2204. }
  2205. else if (pTok->wReserved == ST_NEW)
  2206. {
  2207. LoadString( hInst,
  2208. IDS_NEW,
  2209. szStatus,
  2210. TCHARSIN( sizeof( szStatus)));
  2211. }
  2212. else if (pTok->wReserved & ST_CHANGED)
  2213. {
  2214. LoadString( hInst,
  2215. IDS_CHANGED,
  2216. szStatus,
  2217. TCHARSIN( sizeof( szStatus)));
  2218. }
  2219. else
  2220. {
  2221. LoadString( hInst,
  2222. IDS_UNCHANGED,
  2223. szStatus,
  2224. TCHARSIN( sizeof( szStatus)));
  2225. }
  2226. if ( pTok->wType <= 16 || pTok->wType == ID_RT_DLGINIT )
  2227. {
  2228. LoadString( hInst,
  2229. IDS_RESOURCENAMES+pTok->wType,
  2230. szResIDStr,
  2231. TCHARSIN( sizeof( szResIDStr)));
  2232. }
  2233. else
  2234. {
  2235. #ifdef UNICODE
  2236. _itoa( pTok->wType, szTmpBuf, 10);
  2237. _MBSTOWCS( szResIDStr,
  2238. szTmpBuf,
  2239. WCHARSIN( sizeof( szResIDStr)),
  2240. ACHARSIN( strlen( szTmpBuf) + 1));
  2241. #else
  2242. _itoa(pTok->wType, szResIDStr, 10);
  2243. #endif
  2244. }
  2245. if (fFirstCall)
  2246. {
  2247. SendMessage( hStatusWnd,
  2248. WM_FMTSTATLINE,
  2249. (WPARAM)0,
  2250. (LPARAM)TEXT("10s10s5i8s4i"));
  2251. fFirstCall = FALSE;
  2252. }
  2253. SendMessage( hStatusWnd, WM_UPDSTATLINE, (WPARAM)0, (LPARAM)szResIDStr);
  2254. SendMessage( hStatusWnd, WM_UPDSTATLINE, (WPARAM)1, (LPARAM)szName);
  2255. SendMessage( hStatusWnd, WM_UPDSTATLINE, (WPARAM)2, (LPARAM)pTok->wID);
  2256. SendMessage( hStatusWnd, WM_UPDSTATLINE, (WPARAM)3, (LPARAM)szStatus);
  2257. SendMessage( hStatusWnd,
  2258. WM_UPDSTATLINE,
  2259. (WPARAM)4,
  2260. (LPARAM)lstrlen( pTok->szText));
  2261. }
  2262. /**********************************************************************
  2263. *FUNCTION: SaveMtkList(HWND) *
  2264. * *
  2265. *PURPOSE: Save current Token List *
  2266. * *
  2267. *COMMENTS: *
  2268. * *
  2269. *This saves the current contents of the Token List *
  2270. **********************************************************************/
  2271. static BOOL SaveMtkList(HWND hWnd, FILE *fpTokFile)
  2272. {
  2273. BOOL bSuccess = TRUE;
  2274. int IOStatus; // result of a file write
  2275. UINT cTokens;
  2276. UINT cCurrentTok = 0;
  2277. TCHAR *szTmpBuf;
  2278. CHAR *szTokBuf;
  2279. TCHAR str[255] = TEXT("");
  2280. TOKENDELTAINFO FAR *pTokNode;
  2281. LPTSTR lpstrToken;
  2282. // Set the cursor to an hourglass during the file transfer
  2283. hSaveCursor = SetCursor(hHourGlass);
  2284. // Find number of tokens in the list
  2285. cTokens = (UINT) SendMessage( hListWnd, LB_GETCOUNT, (WPARAM)0, (LPARAM)0);
  2286. if (cTokens != LB_ERR)
  2287. {
  2288. for (cCurrentTok = 0; bSuccess && (cCurrentTok < cTokens); cCurrentTok++)
  2289. {
  2290. #ifdef UNICODE
  2291. int nLenW = 0;
  2292. int nLenA = 0;
  2293. #endif
  2294. // Get each token from list
  2295. HGLOBAL hMem = (HGLOBAL)SendMessage( hListWnd,
  2296. LB_GETITEMDATA,
  2297. (WPARAM)cCurrentTok,
  2298. (LPARAM)0);
  2299. lpstrToken = (LPTSTR)GlobalLock( hMem);
  2300. #ifdef UNICODE
  2301. nLenW = lstrlen( lpstrToken) + 1;
  2302. szTmpBuf = (TCHAR *)FALLOC( (nLenA = MEMSIZE( nLenW)));
  2303. lstrcpy( szTmpBuf, lpstrToken);
  2304. GlobalUnlock( hMem);
  2305. szTokBuf = (CHAR *)FALLOC( nLenA);
  2306. _WCSTOMBS( szTokBuf, szTmpBuf, nLenA, nLenW);
  2307. RLFREE( szTmpBuf);
  2308. #else
  2309. szTokBuf = (CHAR *)FALLOC( strlen( lpstrToken) + 1);
  2310. lstrcpy( szTokBuf, lpstrToken);
  2311. #endif
  2312. IOStatus = fprintf(fpTokFile, "%s\n", szTokBuf);
  2313. if ( IOStatus != (int) strlen(szTokBuf) + 1 )
  2314. {
  2315. LoadString( hInst,
  2316. IDS_FILESAVEERR,
  2317. str,
  2318. TCHARSIN( sizeof( str)));
  2319. MessageBox( hWnd, str, NULL, MB_OK | MB_ICONHAND);
  2320. bSuccess = FALSE;
  2321. }
  2322. RLFREE( szTokBuf);
  2323. }
  2324. }
  2325. pTokNode = pTokenDeltaInfo;
  2326. while (pTokNode)
  2327. {
  2328. TOKEN *pTok;
  2329. int nLenW = 0;
  2330. int nLenA = 0;
  2331. pTok = &(pTokNode->DeltaToken);
  2332. #ifdef UNICODE
  2333. nLenW = TokenToTextSize( pTok);
  2334. szTmpBuf = (TCHAR *)FALLOC( (nLenA = MEMSIZE( nLenW)));
  2335. ParseTokToBuf( szTmpBuf, pTok);
  2336. szTokBuf = (CHAR *)FALLOC( nLenA);
  2337. _WCSTOMBS( szTokBuf, szTmpBuf, nLenA, nLenW);
  2338. RLFREE( szTmpBuf);
  2339. #else
  2340. szTokBuf = (CHAR *)FALLOC( TokenToTextSize( pTok));
  2341. ParseTokToBuf( szTokBuf, pTok);
  2342. #endif
  2343. IOStatus = fprintf(fpTokFile, "%s\n", szTokBuf);
  2344. if ( IOStatus != (int) strlen(szTokBuf) + 1 )
  2345. {
  2346. LoadString( hInst,
  2347. IDS_FILESAVEERR,
  2348. str,
  2349. TCHARSIN( sizeof(str)));
  2350. MessageBox( hWnd, str, NULL, MB_OK | MB_ICONHAND);
  2351. bSuccess = FALSE;
  2352. }
  2353. pTokNode = pTokNode->pNextTokenDelta;
  2354. }
  2355. // restore cursor
  2356. SetCursor(hSaveCursor);
  2357. return (bSuccess);
  2358. }
  2359. /**
  2360. * Function: CleanDeltaList
  2361. * frees the pTokenDeltaInfo list
  2362. */
  2363. static void CleanDeltaList(void)
  2364. {
  2365. TOKENDELTAINFO FAR *pTokNode;
  2366. while (pTokNode = pTokenDeltaInfo)
  2367. {
  2368. pTokenDeltaInfo = pTokNode->pNextTokenDelta;
  2369. RLFREE( pTokNode->DeltaToken.szText);
  2370. RLFREE( pTokNode);
  2371. }
  2372. }
  2373. static TOKENDELTAINFO FAR *InsertMtkList(FILE * fpTokFile)
  2374. {
  2375. TOKENDELTAINFO FAR * ptTokenDeltaInfo, FAR * pTokenDeltaInfo = NULL;
  2376. int scTokStat;
  2377. TOKEN tToken;
  2378. UINT wcChars = 0;
  2379. LPTSTR lpstrToken;
  2380. rewind(fpTokFile);
  2381. while ( (scTokStat = GetToken( fpTokFile, &tToken)) >= 0 )
  2382. {
  2383. if ( scTokStat == 0 )
  2384. {
  2385. if ( tToken.wReserved != ST_CHANGED )
  2386. {
  2387. HGLOBAL hMem = GlobalAlloc( GMEM_ZEROINIT, MEMSIZE( TokenToTextSize( &tToken)));
  2388. lpstrToken = (LPTSTR)GlobalLock( hMem);
  2389. ParseTokToBuf( lpstrToken, &tToken);
  2390. GlobalUnlock( hMem);
  2391. // only add tokens that aren't changed && old
  2392. if ( SendMessage( hListWnd,
  2393. LB_ADDSTRING,
  2394. (WPARAM)0,
  2395. (LPARAM)hMem) < 0 )
  2396. {
  2397. QuitA( IDS_ENGERR_11, NULL, NULL);
  2398. }
  2399. }
  2400. else
  2401. {
  2402. // the current token is delta info so save in delta list.
  2403. if (!pTokenDeltaInfo)
  2404. {
  2405. ptTokenDeltaInfo = pTokenDeltaInfo =
  2406. UpdateTokenDeltaInfo(&tToken);
  2407. }
  2408. else
  2409. {
  2410. ptTokenDeltaInfo->pNextTokenDelta =
  2411. UpdateTokenDeltaInfo(&tToken);
  2412. ptTokenDeltaInfo = ptTokenDeltaInfo->pNextTokenDelta;
  2413. }
  2414. }
  2415. RLFREE( tToken.szText);
  2416. }
  2417. }
  2418. return(pTokenDeltaInfo);
  2419. }
  2420. /*
  2421. * About -- message processor for about box
  2422. *
  2423. */
  2424. //#ifdef RLWIN32
  2425. INT_PTR CALLBACK About(
  2426. HWND hDlg,
  2427. UINT message,
  2428. WPARAM wParam,
  2429. LPARAM lParam)
  2430. {
  2431. switch( message )
  2432. {
  2433. case WM_INITDIALOG:
  2434. {
  2435. WORD wRC = SUCCESS;
  2436. CHAR szModName[ MAXFILENAME];
  2437. GetModuleFileNameA( hInst, szModName, sizeof( szModName));
  2438. if ( (wRC = GetCopyright( szModName,
  2439. szDHW,
  2440. DHWSIZE)) == SUCCESS )
  2441. {
  2442. SetDlgItemTextA( hDlg, IDC_COPYRIGHT, szDHW);
  2443. }
  2444. else
  2445. {
  2446. ShowErr( wRC, NULL, NULL);
  2447. }
  2448. }
  2449. break;
  2450. case WM_COMMAND:
  2451. if ((wParam == IDOK) || (wParam == IDCANCEL))
  2452. {
  2453. EndDialog(hDlg, TRUE);
  2454. }
  2455. break;
  2456. default:
  2457. return( FALSE);
  2458. }
  2459. return( TRUE);
  2460. }
  2461. //...................................................................
  2462. int RLMessageBoxA(
  2463. LPCSTR pszMsgText)
  2464. {
  2465. return( MessageBoxA( hMainWnd, pszMsgText, szAppName, MB_ICONHAND|MB_OK));
  2466. }
  2467. //...................................................................
  2468. void Usage()
  2469. {
  2470. return;
  2471. }
  2472. //...................................................................
  2473. void DoExit( int nErrCode)
  2474. {
  2475. ExitProcess( (UINT)nErrCode);
  2476. }