Leaked source code of windows server 2003
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.

3028 lines
96 KiB

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