Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Toolkit User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

15.8 Tip of the Day Dialog

A tip of the day dialog is displayed when the user starts the application. It displays random but useful information about the application.

Figure 125: Example Tip of the Day

15.8.1 The SECTipOfDay Class

SECTipOfDay stores tips in a plain ASCII file so you can easily create tip files (*.tip) with any editor. SECTipOfDay is designed to be fully customizable. You can specify different fonts or icons and change other attributes by deriving your own tip class from SECTipOfDay.

Figure 126: Objective Toolkit SECTipOfDay Class Hierarchy

15.8.2 SECTipOfDay Resource IDs

The following resource IDs are available for the SECTipOfDay class. You can use them to display items on the dialog selectively. See Section 15.8.3.4, "To hide buttons on the tip of the day dialog."

Table 41: Resource IDs for SECTipofDay

Resource ID Description
IDC_TOD_OK_BUTTON The OK button ID.
IDC_TOD_NEXT_BUTTON The Next Tip button ID.
IDC_TOD_PREV_BUTTON The Previous Tip button ID.
IDC_TOD_HELP_BUTTON The Help button ID.
IDC_TOD_SHOW_CHECK The Show tips at startup check box.
IDC_TOD_GROUPBOX The tip itself.

15.8.3 Using SECTipOfDay

The SECTipOfDay class has the same interface as CDialog so you can make SECTipOfDay modal or modeless. The SECTipOfDay constructor takes arguments that specify the tip file, tip number, and other parameters specific to SECTipOfDay.

It is the application's responsibility to store the tip number so that it can provide the user with a new tip at every application invocation.

15.8.3.1 To create a modal tip of the day dialog

The following changes are typically done in the InitInstance() method of the application, as part of the initialization of the application. The code is executed after the main frame has been created and displayed.

  1. Load the startup status and tip from a file, registry, or other source. For example:

  2. Instantiate an SECTipOfDay object by passing the tip and startup information to the constructor and then calling the DoModal() method. For example:

      if (m_bShowTipAtStartup)
      {
          SECTipOfDay MyTips(_T("todtest.tip"),++m_nLastTip);
          MyTips.DoModal();
      }
      

15.8.3.2 To create a modeless tip of the day dialog

  1. Load the startup status and tip from a file, registry, or other source.

  2. Create an SECTipOfDay object on the heap with the new operator.

      m_pModelessTip =
          new SECTipOfDay(_T("todtest.tip"),++m_nLastTip,
                          m_bShowTipAtStartup);
      


    You can declare the object on the stack (for example, as the member of a class) as long as the object is not expected to go out of scope while the tip of the day window is displayed.

  3. Display the dialog in a modeless manner by calling CDialog::Create() and CDialog::ShowWindow().

          
      theApp.m_pModelessTip->Create();
          theApp.m_pModelessTip->ShowWindow(SW_SHOW);
      

15.8.3.3 To change the caption of the tip of the day dialog

  1. Derive a class from SECTipOfDay.

  2. Override the OnInitDialog() method. In the override, call the base class implementation and then call the CDialog::SetWindowText() method. For example:

      CMyTipOfDay::OnInitDialog()
      {
          SECTipOfDay::OnInitDialog();
      
          // Change the caption to something else
          this->SetWindowText(
                _T("This is my custom tip du jour"));
          
          // FYI, by default SECTipOfDay, centers the tip,
          // you might want
          // to move it else where here.
          
          return TRUE;
      }
      

15.8.3.4 To hide buttons on the tip of the day dialog

  1. Derive a class from SECTipOfDay.

  2. Override the OnInitDialog() method. In the override, call the base class implementation and then call ShowWindow(SW_HIDE) for the dialog items to be hidden. See Section 15.8.2 for a list of resource IDS. For example:

15.8.4 SECTipOfDay Sample

The Objective Toolkit todtest sample (Samples\Toolkit\MFC\UIExt\todtest) demonstrates the SECTipOfDay class and shows how to customize the class to specify a different font and icon. This sample does not ship with the product. For information on how to obtain this sample, see Section 3.6.1, "Location of Sample Code," in the Stingray Studio Getting Started Guide.



Previous fileTop of DocumentContentsNo linkNext file

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.