Property Pages for Credentials

This section describes the logistics of property pages. When a user selects the 'Properties' option from a menu (either the File menu or a context menu), then a KHUI_ACTION_PROPERTIES action is triggered. This is handled by the credentials window and triggers the launch of a property sheet if there is a valid context to extract properties from.

Sequence of actions:

In addition to the ctx member, depending on the scope of the context, other fields of the khui_property_sheet structure could also be set:

The following code shows how this message might be handled.

       // Message handler code for KMSG_CRED_PP_BEGIN

       khui_property_sheet * ps;
       PROPSHEETPAGE       * psp;     // from prsht.h

       if (ps->credtype == credtype_id &&
           ps->cred) {

           // We have been requested to show a property sheet for one of
           // our credentials.

           // The PROPSHEETPAGE structure has to exist until we remove the
           // property sheet page when we are handling KMSG_CRED_PP_END.

           psp = malloc(sizeof(*psp));
           ZeroMemory(p, sizeof(*psp));

           psp->dwSize = sizeof(*psp);
           psp->dwFlags = 0;

           // hResModule is the handle to the resource module
           psp->hInstance = hResModule;

           // IDD_PP_CRED is the dialog template for our property page
           psp->pszTemplate = MAKEINTRESOURCE(IDD_PP_CRED);

           // pp_cred_dlg_proc is the message handler for our property
           // page.  See the Platform SDK for details.
           psp->pfnDlgProc = pp_cred_dlg_proc;

           // We can pass the khui_property_sheet structure as the
           // lParam for the message handler so it knows the scope of
           // the property sheet.
           psp->lParam = (LPARAM) ps;

           // Finally, add a property page for our credential type
           // stored in credtype_id.  Note that only one property page
           // can be added per credential type.

           khui_ps_add_page(ps, credtype_id, 0, psp, NULL);

           return KHM_ERROR_SUCCESS;
       }

Continuing our example from above, the following code could be used to handle this message:

     // Handler for KMSG_CRED_PP_END

     khui_property_page * p = NULL;

     // If a property sheet was added by us, this call would get
     // a handle to the property page structure.

     if (KHM_SUCCEEDED(khui_ps_find_page(ps, credtype_id, &p))) {

         // It is safe to assume that the property page window has
         // been destroyed by the time we receive KMSG_CRED_PP_END.
         // So we can free the PROPSHEETPAGE structure we allocated
         // above.

         if (p->p_page)
             free(p->p_page);
         p->p_page = NULL;

         // The property page structure we added will automatically
         // be removed and freed by the application.
     }

     return KHM_ERROR_SUCCESS;

Note:
The maximum number of property sheets that can be open at one time is currently set to 256. Each property sheet can have a maximum of 16 property pages.

Generated on Fri Aug 3 08:27:13 2007 for Network Identity Manager by Doxygen 1.5.2
© 2004-2007 Massachusetts Institute of Technology.
© 2005-2007 Secure Endpoints Inc.
Contact khimaira@mit.edu