Skip to content

Commit 18a064d

Browse files
authored
example needed to mitigate dev floundering (#4210)
It is not easy to match up variant vt types with POD types. Especially since there is a gradual transition to modern C++. I used a number of dev hours on attempts to match the variant type, vt, to make the true/false work. The m_bValue type for the simple property was a BOOL type, but trying to create a variant of type BOOL directly didn't work. Only by looking at VC Sample code for VisualStudioDemo did I see the (_variant_t)true construct, which becomes the standard_cast contruct in modern C++. I figured my Example code could make other programmer's efforts easier.
1 parent 8e6bd58 commit 18a064d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/mfc/reference/cmfcpropertygridproperty-class.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,17 @@ Sets the value of a property grid property.
15131513
```
15141514
virtual void SetValue(const _variant_t& varValue);
15151515
```
1516-
1516+
Example:
1517+
```
1518+
void SetPropBarValue( UINT propId, const DWORD& barPropDwordValue )
1519+
{
1520+
auto property = propertiesGridCtrlList.FindItemByData( propId );
1521+
if( property )
1522+
{
1523+
property->SetValue( static_cast< _variant_t >( barPropDwordValue == 1 ) ); // sets property bar value to true or false depending on dword value
1524+
}
1525+
}
1526+
```
15171527
### Parameters
15181528
15191529
*`varValue`*\

0 commit comments

Comments
 (0)