void __fastcall TCacheDemoForm::ToggleUpdateMode(System::TObject* Sender) { bool NewState; // Toggle the state of the CachedUpdates property if (IsPublishedProp(FDataSet, "CachedUpdates")) { FDataSet->Close(); NewState = !GetOrdProp(FDataSet, "CachedUpdates"); SetOrdProp(FDataSet, "CachedUpdates", NewState); // Enable/Disable Controls SetControlStates(NewState); FDataSet->Open(); } }
bool TPropertyHandler::PropertyExists(TComponent* comp, String prName) { if (prName == "sped_sped_MaxRecentFiles") ShowMessage("sped_MaxRecentFiles"); if (!IsPublishedProp(comp, prName)) { // #ifdef PROPERTYHANDLER_SHOW_WARNINGS ShowMessage( "TPropertyHandler warning:\n\n" "Property '" + GetName(comp) + "." + prName + "' does not exist." ); // #endif return false; } return true; }
void TPropertyHandler::SetNameValue(TComponent* comp, String prName_Value) { if (prName_Value.LastDelimiter("\r\n")) { // Multi-line string, so call SetNamesValues(): SetNamesValues(comp, prName_Value); return; } String name2, name1, value; // Reads like this: "name2.name1=value". int sep = prName_Value.Pos("="); String names = prName_Value.SubString(1, sep - 1); value = prName_Value.SubString(sep + 1, prName_Value.Length() - sep + 1); sep = names.Pos("."); if (sep) { // Format is "propname.subprop=val": name1 = names.SubString(sep + 1, names.Length() - sep + 1); name2 = names.SubString(1, sep - 1); // name2 is the subcomp of comp. if (!IsPublishedProp(comp, name2)) // No warning. { /* name2 is not a component of comp, but it might be a component of its own, like CheckBox1 is a sub-component of Form1. */ if ((comp = GetSubComponent(comp, name2)) == NULL) return; else { SetPropValue(comp, name1, value); return; } } if (!IsClass(comp, name2)) return; // Get pointer to subObj: TObject *subObj = (TObject *)GetOrdProp(comp, name2); if (subObj == NULL) return; SetPropValue(subObj, name1, value); } else { // Format is "propname=val": SetPropValue(comp, names, value); } }