123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- // SelFile.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SelFile.h"
- #include "ShowPhoto.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // SelFile dialog
- SelFile::SelFile(CWnd* pParent /*=NULL*/)
- : CDialog(SelFile::IDD, pParent)
- {
- //{{AFX_DATA_INIT(SelFile)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void SelFile::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SelFile)
- DDX_Control(pDX, IDC_LIST1, m_List1);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(SelFile, CDialog)
- //{{AFX_MSG_MAP(SelFile)
- ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SelFile message handlers
- BOOL SelFile::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- CString str;
- for(int i=0; i<m_pArray->GetSize (); i++)
- {
- str=m_pArray->ElementAt (i);
- str=str.Right(str.GetLength()-str.ReverseFind('\\')-1);
- if(m_List1.GetCount()%2)
- m_List1.AddEntry( str , g_gridcol1, m_List1.GetCount());
- else
- m_List1.AddEntry( str , g_gridcol2, m_List1.GetCount());
- }
- m_List1.Invalidate ();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SelFile::OnOK()
- {
- // TODO: Add extra validation here
- int pos=m_List1.GetCurSel();
- if(pos==-1)
- {
- AfxMessageBox("请先选中您要查看的附件!");return;
- }
- CString str=m_pArray->ElementAt(pos);
- CString ext;
- if(str.Find(".")!=-1)
- ext=str.Right(str.GetLength()-str.ReverseFind('.')-1);
- ext.MakeLower ();
- if(0)//ext=="jpg" || ext=="jpeg" || ext=="png" || ext=="gif"|| ext=="bmp")
- {
- Image *m_pImg=NULL;
- ::LoadImageFromBuf (&m_pImg, str);
- if(m_pImg==NULL)
- {
- AfxMessageBox("无效图片文件!");return;
- }
- ShowPhoto dlg;
- dlg.m_pImg=m_pImg;
- dlg.DoModal();
- delete m_pImg;
- }
- else
- {
- ShellExecute(NULL, _T("open"), str, NULL, NULL, SW_SHOWMAXIMIZED);
- }
- }
- void SelFile::OnDblclkList1()
- {
- // TODO: Add your control notification handler code here
- OnOK() ;
- }
|