Take a look at this code. It sets the style properties for cell (4,2).
SetStyleRange( CGXRange(4, 2), CGXStyle() .SetValue("Welcome") //Text to be displayed .SetControl(GX_IDS_CTRL_STATIC) //Static, no editing .SetVerticalAlignment(DT_VCENTER) //Center vertical .SetHorizontalAlignment(DT_CENTER)//Center horizontal .SetEnabled(FALSE) // User cannot click on it ); |
At first glance, you might think the syntax is wrong. SetStyleRange() takes two arguments in the above call. The second argument is:
CGXStyle() .SetValue("Welcome") .SetControl(GX_IDS_CTRL_STATIC) .SetVerticalAlignment(DT_VCENTER) .SetHorizontalAlignment(DT_CENTER) .SetEnabled(FALSE) |
The methods SetValue(), SetControl(), SetVerticalAlignment(), SetHorizontalAlignment(), and SetEnabled() are all members of CGXStyle. Each of these methods has a return value of the this pointer. That is, each method returns a reference to its object. So the call to CGXStyle().SetValue("Welcome") returns a reference to the style object which allows it to call SetControl(GX_IDS_CTRL_STATIC), which in turn returns a reference to the style object, which allows it to call SetVerticalAlignment(DT_VCENTER), and so on. The code above is a shortcut for writing the code below. It is intelligible and makes it easier for the programmer by allowing him to write a single statement to initialize all the attributes instead of one statement for each attribute.
SetStyleRange(CGXRange(4,2), CGXStyle().SetValue("Welcome")); SetStyleRange(CGXRange(4,2), CGXStyle().SetControl(GX_IDS_CTRL_STATIC)); SetStyleRange(CGXRange(4,2), CGXStyle().SetVerticalAlignment(DT_VCENTER)); SetStyleRange(CGXRange(4,2), CGXStyle().SetHorizontalAlignment(DT_CENTER)); SetStyleRange(CGXRange(4,2), CGXStyle().SetEnabled(FALSE)); |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.