int TFileOpen::updateListBoxes() { int Result; char Path[fsPathName+1]; if (GetDlgItem(hWindow, id_FList)) { strcpy(Path, pathName); Result = DlgDirList(hWindow, Path, id_FList, id_FPath, 0); if (Result) DlgDirList(hWindow, "*.*", id_DList, 0, 0x0C010); } else { strncpy(Path, pathName, getFileName(pathName) - pathName); strncat(Path, "*.*", fsPathName); Result = DlgDirList(hWindow, Path, id_DList, id_FPath, 0x0C010); } if (Result) { strncpy(fileSpec, getFileName(pathName), fsFileSpec); strcpy(pathName, fileSpec); updateFileName(); } return Result; }
DLGRETURN CALLBACK DirDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { WORD notify_message; switch(message) { case WM_INITDIALOG: DlgDirList(hwnd, szDirName, IDC_FILES, IDC_FOLDER, DDL_DRIVES | DDL_DIRECTORY); SetDlgItemText(hwnd, IDC_TARGET, szFolderName); return FALSE; case WM_COMMAND: notify_message = HIWORD(wParam); switch (LOWORD(wParam)) { case IDC_FILES: if (notify_message == LBN_DBLCLK) { CHAR szPath[MAXSTR]; DlgDirSelectEx(hwnd, szPath, sizeof(szPath), IDC_FILES); DlgDirList(hwnd, szPath, IDC_FILES, IDC_FOLDER, DDL_DRIVES | DDL_DIRECTORY); } return FALSE; case IDOK: GetDlgItemText(hwnd, IDC_FOLDER, szDirName, sizeof(szDirName)); GetDlgItemText(hwnd, IDC_TARGET, szFolderName, sizeof(szFolderName)); EndDialog(hwnd, TRUE); return TRUE; case IDCANCEL: EndDialog(hwnd, FALSE); return TRUE; } return FALSE; } return FALSE; }
void populate_dir (void) { char buf[MAX_PATH]; char mask[MAX_MASK_LEN]; GetWindowText(GetDlgItem(hMainWindow, IDC_MANPATH), buf, sizeof(buf)); GetWindowText(GetDlgItem(hMainWindow, IDC_MASK), mask, sizeof(mask)); if (!DirectoryExists(buf)) { current_path_to_edit (); strcpy (buf, CurrentPath); } else { size_t off; off = strlen(buf); if ((off) && (buf[off-1] != '\\') && (buf[off-1] != '/')) { buf[off] = '\\'; buf[off+1] = 0; } strcpy (CurrentPath, buf); current_path_to_edit (); } DlgDirListComboBox(hMainWindow, buf, IDC_DRIVES, 0, DDL_DRIVES); DlgDirList (hMainWindow, buf, IDC_DIRS, 0, DDL_DIRECTORY + DDL_EXCLUSIVE); /* if you want to show only files that match mask - uncomment next line */ //strcat (buf, mask); DlgDirList (hMainWindow, buf, IDC_FILES, IDC_REALPATH, 0x27); snprintf (mask, sizeof(mask), "[-%c-]", 'a' +_getdrive() - 1); ComboBox_SelectString (GetDlgItem(hMainWindow, IDC_DRIVES), 0, mask); }
int far pascal zDlgDirList( HWND pp1, LPSTR pp2, int pp3, int pp4, UINT pp5 ) { int r; SaveRegs(); /* ** Log IN Parameters (No Create/Destroy Checking Yet!) */ LogIn( (LPSTR)"APICALL:DlgDirList HWND+LPSTR+int+int+UINT+", pp1, pp2, pp3, pp4, pp5 ); /* ** Call the API! */ RestoreRegs(); GrovelDS(); r = DlgDirList(pp1,pp2,pp3,pp4,pp5); UnGrovelDS(); SaveRegs(); /* ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!) */ LogOut( (LPSTR)"APIRET:DlgDirList int++++++", r, (short)0, (short)0, (short)0, (short)0, (short)0 ); RestoreRegs(); return( r ); }
ULONG FASTCALL WU32DlgDirList(PVDMFRAME pFrame) { ULONG ul; PSZ psz2; register PDLGDIRLIST16 parg16; UpdateDosCurrentDirectory(DIR_DOS_TO_NT); GETARGPTR(pFrame, sizeof(DLGDIRLIST16), parg16); GETPSZPTR(parg16->f2, psz2); // // KidPix passes an invalid filetype flag (0x1000) that Win3.1 doesn't // check for. Win32 does, and fails the API, so mask that flag off here. // John Vert (jvert) 11-Jun-1993 // ul = GETINT16(DlgDirList( HWND32(parg16->f1), psz2, WORD32(parg16->f3), WORD32(parg16->f4), WORD32(parg16->f5) & DDL_VALID )); UpdateDosCurrentDirectory(DIR_NT_TO_DOS); FREEPSZPTR(psz2); FREEARGPTR(parg16); RETURN(ul); }
void FileBox::resetDlg( HWND hDlg ) { DlgDirList( hDlg, path, IDD_FLIST, IDD_FPATH, fileAttr ); // set the directory list to the // specified path. SetDlgItemText( hDlg, IDD_FNAME, path ); // set the file name to the // specified name. }
BOOL CDisciplineLetterTemplate::OnInitDialog() { CDialog::OnInitDialog(); // // Set the pointers to the controls // pListBoxFILES = (CListBox *)GetDlgItem(LETTERTEMPLATE_FILES); pEditPREVIEW = (CEdit *)GetDlgItem(LETTERTEMPLATE_PREVIEW); // // Display the file names // char path[MAX_PATH]; strcpy(path, szDisciplineLetterTemplateFolder); DlgDirList(path, LETTERTEMPLATE_FILES, 0, 0); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; char pszCurDir[MAX_PATH]; switch (message) { case WM_CREATE: GetCurrentDirectory(MAX_PATH, pszCurDir); cZeusCacheManager::Create(); cZeusCacheManager::Get()->MapDiskMemory(pszCurDir); gs_Mem.Update(); InvalidateRect(hWnd, NULL, TRUE); SetWindowLong(CreateWindow("LISTBOX", "", WS_VISIBLE | WS_CHILD | LBS_STANDARD, 0, 0, 180, 200, hWnd, NULL, hInst, NULL), GWL_ID, IDC_FILELIST); DlgDirList(hWnd, pszCurDir, IDC_FILELIST, 0, DDL_ARCHIVE); SetWindowLong(CreateWindow("EDIT", "", WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_VSCROLL | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_MULTILINE | ES_READONLY, 0, 300, 400, 200, hWnd, NULL, hInst, NULL), GWL_ID, IDC_FILETEXT); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; case IDC_FILELIST: switch (wmEvent) { case LBN_DBLCLK: { char lpFile[MAX_PATH]; DlgDirSelectEx(hWnd, lpFile, MAX_PATH, IDC_FILELIST); HANDLE hFile = cZeusCacheManager::Get()->OpenFile(lpFile); char lpText[1024]={0}; DWORD nRead = 0; DWORD dwSize = cZeusCacheManager::Get()->GetFileSize(hFile); char * buffer = new char[dwSize+1]; cZeusCacheManager::Get()->ReadFile(hFile, buffer, dwSize, &nRead); buffer[dwSize] = 0; SetDlgItemText(hWnd, IDC_FILETEXT, buffer); delete buffer; cZeusCacheManager::Get()->CloseFile(hFile); gs_Mem.Update(); InvalidateRect(hWnd, NULL, TRUE); } break; } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); gs_Mem.Draw(hdc); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); cZeusCacheManager::Destroy(); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
BOOL WINPROC EXPORT DlgFloppyProc (HWND hWnd, WORD msg, WORD wParam, LONG lParam) /************************************************************************/ { int iNum; WORD wSel; DWORD dwResult; FNAME szFileName; STRING szExt; STRING szPref; STRING szTitle; STRING szText; char szNum[8]; switch (msg) { case WM_INITDIALOG: SET_CLASS_HBRBACKGROUND(hWnd, ( HBRUSH )GetStockObject(LTGRAY_BRUSH)); CenterPopup (hWnd); if (bSaving) { LoadString (hInstAstral, IDS_SAVEFLOPPY, szPref, sizeof(szPref)); SetWindowText (hWnd, szPref); ShowWindow (GetDlgItem(hWnd, IDC_CHOOSEFILE), SW_HIDE); } else { LoadString (hInstAstral, IDS_LOADFLOPPY, szPref, sizeof(szPref)); SetWindowText (hWnd, szPref); EnableWindow (GetDlgItem (hWnd, IDOK), FALSE); } LoadString (hInstAstral, IDS_SELFLOPPY, szPref, sizeof(szPref)); SetDlgItemText (hWnd, IDC_FLOPPY_TEXT, szPref); clr ((LPTR)szFloppies, sizeof(szFloppies)); if ( (GetFloppyDrives (szFloppies)) <= 1) { // if only one floppy, hide second button ShowWindow (GetDlgItem(hWnd, IDC_FLOPPY2), SW_HIDE); } else { SetDlgItemText (hWnd, IDC_FLOPPY2, &szFloppies[3]); } SetDlgItemText (hWnd, IDC_FLOPPY1, szFloppies); iStartDrive = CURRENTDRIVE; break; case WM_CTLCOLOR: return( (BOOL)SetControlColors( (HDC)wParam, hWnd, (HWND)LOWORD(lParam), HIWORD(lParam) ) ); case WM_COMMAND: switch (wParam) { case IDC_FLOPPY1: case IDC_FLOPPY2: iFloppyIndex = wParam - IDC_FLOPPY1; if (iFloppyIndex) iFloppyIndex += 2; // format the search spec. lstrcpy (szFileSpec, &szFloppies[iFloppyIndex]); lstrcat (szFileSpec, "\\"); LoadString (hInstAstral, IDS_GALLERY_PREFIX, szPref, sizeof(szPref)); lstrcat (szFileSpec, szPref); LoadString (hInstAstral, IDN_ART, szExt, sizeof(szExt)); lstrcat (szFileSpec, szExt); if (bSaving) { if (! FloppySpace (iFloppyIndex)) { LoadString (hInstAstral, IDS_SAVEFLOPPY, szTitle, sizeof(szTitle)); LoadString (hInstAstral, IDS_ENOTSPACE, szText, sizeof(szText)); MessageBox (hWnd, szText, szTitle, MB_OK | MB_ICONEXCLAMATION); break; } if (! DlgDirList (hWnd, szFileSpec, IDC_CHOOSEFILE, 0, DDL_READWRITE)) { // no files found iNum = 1; } else { // find last picture number used in listbox iNum = FindLastNumber (hWnd); iNum++; } // format a pathname/filename and save the picture wsprintf (szNum, "%d", iNum); lstrcpy (szFileSpec, &szFloppies[iFloppyIndex]); lstrcat (szFileSpec, "\\"); lstrcat (szFileSpec, szPref); lstrcat (szFileSpec, szNum); LoadString (hInstAstral, IDS_GALLERY_EXT, szExt, sizeof(szExt)); lstrcat (szFileSpec, szExt); CHDRIVE (iStartDrive); AstralDlgEnd (hWnd, NO|2); } else { DlgDirList (hWnd, szFileSpec, IDC_CHOOSEFILE, 0, DDL_READWRITE); dwResult = SendDlgItemMessage (hWnd, IDC_CHOOSEFILE, LB_GETCOUNT, 0, 0L); if (dwResult == (DWORD)0) { LoadString (hInstAstral, IDS_LOADFLOPPY, szTitle, sizeof(szTitle)); LoadString (hInstAstral, IDS_NOPICTURES, szText, sizeof(szText)); MessageBox (hWnd, szText, szTitle, MB_OK | MB_ICONEXCLAMATION); break; } else if (dwResult == (DWORD)1) { clr ((LPTR)szFileName, sizeof(FNAME)); SendDlgItemMessage (hWnd, IDC_CHOOSEFILE, LB_GETTEXT, (WPARAM)0, (LPARAM)((LPSTR)szFileName)); if (szFileName[0] != 0) { lstrcpy (szFileSpec, &szFloppies[iFloppyIndex]); lstrcat (szFileSpec, "\\"); lstrcat (szFileSpec, szFileName); } else clr ((LPTR)szFileSpec, sizeof(STRING)); CHDRIVE (iStartDrive); AstralDlgEnd (hWnd, NO|2); } } break; case IDOK: if ((dwResult = SendDlgItemMessage (hWnd, IDC_CHOOSEFILE, LB_GETCURSEL, 0, 0L)) != LB_ERR) { wSel = (WPARAM)dwResult; clr ((LPTR)szFileName, sizeof(FNAME)); SendDlgItemMessage (hWnd, IDC_CHOOSEFILE, LB_GETTEXT, (WPARAM)wSel, (LPARAM)((LPSTR)szFileName)); if (szFileName[0] != 0) { lstrcpy (szFileSpec, &szFloppies[iFloppyIndex]); lstrcat (szFileSpec, "\\"); lstrcat (szFileSpec, szFileName); CHDRIVE (iStartDrive); AstralDlgEnd (hWnd, NO|2); } else clr ((LPTR)szFileSpec, sizeof(STRING)); } break; case IDCANCEL: clr ((LPTR)szFileSpec, sizeof(STRING)); CHDRIVE (iStartDrive); AstralDlgEnd (hWnd, NO|2); break; case IDC_CHOOSEFILE: if ( HIWORD(lParam) == LBN_DBLCLK ) SendMessage (hWnd, WM_COMMAND, IDOK, 1L); else if ((SendDlgItemMessage (hWnd, IDC_CHOOSEFILE, LB_GETCURSEL, 0, 0L)) != LB_ERR) { EnableWindow (GetDlgItem (hWnd, IDOK), TRUE); } break; default: return (FALSE); } break; default: return (FALSE); break; } return (TRUE); }
BOOL WINPROC EXPORT DlgOpenProc( /************************************************************************/ HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL Bool; ITEMID id; WORD wMsg, wIndex; int i, ii, l, fp, hi, lo; FNAME szDriveNDir, szFileName, szExtension; HMENU hMenu; STRING szString; char cChar; BOOL bModifySaveName; static BOOL bDisableCancel; switch (msg) { case WM_INITDIALOG: SET_CLASS_HBRBACKGROUND(hDlg, ( HBRUSH )GetStockObject(LTGRAY_BRUSH)); CenterPopup( hDlg ); if ( !DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr) ) { lstrcpy( szFileSpec, lstrchr( szFileSpec, '*' ) ); DlgDirList(hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr); } SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving); CheckComboItem( hDlg, IDC_FILETYPES, IDC_ART, IDC_BMP, IDC_ART + (idFileType-IDN_ART) ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_LIMITTEXT, MAX_FNAME_LEN-1, 0L); LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, NO ); CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath ); CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed ); for (i = IDC_ART; bImageOpen && i <= IDC_BMP; ++i) { ii = i-IDC_ART; if (lstrlen(Readers[ii].szDLL)) { lstrcpy(szString, Control.ProgHome); lstrcat(szString, Readers[ii].szDLL); if (!FileExists(szString)) { if ( GetPrivateProfileString( "Micrografx", "Libraries", "", szString, sizeof(STRING), "MGX.INI" ) > 2 ) FixPath( szString ); lstrcat(szString, Readers[ii].szDLL); if (!FileExists(szString)) { ControlEnable( hDlg, i, NO); continue; } } } if (fSaving) ControlEnable( hDlg, i, lpImage && Readers[ii].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))] ); else ControlEnable( hDlg, i, Readers[ii].bOpen ); } if ( bImageOpen && lpImage ) { idDataType = lpImage->DataType; for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i) ControlEnable( hDlg, i, Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]); CheckComboItem( hDlg, IDC_DATATYPES, IDC_SAVECT, IDC_SAVE24BITCOLOR, idDataType ); ControlEnable( hDlg, IDC_SAVECOMPRESS, Readers[idFileType-IDN_ART].bCompressed ); } SetFocus( GetDlgItem( hDlg, IDC_FNAME ) ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL, NULL, MAKELONG(0, 0x7fff)); bNavigated = NO; bDisableCancel = NO; return( FALSE ); case WM_PALETTECHANGED: break; case WM_MENUSELECT: lo = LOWORD(lParam); hi = HIWORD(lParam); if (hi == 0) break; if (lo == -1) break; if (lo & MF_SYSMENU) break; if (lo & MF_POPUP) { hMenu = (HMENU)wParam; while (GetSubMenu(hMenu, 0)) hMenu = GetSubMenu(hMenu, 0); id = GetMenuItemID(hMenu, 0); if (id <= 0) break; wParam = id - 1; } HintLine( wParam ); break; case WM_SETCURSOR: return( SetupCursor( wParam, lParam, idOpen ) ); case WM_CLOSE: AstralDlgEnd( hDlg, FALSE|2 ); break; case WM_MEASUREITEM: case WM_DRAWITEM: id = ((LPDRAWITEMSTRUCT)lParam)->CtlID; Bool = ( id == IDC_DRIVES || id == IDC_DIRS ); return( OwnerDraw( hDlg, msg, lParam, Bool ) ); // break; case WM_CTLCOLOR: return( (BOOL)SetControlColors( (HDC)wParam, hDlg, (HWND)LOWORD(lParam), HIWORD(lParam) ) ); case WM_COMMAND: if (wParam != IDCANCEL) bDisableCancel = NO; switch(wParam) { case IDC_FILETYPES: // case IDC_ART: // case IDC_TIFF: // case IDC_BMP: if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) ) break; idFileType = IDN_ART + (wParam-IDC_ART); if (bNavigated) { LookupExtension( idFileType, szFileSpec ); } else GetFileLocation( idFileType, szFileSpec ); for (i = IDC_SAVECT; i <= IDC_SAVE24BITCOLOR; ++i) ControlEnable( hDlg, i, Readers[idFileType-IDN_ART].bTypes[i-IDC_SAVECT]); ControlEnable( hDlg, IDC_SAVECOMPRESS, Readers[idFileType-IDN_ART].bCompressed ); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO ); SendMessage( hDlg, WM_COMMAND, IDOK, 0L ); break; case IDC_DATATYPES: // case IDC_SAVECT: // case IDC_SAVELA: // case IDC_SAVESP: // scatterprint // case IDC_SAVE8BITCOLOR: // case IDC_SAVE24BITCOLOR: if ( !(wParam = HandleCombo( hDlg, wParam, lParam )) ) break; idDataType = wParam; break; case IDC_SAVEPATH: Save.OKtoSavePath = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVEPATH, BM_GETCHECK, 0, 0L); // Save.OKtoSavePath = !Save.OKtoSavePath; // CheckDlgButton( hDlg, IDC_SAVEPATH, Save.OKtoSavePath ); break; case IDC_SAVECOMPRESS: Save.Compressed = (BOOL)SendDlgItemMessage (hDlg, IDC_SAVECOMPRESS, BM_GETCHECK, 0, 0L); // Save.Compressed = !Save.Compressed; // CheckDlgButton( hDlg, IDC_SAVECOMPRESS, Save.Compressed ); break; case IDC_DRIVES: wMsg = HIWORD(lParam); if ( wMsg != CBN_SELCHANGE ) break; wIndex = SendDlgItemMessage( hDlg, wParam, CB_GETCURSEL, 0, 0L); SendDlgItemMessage( hDlg, wParam, CB_GETLBTEXT, wIndex, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if (CHDRIVE( *szDriveNDir - 'a' )) { LoadComboWithDrives(hDlg, IDC_DRIVES); break; } if (!CURRENTDIR(szString, sizeof(szString))) { GetDlgItemText(hDlg, IDC_FPATH, szString, sizeof(szString)); CHDRIVE(*szString - 'a'); LoadComboWithDrives(hDlg, IDC_DRIVES); } //12/15 SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, NO); DlgDirList( hDlg, szFileSpec, IDC_FLIST, IDC_FPATH, wFileAttr ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); SetDlgItemText( hDlg, IDC_DISKSPACE, DriveSize( *szDriveNDir - 'a', szString ) ); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); bNavigated = YES; break; case IDC_DIRS: wMsg = HIWORD(lParam); if ( wMsg == LBN_DBLCLK ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != LBN_SELCHANGE ) break; wIndex = SendDlgItemMessage( hDlg, wParam, LB_GETCURSEL, 0, 0L); // Figure out how to build the path name based on the selection SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, wIndex, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if ( id == IDC_PATHICON_OPEN ) i = 0; // Must start building the path from the root else if ( id == IDC_PATHICON_ACTIVE ) i = 9999; // Don't build any path - we're there else i = wIndex; // OK to build a relative path szFileName[0] = '\0'; for ( ; i<=wIndex; i++ ) { SendDlgItemMessage( hDlg, wParam, LB_GETTEXT, i, (long)(LPSTR)szDriveNDir ); id = ExtractStringID( szDriveNDir ); if ( id == IDC_PATHICON_CLOSED && i != wIndex ) continue; lstrcat( szFileName, SkipSpaces(szDriveNDir) ); if ( id != IDC_PATHICON_ROOT ) lstrcat( szFileName, "\\" ); } lstrcat( szFileName, szFileSpec ); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); bNavigated = YES; break; case IDC_FLIST: wMsg = HIWORD(lParam); if ( wMsg == LBN_DBLCLK ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != LBN_SELCHANGE ) break; /* If a directory is selected... */ if (DlgDirSelectEx(hDlg, szFileName, sizeof(szFileName), wParam)) lstrcat(szFileName, szFileSpec); // 1-2-92 - TMR - always use SetFileName for all FNAME sets // SetDlgItemText(hDlg, IDC_FNAME, szFileName); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); SendDlgItemMessage(hDlg, IDC_FNAME, EM_SETSEL, NULL, MAKELONG(0, 0x7fff)); // SendDlgItemMessage(hDlg, IDC_FNAME, CB_SETEDITSEL, // NULL, MAKELONG(0, 0x7fff)); break; case IDC_FNAME: /* If the name is changed, disable OK if its length goes 0 */ if (HIWORD(lParam) != EN_CHANGE) // if (HIWORD(lParam) != CBN_EDITCHANGE) break; ControlEnable( hDlg, IDOK, (BOOL)SendDlgItemMessage( hDlg, wParam, WM_GETTEXTLENGTH, 0, 0L)); // 1-2-92 - TMR - make sure Edit Box has focus to make sure // that szSaveName only gets overwritten from user input // 1-3-92 - TMR - move this after ControlEnable if (GetFocus() != GetDlgItem(hDlg, IDC_FNAME)) break; if (fSaving) { GetDlgItemText(hDlg, IDC_FNAME, szSaveName, MAX_FNAME_LEN); fUntitled = NO; } break; case IDC_FPATH: wMsg = HIWORD(lParam); if ( wMsg == BN_DOUBLECLICKED ) { SendMessage(hDlg, WM_COMMAND, IDOK, 1L); break; } if ( wMsg != BN_CLICKED ) break; GetDlgItemText(hDlg, wParam, szFileName, sizeof(szFileName)); if ( !szFileName[0] ) break; FixPath( szFileName ); lstrcat( szFileName, szFileSpec ); SetFileName(hDlg, IDC_FNAME, szFileName, szSaveName, NO ); bNavigated = YES; break; case IDOK: GetDlgItemText(hDlg, IDC_FNAME, szFileName,sizeof(szFileName)); bModifySaveName = fSaving && StringsEqual(szFileName, szSaveName); /* Strip off the drive and directory to make */ /* a DlgDirlist() call to switch over to them */ /* Loop backwards over the file name */ l = lstrlen(szFileName); while( --l >= 0 ) { cChar = szFileName[l]; /* If we find a wildcard, the next DlgDirList() takes */ /* care of drive and directory switching; so get out */ if ( cChar == '?' || cChar == '*' ) break; /* If we find a drive or directory, handle it and get out */ if ( cChar == '\\' || cChar == ':' ) { lstrcpy(szDriveNDir, szFileName); l++; szDriveNDir[l] = '\0'; lstrcat(szDriveNDir, szFileSpec); // 1-3-92 - TMR - Handle directory change error if (DlgDirList(hDlg, szDriveNDir, IDC_FLIST, IDC_FPATH, wFileAttr)) lstrcpy( szFileName, &szFileName[l] ); else { szDriveNDir[l] = '\0'; Message(IDS_EDIRECTORYCHANGE, Lowercase(szDriveNDir)); szFileName[0] = '\0'; } break; } } // 1-3-92 - TMR add extension if none present /* Check to see if the file has an extension... */ if ( !lstrchr( szFileName, '.' ) ) // if no extension... if ( LookupExtension( idFileType, szExtension ) ) { if (lstrlen(szFileName)) lstrcat( szFileName, extension(szExtension) ); else lstrcat( szFileName, szExtension); } if (bModifySaveName) lstrcpy(szSaveName, szFileName); /* Try to display a new list box */ if ( !szFileName[0] ) lstrcat(szFileName, szFileSpec); if (DlgDirList(hDlg, szFileName, IDC_FLIST, IDC_FPATH, wFileAttr)) { /* A wildcard was found and a new list displayed */ lstrcpy(szFileSpec, szFileName); SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); break; } // If there is still a path or wildcards in the name, the // file specification must be invalid if (lstrchr(szFileName, '\\') || lstrchr(szFileName, ':') || lstrchr(szFileName, '?') || lstrchr(szFileName, '*')) { lstrcpy(szString, szFileName); stripfile(szString); Message(IDS_EDIRECTORYCHANGE, Lowercase(szString)); lstrcpy(szFileSpec, filename(szFileName)); lstrcpy(szFileName, szFileSpec); // is this needed? SetFileName(hDlg, IDC_FNAME, szFileSpec, szSaveName, fSaving ); break; } /* No wildcards, and the drive and dir have been changed */ LoadComboWithDrives( hDlg, IDC_DRIVES ); LoadComboWithDirectories( hDlg, IDC_DIRS, YES ); /* Check to see if the file has 8 characters or less... */ if ( fSaving ) RemoveWhiteSpace( szFileName ); FixFileName( szFileName ); /* Check to see if the file has an extension... */ if ( !lstrchr( szFileName, '.' ) ) // if no extension... if ( LookupExtension( idFileType, szExtension ) ) lstrcat( szFileName, extension(szExtension) ); // Build the fully qualified path name GetDlgItemText( hDlg, IDC_FPATH, szString, sizeof(szString) ); FixPath( szString ); lstrcat( szString, szFileName ); /* Check to see if the file exists... */ if ( (fp = _lopen( szString, OF_READ ) ) < 0 ) { /* The file does not exist */ if ( !fSaving ) { Message(IDS_EOPEN, Lowercase(szString)); break; } } else { _lclose( fp ); if ( fSaving ) { if ( !AstralAffirm( IDS_OVERWRITEIMAGE, Lowercase(szString) ) ) break; } } lstrcpy( szFileSpec, szString ); AstralDlgEnd(hDlg, TRUE|2); break; case IDC_CANCEL: case IDCANCEL: if ( bDisableCancel && !LOWORD(lParam) ) break; GetDlgItemText(hDlg, IDC_FPATH, szFileSpec,sizeof(szFileSpec)); AstralDlgEnd(hDlg, FALSE|2); break; default: return( FALSE ); } break; default: return( FALSE ); } return( TRUE ); }
LRESULT CALLBACK OpenFileProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { char *FileOnly,CurrentList[MAX_FILENAME_CHARS]; switch(uMsg) { case WM_INITDIALOG: sprintf(ReturnFilename,"%s*.%s",ImagesPath,Suffix); DlgDirList(hDlg,ReturnFilename,IDC_LIST,IDC_DIRECTORY,DDL_DIRECTORY | DDL_DRIVES); GetFullPathName(ReturnFilename,MAX_FILENAME_CHARS,CurrentList,&FileOnly); SetDlgItemText(hDlg,IDC_DIRECTORY,CurrentList); break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_LIST: if (HIWORD(wParam) == LBN_DBLCLK) { if (DlgDirSelectEx(hDlg,ReturnFilename,sizeof(ReturnFilename),IDC_LIST)) { if (strlen(ReturnFilename) == 2 && ReturnFilename[1] == ':') lstrcat(ReturnFilename,"\\"); lstrcat(ReturnFilename,"*."); lstrcat(ReturnFilename,Suffix); DlgDirList(hDlg,ReturnFilename,IDC_LIST,IDC_DIRECTORY,DDL_DIRECTORY | DDL_DRIVES); GetFullPathName(ReturnFilename,MAX_FILENAME_CHARS,CurrentList,&FileOnly); SetDlgItemText(hDlg,IDC_DIRECTORY,CurrentList); } else { EndDialog(hDlg,IDOK); } } break; case IDCANCEL: strcpy(ReturnFilename,""); EndDialog(hDlg,IDCANCEL); break; case IDOK: GetDlgItemText(hDlg,IDC_DIRECTORY,ReturnFilename,MAX_FILENAME_CHARS); if (strlen(ReturnFilename) > 5 && ReturnFilename[strlen(ReturnFilename)-5] == '*') { /* wildcards in edit box */ strcpy(ReturnFilename,"none?"); if (DlgDirSelectEx(hDlg,ReturnFilename,sizeof(ReturnFilename),IDC_LIST)) { /* user selected directory/drive */ MessageBox(hDlg,"Cannot select a directory\n(Try double-clicking.)", "Error",MB_OK | MB_APPLMODAL); } else if (strcmp(ReturnFilename,"none?") == 0) { /* nothing selected; user clicked ok */ strcpy(ReturnFilename,""); EndDialog(hDlg,IDCANCEL); } else /* something selected, user clicked ok */ EndDialog(hDlg,IDOK); break; } else /* user typed something in edit box */ EndDialog(hDlg,IDOK); break; } break; default: return(FALSE); } return(TRUE); }