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.

680 lines
19 KiB

  1. /*-----------------------------------------------------------------------------+
  2. | DLGS.C |
  3. | |
  4. | Routines to handle selection range display |
  5. | |
  6. | (C) Copyright Microsoft Corporation 1991. All rights reserved. |
  7. | |
  8. | Revision History |
  9. | Oct-1992 MikeTri Ported to WIN32 / WIN16 common code |
  10. | |
  11. +-----------------------------------------------------------------------------*/
  12. //#undef NOSCROLL // SB_* and scrolling routines
  13. //#undef NOWINOFFSETS // GWL_*, GCL_*, associated routines
  14. //#undef NOCOLOR // color stuff
  15. //#include <string.h>
  16. #include <windows.h>
  17. #include <windowsx.h>
  18. #include <mmsystem.h>
  19. #include "mplayer.h"
  20. #include "stdlib.h"
  21. extern UINT gwCurScale;
  22. TCHAR aszHelpFile[] = TEXT("MPLAYER.HLP");
  23. /*
  24. * FUNCTION PROTOTYPES
  25. */
  26. INT_PTR FAR PASCAL _EXPORT setselDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  27. INT_PTR FAR PASCAL _EXPORT optionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  28. INT_PTR FAR PASCAL _EXPORT mciDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  29. /*--------------------------------------------------------------+
  30. | ******************* PUBLIC FUNCTIONS ************************ |
  31. +--------------------------------------------------------------*/
  32. /*--------------------------------------------------------------+
  33. | setselDialog - bring up the dialog for Set Selection |
  34. | |
  35. +--------------------------------------------------------------*/
  36. BOOL FAR PASCAL setselDialog(HWND hwnd)
  37. {
  38. FARPROC fpfn;
  39. frameboxInit(ghInst, ghInstPrev);
  40. fpfn = MakeProcInstance((FARPROC)setselDlgProc, ghInst);
  41. DialogBox(ghInst, TEXT("SetSelection"), hwnd, (DLGPROC)fpfn);
  42. return TRUE; // should we check return value?
  43. }
  44. static BOOL sfNumLastChosen;
  45. static BOOL sfInUpdate = FALSE;
  46. /*--------------------------------------------------------------+
  47. | setselDlgProc - dialog procedure for Set Selection dialog |
  48. | |
  49. +--------------------------------------------------------------*/
  50. INT_PTR PASCAL _EXPORT setselDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  51. {
  52. int iItem;
  53. DWORD_PTR fr, fr2, frIn, frOut, frMarkIn, frMarkOut, frCurrent;
  54. TCHAR ach[80];
  55. LPTSTR lpsz = (LPTSTR)ach;
  56. static int aKeyWordIds[] = {
  57. IDC_EDITALL, IDH_SELECT_ALL,
  58. IDC_EDITNONE, IDH_SELECT_NONE,
  59. IDC_EDITSOME, IDH_SELECT_FROM,
  60. IDC_EDITFROM, IDH_SELECT_FROM,
  61. IDC_ETTEXT, IDH_SELECT_FROM,
  62. IDC_EDITTO, IDH_SELECT_FROM,
  63. IDC_ESTEXT, IDH_SELECT_FROM,
  64. IDC_EDITNUM, IDH_SELECT_FROM,
  65. 0, 0
  66. };
  67. frMarkIn = frIn = SendMessage(ghwndTrackbar, TBM_GETSELSTART, 0, 0);
  68. frMarkOut = frOut = SendMessage(ghwndTrackbar, TBM_GETSELEND, 0, 0);
  69. frCurrent = SendMessage(ghwndTrackbar, TBM_GETPOS, 0, 0);
  70. switch(msg){
  71. case WM_INITDIALOG:
  72. if (gwCurScale == ID_TIME) {
  73. LOADSTRING(IDS_TIMEMODE, ach);
  74. SetWindowText(hwnd, lpsz);
  75. } else if (gwCurScale == ID_FRAMES) {
  76. LOADSTRING(IDS_FRAMEMODE, ach);
  77. SetWindowText(hwnd, lpsz);
  78. } else {
  79. LOADSTRING(IDS_TRACKMODE, ach);
  80. SetWindowText(hwnd, lpsz);
  81. }
  82. /* Always put something here - if no selection, use the cur frame */
  83. if (frMarkIn == -1 || frMarkOut == -1) {
  84. SetDlgItemInt(hwnd, IDC_EDITFROM, (UINT)frCurrent, FALSE);
  85. SetDlgItemInt(hwnd, IDC_EDITTO, (UINT)frCurrent, FALSE);
  86. SetDlgItemInt(hwnd, IDC_EDITNUM, 0, FALSE);
  87. } else {
  88. SetDlgItemInt(hwnd, IDC_EDITFROM, (UINT)frMarkIn, FALSE);
  89. SetDlgItemInt(hwnd, IDC_EDITTO, (UINT)frMarkOut, FALSE);
  90. SetDlgItemInt(hwnd, IDC_EDITNUM, (UINT)(frMarkOut - frMarkIn), FALSE);
  91. }
  92. if (frMarkIn == -1 || frMarkOut == -1) {
  93. /* turn on the NONE radio button */
  94. CheckRadioButton(hwnd, IDC_EDITALL, IDC_EDITNONE, IDC_EDITNONE);
  95. } else if(frMarkIn == gdwMediaStart &&
  96. frMarkOut == gdwMediaStart + gdwMediaLength){
  97. /* turn on the ALL button, it is all selected */
  98. CheckRadioButton(hwnd, IDC_EDITALL, IDC_EDITNONE, IDC_EDITALL);
  99. } else {
  100. /* turn on the From/To portion */
  101. CheckRadioButton(hwnd, IDC_EDITALL, IDC_EDITNONE, IDC_EDITSOME);
  102. }
  103. return TRUE;
  104. case WM_CONTEXTMENU:
  105. {
  106. int i;
  107. for (i = 0; aKeyWordIds[i]; i+=2)
  108. if (aKeyWordIds[i] == GetDlgCtrlID((HWND)wParam))
  109. break;
  110. if (aKeyWordIds[i] == 0)
  111. break;
  112. WinHelp((HWND)wParam, aszHelpFile, HELP_CONTEXTMENU, (UINT_PTR)(LPVOID)aKeyWordIds);
  113. return TRUE;
  114. }
  115. case WM_HELP:
  116. {
  117. int i;
  118. for (i = 0; aKeyWordIds[i]; i+=2)
  119. if (aKeyWordIds[i] == ((LPHELPINFO)lParam)->iCtrlId)
  120. break;
  121. if (aKeyWordIds[i] == 0)
  122. break;
  123. WinHelp(((LPHELPINFO)lParam)->hItemHandle, aszHelpFile,
  124. HELP_WM_HELP, (UINT_PTR)(LPVOID)aKeyWordIds);
  125. return TRUE;
  126. }
  127. case WM_COMMAND:
  128. switch(LOWORD(wParam)){
  129. WORD Code;
  130. BOOL OK;
  131. case IDOK:
  132. /* We hit this AFTER we press OK on the selection box */
  133. /* Make sure box we're editing loses focus before we */
  134. /* execute, so values will be set properly. */
  135. SetFocus(GetDlgItem(hwnd, IDOK));
  136. if (IsDlgButtonChecked(hwnd, IDC_EDITALL)) {
  137. /* this is the All: case */
  138. frIn = gdwMediaStart;
  139. frOut = gdwMediaStart + gdwMediaLength;
  140. } else if (IsDlgButtonChecked(hwnd, IDC_EDITNONE)){
  141. /* this is the None: case */
  142. frIn = frOut = (DWORD)(-1);
  143. } else {
  144. /* this is the From: To: case */
  145. iItem = 0;
  146. frIn = GetDlgItemInt(hwnd, IDC_EDITFROM, &OK, FALSE);
  147. if (!OK)
  148. iItem = IDC_EDITFROM; // we misbehaved
  149. else {
  150. frOut = GetDlgItemInt(hwnd, IDC_EDITTO, &OK, FALSE);
  151. if (!OK)
  152. iItem = IDC_EDITTO;
  153. }
  154. if ((!OK)
  155. || (frOut < frIn)
  156. || ((long)frIn < (long)gdwMediaStart)
  157. || (frOut > gdwMediaStart + gdwMediaLength)) {
  158. if (!iItem && (long)frIn < (long)gdwMediaStart)
  159. iItem = IDC_EDITFROM; // who misbehaved?
  160. else if (!iItem)
  161. iItem = IDC_EDITTO;
  162. // Don't beep -- Lose focus message already beeped
  163. // MessageBeep(MB_ICONEXCLAMATION);
  164. /* Illegal values, display msg box */
  165. ErrorResBox(hwnd, ghInst,
  166. MB_ICONEXCLAMATION | MB_OK,
  167. IDS_APPNAME, IDS_FRAMERANGE);
  168. /* Prevent box from ending */
  169. /* select offending value */
  170. SetFocus(GetDlgItem(hwnd, iItem));
  171. SendMessage(GetDlgItem(hwnd, iItem),
  172. EM_SETSEL, 0, (LPARAM)-1);
  173. return TRUE;
  174. }
  175. }
  176. SendMessage(ghwndTrackbar, TBM_SETSELSTART, (WPARAM)FALSE, frIn);
  177. SendMessage(ghwndTrackbar, TBM_SETSELEND, (WPARAM)TRUE, frOut);
  178. DirtyObject(TRUE);
  179. EndDialog(hwnd, TRUE);
  180. break;
  181. case IDCANCEL:
  182. EndDialog(hwnd, FALSE);
  183. break;
  184. case IDC_EDITALL:
  185. CheckRadioButton(hwnd, IDC_EDITALL,
  186. IDC_EDITNONE, IDC_EDITALL);
  187. break;
  188. case IDC_EDITNONE:
  189. CheckRadioButton(hwnd, IDC_EDITALL,
  190. IDC_EDITNONE, IDC_EDITNONE);
  191. break;
  192. case IDC_EDITSOME:
  193. CheckRadioButton(hwnd, IDC_EDITALL,
  194. IDC_EDITNONE, IDC_EDITSOME);
  195. /* put the focus on the FROM box */
  196. SetFocus(GetDlgItem(hwnd, IDC_EDITFROM));
  197. break;
  198. case IDC_EDITNUM:
  199. /* turn on the FROM box if it isn't */
  200. Code = GET_WM_COMMAND_CMD(wParam, lParam);
  201. if (!IsDlgButtonChecked(hwnd, IDC_EDITSOME))
  202. {
  203. SetFocus(GetDlgItem(hwnd, IDC_EDITSOME));
  204. CheckRadioButton(hwnd, IDC_EDITALL,
  205. IDC_EDITNONE, IDC_EDITSOME);
  206. }
  207. if (!sfInUpdate && Code == EN_KILLFOCUS) {
  208. sfNumLastChosen = TRUE;
  209. goto AdjustSomething;
  210. }
  211. break;
  212. case IDC_EDITTO:
  213. /* turn on the FROM box if it isn't */
  214. Code = GET_WM_COMMAND_CMD(wParam, lParam);
  215. if (!IsDlgButtonChecked(hwnd, IDC_EDITSOME))
  216. {
  217. SetFocus(GetDlgItem(hwnd, IDC_EDITSOME));
  218. CheckRadioButton(hwnd, IDC_EDITALL,
  219. IDC_EDITNONE, IDC_EDITSOME);
  220. }
  221. if (!sfInUpdate && Code == EN_KILLFOCUS) {
  222. sfNumLastChosen = FALSE;
  223. goto AdjustSomething;
  224. }
  225. break;
  226. case IDC_EDITFROM:
  227. /* turn on the FROM box if it isn't */
  228. Code = GET_WM_COMMAND_CMD(wParam, lParam);
  229. if (!IsDlgButtonChecked(hwnd, IDC_EDITSOME))
  230. {
  231. CheckRadioButton(hwnd, IDC_EDITALL,
  232. IDC_EDITNONE, IDC_EDITSOME);
  233. if (GetFocus() != GetDlgItem(hwnd, IDC_EDITSOME))
  234. SetFocus(GetDlgItem(hwnd, IDC_EDITSOME));
  235. }
  236. if (!sfInUpdate && Code == EN_KILLFOCUS) {
  237. sfNumLastChosen = FALSE;
  238. goto AdjustSomething;
  239. }
  240. break;
  241. AdjustSomething:
  242. sfInUpdate = TRUE;
  243. fr = GetDlgItemInt(hwnd, IDC_EDITFROM, &OK, FALSE);
  244. if (!OK)
  245. MessageBeep(MB_ICONEXCLAMATION);
  246. else {
  247. if ((long)fr < (long)gdwMediaStart) {
  248. MessageBeep(MB_ICONEXCLAMATION);
  249. fr = gdwMediaStart;
  250. }
  251. if (fr > gdwMediaStart + gdwMediaLength) {
  252. MessageBeep(MB_ICONEXCLAMATION);
  253. fr = gdwMediaStart + gdwMediaLength;
  254. }
  255. // We have to do this in time format, or if fr changed
  256. SetDlgItemInt(hwnd, IDC_EDITFROM, (UINT)fr, FALSE);
  257. if (sfNumLastChosen) {
  258. /* They changed the number of frames last, */
  259. /* so keep it constant. */
  260. AdjustTo:
  261. fr2 = GetDlgItemInt(hwnd, IDC_EDITNUM, &OK, FALSE);
  262. if (!OK)
  263. MessageBeep(MB_ICONEXCLAMATION);
  264. else {
  265. if (fr + fr2 > gdwMediaStart + gdwMediaLength) {
  266. MessageBeep(MB_ICONEXCLAMATION);
  267. fr2 = gdwMediaStart + gdwMediaLength - fr;
  268. }
  269. // if (fr2 < 0)
  270. // fr2 = 0;
  271. // We have to do this in time format, or if fr changed
  272. SetDlgItemInt(hwnd, IDC_EDITNUM, (UINT)fr2, FALSE);
  273. SetDlgItemInt(hwnd, IDC_EDITTO, (UINT)(fr + fr2), FALSE);
  274. }
  275. } else {
  276. /* They changed a frame number last, */
  277. /* so vary the number of frames */
  278. fr2 = GetDlgItemInt(hwnd, IDC_EDITTO, &OK, FALSE);
  279. if (!OK)
  280. MessageBeep(MB_ICONEXCLAMATION);
  281. else {
  282. if (fr2 < fr) {
  283. /* Set TO = FROM */
  284. SetDlgItemInt(hwnd, IDC_EDITNUM, 0, FALSE);
  285. goto AdjustTo;
  286. }
  287. if (fr2 > gdwMediaStart + gdwMediaLength) {
  288. MessageBeep(MB_ICONEXCLAMATION);
  289. fr2 = gdwMediaStart + gdwMediaLength;
  290. }
  291. SetDlgItemInt(hwnd, IDC_EDITNUM, (UINT)(fr2 - fr), FALSE);
  292. // must redraw for time mode or if fr2 changed
  293. SetDlgItemInt(hwnd, IDC_EDITTO, (UINT)fr2, FALSE);
  294. }
  295. }
  296. }
  297. sfInUpdate = FALSE;
  298. return TRUE;
  299. break;
  300. }
  301. break;
  302. }
  303. return FALSE;
  304. }
  305. /*--------------------------------------------------------------+
  306. | optionsDialog - bring up the dialog for Options |
  307. | |
  308. +--------------------------------------------------------------*/
  309. BOOL FAR PASCAL optionsDialog(HWND hwnd)
  310. {
  311. FARPROC fpfn;
  312. #if 0
  313. DWORD ThreadId;
  314. DWORD WindowThreadId;
  315. #endif
  316. fpfn = MakeProcInstance((FARPROC)optionsDlgProc, ghInst);
  317. #if 0
  318. Problem:
  319. When in-place editing, bring up the Options (or other) dialog,
  320. then bring another app into the foreground. If you now click on
  321. our container, you just get a beep. You can get back using the
  322. Task List.
  323. I can't get it to work with AttachThreadInput, but I'm not even
  324. sure that this should be the server's responsibility. It's the
  325. container that's receiving the mouse clicks.
  326. I haven't had any word from the OLE guys on this question.
  327. if (gfOle2IPEditing)
  328. {
  329. ThreadId = GetCurrentThreadId( );
  330. WindowThreadId = GetWindowThreadProcessId(ghwndCntr, NULL);
  331. AttachThreadInput(WindowThreadId, ThreadId, TRUE);
  332. }
  333. #endif
  334. DialogBox(ghInst, TEXT("Options"), hwnd, (DLGPROC)fpfn);
  335. #if 0
  336. if (gfOle2IPEditing)
  337. AttachThreadInput(ThreadId, WindowThreadId, FALSE);
  338. #endif
  339. return TRUE; // should we check return value?
  340. }
  341. /*--------------------------------------------------------------+
  342. | optionsDlgProc - dialog procedure for Options dialog |
  343. | |
  344. +--------------------------------------------------------------*/
  345. INT_PTR FAR PASCAL _EXPORT optionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  346. {
  347. UINT w;
  348. HDC hdc;
  349. static int aKeyWordIds[] =
  350. {
  351. OPT_AUTORWD, IDH_OPT_AUTO,
  352. OPT_AUTOREP, IDH_OPT_REPEAT,
  353. IDC_OLEOBJECT, IDH_OPT_CAPTCONTROL,
  354. OPT_BAR, IDH_OPT_CAPTCONTROL,
  355. OPT_BORDER, IDH_OPT_BORDER,
  356. OPT_PLAY, IDH_OPT_PLAYCLIENT,
  357. OPT_DITHER, IDH_OPT_DITHER,
  358. IDC_CAPTIONTEXT, IDH_OPT_CAPTION,
  359. IDC_TITLETEXT, IDH_OPT_CAPTION,
  360. 0 , 0
  361. };
  362. switch(msg){
  363. case WM_INITDIALOG:
  364. /* Take advantage of the fact that the button IDS are the */
  365. /* same as the bit fields. */
  366. for (w = OPT_FIRST; w <= OPT_LAST; w <<= 1)
  367. CheckDlgButton(hwnd, w, gwOptions & w);
  368. /* Enable and Fill the Title Text */
  369. /* limit this box to CAPTION_LEN chars of input */
  370. SendMessage(GetDlgItem(hwnd, IDC_TITLETEXT), EM_LIMITTEXT,
  371. (WPARAM)CAPTION_LEN, 0L);
  372. SendMessage(hwnd, WM_COMMAND, (WPARAM)OPT_BAR, 0L);
  373. hdc = GetDC(NULL);
  374. if (!(GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) ||
  375. !(gwDeviceType & DTMCI_CANWINDOW)) {
  376. CheckDlgButton(hwnd, OPT_DITHER, FALSE);
  377. EnableWindow(GetDlgItem(hwnd, OPT_DITHER), FALSE);
  378. #if 0
  379. CheckDlgButton(hwnd, OPT_USEPALETTE, FALSE);
  380. EnableWindow(GetDlgItem(hwnd, OPT_USEPALETTE), FALSE);
  381. #endif
  382. }
  383. ReleaseDC(NULL, hdc);
  384. return TRUE;
  385. case WM_CONTEXTMENU:
  386. {
  387. WinHelp((HWND)wParam, aszHelpFile, HELP_CONTEXTMENU, (UINT_PTR)(LPVOID)aKeyWordIds);
  388. return TRUE;
  389. }
  390. case WM_HELP:
  391. {
  392. int i;
  393. for (i = 0; aKeyWordIds[i]; i+=2)
  394. if (aKeyWordIds[i] == ((LPHELPINFO)lParam)->iCtrlId)
  395. break;
  396. WinHelp(((LPHELPINFO)lParam)->hItemHandle, aszHelpFile,
  397. HELP_WM_HELP, (UINT_PTR)(LPVOID)aKeyWordIds);
  398. return TRUE;
  399. }
  400. case WM_COMMAND:
  401. switch(LOWORD(wParam)){
  402. BOOL f;
  403. case IDOK:
  404. /* Change auto-repeat on the fly:
  405. * If the auto-repeat option has changed
  406. * and we're playing right now, toggle
  407. * the appropriate global option and call
  408. * PlayMCI(). This will update things.
  409. * Note that if we are currently playing
  410. * a selection, this causes the whole clip
  411. * to be played. Is there any way round this?
  412. */
  413. if ((gwStatus == MCI_MODE_PLAY)
  414. &&(((gwOptions & OPT_AUTOREP) == OPT_AUTOREP)
  415. != (BOOL)IsDlgButtonChecked(hwnd, OPT_AUTOREP)))
  416. {
  417. gwOptions ^= OPT_AUTOREP;
  418. PlayMCI(0,0);
  419. }
  420. gwOptions &= OPT_SCALE; // keep the Scale Mode
  421. /* Take advantage of the fact that the button IDS are the */
  422. /* same as the bit fields. */
  423. for (w = OPT_FIRST; w <= OPT_LAST; w <<= 1)
  424. if (IsDlgButtonChecked(hwnd, w))
  425. gwOptions |= w;
  426. if (IsDlgButtonChecked(hwnd, OPT_BAR))
  427. {
  428. GetWindowText(GetDlgItem(hwnd, IDC_TITLETEXT),
  429. gachCaption, CHAR_COUNT(gachCaption));
  430. if (gachCaption[0])
  431. gwOptions |= OPT_TITLE;
  432. else
  433. gwOptions &= ~OPT_TITLE;
  434. }
  435. DirtyObject(FALSE);
  436. EndDialog(hwnd, TRUE);
  437. break;
  438. case IDCANCEL:
  439. EndDialog(hwnd, FALSE);
  440. break;
  441. case OPT_BAR:
  442. f = IsDlgButtonChecked(hwnd, OPT_BAR);
  443. EnableWindow(GetDlgItem(hwnd, IDC_CAPTIONTEXT), f);
  444. EnableWindow(GetDlgItem(hwnd, IDC_TITLETEXT), f);
  445. if(f) {
  446. SetWindowText(GetDlgItem(hwnd, IDC_TITLETEXT), gachCaption);
  447. } else {
  448. GetWindowText(GetDlgItem(hwnd, IDC_TITLETEXT),
  449. gachCaption, CHAR_COUNT(gachCaption));
  450. SetWindowText(GetDlgItem(hwnd, IDC_TITLETEXT), TEXT(""));
  451. }
  452. break;
  453. }
  454. }
  455. return FALSE;
  456. }
  457. /*--------------------------------------------------------------+
  458. | mciDialog - bring up the dialog for MCI Send Command |
  459. | |
  460. +--------------------------------------------------------------*/
  461. BOOL FAR PASCAL mciDialog(HWND hwnd)
  462. {
  463. FARPROC fpfn;
  464. fpfn = MakeProcInstance((FARPROC)mciDlgProc, ghInst);
  465. DialogBox(ghInst, MAKEINTATOM(DLG_MCICOMMAND), hwnd, (DLGPROC)fpfn);
  466. return TRUE; // should we check return value?
  467. }
  468. /* StripLeadingAndTrailingWhiteSpace
  469. *
  470. * Removes blanks at the beginning and end of the string.
  471. *
  472. * Parameters:
  473. *
  474. * pIn - Pointer to the beginning of the string
  475. *
  476. * InLen - Length of the input string. If 0, the length will be checked.
  477. *
  478. * pOutLen - Pointer to a buffer to receive the length of the output string.
  479. *
  480. * Return:
  481. *
  482. * Pointer to the output string.
  483. *
  484. * Remarks:
  485. *
  486. * If InLen == *pOutLen, the string has not changed.
  487. *
  488. * This routine is destructive: all trailing white space is converted
  489. * to NULLs.
  490. *
  491. *
  492. * Andrew Bell, 4 January 1995
  493. */
  494. LPTSTR StripLeadingAndTrailingWhiteSpace(LPTSTR pIn, DWORD InLen, LPDWORD pOutLen)
  495. {
  496. LPTSTR pOut = pIn;
  497. DWORD Len = InLen;
  498. if (Len == 0)
  499. Len = lstrlen(pIn);
  500. /* Strip trailing blanks:
  501. */
  502. while ((Len > 0) && (pOut[Len - 1] == TEXT(' ')))
  503. {
  504. pOut[Len - 1] = TEXT('\0');
  505. Len--;
  506. }
  507. /* Strip leading blanks:
  508. */
  509. while ((Len > 0) && (*pOut == TEXT(' ')))
  510. {
  511. pOut++;
  512. Len--;
  513. }
  514. if (pOutLen)
  515. *pOutLen = Len;
  516. return pOut;
  517. }
  518. INT_PTR FAR PASCAL _EXPORT mciDlgProc(HWND hwnd, unsigned msg, WPARAM wParam, LPARAM lParam)
  519. {
  520. TCHAR ach[MCI_STRING_LENGTH];
  521. UINT w;
  522. DWORD dw;
  523. LPTSTR pStrip;
  524. DWORD NewLen;
  525. switch (msg)
  526. {
  527. case WM_INITDIALOG:
  528. SendDlgItemMessage(hwnd, IDC_MCICOMMAND, EM_LIMITTEXT, CHAR_COUNT(ach) -1, 0);
  529. return TRUE;
  530. case WM_COMMAND:
  531. switch (LOWORD(wParam))
  532. {
  533. case IDOK:
  534. w = GetDlgItemText(hwnd, IDC_MCICOMMAND, ach, CHAR_COUNT(ach));
  535. /* Strip off any white space at the start of the command,
  536. * otherwise we get an MCI error. Remove it from the
  537. * end also.
  538. */
  539. pStrip = StripLeadingAndTrailingWhiteSpace(ach, w, &NewLen);
  540. if (w > NewLen)
  541. {
  542. SetDlgItemText(hwnd, IDC_MCICOMMAND, pStrip);
  543. w = GetDlgItemText(hwnd, IDC_MCICOMMAND, ach, CHAR_COUNT(ach));
  544. }
  545. if (w == 0)
  546. break;
  547. SendDlgItemMessage(hwnd, IDC_MCICOMMAND, EM_SETSEL, 0, (LPARAM)-1);
  548. dw = SendStringMCI(ach, ach, CHAR_COUNT(ach));
  549. if (dw != 0)
  550. {
  551. mciGetErrorString(dw, ach, CHAR_COUNT(ach));
  552. // Error1(hwnd, IDS_DEVICEERROR, (LPTSTR)ach);
  553. }
  554. SetDlgItemText(hwnd, IDC_RESULT, ach);
  555. break;
  556. case IDCANCEL:
  557. EndDialog(hwnd, FALSE);
  558. break;
  559. }
  560. break;
  561. }
  562. return FALSE;
  563. }
  564.