// DirDialog.cpp - implements class CDirDialog
// The CDirDialog class implements a directory selection dialog by deriving from the file
// selection dialog class (CFileDialog). This dialog has the advantages of the standard
// file open dialog (resizeable, ability to create/delete directories etc) but is
// customized for the selection of a directory rather than a file.
//
// USER INTERFACE
// --------------
//
// For example, the user can double click on a directory name or type it into the
// edit control to open it in the directory listing display. To say that this is
// the directory they want the user must click the "Open" button. When the user
// enters a backslash (\) as the last character in the edit control the display is
// changed to show the contents of the directory if it exists. The same is done if
// the user presses the Enter key except that if the directory does not exist the
// user is asked if they want to create it.
//
// When the user enters other characters and the contents don't end in a backslash
// then automatic directory name completion is attempted. If the contents of the
// edit box are the first character(s) of one unique existing directory then the
// rest of the directory name is added to the end of the edit box. These characters
// are selected so that the user can type something else and it they will be ignored.
//
// When selecting a directory you would normally not want to see files, but you may on
// occasion. The normal "Files of Type:" drop down list is available but it has an
// extra entry "Show Folders Only" that is selected by default. When files are
// displayed double clicking of them is ignored (unlike the normal File Open dialog).
// Double-clicking a directory name changes to that directory as normal.
//
// PROGRAMMER INTERFACE
// --------------------
//
// Add DirDialog.cpp and DirDialog.h to your project. Include DirDialog.h
// in the source file(s) where you want to use the CDirDialog class.
//
// Create a CDirDialog object using the constructor described below. If necessary
// you may then modify values in the m_ofn member of the CFileDialog base class
// (see the Win32 documentation for OPENFILENAME). For example, to change the
// text that appears in the title bar of the dialog use m_ofn.lpstrTitle.
//
// Call DoModal() to activate the dialog. If DoModal() return IDOK you can then
// call GetPath() to obtain the name of the directory that the user selected.
//
//
// CDirDialog::CDirDialog(LPCTSTR lpstrInitialDir = NULL,
// LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
//
// lpstrInitialDir
// The initial directory. If NULL then the current directory is used.
// See lpstrInitialDir in the Win32 documentation for OPENFILENAME for more info.
//
// lpszFilter
// The string pairs that specify the file filters to use. See lpszFilter
// in the documentation for the CFileDialog constructor for more info.
// Note that an extra entry is always added that allows the user to hide the
// display of all files. If NULL is used (the default) then only the
// "no files" entry and an "all files" entry are provided.
//
// pParentWnd
// A pointer to the dialog parent window.
//
// virtual int CDirDialog::DoModal()
//
// see CFileDialog::DoModal().
//
// CString CDirDialog::GetPath()
//
// return value
// The full path name chosen by the user.
//
// Example:
//
// // Called when the Browse button is clicked in CMyDialog
// void CMyDialog::OnBrowseDir()
// {
// if (!UpdateData(TRUE)) // Update current value of m_dir from control
// return;
//
// CDirDialog dlg(m_dir,
// "JPEG Files (*.jpg; *.jpeg)|*.jpg;*.jpeg|All Files (*.*)|*.*||",
// this);
// dlg.m_ofn.lpstrTitle = "Select Folder to Store Images";
//
// if (dlg.DoModal() == IDOK)
// {
// m_dir = dlg.GetPath(); // Store selected directory name back into the control
// UpdateData(FALSE);
// }
// }
//
//
// INTERNAL DESIGN
// ---------------
//
// The following changes are made to the controls in the standard file open dialog:
//
// The "Open" button is hidden and replaced with another button (IDC_OPEN).
// The normal edit control (edt1) where the file name is entered is hidden and replaced
// by a "subclassed" edit control (IDC_DIR) of class CDirEdit (derived from CEdit).
// By hiding and replacing these controls we can manipulate the behaviour
// of the dialog in ways not provided for in any other way. For example, by changing
// the contents of the hidden edit control (edt1) and simulating a click of the hidden
// Open button (IDOK) we can force the contents of a directory to be displayed.
//
// An extra entry is added to the file types drop down combo called "Show Folders Only"
// that causes no files to be displayed. (If no filters are supplied at all by using
// the default value of NULL, then an "All Files" filter type is also added.)
// The filter string is a single dot (full-stop) which will match no files.
//
// The new edit control (IDC_DIR) is subclassed so that the contents are monitored and
// the some keys can be intercepted. When the contents are changed and they end with
// a backslash the current display is changed to point to the directory entered (if it
// exists). When return is pressed the directory is also changed, but if it doesn't
// exist then the user is asked if he wants to create it. The way the directory is
// changed (ie. the files of that directory are shown in the display) is by putting the
// directory name into the original edit control (edt1) and simulating a click of the
// original Open button (IDOK). Directory name completion is also performed as the
// user types in a directory name.
//
// The IDC_OPEN button is used as a replacement for the IDOK button while still allowing
// the hidden IDOK button to be used to change the displayed directory.
//
// The CDirDialog class is derived from CFileDialog. The following base class members
// are overridden:
// - OnInitDone: so that the dialog controls can be reorganized
// - OnFolderChange: so that when the user clicks on a folder name the edit control can
// be updated to reflect the name of the currently selected directory
// - OnFileNameOK: always returns TRUE so that the user can't select files by
// double-clicking them (this is a DIRECTORY selection dialog after all)
#include "stdafx.h"
// If you don't want this as part of your project (eg to put in a library) remove
// the above #include "stdafx.h" and uncomment the following 3 lines:
//#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
//#include <afxwin.h> // MFC core and standard components
//#include <afxext.h> // MFC extensions
#include <Dlgs.h> // For file dialog control IDs
#include <imagehlp.h> // For ::MakeSureDirectoryPathExists()
#include "DirDialog.h" // Our own header file
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define IDC_DIR 181 // New edit control for entering the directory name
#define IDC_OPEN 182 // New "Open" button
// Class CDlgWnd
BEGIN_MESSAGE_MAP(CDlgWnd, CWnd)
ON_BN_CLICKED(IDC_OPEN, OnOpen)
END_MESSAGE_MAP()
void CDlgWnd::OnOpen()
{
// Get the text and check whether it is a valid directory
CString ss;
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_DIR);
ASSERT(pEdit != NULL);
pEdit->GetWindowText(ss);
int len = ss.GetLength();
if (len == 2 && ss[0] == '\\' && ss[1] == '\\')
{
AfxMessageBox(ss + _T("\nThis is not a va
没有合适的资源?快使用搜索试试~ 我知道了~
VC++的图片查看工具完整代码
共56个文件
cur:8个
h:7个
sbr:6个
需积分: 5 0 下载量 9 浏览量
2022-12-27
17:22:49
上传
评论
收藏 2.05MB RAR 举报
温馨提示
VC++的图片查看工具完整代码,支持图片平滑拖动、放大、缩小等,支持目录中获得所有图片,定时播放,可用于找到所有图片
资源推荐
资源详情
资源评论
收起资源包目录
PicturePlayer.rar (56个子文件)
PicturePlayer
DirDialog.cpp 29KB
2.jpg 25KB
JpgDll.dll 140KB
PicturePlayer.h 1KB
PicturePlayerView.cpp 25KB
DirDialog.h 2KB
PicturePlayer.plg 2KB
MainFrm.cpp 5KB
res
zoom_out.cur 626B
Thumbs.db 6KB
disable_toolbar.bmp 26KB
hand.cur 326B
lnodrop.cur 766B
3dgarro.cur 766B
PicturePlayerDoc.ico 1KB
Toolbar.bmp 26KB
PicturePlayer.ico 1KB
PicturePlayer.rc2 405B
1.bmp 70B
cur00001.cur 326B
cursor1.cur 2KB
drag_cur.cur 326B
cur00002.cur 766B
Resource.h 1005B
PicturePlayer.cpp 4KB
PicturePlayer.rc 13KB
PicturePlayerView.h 5KB
MainFrm.h 2KB
PicturePlayer.dsp 5KB
PicturePlayer.clw 3KB
PicturePlayerDoc.cpp 2KB
StdAfx.cpp 215B
PicturePlayer.opt 390KB
PicturePlayer.ncb 145KB
PicturePlayer.aps 87KB
PicturePlayer.dsw 549B
PicturePlayerDoc.h 1KB
JpgDll.lib 2KB
Debug
DirDialog.obj 56KB
2.jpg 25KB
Thumbs.db 5KB
PicturePlayer.res 72KB
DirDialog.sbr 0B
PicturePlayer.obj 22KB
StdAfx.obj 103KB
PicturePlayerDoc.obj 14KB
PicturePlayer.sbr 0B
StdAfx.sbr 1.3MB
PicturePlayer.bsc 3.09MB
PicturePlayerView.sbr 0B
PicturePlayer.exe 2.25MB
MainFrm.sbr 0B
PicturePlayerDoc.sbr 0B
PicturePlayerView.obj 96KB
MainFrm.obj 26KB
StdAfx.h 1KB
共 56 条
- 1
资源评论
扬长而去
- 粉丝: 2
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功