按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
#define CG_IDS_DISK_SPACE 104
#define CG_IDS_DISK_SPACE_UNAVAIL 105
#define IDB_LIGHTBULB 106
#define IDD_TIP 107
#define CG_IDS_TIPOFTHEDAY 108 // Tips 所加,一个字符串。稍后我要把它改为中文内容。
#define CG_IDS_TIPOFTHEDAYMENU 109
#define CG_IDS_DIDYOUKNOW 110 // Tips 所加,一个字符串。稍后我要把它改为中文内容。
#define CG_IDS_FILE_ABSENT 111
#define CG_IDP_FILE_CORRUPT 112
#define CG_IDS_TIPOFTHEDAYHELP 113
#define IDC_PHYSICAL_MEM 1000 // SysInfo所加,代表「可用内存」这个static 字段
802
…………………………………………………………Page 865……………………………………………………………
16 ponents & ActiveX Controls
第 章 站眾的肩膀 使用
#define IDC_BULB 1000
#define IDC_DISK_SPACE 1001 // SysInfo所加,代表「磁盘剩余空间」这个static 字段
#define IDC_STARTUP 1001
#define IDC_NEXTTIP 1002
#define IDC_TIPSTRING 1004
。。。
TEST。H (阴影部份为新增内容)
class CTestApp : public CWinApp
{
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
CTestApp();
。。。
private:
void ShowTipAtStartup(void);
private:
void ShowTipOfTheDay(void);
}
TEST。CPP (阴影部份为新增内容)
#0001 。。。
#0002 #include 〃Splash。h〃
#0003 #include
#0004 #include
#0005
#0006 BEGIN_MESSAGE_MAP(CTestApp; CWinApp)
#0007 ON_MAND(CG_IDS_TIPOFTHEDAY; ShowTipOfTheDay)
#0008 //{{AFX_MSG_MAP(CTestApp)
#0009 ON_MAND(ID_APP_ABOUT; OnAppAbout)
#0010 // NOTE the ClassWizard will add and remove mapping macros here。
#0011 // DO NOT EDIT what you see in these blocks of generated code!
#0012 //}}AFX_MSG_MAP
#0013 // Standard file based document mands
#0014 ON_MAND(ID_FILE_NEW; CWinApp::OnFileNew)
#0015 ON_MAND(ID_FILE_OPEN; CWinApp::OnFileOpen)
#0016 // Standard print setup mand
#0017 ON_MAND(ID_FILE_PRINT_SETUP; CWinApp::OnFilePrintSetup)
#0018 END_MESSAGE_MAP()
#0019
#0020 BOOL CTestApp::InitInstance()
#0021 {
#0022 // CG: The following block was added by the Splash Screen ponent。
803
…………………………………………………………Page 866……………………………………………………………
第篇 深入 MFC 程式設計
#0023 {
#0024 CmandLineInfo cmdInfo;
#0025 ParsemandLine(cmdInfo);
#0026 CSplashWnd::EnableSplashScreen(cmdInfo。m_bShowSplash);
#0027 }
#0028
#0029 AfxEnableControlContainer();
#0030 。。。
#0031
#0032 // CG: This line inserted by 'Tip of the Day' ponent。
#0033 ShowTipAtStartup();
#0034
#0035 return TRUE;
#0036 }
#0037 。。。
#0038 BOOL CTestApp::PreTranslateMessage(MSG* pMsg)
#0039 {
#0040 // CG: The following lines were added by the Splash Screen ponent。
#0041 if (CSplashWnd::PreTranslateAppMessage(pMsg))
#0042 return TRUE;
#0043
#0044 return CWinApp::PreTranslateMessage(pMsg);
#0045 }
#0046
#0047 BOOL CAboutDlg::OnInitDialog()
#0048 {
#0049 CDialog::OnInitDialog(); // CG: This was added by System Info ponent。
#0050
#0051 // CG: Following block was added by System Info ponent。
#0052 {
#0053 CString strFreeDiskSpace;
#0054 CString strFreeMemory;
#0055 CString strFmt;
#0056
#0057 // Fill available memory
#0058 MEMORYSTATUS MemStat;
#0059 MemStat。dwLength = sizeof(MEMORYSTATUS);
#0060 GlobalMemoryStatus(&MemStat);
#0061 strFmt。LoadString(CG_IDS_PHYSICAL_MEM);
#0062 strFreeMemory。Format(strFmt; MemStat。dwTotalPhys / 1024L);
#0063
#0064 //TODO: Add a static control to your About Box to receive the memory
#0065 // information。 Initialize the control with code like this:
#0066 // SetDlgItemText(IDC_PHYSICAL_MEM; strFreeMemory);
#0067
#0068 // Fill disk free information
804
…………………………………………………………Page 867……………………………………………………………
16 ponents & ActiveX Controls
第 章 站眾的肩膀 使用
#0069 struct _diskfree_t diskfree;
#0070 int nDrive = _getdrive(); // use current default drive
#0071 if (_getdiskfree(nDrive; &diskfree) == 0)
#0072 {
#0073 strFmt。LoadString(CG_IDS_DISK_SPACE);
#0074 strFreeDiskSpace。Format(strFmt;
#0075 (DWORD)diskfree。avail_clusters *
#0076 (DWORD)diskfree。sectors_per_cluster *
#0077 (DWORD)diskfree。bytes_per_sector / (DWORD)1024L;
#0078 nDrive…1 + _T('A'));
#0079 }
#0080 else
#0081 strFreeDiskSpace。LoadString(CG_IDS_DISK_SPACE_UNAVAIL);
#0082
#0083 //TODO: Add a static control to your About Box to receive the memory
#0084 // information。 Initialize the control with code like this:
#0085 // SetDlgItemText(IDC_DISK_SPACE; strFreeDiskSpace);
#0086 }
#0087
#0088 return TRUE; // CG: This was added by System Info ponent。
#0089 }
TEST。RC (阴影部份为新增内容)
IDB_SPLASH BITMAP DISCARDABLE 〃Splsh16。bmp〃
。。。
IDD_TIP DIALOG DISCARDABLE 0; 0; 231; 164
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION 〃Tip of the Day〃
FONT 8; 〃MS Sans Serif〃
BEGIN
CONTROL 〃〃;…1;〃Static〃;SS_BLACKFRAME;12;11;207;123
LTEXT 〃Some String〃;IDC_TIPSTRING;28;63;177;60
CONTROL 〃&Show Tips on StartUp〃;IDC_STARTUP;〃Button〃;
BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP;13;146;85;10
PUSHBUTTON 〃&Next Tip〃;IDC_NEXTTIP;109;143;50;14;WS_GROUP
DEFPUSHBUTTON 〃&Close〃;IDOK;168;143;50;14;WS_GROUP
CONTROL 〃〃;IDC_BULB;〃Static〃;SS_BITMAP;20;17;190;111
END
。。。
STRINGTABLE DISCARDABLE
BEGIN
CG_IDS_PHYSICAL_MEM 〃%lu KB〃
CG_IDS_DISK_SPACE 〃%lu KB Free on %c:〃
CG_IDS_DISK_SPACE_UNAVAIL 〃Unavailable〃
CG_IDS_TIPOFTHEDAY 〃Displays a Tip of the Day。〃
805
…………………………………………………………Page 868……………………………………………………………
第篇 深入 MFC 程式設計
CG_IDS_TIPOFTHEDAYMENU 〃Ti&p of the Day。。。〃
CG_IDS_DIDYOUKNOW 〃Did You Know。。。〃