Preview_demo

所属分类:对话框与窗口
开发工具:Visual C++
文件大小:30KB
下载次数:17
上传日期:2005-05-10 16:30:05
上 传 者wang__yi
说明:  这是一个对VC中的通用对话框窗口功能的一个扩展,它可以在你选择图像文件的时候直接对特殊性内容进行预览,使用方便
(this is a VC General dialog window function in an expansion, it can choose images in your document directly to the special preview content, ease of use)

文件列表:
CDIB.cpp (20159, 1999-05-25)
CDIB.h (2956, 1999-05-25)
ChildFrm.cpp (1538, 1999-05-25)
ChildFrm.h (1397, 1999-05-25)
CPreviewFileDialog.cpp (3756, 1999-05-25)
CPreviewFileDialog.h (1400, 1999-05-25)
MainFrm.cpp (2528, 1999-05-25)
MainFrm.h (1542, 1999-05-25)
Release (0, 1999-05-25)
res (0, 1999-05-25)
resource.h (646, 1999-05-25)
res\TestPreview.ico (1078, 1999-05-25)
res\TestPreview.rc2 (403, 1999-05-25)
res\TestPreviewDoc.ico (1078, 1999-05-25)
res\Toolbar.bmp (1078, 1999-05-25)
StdAfx.cpp (213, 1999-05-25)
StdAfx.h (1054, 1999-05-25)
TestPreview.cpp (4626, 1999-05-25)
TestPreview.dsp (4989, 1999-05-25)
TestPreview.dsw (545, 1999-05-25)
TestPreview.h (1411, 1999-05-25)
TestPreview.plg (2248, 1999-05-25)
TestPreview.rc (14433, 1999-05-25)
TestPreview.reg (715, 1999-05-25)
TestPreviewDoc.cpp (2734, 1999-05-25)
TestPreviewDoc.h (1417, 1999-05-25)
TestPreviewView.cpp (2729, 1999-05-25)
TestPreviewView.h (1971, 1999-05-25)
Upload.txt (2571, 1999-05-25)

Many times you may want to allow your users to see a preview of the file that they are about to open. CPreviewFileDialog does just that. The only work that you will have to do is to write a class derived from CAbstractPreview . Two functions will have to be implemented in this class. SetPreviewFile(const CString& csFileName) - This function is called each time the user changes his selection. This method allows you to open the file and get things ready for painting it in the Open File Dialog ( and yes , you can use it for a save Dialog also). Keep in mind that the file name passed may not be a valid one. For eg: if the user chooses a directory, you will get the name of the directory. It is upto you to decide how you want this case handled. DrawPreview(CDC *pDC,int x,int y,int width,int height) - This routine will be called to actually paint the image. The DC which is sent is not clipped. You will have to make sure that you keep within the bounds. The preview is shown on the right hand side of the window. By default, the width and height of the preview window are 100 bytes. You may want to draw on a smaller scale . Or, more often , you may have to scale your view to the smallest fitting rectangle. You can call the routine Calc for this. Pass it the width and height of your original view and the window width and height passed to you. You will get a CRect which centres your view. One more small thing ! The sample project contains a dialog called "FILEOPEN_TEMPLATE". You will have to copy this into your project resource file. Also , please do not forget to include CPreviewFileDialog.cpp in your project. I`m aware that the file name has an extra C prefixed, but I had to rename it as it was conflicting with some of my older projects which are in the include path. In every other way, use CPreviewFileDialog exactly as you would CFileDialog. Just pass its constructor a pointer to a class derived from CAbstractPreview. CPreviewFileDialg also provides a checkbox the user can use to disable the preview feature. The files to look at in the sample are CTestPreviewDoc - take a look at OnFileOpen... I have used a support class called CDIB to handle Device Independent Bitmaps. You are free to use it , but let me warn you , no comments in the code and no formal help from me. Be warned also, that it is meant primarily for 8 bit bitmaps. If you have a doubt , mail me rrajivram@hotmail.com and I`ll try to help. Have a look at the sample and happy previewing.

近期下载者

相关文件


收藏者