Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » OptionImage ctrl: how to make it better...
Re: OptionImage ctrl: how to make it better... [message #2466 is a reply to message #2465] Thu, 13 April 2006 18:16 Go to previous messageGo to previous message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
The '.' makes you work with instance on the left.

'ctrl.' means you want to do something with arrayctrl (and there's no ThreeState method defined for that class)

'ctrl.Create<OptionImage>().' means you want to call "Create" method of ctrl to create OptionImage class instance with default (void) constructor. And that Create method returns reference to the freshly created control (OptionImage), so the last '.' indicates you want to do something with OptionImage.
Now there's perfectly legal to use "ThreeState" method on that one.

It's like many single lines put into one long.
I think this code would do the same (but I'm writing it just by hand, so maybe there will be some mistake)

    OptionImage &option_instance = ctrl.Create<OptionImage>();
    option_instance.ThreeState();
    option_instance.SetImage(imgYes(), imgNo(), imgMaybe());


i.e. in first line you create your option object instance in memory (and add it to arractrl).
And on next lines you are customizing it's behaviour by calling it's methods.

The long line with many dots is a nice shortcut, which is using the fact that many methods returns the reference to "this" instance, allowing you to continue with another '.'.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Different color for three state option button
Next Topic: How to create a non modal dialog
Goto Forum:
  


Current Time: Fri May 10 14:38:29 CEST 2024

Total time taken to generate the page: 0.02845 seconds