void CImageDialog::OnBnClickedOk() { // TODO: Add your control notification handler code here m_strImageProperty=m_ImagePreview.GetImageProperty(); CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); g_pResourceView->InsertImage(m_strImagePathName, pUIView->GetDocument()->GetTitle()); OnOK(); }
BOOL CImageDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_btnMask.EnableOtherButton(_T("Other")); m_btnMask.SetColor((COLORREF)0); m_btnMask.SetColumnsNumber(10); m_ctlFade.SetRange(0,255); m_ctlFade.SetPos(255); CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); m_pManager = pUIView->GetPaintManager(); m_ImagePreview.SetManager(m_pManager); m_strImagePathName=m_strImageProperty; LPCTSTR pStrImage=m_strImageProperty; CDuiString sItem; CDuiString sValue; LPTSTR pstr = NULL; while( *pStrImage != _T('\0') ) { sItem.Empty(); sValue.Empty(); while( *pStrImage != _T('\0') && *pStrImage != _T('=') ) { LPTSTR pstrTemp = ::CharNext(pStrImage); while( pStrImage < pstrTemp) { sItem += *pStrImage++; } } if( *pStrImage++ != _T('=') ) break; if( *pStrImage++ != _T('\'') ) break; while( *pStrImage != _T('\0') && *pStrImage != _T('\'') ) { LPTSTR pstrTemp = ::CharNext(pStrImage); while( pStrImage < pstrTemp) { sValue += *pStrImage++; } } if( *pStrImage++ != _T('\'') ) break; if( !sValue.IsEmpty() ) { if( sItem == _T("file")) m_strImagePathName = sValue; else if( sItem == _T("dest") ) m_strDest = sValue; else if( sItem == _T("source") ) m_strSource = sValue; else if( sItem == _T("corner") ) m_strCorner = sValue; else if( sItem == _T("mask") ) { DWORD dwMask; if( sValue[0] == _T('#')) dwMask = _tcstoul(sValue.GetData() + 1, &pstr, 16); else dwMask = _tcstoul(sValue.GetData(), &pstr, 16); dwMask&=0x00FFFFFF; m_btnMask.SetColor(RGB(GetBValue(dwMask),GetGValue(dwMask),GetRValue(dwMask))); } else if( sItem == _T("fade") ) { m_nFade = (BYTE)_tcstoul(sValue.GetData(), &pstr, 10); } else if( sItem == _T("hole") ) { m_bHole = (_tcscmp(sValue.GetData(), _T("true")) == 0); } } if( *pStrImage++ != _T(' ') ) break; } m_ctlFade.SetPos(m_nFade); int nIndex=m_lstImages.AddString(_T("(无)")); m_lstImages.SetItemDataPtr(nIndex,(void*)(LPCTSTR)m_strNullImage); LPCTSTR pstrImage=NULL; LPTSTR pszFileName=NULL; const CStringArray* parrImage=g_pResourceView->GetImageTree(pUIView->GetDocument()->GetTitle()); if(parrImage) { for(int i=0;i<parrImage->GetSize();i++) { pstrImage=parrImage->GetAt(i); pszFileName=_tcsrchr((LPTSTR)pstrImage,_T('\\'))+1; nIndex=m_lstImages.AddString(pszFileName); m_lstImages.SetItemDataPtr(nIndex,(void*)pstrImage); } } int nPos = m_strImagePathName.ReverseFind(_T('\\')); CString strFileName = (nPos==-1) ? m_strImagePathName : m_strImagePathName.Right(m_strImagePathName.GetLength() - nPos - 1); m_strImagePathName.IsEmpty()?m_lstImages.SelectString(-1,_T("(无)")):m_lstImages.SelectString(-1,strFileName); UpdateData(FALSE); SetImageProperty(m_strImagePathName); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }