A tip of the day dialog is displayed when the user starts the application. It displays random but useful information about the application.
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.
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."
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. |
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.
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.
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); |
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(); } |
Load the startup status and tip from a file, registry, or other source.
Create an SECTipOfDay object on the heap with the new operator.
m_pModelessTip = new SECTipOfDay(_T("todtest.tip"),++m_nLastTip, m_bShowTipAtStartup); |
Display the dialog in a modeless manner by calling CDialog::Create() and CDialog::ShowWindow().
theApp.m_pModelessTip->Create(); theApp.m_pModelessTip->ShowWindow(SW_SHOW); |
Derive a class from SECTipOfDay.
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; } |
Derive a class from SECTipOfDay.
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:
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; } |
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.
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.