📄 mdidemo.cpp
字号:
// MDIDemo.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "MDIDemo.h"
#include "HyperLink.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "MDIDemoDoc.h"
#include "MDIDemoView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMDIDemoApp
BEGIN_MESSAGE_MAP(CMDIDemoApp, CWinApp)
//{{AFX_MSG_MAP(CMDIDemoApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
//ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
//ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMDIDemoApp construction
CMDIDemoApp::CMDIDemoApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMDIDemoApp object
CMDIDemoApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMDIDemoApp initialization
BOOL CMDIDemoApp::InitInstance()
{
AfxEnableControlContainer();
if(!::AfxInitRichEdit())
{
AfxMessageBox("RichEdit没有加载成功");
}
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
/* CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_MDIDEMTYPE,
RUNTIME_CLASS(CMDIDemoDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMDIDemoView));
AddDocTemplate(pDocTemplate);
*/
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
void EnableVisibleChildren();
void ExtendDlg(int nResourceID, BOOL bExpand);
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CHyperLink m_firstlink;
CEdit m_edit1;
CString m_str;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
afx_msg void Oncontribute();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
void CAboutDlg::ExtendDlg(int nResourceID, BOOL bExpand)
{
// 如果bExpand==TRUE,则扩展对话框为最大;
// 否则缩小对话框,新的对话框的底部为资源nResourceID控件分割
static CRect rcLarge;
static CRect rcSmall;
CString sExpand;
// 在开始时,保存对话框的最大和最小尺寸
if(rcLarge.IsRectNull())
{
CRect rcLandmark;
// 得到分割条的指针
CWnd* pWndLandmark=GetDlgItem(nResourceID);
ASSERT(pWndLandmark);
// 得到对话框的尺寸
GetWindowRect(rcLarge);
// 得到分割条在对话框中的位置
pWndLandmark->GetWindowRect(rcLandmark);
rcSmall=rcLarge;
rcSmall.bottom=rcLandmark.top;
}
if(bExpand)
{
// 扩展对话框:重新设置对话框到其原始(最大)尺寸(rcLarge)
SetWindowPos(NULL,0,0,rcLarge.Width(),rcLarge.Height(),
SWP_NOMOVE|SWP_NOZORDER);
sExpand="<<算了吧";
EnableVisibleChildren();
}
else
{
// 缩小对话框:重新设置对话框到其最小尺寸(rcSmall)
SetWindowPos(NULL,0,0,rcSmall.Width(),rcSmall.Height(),
SWP_NOMOVE|SWP_NOZORDER);
sExpand="捐助我们>>";
EnableVisibleChildren();
}
// 设置按钮的文字
SetDlgItemText(IDC_contribute,sExpand);
}
void CAboutDlg::EnableVisibleChildren()
{
// 下面的代码使不在当前对话框中的按钮失效。
// 这样可以避免使用Tab键或者快捷键移动到隐藏的控件
// 得到第一个子控件
CWnd* pWndCtrl=GetWindow(GW_CHILD);
CRect rcRest;
CRect rcControl;
CRect rcShow;
GetWindowRect(rcShow);
// 遍历对话框中的控件
while(pWndCtrl!=NULL)
{
pWndCtrl->GetWindowRect(rcControl);
if(rcRest.IntersectRect(rcShow,rcControl))
pWndCtrl->EnableWindow(TRUE);
else
pWndCtrl->EnableWindow(FALSE);
// 得到在控件组中的下一个
pWndCtrl=pWndCtrl->GetWindow(GW_HWNDNEXT);
}
}
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
m_str = _T("首先希望你能先去我们官方网站查询一下信息。\r\n也可以用下列信息联系我\r\nwww.8dragon.com \r\nwww.csdn.net VC硬件系统版斑竹AthlonxpX86(桃源村)\r\n地址: 甘肃兰州工专机电04-2班,叶树深。电话号码:0931-3979882\r\n邮箱: yds_086@163.com\r\nQQ:176156000\r\n当然也可以直接打钱给我\r\n农行金穗卡95599 8121 02559 16912");
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Control(pDX, IDC_firstlink, m_firstlink);
DDX_Control(pDX, IDC_AEDIT1, m_edit1);
DDX_Text(pDX, IDC_AEDIT1, m_str);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_BN_CLICKED(IDC_contribute, Oncontribute)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CAboutDlg::OnInitDialog()
{
ExtendDlg(IDC_SEPARATE,FALSE);
m_edit1.SetSel(0,-1,TRUE);
//AfxMessageBox("");
GetDlgItem(IDC_ASTATIC)->SetWindowText("........飘啊摇啊,淡漠了生活,忘记了梦想,就这样浑浑噩噩的活着..........梦已死。\r\n6年前当我还上初中的时候,我的梦想是能够得到一块8031......但是......\r\n面对现实的无奈......我发誓要为有与我有同样经历的人做些什么......\r\n我希望本软件能是免费的,以实现我6年前的诺言。\r\n但我的肉体却活在现实中,我希望有人能施舍点给我的躯壳。\r\n我真的不希望再为房租,伙食,和高的吓人的药费而烦恼。\r\n本软件还不完善,如果你觉的本软件对你有帮助并希望它能更好的发展。\r\n你能否伸出你的援助之手?\r\n您的每一分钱都将是我完成本软件的巨大动力,至少能让我知道这个世界上还有人还在支持我.....");
m_firstlink.SetURL(_T("http://www.8dragon.com"));
this->UpdateData(FALSE);
return 0;
}
void CAboutDlg::Oncontribute()
{
// TODO: Add your control notification handler code here
static BOOL bExpand = TRUE;
// 以IDC_SEPARATE分割对话框
ExtendDlg(IDC_SEPARATE,bExpand);
bExpand=!bExpand;
// m_edit1.SetWindowText();
this->UpdateData(FALSE);
//m_edit1.SetSel(0,-1,TRUE);
}
// App command to run the dialog
void CMDIDemoApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
// aboutDlg->ShowWindow(SW_SHOW);
}
/////////////////////////////////////////////////////////////////////////////
// CMDIDemoApp message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -