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; }
static void on_dir_dblclick (void) { char buf[MAX_PATH]; if (DlgDirSelectEx (hMainWindow, buf, sizeof(buf), IDC_DIRS)) { strcat (CurrentPath, buf); strcpy (buf, CurrentPath); PathCanonicalize(CurrentPath, buf); current_path_to_edit (); populate_dir (); } }
ULONG FASTCALL WU32DlgDirSelect(PVDMFRAME pFrame) { ULONG ul; PSZ psz2; register PDLGDIRSELECT16 parg16; GETARGPTR(pFrame, sizeof(DLGDIRSELECT16), parg16); ALLOCVDMPTR(parg16->f2, MAX_VDMFILENAME, psz2); ul = GETBOOL16(DlgDirSelectEx( HWND32(parg16->f1), psz2, SIZE_BOGUS, WORD32(parg16->f3) )); FLUSHVDMPTR(parg16->f2, strlen(psz2)+1, psz2); FREEVDMPTR(psz2); FREEARGPTR(parg16); RETURN(ul); }
// // 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 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); }