4 * Copyright 1994 Martin Ayotte
16 #include "selectors.h"
17 #include "../rc/sysres.h"
19 #include "stackframe.h"
21 #define OPENFILEDLG2 11
22 #define SAVEFILEDLG2 12
24 static DWORD CommDlgLastError = 0;
26 static HBITMAP hFolder = 0;
27 static HBITMAP hFolder2 = 0;
28 static HBITMAP hFloppy = 0;
29 static HBITMAP hHDisk = 0;
30 static HBITMAP hCDRom = 0;
32 /***********************************************************************
33 * FileDlg_Init [internal]
35 static BOOL FileDlg_Init()
37 static BOOL initialized = 0;
40 if (!hFolder) hFolder = LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER));
41 if (!hFolder2) hFolder2 = LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER2));
42 if (!hFloppy) hFloppy = LoadBitmap(0, MAKEINTRESOURCE(OBM_FLOPPY));
43 if (!hHDisk) hHDisk = LoadBitmap(0, MAKEINTRESOURCE(OBM_HDISK));
44 if (!hCDRom) hCDRom = LoadBitmap(0, MAKEINTRESOURCE(OBM_CDROM));
45 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
46 hHDisk == 0 || hCDRom == 0)
48 fprintf(stderr, "FileDlg_Init // Error loading bitmaps !");
56 /***********************************************************************
57 * GetOpenFileName [COMMDLG.1]
59 BOOL GetOpenFileName(LPOPENFILENAME lpofn)
67 if (!FileDlg_Init()) return FALSE;
69 if (lpofn == NULL) return FALSE;
70 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) {
71 dlgTemplate = GlobalLock(lpofn->hInstance);
73 CommDlgLastError = CDERR_LOADRESFAILURE;
77 if (lpofn->Flags & OFN_ENABLETEMPLATE) {
78 hInst = lpofn->hInstance;
79 hResInfo = FindResource(hInst, lpofn->lpTemplateName, RT_DIALOG);
81 CommDlgLastError = CDERR_FINDRESFAILURE;
84 hDlgTmpl = LoadResource(hInst, hResInfo);
86 CommDlgLastError = CDERR_LOADRESFAILURE;
89 dlgTemplate = GlobalLock(hDlgTmpl);
91 dlgTemplate = sysres_DIALOG_3;
94 hInst = GetWindowWord(lpofn->hwndOwner, GWW_HINSTANCE);
95 bRet = DialogBoxIndirectParamPtr(hInst, dlgTemplate, lpofn->hwndOwner,
96 GetWndProcEntry16("FileOpenDlgProc"),
99 printf("GetOpenFileName // return lpstrFile='%s' !\n",
100 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
105 /***********************************************************************
106 * GetSaveFileName [COMMDLG.2]
108 BOOL GetSaveFileName(LPOPENFILENAME lpofn)
116 if (!FileDlg_Init()) return FALSE;
118 if (lpofn == NULL) return FALSE;
119 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) {
120 dlgTemplate = GlobalLock(lpofn->hInstance);
122 CommDlgLastError = CDERR_LOADRESFAILURE;
126 if (lpofn->Flags & OFN_ENABLETEMPLATE) {
127 hInst = lpofn->hInstance;
128 hResInfo = FindResource(hInst, lpofn->lpTemplateName, RT_DIALOG);
130 CommDlgLastError = CDERR_FINDRESFAILURE;
133 hDlgTmpl = LoadResource(hInst, hResInfo);
135 CommDlgLastError = CDERR_LOADRESFAILURE;
138 dlgTemplate = GlobalLock(hDlgTmpl);
140 dlgTemplate = sysres_DIALOG_4; /* SAVEFILEDIALOG */
143 hInst = GetWindowWord(lpofn->hwndOwner, GWW_HINSTANCE);
144 bRet = DialogBoxIndirectParamPtr(hInst, dlgTemplate, lpofn->hwndOwner,
145 GetWndProcEntry16("FileSaveDlgProc"),
147 printf("GetSaveFileName // return lpstrFile='%s' !\n",
148 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
152 /***********************************************************************
153 * FILEDLG_StripEditControl [internal]
154 * Strip pathnames off the contents of the edit control.
156 static void FILEDLG_StripEditControl(HWND hwnd)
160 SendDlgItemMessage(hwnd, edt1, WM_GETTEXT, 511, MAKE_SEGPTR(temp));
161 cp = strrchr(temp, '\\');
165 cp = strrchr(temp, ':');
171 /***********************************************************************
172 * FILEDLG_ScanDir [internal]
174 static BOOL FILEDLG_ScanDir(HWND hWnd, LPSTR newPath)
176 char str[512],str2[512];
179 SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, MAKE_SEGPTR(str2));
181 if (!DlgDirList(hWnd, str, lst1, 0, 0x0000)) return FALSE;
182 DlgDirList(hWnd, "*.*", lst2, stc1, 0x8010);
187 /***********************************************************************
188 * FILEDLG_GetFileType [internal]
190 static LPSTR FILEDLG_GetFileType(LPSTR ptr, WORD index)
194 if (ptr == NULL) return NULL;
200 if (i == index) return ptr;
207 /***********************************************************************
208 * FILEDLG_WMDrawItem [internal]
210 static LONG FILEDLG_WMDrawItem(HWND hWnd, WORD wParam, LONG lParam)
212 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)PTR_SEG_TO_LIN(lParam);
215 HBITMAP hBitmap, hPrevBitmap;
220 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1) {
221 hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH));
222 SelectObject(lpdis->hDC, hBrush);
223 FillRect(lpdis->hDC, &lpdis->rcItem, hBrush);
224 SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
226 TextOut(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
228 if (lpdis->itemState != 0) {
229 InvertRect(lpdis->hDC, &lpdis->rcItem);
234 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2) {
235 hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH));
236 SelectObject(lpdis->hDC, hBrush);
237 FillRect(lpdis->hDC, &lpdis->rcItem, hBrush);
238 SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
242 GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
243 TextOut(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
244 lpdis->rcItem.top, str, strlen(str));
245 hMemDC = CreateCompatibleDC(lpdis->hDC);
246 hPrevBitmap = SelectObject(hMemDC, hBitmap);
247 BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
248 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
249 SelectObject(hMemDC, hPrevBitmap);
251 if (lpdis->itemState != 0) {
252 InvertRect(lpdis->hDC, &lpdis->rcItem);
256 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2) {
257 hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH));
258 SelectObject(lpdis->hDC, hBrush);
259 FillRect(lpdis->hDC, &lpdis->rcItem, hBrush);
260 SendMessage(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
270 GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
271 TextOut(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
272 lpdis->rcItem.top, str, strlen(str));
273 hMemDC = CreateCompatibleDC(lpdis->hDC);
274 hPrevBitmap = SelectObject(hMemDC, hBitmap);
275 BitBlt(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
276 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
277 SelectObject(hMemDC, hPrevBitmap);
279 if (lpdis->itemState != 0) {
280 InvertRect(lpdis->hDC, &lpdis->rcItem);
287 /***********************************************************************
288 * FILEDLG_WMMeasureItem [internal]
290 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WORD wParam, LONG lParam)
293 LPMEASUREITEMSTRUCT lpmeasure;
295 GetObject(hFolder2, sizeof(BITMAP), (LPSTR)&bm);
296 lpmeasure = (LPMEASUREITEMSTRUCT)PTR_SEG_TO_LIN(lParam);
297 lpmeasure->itemHeight = bm.bmHeight;
301 /***********************************************************************
302 * FILEDLG_WMInitDialog [internal]
304 static LONG FILEDLG_WMInitDialog(HWND hWnd, WORD wParam, LONG lParam)
307 LPOPENFILENAME lpofn;
311 SetWindowLong(hWnd, DWL_USER, lParam);
312 lpofn = (LPOPENFILENAME)lParam;
314 /* read filter information */
315 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFilter);
318 strcpy(tmpstr, pstr);
319 SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, MAKE_SEGPTR(tmpstr));
325 /* set default filter */
326 SendDlgItemMessage(hWnd, cmb1, CB_SETCURSEL,
327 lpofn->nFilterIndex - 1, 0);
328 strcpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrFilter),
329 lpofn->nFilterIndex));
330 SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr));
334 DlgDirListComboBox(hWnd, MAKE_SEGPTR(tmpstr), cmb2, 0, 0xC000);
336 /* read initial directory */
337 if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL) {
338 strcpy(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir));
339 if (strlen(tmpstr) > 0 && tmpstr[strlen(tmpstr)-1] != '\\'
340 && tmpstr[strlen(tmpstr)-1] != ':')
347 if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
348 fprintf(stderr, "FileDlg: couldn't read initial directory!\n");
351 /* select current drive in combo 2 */
352 n = DOS_GetDefaultDrive();
353 SendDlgItemMessage(hWnd, cmb2, CB_SETCURSEL, n, 0);
355 if (!(lpofn->Flags & OFN_SHOWHELP)) {
356 ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
358 if (lpofn->Flags & OFN_HIDEREADONLY) {
359 ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
364 /***********************************************************************
365 * FILEDLG_WMCommand [internal]
367 static LONG FILEDLG_WMCommand(HWND hWnd, WORD wParam, LONG lParam)
370 LPOPENFILENAME lpofn;
371 char tmpstr[512], tmpstr2[512];
374 lpofn = (LPOPENFILENAME)GetWindowLong(hWnd, DWL_USER);
377 FILEDLG_StripEditControl(hWnd);
378 if (HIWORD(lParam) == LBN_DBLCLK) {
379 lRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0);
380 if (lRet == LB_ERR) return TRUE;
381 SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, lRet, MAKE_SEGPTR(tmpstr));
382 SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr));
383 return SendMessage(hWnd, WM_COMMAND, IDOK, 0);
387 FILEDLG_StripEditControl(hWnd);
388 if (HIWORD(lParam) == LBN_DBLCLK) {
389 lRet = SendDlgItemMessage(hWnd, lst2, LB_GETCURSEL, 0, 0);
390 if (lRet == LB_ERR) return TRUE;
391 SendDlgItemMessage(hWnd, lst2, LB_GETTEXT, lRet, MAKE_SEGPTR(tmpstr));
393 if (tmpstr[0] == '[') {
394 tmpstr[strlen(tmpstr) - 1] = 0;
395 strcpy(tmpstr,tmpstr+1);
397 strcat(tmpstr, "\\");
398 FILEDLG_ScanDir(hWnd, tmpstr);
403 if (HIWORD(lParam) == CBN_SELCHANGE) {
404 lRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0);
405 if (lRet == LB_ERR) return TRUE;
406 strcpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrFilter),
408 SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr));
409 FILEDLG_ScanDir(hWnd, "");
414 FILEDLG_StripEditControl(hWnd);
415 lRet = SendDlgItemMessage(hWnd, cmb2, CB_GETCURSEL, 0, 0L);
416 if (lRet == LB_ERR) return 0;
417 SendDlgItemMessage(hWnd, cmb2, CB_GETLBTEXT, lRet, MAKE_SEGPTR(tmpstr));
418 sprintf(tmpstr, "%c:", tmpstr[2]);
419 FILEDLG_ScanDir(hWnd, tmpstr);
429 SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, MAKE_SEGPTR(tmpstr));
431 pstr = strrchr(tmpstr, '\\');
432 if (pstr == NULL) pstr = strrchr(tmpstr, ':');
434 if (strchr(tmpstr,'*') != NULL || strchr(tmpstr,'?') != NULL) {
435 /* edit control contains wildcards */
437 strcpy(tmpstr2, pstr+1);
440 strcpy(tmpstr2, tmpstr);
443 printf("commdlg: %s, %s\n", tmpstr, tmpstr2);
444 SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2));
445 FILEDLG_ScanDir(hWnd, tmpstr);
449 /* no wildcards, we might have a directory or a filename */
450 /* try appending a wildcard and reading the directory */
451 pstr2 = tmpstr + strlen(tmpstr);
452 if (pstr == NULL || *(pstr+1) != 0) {
453 strcat(tmpstr, "\\");
455 lRet = SendDlgItemMessage(hWnd, cmb1, CB_GETCURSEL, 0, 0);
456 if (lRet == LB_ERR) return TRUE;
457 strcpy(tmpstr2, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrFilter),
459 SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2));
460 /* if ScanDir succeeds, we have changed the directory */
461 if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
463 /* if not, this must be a filename */
467 /* strip off the pathname */
469 strcpy(tmpstr2, pstr+1);
470 SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2));
471 /* Should we MessageBox() if this fails? */
472 if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
473 strcpy(tmpstr, tmpstr2);
475 SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr));
478 ShowWindow(hWnd, SW_HIDE);
479 strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFile), tmpstr);
480 lpofn->nFileOffset = 0;
481 lpofn->nFileExtension = strlen(PTR_SEG_TO_LIN(lpofn->lpstrFile)) - 3;
482 if (PTR_SEG_TO_LIN(lpofn->lpstrFileTitle) != NULL) {
483 lRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0);
484 SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, lRet, MAKE_SEGPTR(tmpstr));
485 strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFileTitle), tmpstr);
487 EndDialog(hWnd, TRUE);
490 EndDialog(hWnd, FALSE);
496 /***********************************************************************
497 * FileOpenDlgProc [COMMDLG.6]
499 BOOL FileOpenDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
503 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
506 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
509 return FILEDLG_WMDrawItem(hWnd, wParam, lParam);
512 return FILEDLG_WMCommand(hWnd, wParam, lParam);
517 SetBkColor((HDC)wParam, 0x00C0C0C0);
518 switch (HIWORD(lParam))
521 SetTextColor((HDC)wParam, 0x00000000);
523 case CTLCOLOR_STATIC:
524 SetTextColor((HDC)wParam, 0x00000000);
534 /***********************************************************************
535 * FileSaveDlgProc [COMMDLG.7]
537 BOOL FileSaveDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
541 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
544 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
547 return FILEDLG_WMDrawItem(hWnd, wParam, lParam);
550 return FILEDLG_WMCommand(hWnd, wParam, lParam);
555 SetBkColor((HDC)wParam, 0x00C0C0C0);
556 switch (HIWORD(lParam))
559 SetTextColor((HDC)wParam, 0x00000000);
561 case CTLCOLOR_STATIC:
562 SetTextColor((HDC)wParam, 0x00000000);
572 /***********************************************************************
573 * ChooseColor [COMMDLG.5]
575 BOOL ChooseColor(LPCHOOSECOLOR lpChCol)
579 wndPtr = WIN_FindWndPtr(lpChCol->hwndOwner);
580 bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, sysres_DIALOG_8,
581 lpChCol->hwndOwner, GetWndProcEntry16("ColorDlgProc"),
587 /***********************************************************************
588 * ColorDlgProc [COMMDLG.8]
590 BOOL ColorDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
594 printf("ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
595 ShowWindow(hWnd, SW_SHOWNORMAL);
601 EndDialog(hWnd, TRUE);
604 EndDialog(hWnd, FALSE);
613 /***********************************************************************
614 * FindTextDlg [COMMDLG.11]
616 BOOL FindText(LPFINDREPLACE lpFind)
622 lpTemplate = sysres_DIALOG_9;
623 wndPtr = WIN_FindWndPtr(lpFind->hwndOwner);
624 bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, lpTemplate,
625 lpFind->hwndOwner, GetWndProcEntry16("FindTextDlgProc"),
631 /***********************************************************************
632 * ReplaceTextDlg [COMMDLG.12]
634 BOOL ReplaceText(LPFINDREPLACE lpFind)
640 lpTemplate = sysres_DIALOG_10;
641 wndPtr = WIN_FindWndPtr(lpFind->hwndOwner);
642 bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, lpTemplate,
643 lpFind->hwndOwner, GetWndProcEntry16("ReplaceTextDlgProc"),
649 /***********************************************************************
650 * FindTextDlgProc [COMMDLG.13]
652 BOOL FindTextDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
656 printf("FindTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
657 ShowWindow(hWnd, SW_SHOWNORMAL);
663 EndDialog(hWnd, TRUE);
666 EndDialog(hWnd, FALSE);
675 /***********************************************************************
676 * ReplaceTextDlgProc [COMMDLG.14]
678 BOOL ReplaceTextDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
682 printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
683 ShowWindow(hWnd, SW_SHOWNORMAL);
689 EndDialog(hWnd, TRUE);
692 EndDialog(hWnd, FALSE);
701 /***********************************************************************
702 * PrintDlg [COMMDLG.20]
704 BOOL PrintDlg(LPPRINTDLG lpPrint)
710 printf("PrintDlg(%p) // Flags=%08lX\n", lpPrint, lpPrint->Flags);
711 if (lpPrint->Flags & PD_PRINTSETUP) {
712 lpTemplate = sysres_DIALOG_6;
714 lpTemplate = sysres_DIALOG_5;
716 wndPtr = WIN_FindWndPtr(lpPrint->hwndOwner);
717 if (lpPrint->Flags & PD_PRINTSETUP)
718 bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, lpTemplate,
719 lpPrint->hwndOwner, GetWndProcEntry16("PrintSetupDlgProc"),
722 bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, lpTemplate,
723 lpPrint->hwndOwner, GetWndProcEntry16("PrintDlgProc"),
729 /***********************************************************************
730 * PrintDlgProc [COMMDLG.21]
732 BOOL PrintDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
736 printf("PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
737 ShowWindow(hWnd, SW_SHOWNORMAL);
743 EndDialog(hWnd, TRUE);
746 EndDialog(hWnd, FALSE);
755 /***********************************************************************
756 * PrintSetupDlgProc [COMMDLG.22]
758 BOOL PrintSetupDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
762 printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
763 ShowWindow(hWnd, SW_SHOWNORMAL);
769 EndDialog(hWnd, TRUE);
772 EndDialog(hWnd, FALSE);
781 /***********************************************************************
782 * CommDlgExtendError [COMMDLG.26]
784 DWORD CommDlgExtendError(void)
786 return CommDlgLastError;
790 /***********************************************************************
791 * GetFileTitle [COMMDLG.27]
793 int GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
796 printf("GetFileTitle(%p %p %d); \n", lpFile, lpTitle, cbBuf);
797 if (lpFile == NULL || lpTitle == NULL) return -1;
798 len = strlen(lpFile);
799 if (len == 0) return -1;
800 if (strchr(lpFile, '*') != NULL) return -1;
801 if (strchr(lpFile, '[') != NULL) return -1;
802 if (strchr(lpFile, ']') != NULL) return -1;
804 if (lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':') return -1;
805 for (i = len; i >= 0; i--) {
806 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':') {
811 printf("\n---> '%s' ", &lpFile[i]);
812 len = min(cbBuf, strlen(&lpFile[i]) + 1);
813 strncpy(lpTitle, &lpFile[i], len + 1);