applet_module Class Reference
[Windows Control Panel Library]

#include <winstl/control_panel/applet_module.hpp>

List of all members.


Detailed Description

Represents a Control Panel Applet module, and provides methods for loading and accessing applets.

The following code enumerates all the applet modules in the Windows system directory, and prints out the name and description of each applet contained within.

#include <winstl/findfile_sequence.hpp>
#include <winstl/system_directory.hpp>
#include <winstl/control_panel/applet_module.hpp>

#include <iostream>

int main()
{
  try
  {
    winstl::system_directory    sysDir;
    winstl::findfile_sequence   files(sysDir, "*.cpl", winstl::findfile_sequence::files);

    { for(winstl::findfile_sequence::const_iterator b = files.begin(); b != files.end(); ++b)
    {
      winstl::applet_module module(*b, winstl::applet_module:dontExpectNonZeroInit);

      winstl::applet_module::const_iterator b = module.begin();
      winstl::applet_module::const_iterator e = module.end();

      std::cout << "path:          " << module.get_path() << std::endl;
      for(; b != e; ++b)
      {
        winstl::applet const  &applet = *b;

        std::cout << " applet index: " << applet.get_index() << std::endl;

        std::cout << "  name:        " << applet.get_name() << std::endl;
        std::cout << "  description: " << applet.get_description() << std::endl;
      }
      std::cout << std::endl;
    }}
  }
  catch(std::exception &x)
  {
    std::cerr << "Exception: " << x.what() << std::endl;
  }

  return 0;
}

Note the use of the dontExpectNonZeroInit flag, which is recommended because several common control panel modules do not correctly implement their CPL_INIT handlers.

Examples:

by_library/windows_control_panel/windows_control_panel/windows_control_panel.cpp.


Member Types

typedef applet_module class_type
 The type of this class.
typedef applet value_type
 The value type.
typedef size_t size_type
 The size type.
typedef size_t index_type
 The index type.
typedef
stlsoft::basic_simple_string
< TCHAR > 
string_type
 The string type.
typedef applets_type_::iterator iterator
 The mutating (non-const) iterator type.
typedef
applets_type_::const_iterator 
const_iterator
 The non-mutating (const) iterator type.
typedef void(__stdcall * onFailureS )(TCHAR const *path)
 Prototype of stdcall function that receives error notifications.
typedef void (1 *onFailureC)(TCHAR const *path)
 Prototype of cdecl function that receives error notifications.

Public Types

Member Constants
enum  load_flags {
  ignoreIconLoadFailures = 0x0001,
  dontExpectNonZeroInit = 0x0002,
  assumeOneAppletIfNone = 0x0004
}
 Flags that moderate the load behaviour. More...

Public Member Functions

Construction
 applet_module (TCHAR const *path, int flags=ignoreIconLoadFailures, HWND hwndParent=NULL)
 Constructs an instance containing all the applets in the given module.
Attributes
string_type const & get_path () const
 The path used to initialise the instance.
Accessors
size_type size () const
 The number of applets in the module.
value_typeoperator[] (index_type index)
 Returns a mutable (non-const) reference to the applet at the index.
value_type const & operator[] (index_type index) const
 Returns a non-mutable (const) reference to the applet at the index.
Iteration
iterator begin ()
 Begins the iteration.
iterator end ()
 Ends the iteration.
const_iterator begin () const
 Begins the iteration.
const_iterator end () const
 Ends the iteration.

Classes

struct  error_translator

Member Typedef Documentation

The type of this class.

typedef applet value_type

The value type.

typedef size_t size_type

The size type.

typedef size_t index_type

The index type.

typedef stlsoft:: basic_simple_string<TCHAR> string_type

The string type.

typedef applets_type_::iterator iterator

The mutating (non-const) iterator type.

typedef applets_type_::const_iterator const_iterator

typedef void( __stdcall * onFailureS)(TCHAR const *path)

Prototype of stdcall function that receives error notifications.


Member Enumeration Documentation

enum load_flags

Flags that moderate the load behaviour.

Enumerator:
ignoreIconLoadFailures  Ignores icon load failures and continues applet loading.
dontExpectNonZeroInit  Some applet module entry points don't return 0.
assumeOneAppletIfNone  Some applet module entry points return 0 from CPL_GETCOUNT.


Constructor & Destructor Documentation

applet_module ( TCHAR const *  path,
int  flags = ignoreIconLoadFailures,
HWND  hwndParent = NULL 
) [explicit]

Constructs an instance containing all the applets in the given module.

Parameters:
path [in] Path of the applet module.
flags [in] Flags that moderate the loading behaviour.
hwndParent [in] Handle to a window to act as the parent for the dialog(s) of the applet(s) contained in the module
Exceptions:
winstl::control_panel_exception Thrown if the applet module initialisation fails.
winstl::resource_exception Thrown if the icon cannot be loaded for a given applet, and ignoreIconLoadFailures.


Member Function Documentation

typedef void ( 1 *  onFailureC  )  const

Prototype of cdecl function that receives error notifications.

string_type const& get_path (  )  const

The path used to initialise the instance.

Examples:
by_library/windows_control_panel/windows_control_panel/windows_control_panel.cpp.

size_type size (  )  const

The number of applets in the module.

value_type& operator[] ( index_type  index  ) 

Returns a mutable (non-const) reference to the applet at the index.

Parameters:
index [in] Applet index
Note:
The behaviour is undefined if index >= size()

value_type const& operator[] ( index_type  index  )  const

Returns a non-mutable (const) reference to the applet at the index.

Parameters:
index [in] Applet index
Note:
The behaviour is undefined if index >= size()

iterator begin (  ) 

Begins the iteration.

Returns:
An iterator representing the start of the sequence
Examples:
by_library/windows_control_panel/windows_control_panel/windows_control_panel.cpp.

iterator end (  ) 

Ends the iteration.

Returns:
An iterator representing the end of the sequence
Examples:
by_library/windows_control_panel/windows_control_panel/windows_control_panel.cpp.

const_iterator begin (  )  const

Begins the iteration.

Returns:
An iterator representing the start of the sequence

const_iterator end (  )  const

Ends the iteration.

Returns:
An iterator representing the end of the sequence


The documentation for this class was generated from the following file:

Generated on Thu Jun 10 08:59:15 2010 for STLSoft by  doxygen 1.5.6