123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- // CBitmapPage.cpp : implementation file
- //
- #include "stdafx.h"
- #include "resource.h"
- #include "bitmappage.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CBitmapPage property page
- IMPLEMENT_DYNCREATE(CBitmapPage, CPropertyPage)
- CBitmapPage::CBitmapPage() : CPropertyPage(CBitmapPage::IDD)
- {
- //{{AFX_DATA_INIT(CBitmapPage)
- m_strDynFile = _T("");
- m_strStaticFile = _T("");
- m_bStretch = FALSE;
- m_bDyn = FALSE;
- m_strDynCondition = _T("");
- //}}AFX_DATA_INIT
- }
- CBitmapPage::~CBitmapPage()
- {
- }
- void CBitmapPage::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CBitmapPage)
- DDX_Text(pDX, ID_DYNPIC, m_strDynFile);
- DDX_Text(pDX, ID_STATICPIC, m_strStaticFile);
- DDX_Check(pDX, ID_STRETCH, m_bStretch);
- DDX_Check(pDX, IDC_DYNAMIC, m_bDyn);
- DDX_Text(pDX, IDC_DYNCONDITION, m_strDynCondition);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CBitmapPage, CPropertyPage)
- //{{AFX_MSG_MAP(CBitmapPage)
- ON_BN_CLICKED(ID_SELSTATIC, OnSelstatic)
- ON_BN_CLICKED(ID_SELDYN, OnSeldyn)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CBitmapPage message handlers
- BOOL CBitmapPage::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
-
- // TODO: Add extra initialization here
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CBitmapPage::SelectFile(CString& strFileName)
- {
- UpdateData(TRUE);
- DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
- if(strFileName.IsEmpty()) strFileName = "bitmap\\home.bmp";
- LPSTR lpszFile = (char*)(const char*)strFileName;
- LPSTR lpszFilter = (char *)(LPCTSTR)g_strPictureFile1;
- //LPSTR lpszFilter = "BMP files (*.bmp)|*.bmp|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif||";
- //"BMP file (*.bmp)|*.bmp|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg)||";
- //"Picture file(*.png;*.bmp)|*.png;*.bmp|BMP(*.BMP)|*.BMP||"
- int INDEX=0;
- CString sTemp1=strFileName;
- sTemp1 = sTemp1.MakeLower();
-
- if( -1!=sTemp1.Find( ".bmp" ) )
- INDEX = 1;
- else if( -1!=sTemp1.Find( ".png" ) )
- INDEX = 2;
- else if( -1!=sTemp1.Find( ".gif" ) )
- INDEX = 4;
- else if( -1!=sTemp1.Find( ".jpg" ) )
- INDEX = 3;
- CFileDialog dlg(TRUE,NULL,lpszFile,dwFlags,lpszFilter);
- dlg.m_pOFN->nFilterIndex = INDEX;
- if(dlg.DoModal()==IDOK)
- {
- strFileName = dlg.GetFileName();
- UpdateData(FALSE);
- }
- }
- void CBitmapPage::OnSelstatic()
- {
- SelectFile(m_strStaticFile);
- }
- void CBitmapPage::OnSeldyn()
- {
- SelectFile(m_strDynFile);
- }
|