void DotsPlotWndProperty::UpdatePropertyValue(const wchar_t * propertyName) { CMFCPropertyGridProperty * property = NULL; for (int i = 0; i < this->GetPropertyCount(); i++) { CMFCPropertyGridProperty * aProperty = this->GetProperty(i); if (wcscmp(aProperty->GetName(), propertyName) == 0) { property = aProperty; break; } } if (property == NULL) return; _variant_t value = property->GetValue(); PlotWndPropDots * objProp = (PlotWndPropDots *)this->target; if (wcscmp(propertyName, L"Max Value") == 0) { _variant_t value = property->GetValue(); value.intVal = (int)objProp->GetMaxValue(); property->SetValue(value); } //else if (wcscmp(propertyName, L"Frame Count") == 0) //{ // _variant_t value = property->GetValue(); // value.intVal = (int)objProp->frameCount; // property->SetValue(value); //} }
LRESULT xRenderSettingPane::OnPropertyChanged(WPARAM wParam, LPARAM lParam) { CMFCPropertyGridProperty * prop = (CMFCPropertyGridProperty *)lParam; IPropertyObj * obj = xRenderSetting::Instance(); const char * name = prop->GetName(); const Property * p = obj->GetProperty(name); if (p) { char cdata[128]; const COleVariant & strValue = prop->GetValue(); CString val = (CString)strValue; Strcpy(cdata, 128, (const char *)val); if (p->type == PT_Bool) { bool bdata = (strValue.boolVal == -1); obj->SetPropertyData(p, &bdata); } else if (p->type == PT_Int && p->enumObj) { const cEnum * e = p->enumObj->GetEnum(cdata); obj->SetPropertyData(p, &e->val); } } return S_OK; }
BOOL CPropertiesWnd::IsComboType() { CMFCPropertyGridProperty *pProp = m_wndPropList.FindItemByData(PROP_DATA_TYPE); if (pProp) { CString strValue(pProp->GetValue()); return strValue.CompareNoCase(_T("Combo")) == 0; } return FALSE; }
static void PrintPropList( CMFCPropertyGridCtrl* pPropDataList ) { int count = pPropDataList->GetPropertyCount(); acutPrintf( _T( "\n属性数据控件包含的数据个数:%d" ), count ); for( int i = 0; i < count; i++ ) { CMFCPropertyGridProperty* pProp = pPropDataList->GetProperty( i ); acutPrintf( _T( "\name=%s\tvalue=%s" ), pProp->GetName(), pProp->GetValue() ); } acutPrintf( _T( "\n" ) ); }
LRESULT CSpriteSet::OnPropertyChanged (WPARAM,LPARAM lParam) { CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty*) lParam; const COleVariant& strValue=pProp->GetValue();//获得子项值 CString strTmp = CString(strValue.bstrVal); strTmp = pProp->GetName(); return 0; }
void CDlgAddCards::OnClickedBtnOK() { // TODO: 在此添加控件通知处理程序代码 // int nCnt = m_proCard.GetPropertyCount(); for( int i = 0; i < nCnt; i++) { CMFCPropertyGridProperty* pProp = m_proCard.GetProperty(i); if(!pProp || FALSE == pProp->IsEnabled()) continue; CCardField* pField = (CCardField*)(pProp->GetData()); if(!pField) continue; CString sv = CXxwMfcPub::OleVar2Str(pProp->GetValue()); string sValue = sv.GetBuffer(0); pField->sInstantValue = pField->FormatValue(sValue);//修改值 } for(int r = 0; r < m_lstDevicesSelected.GetItemCount(); ++r) { CCardLine* pLine = (CCardLine*)(m_lstDevicesSelected.GetItemData(r)); CCard newCard = m_swiCard; for (int i = 0 ; i < m_vecKeynames.size(); i++) { CCardField* pFld = pLine->m_card.FindFieldByKeyname(m_vecKeynames[i]); CCardField* pFldNew = newCard.FindFieldByKeyname(m_vecKeynames[i]); if (pFld && pFldNew) { pFldNew->sInstantValue = pFld->sInstantValue;//替换为选择的值 } } CCardLine* pLineNew = theApp.m_parserSwi.AddNewCard(newCard);//添加新卡 m_AllCardsNew.insert(make_pair(newCard.m_sName, pLineNew)); } // 获得父窗口的句柄 HWND hWnd = m_pParentWnd->GetSafeHwnd(); // 向父窗口发送消息 if (hWnd == NULL) return (void)MessageBox(_T("获得父窗口句柄失败!")); ::SendNotifyMessage(hWnd,WM_MY_ADDCARDS_OK,(WPARAM)0, (LPARAM)0); //从“待选”中删除所有的行 m_lstDevicesSelected.DeleteAllItems();//删除所有的行 UpdateBtnOK(); SetFocus();//获得焦点并显示,以免被隐藏 }
LRESULT CDlgAddCards::OnPropertyChanged(WPARAM wparam,LPARAM lParam) { CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty*) lParam; switch( wparam ) { case(IDC_MFCPROPERTYGRID)://来自控件IDC_MFCPROPERTYGRID1 { CCardField* pField = (CCardField*)pProp->GetData(); if(!pField) return 0; CString sv = CXxwMfcPub::OleVar2Str(pProp->GetValue()); string sValue = sv.GetBuffer(0); pField->sInstantValue = pField->FormatValue(sValue);//修改值 } break; } return 0; }
void CPropertiesWnd::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { CMFCPropertyGridProperty * pProperty = m_wndPropList.GetCurSel(); CString sMenuItemText; CIconMenu popup; if (pProperty && !pProperty->IsGroup() && popup.CreatePopupMenu()) { sMenuItemText.LoadString(IDS_SCIEDIT_COPY); popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText); int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0); switch (cmd) { case 0: break; // no command selected case WM_COPY: CStringUtils::WriteAsciiStringToClipboard(pProperty->GetValue(), GetSafeHwnd()); break; } } }
bool PropertyDataUpdater::WriteDataToGE( CMFCPropertyGridCtrl* pPropDataList, const AcDbObjectId& objId ) { if( pPropDataList == NULL ) return false; if( objId.isNull() ) return false; // 没有属性数据可更新 if( pPropDataList->GetPropertyCount() == 0 ) return false; AcTransaction* pTrans = actrTransactionManager->startTransaction(); if( pTrans == 0 ) return false; AcDbObject* pObj; if( Acad::eOk != pTrans->getObject( pObj, objId, AcDb::kForWrite ) ) { actrTransactionManager->abortTransaction(); return false; } DataObject* pDO = DataObject::cast( pObj ); if( pDO == 0 ) { actrTransactionManager->abortTransaction(); return false; } //acutPrintf(_T("\n写入数据...")); DataHelperImpl dh( pDO ); int nCount = pPropDataList->GetPropertyCount(); for ( int i = 0; i < nCount; i++ ) { CMFCPropertyGridProperty* pProp = pPropDataList->GetProperty( i ); // 扩展数据中默认采用"字符串"类型保存数据 // COleVariant会自动转换成CString CString value = pProp->GetValue(); dh.setPropertyData( pProp->GetName(), value ); // 更新属性数据 } actrTransactionManager->endTransaction(); return true; }
LRESULT xKeyFrameTab::OnPropertyChanged(WPARAM wParam, LPARAM lParam) { int i = GetActiveTab(); IPropertyObj * obj = NULL; switch (i) { case 0: obj = Environment::Instance()->GetKeyFrame(0); break; case 1: obj = Environment::Instance()->GetKeyFrame(1); break; case 2: obj = Environment::Instance()->GetKeyFrame(2); break; case 3: obj = Environment::Instance()->GetKeyFrame(3); break; case 4: obj = Environment::Instance()->GetGlobalParam(); break; } if (!obj) return S_OK; CMFCPropertyGridProperty * prop = (CMFCPropertyGridProperty *)lParam; const char * name = prop->GetName(); const Property * p = obj->GetProperty(name); if (p) { if (p->type == PT_TString && p->size == 128) { const COleVariant & strValue = prop->GetValue(); CString val = (CString)strValue; TString128 data = (LPCTSTR)val; obj->SetPropertyData(p, &data); } else if (p->type == PT_Float) { const COleVariant & strValue = prop->GetValue(); CString val = (CString)strValue; float data = (float)atof((LPCTSTR)val); obj->SetPropertyData(p, &data); } else if (p->type == PT_Color) { xPropertyGridColorPick * colorPick = (xPropertyGridColorPick *)prop; COLORREF color = colorPick->GetColor(); int r = GetRValue(color); int g = GetGValue(color); int b = GetBValue(color); Color4 data = Color4(r / 255.0f, g / 255.0f, b / 255.0f); obj->SetPropertyData(p, &data); } } return S_OK; }
// MFC bug, this does not work! // Details : can not retrieve the data just input. bool CReflectiveUI::ValidateItemData(CMFCPropertyGridProperty* pProp) { CMFCPropertyGridProperty* pItem = pProp; assert( _GridPropertyMap.find(pItem) != _GridPropertyMap.end() ); SPropertyObject PO = _GridPropertyMap[pItem]; bool bValid = true; switch ( PO._pProperty->GetTypeID() ) { case eptBool: { TypedProperty<bool>* pTypedProperty = (TypedProperty<bool>*)PO._pProperty; bValid = pTypedProperty->ValidateValue( pItem->GetValue().boolVal != 0); break; } case eptByte: { TypedProperty<char>* pTypedProperty = (TypedProperty<char>*)PO._pProperty; bValid = pTypedProperty->ValidateValue( pItem->GetValue().bVal ); break; } case eptShort: { TypedProperty<short>* pTypedProperty = (TypedProperty<short>*)PO._pProperty; bValid = pTypedProperty->ValidateValue( pItem->GetValue().iVal ); break; } case eptInt: { TypedProperty<int>* pTypedProperty = (TypedProperty<int>*)PO._pProperty; bValid = pTypedProperty->ValidateValue( pItem->GetValue().intVal ); break; } case eptLong: { TypedProperty<long>* pTypedProperty = (TypedProperty<long>*)PO._pProperty; bValid = pTypedProperty->ValidateValue( pItem->GetValue().lVal ); break; } case eptPtr: { break; } case eptOgreReal: { TypedProperty<Ogre::Real>* pTypedProperty = (TypedProperty<Ogre::Real>*)PO._pProperty; bValid = pTypedProperty->ValidateValue( pItem->GetValue().fltVal ); break; } case eptOgreString: { TypedProperty<Ogre::String>* pTypedProperty = (TypedProperty<Ogre::String>*)PO._pProperty; GString gStr(pItem->GetValue().bstrVal); bValid = pTypedProperty->ValidateValue( gStr.ToMbcs() ); break; } }; if (!bValid) { pItem->SetValue(pItem->GetOriginalValue()); } return bValid; }
void CReflectiveUI::OnPropertyChanged(CMFCPropertyGridProperty* pProp) { //if (!ValidateItemData(pProp)) //{ // return; //} CMFCPropertyGridProperty* pItem = pProp; const COleVariant variant = pItem->GetValue(); assert( _GridPropertyMap.find(pItem) != _GridPropertyMap.end() ); SPropertyObject PO = _GridPropertyMap[pItem]; switch ( PO._pProperty->GetTypeID() ) { case eptBool: { TypedProperty<bool>* pTypedProperty = (TypedProperty<bool>*)PO._pProperty; pTypedProperty->SetValue( PO._pObject, pItem->GetValue().boolVal != 0); break; } case eptByte: { TypedProperty<char>* pTypedProperty = (TypedProperty<char>*)PO._pProperty; pTypedProperty->SetValue( PO._pObject, pItem->GetValue().bVal ); break; } case eptShort: { TypedProperty<short>* pTypedProperty = (TypedProperty<short>*)PO._pProperty; pTypedProperty->SetValue( PO._pObject, pItem->GetValue().iVal ); break; } case eptInt: { TypedProperty<int>* pTypedProperty = (TypedProperty<int>*)PO._pProperty; pTypedProperty->SetValue( PO._pObject, pItem->GetValue().intVal ); break; } case eptLong: { TypedProperty<long>* pTypedProperty = (TypedProperty<long>*)PO._pProperty; pTypedProperty->SetValue( PO._pObject, pItem->GetValue().lVal ); break; } case eptPtr: { break; } case eptOgreReal: { TypedProperty<Ogre::Real>* pTypedProperty = (TypedProperty<Ogre::Real>*)PO._pProperty; pTypedProperty->SetValue( PO._pObject, pItem->GetValue().fltVal ); break; } case eptOgreString: { TypedProperty<Ogre::String>* pTypedProperty = (TypedProperty<Ogre::String>*)PO._pProperty; GString gStr(pItem->GetValue().bstrVal); pTypedProperty->SetValueFromString( PO._pObject, gStr.ToMbcs() ); break; } case eptOgreVector2: { TypedProperty<Ogre::Vector2>* pTypedProperty = (TypedProperty<Ogre::Vector2>*)PO._pProperty; GString gStr(pItem->GetValue().bstrVal); pTypedProperty->SetValueFromString( PO._pObject, gStr.ToMbcs() ); } break; case eptOgreVector3: { TypedProperty<Ogre::Vector3>* pTypedProperty = (TypedProperty<Ogre::Vector3>*)PO._pProperty; GString gStr(pItem->GetValue().bstrVal); pTypedProperty->SetValueFromString( PO._pObject, gStr.ToMbcs() ); } break; case eptOgreVector4: { TypedProperty<Ogre::Vector4>* pTypedProperty = (TypedProperty<Ogre::Vector4>*)PO._pProperty; GString gStr(pItem->GetValue().bstrVal); pTypedProperty->SetValueFromString( PO._pObject, gStr.ToMbcs() ); } break; case eptOgreColorValue: { TypedProperty<Ogre::ColourValue>* pTypedProperty = (TypedProperty<Ogre::ColourValue>*)PO._pProperty; Ogre::ColourValue val; val.setAsABGR(pItem->GetValue().intVal); pTypedProperty->SetValue( PO._pObject, val); } break; case eptOgreQuaternion: { TypedProperty<Ogre::Quaternion>* pTypedProperty = (TypedProperty<Ogre::Quaternion>*)PO._pProperty; GString gStr(pItem->GetValue().bstrVal); pTypedProperty->SetValueFromString( PO._pObject, gStr.ToMbcs() ); } break; case eptOgreMatrix3: { TypedProperty<Ogre::Matrix3>* pTypedProperty = (TypedProperty<Ogre::Matrix3>*)PO._pProperty; GString gStr(pItem->GetValue().bstrVal); pTypedProperty->SetValueFromString( PO._pObject, gStr.ToMbcs() ); } break; case eptOgreMatrix4: { TypedProperty<Ogre::Matrix4>* pTypedProperty = (TypedProperty<Ogre::Matrix4>*)PO._pProperty; GString gStr(pItem->GetValue().bstrVal); pTypedProperty->SetValueFromString( PO._pObject, gStr.ToMbcs() ); } break; }; }
LRESULT CLegoBrickPropertiesWnd::OnPropertyChanged (WPARAM,LPARAM lParam) { CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty*) lParam; //do something CMainFrame* pFrame = (CMainFrame*) AfxGetMainWnd(); HTREEITEM hSelected = pFrame->GetClassView()->GetTreeView()->GetSelectedItem(); LBInfoNode* pBrickNode = (LBInfoNode*)pFrame->GetClassView()->GetTreeView()->GetItemData(hSelected); CString str; if (pProp == pPropType) { CString strType = (LPCTSTR)(_bstr_t)pProp->GetValue(); for (int i=0; i<NUMOFBRICKTYPE; i++) { if (strType == strmap[i].str) pBrickNode->bi.brick.type = strmap[i].bt; } int idxImage, idxSelImage; CViewTree* pTreeCtrl = pFrame->GetClassView()->GetTreeView(); pTreeCtrl->GetItemImage(hSelected, idxImage, idxSelImage); DWORD_PTR data = pTreeCtrl->GetItemData(hSelected); str = pFrame->GetClassView()->MakeLegoBrickString(&(pBrickNode->bi)); HTREEITEM hNewItem; // notype if (pBrickNode->bi.brick.type == NOTYPE) { hNewItem = pTreeCtrl->InsertItem(str, idxImage, idxSelImage, TVI_ROOT, TVI_LAST); pTreeCtrl->SetItemData(hNewItem, data); } // one row brick else if (pBrickNode->bi.brick.type >= ONE_BY_ONE && pBrickNode->bi.brick.type <= ONE_BY_TWELVE) { hNewItem = pTreeCtrl->InsertItem(str, idxImage, idxSelImage, pFrame->GetClassView()->hRoot1, TVI_SORT); pTreeCtrl->SetItemData(hNewItem, data); pTreeCtrl->Expand(pFrame->GetClassView()->hRoot1, TVE_EXPAND); } // two row brick else { hNewItem = pTreeCtrl->InsertItem(str, idxImage, idxSelImage, pFrame->GetClassView()->hRoot2, TVI_SORT); pTreeCtrl->SetItemData(hNewItem, data); pTreeCtrl->Expand(pFrame->GetClassView()->hRoot2, TVE_EXPAND); } pTreeCtrl->DeleteItem(hSelected); pTreeCtrl->SelectItem(hNewItem); // pFrame->GetClassView()->GetTreeView()->SetItemText(hSelected, str); } if (pProp == pPropColor) { // pBrickNode->bi.brick.color = ((CMFCPropertyGridColorProperty*)pProp)->GetColor(); pBrickNode->bi.brick.color = ((CPHPropertyGridColorProperty*)pProp)->GetColor(); // Get LEGO Color, if NULL -> Not a LEGO color pBrickNode->bi.brick.pLegoColor = ((CPHPropertyGridColorProperty*)pProp)->GetLegoColor(); CBitmap bmp; BYTE bits[960]; // typedef unsigned char BTTE; 4*16*15 = 960 BYTE bits2[960]; // for selected pFrame->GetClassView()->BuildTwoBitsBlocks(pBrickNode->bi.brick.color, bits, bits2); bmp.CreateBitmap(16, 15, 1, 32, bits /*Points to a short-integer array */); int idxImage, idxSelImage; pFrame->GetClassView()->GetTreeView()->GetItemImage(hSelected, idxImage, idxSelImage); pFrame->GetClassView()->GetImageList()->Replace(idxImage, &bmp, NULL); bmp.SetBitmapBits(960, bits2); pFrame->GetClassView()->GetImageList()->Replace(idxSelImage, &bmp, NULL); pFrame->GetClassView()->GetTreeView()->SetImageList( pFrame->GetClassView()->GetImageList(), TVSIL_NORMAL); str = pFrame->GetClassView()->MakeLegoBrickString(&(pBrickNode->bi)); pFrame->GetClassView()->GetTreeView()->SetItemText(hSelected, str); } if (pProp == pPropNum) { pBrickNode->bi.numBricks = (int) pProp->GetValue().intVal; str = pFrame->GetClassView()->MakeLegoBrickString(&(pBrickNode->bi)); pFrame->GetClassView()->GetTreeView()->SetItemText(hSelected, str); } if (&(pBrickNode->bi) != NULL) pBrickNode->bi.brick.SetID(); return 0; }
LRESULT CWorkspaceBar::OnPropertyChanged (WPARAM,LPARAM lParam) { CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty*) lParam; BOOL bResetMDIChild = FALSE; switch ((int) pProp->GetData ()) { case idShowMDITabs: { CString strShowMdiTabOption = (LPCTSTR) (_bstr_t)pProp->GetValue (); bResetMDIChild = TRUE; for (int i = 0; lpszMDITabsStyles [i] != NULL; i++) { if (strShowMdiTabOption == lpszMDITabsStyles [i]) { switch (i) { case 0: theApp.m_Options.m_nMDITabsType = CMDITabOptions::None; break; case 1: theApp.m_Options.m_nMDITabsType = CMDITabOptions::MDITabsStandard; break; case 2: theApp.m_Options.m_nMDITabsType = CMDITabOptions::MDITabbedGroups; theApp.m_Options.m_bMaximizeMDIChild = FALSE; CMFCPropertyGridProperty* pMaximizeChildProp = m_wndPropList.GetProperty (1); if (pMaximizeChildProp != NULL) { _variant_t var ((short)theApp.m_Options.m_bMaximizeMDIChild, VT_BOOL); pMaximizeChildProp->SetValue (var); pMaximizeChildProp->Enable (FALSE); } bResetMDIChild = FALSE; break; } break; } } SetPropState (); } break; case idMaximizeMDIChild: theApp.m_Options.m_bMaximizeMDIChild = (bool) pProp->GetValue (); bResetMDIChild = TRUE; break; case idTabsOnTop: theApp.m_Options.m_bTabsOnTop = (bool) pProp->GetValue (); break; case idActiveTabCloseButton: theApp.m_Options.m_bActiveTabCloseButton = (bool) pProp->GetValue (); break; case idTabsStyle: { CString strStyle = (LPCTSTR) (_bstr_t)pProp->GetValue (); for (int i = 0; lpszStyles [i] != NULL; i++) { if (strStyle == lpszStyles [i]) { switch (i) { case 0: theApp.m_Options.m_nTabsStyle = CMFCTabCtrl::STYLE_3D_SCROLLED; break; case 1: theApp.m_Options.m_nTabsStyle = CMFCTabCtrl::STYLE_3D_ONENOTE; break; case 2: theApp.m_Options.m_nTabsStyle = CMFCTabCtrl::STYLE_3D_VS2005; break; } break; } } } break; case idTabsAutoColor: theApp.m_Options.m_bTabsAutoColor = (bool) pProp->GetValue (); break; case idMDITabsIcons: theApp.m_Options.m_bMDITabsIcons = (bool) pProp->GetValue (); break; case idMDITabsDocMenu: theApp.m_Options.m_bMDITabsDocMenu = (bool) pProp->GetValue (); break; case idDragMDITabs: theApp.m_Options.m_bDragMDITabs = (bool) pProp->GetValue (); break; case idMDITabsContextMenu: theApp.m_Options.m_bMDITabsContextMenu = (bool) pProp->GetValue (); break; case idMDITabsBorderSize: { int nBorderSize = pProp->GetValue ().iVal; theApp.m_Options.m_nMDITabsBorderSize = min (10, max (0, nBorderSize)); } break; case idDisableMDIChildRedraw: theApp.m_Options.m_bDisableMDIChildRedraw = (bool) pProp->GetValue (); break; case idFlatFrame: theApp.m_Options.m_bFlatFrame = (bool) pProp->GetValue (); break; case idCustomTooltips: theApp.m_Options.m_bCustomTooltips = (bool) pProp->GetValue (); break; } theApp.UpdateMDITabs (bResetMDIChild); return 0; }