友情提示:如果本网页打开太慢或显示不完整,请尝试鼠标右键“刷新”本网页!
深入浅出MFC第2版(PDF格式)-第144部分
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部! 如果本书没有阅读完,想下次继续接着阅读,可使用上方 "收藏到我的浏览器" 功能 和 "加入书签" 功能!
#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。。。〃
CG_IDS_FILE_ABSENT 〃Tips file does not exist in the prescribed directory! ¨
END
STRINGTABLE DISCARDABLE
BEGIN
CG_IDP_FILE_CORRUPT 〃Trouble reading the tips file〃
CG_IDS_TIPOFTHEDAYHELP 〃&Help〃
END
MA INFRM。H (阴影部份为新增内容)
class CMainFrame : public CMDIFrameWnd
{
。。。
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
。。。
// Generated message map functions
protected:
afx_msg void OnInitMenu(CMenu* pMenu);
。。。
};
MA INFRM。CPP (阴影部份为新增内容)
#0001 。。。
#0002 #include 〃Splash。h〃
#0003 。。。
#0004 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
#0005 {
#0006 。。。
#0007 // CG: The following line was added by the Splash Screen ponent。
#0008 CSplashWnd::ShowSplashScreen(this);
#0009
#0010 return 0;
#0011 }
#0012 。。。
#0013 /////////////////////////////////////////////////////////////////
#0014 // CMainFrame message handlers
#0015
806
…………………………………………………………Page 869……………………………………………………………
16 ponents & ActiveX Controls
第 章 站眾的肩膀 使用
#0016 void CMainFrame::OnInitMenu(CMenu* pMenu)
#0017 {
#0018 CMDIFrameWnd::OnInitMenu(pMenu);
#0019
#0020 // CG: This block added by 'Tip of the Day' ponent。
#0021 {
#0022 // TODO: This code adds the 〃Tip of the Day〃 menu item
#0023 // on the fly。 It may be removed after adding the menu
#0024 // item to all applicable menu items using the resource
#0025 // editor。
#0026
#0027 // Add Tip of the Day menu item on the fly!
#0028 static CMenu* pSubMenu = NULL;
#0029
#0030 CString strHelp; strHelp。LoadString(CG_IDS_TIPOFTHEDAYHELP);
#0031 CString strMenu;
#0032 int nMenuCount = pMenu…》GetMenuItemCount();
#0033 BOOL bFound = FALSE;
#0034 for (int i=0; i 《 nMenuCount; i++)
#0035 {
#0036 pMenu…》GetMenuString(i; strMenu; MF_BYPOSITION);
#0037 if (strMenu == strHelp)
#0038 {
#0039 pSubMenu = pMenu…》GetSubMenu(i);
#0040 bFound = TRUE;
#0041 ASSERT(pSubMenu != NULL);
#0042 }
#0043 }
#0044
#0045 CString strTipMenu;
#0046 strTipMenu。LoadString(CG_IDS_TIPOFTHEDAYMENU);
#0047 if (!bFound)
#0048 {
#0049 // Help menu is not available。 Please add it!
#0050 if (pSubMenu == NULL)
#0051 {
#0052 // The same pop…up menu is shared between mainfrm and
frame
#0053 // with the doc。
#0054 static CMenu popUpMenu;
#0055 pSubMenu = &popUpMenu;
#0056 pSubMenu…》CreatePopupMenu();
#0057 pSubMenu…》InsertMenu(0; MF_STRING|MF_BYPOSITION;
#0058 CG_IDS_TIPOFTHEDAY; strTipMenu);
#0059 }
#0060 pMenu…》AppendMenu(MF_STRING|MF_BYPOSITION|MF_ENABLED|MF_POPUP;
807
…………………………………………………………Page 870……………………………………………………………
第篇 深入 MFC 程式設計
#0061 (UINT)pSubMenu…》m_hMenu; strHelp);
#0062 DrawMenuBar();
#0063 }
#0064 else
#0065 {
#0066 // Check to see if the Tip of the Day menu has already been
added。
#0067 pSubMenu…》GetMenuString(0; strMenu; MF_BYPOSITION);
#0068
#0069 if (strMenu != strTipMenu)
#0070 {
#0071 // Tip of the Day submenu has not been added to the
#0072 // first position; so add it。
#0073 pSubMenu…》InsertMenu(0; MF_BYPOSITION); // Separator
#0074 pSubMenu…》InsertMenu(0; MF_STRING|MF_BYPOSITION;
#0075 CG_IDS_TIPOFTHEDAY; strTipMenu);
#0076 }
#0077 }
#0078 }
#0080 }
SPLASH。H (全新內容 )
#0001 // CG: This file was added by the Splash Screen ponent。
#0002
#0003 #ifndef _SPLASH_SCRN_
#0004 #define _SPLASH_SCRN_
#0005
#0006 // Splash。h : header file
#0007
#0008 /////////////////////////////////////////////////////////////////
#0009 // Splash Screen class
#0010
#0011 class CSplashWnd : public CWnd
#0012 {
#0013 // Construction
#0014 protected:
#0015 CSplashWnd();
#0016
#0017 // Attributes:
#0018 public:
#0019 CBitmap m_bitmap;
#0020
#0021 // Operations
#0022 public:
#0023 static void EnableSplashScreen(BOOL bEnable = TRUE);
808
…………………………………………………………Page 871……………………………………………………………
16 ponents & ActiveX Controls
第 章 站眾的肩膀 使用
#0024 static void ShowSplashScreen(CWnd* pParentWnd = NULL);
#0025 static BOOL PreTranslateAppMessage(MSG* pMsg);
#0026
#0027 // Overrides
#0028 // ClassWizard generated virtual function overrides
#0029 //{{AFX_VIRTUAL(CSplashWnd)
#0030 //}}AFX_VIRTUAL
#0031
#0032 // Implementation
#0033 public:
#0034 ~CSplashWnd();
#0035 virtual void PostNcDestroy();
#0036
#0037 protected:
#0038 BOOL Create(CWnd* pParentWnd = NULL);
#0039 void HideSplashScreen();
#0040 static BOOL c_bShowSplashWnd;
#0041 static CSplashWnd* c_pSplashWnd;
#0042
#0043 // Generated message map functions
#0044 protected:
#0045 //{{AFX_MSG(CSplashWnd)
#0046 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
#0047 afx_msg void OnPaint();
#0048 afx_msg void OnTimer(UINT nIDEvent);
#0049 //}}
快捷操作: 按键盘上方向键 ← 或 → 可快速上下翻页 按键盘上的 Enter 键可回到本书目录页 按键盘上方向键 ↑ 可回到本页顶部!
温馨提示: 温看小说的同时发表评论,说出自己的看法和其它小伙伴们分享也不错哦!发表书评还可以获得积分和经验奖励,认真写原创书评 被采纳为精评可以获得大量金币、积分和经验奖励哦!