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.

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