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
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
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 “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.
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.
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:
 
m_nLastTip =
GetProfileInt(_T("SampleTip"),_T("CurrentTip"),0);
 
m_bShowTipAtStartup =
(BOOL)GetProfileInt(_T("SampleTip"),_T("ShowAtStart"),1);
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();
}
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);
NOTE >> 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);
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;
}
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 “SECTipOfDay Resource IDs” for a list of resource IDS. For example:
 
CMyTipOfDay::OnInitDialog()
{
SECTipOfDay::OnInitDialog();
 
// Hide the “previous” button and the
// “show at startup” button.
CWnd * pWnd =
(CWnd *)GetDlgItem(IDC_TOD_PREV_BUTTON);
pWnd->ShowWindow(SW_HIDE);
 
pWnd = (CWnd *)GetDlgItem(IDC_TOD_SHOW_CHECK);
pWnd->ShowWindow(SW_HIDE);
// FYI, by default SECTipOfDay, centers the tip,
// you might want
// to move it else where here.
return TRUE;
}
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 “Location of Sample Code” in the Getting Started part.