发布网友 发布时间:2024-10-17 09:05
共2个回答
热心网友 时间:2024-10-17 09:03
首先用AppWizard 建个单文档界面的,在最后一页把View 的基类选成CEditView.(这步你应该会)
然后在资源编辑器中 工具栏中添加 按钮, 用ClassWizard 建出View 对它的响应函数(这步你应该会)
在其中:
TCHAR szCurLine[257];
for(int i =0;i<GetEditCtrl().GetLineCount();i++)
{
szCurLine[ GetEditCtrl().GetLine(i,szCurLine, 256) ] ='\0'; //手动添加 字符串结束标志
//在这里szCurLine 的内容就是第i 行的文本了.
}
热心网友 时间:2024-10-17 09:05
以下代码加入到:MainFrm.cpp里
void CMainFrame::OnUpdateFormatReturn(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
以下代码加入到starliu.cpp里 starliu是我自己起的名字,你可以自己起一个
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
char hostname[_MAX_PATH]; //定义主机名
char username[_MAX_PATH]; //定义用户名
DWORD dwSize=_MAX_PATH;
DWORD dwSize1=_MAX_PATH;
MEMORYSTATUS mem_stat; //定义可用物理内存
GlobalMemoryStatus(&mem_stat);
GetComputerName(hostname,&dwSize); //GET
GetUserName(username,&dwSize1);
GetDlgItem(IDC_HOSTNAME)->SetWindowText(hostname); //WRITE
GetDlgItem(IDC_ORGANIZATION)->SetWindowText(username);
CString str;
str.Format("%d,%3dKB",mem_stat.dwTotalPhys/1024/1000,mem_stat.dwTotalPhys/1024-mem_stat.dwTotalPhys/1024/1000*1000);
GetDlgItem(IDC_MEMPHYS)->SetWindowText(str);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAboutDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
CStatic *pMailto=(CStatic*)GetDlgItem(IDC_MAILTO);
pMailto->GetWindowRect(&rect);
ScreenToClient(&rect);
if(rect.PtInRect(point))
{
HCURSOR cursor=AfxGetApp()->LoadCursor(IDC_MAIL_CURSOR);
SetCursor(cursor);
}
CDialog::OnMouseMove(nFlags, point);
}
void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
CStatic *p=(CStatic*)GetDlgItem(IDC_MAILTO);
p->GetWindowRect(&rect);
ScreenToClient(&rect);
if(rect.PtInRect(point))
{
ShellExecute(NULL, "open", "mailto:leomarswu@163.com?subject=反馈&Body=如果您有什么建议请在此写入!", NULL, NULL, SW_SHOWNORMAL);
}
CDialog::OnLButtonDown(nFlags, point);
}
以下代码加入到starliuView.cpp里
void CNotepadView::OnFormatFont()
{
// TODO: Add your command handler code here
//字体修改实现;
LOGFONT lf;
CFont *font=this->GetEditCtrl().GetFont(); //GET当前字体;
if(font==NULL) //if当前无字体,创建默认的字体;
{
font =new CFont;
font->CreatePointFont(120,"Fixedsys");
font->GetLogFont(&lf);
delete font;
}
else
{
font->GetLogFont(&lf);
}
CFontDialog cf(&lf);
if(cf.DoModal()==IDOK)
{
this->m_Font.DeleteObject();
this->m_Font.CreateFontIndirect(&lf);
this->SetFont(&this->m_Font);
}
}
void CNotepadView::OnFormatReturn()
{
// TODO: Add your command handler code here
//自动换行实现
bChk=!bChk;
if(!bChk)
{
ShowScrollBar(SB_HORZ,true);
}
else
{
ShowScrollBar(SB_HORZ,false);
}
}
void CNotepadView::OnUpdateFormatReturn(CCmdUI* pCmdUI) //update UI handler
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(bChk);
}
热心网友 时间:2024-10-17 09:03
以下代码加入到:MainFrm.cpp里
void CMainFrame::OnUpdateFormatReturn(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
以下代码加入到starliu.cpp里 starliu是我自己起的名字,你可以自己起一个
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
char hostname[_MAX_PATH]; //定义主机名
char username[_MAX_PATH]; //定义用户名
DWORD dwSize=_MAX_PATH;
DWORD dwSize1=_MAX_PATH;
MEMORYSTATUS mem_stat; //定义可用物理内存
GlobalMemoryStatus(&mem_stat);
GetComputerName(hostname,&dwSize); //GET
GetUserName(username,&dwSize1);
GetDlgItem(IDC_HOSTNAME)->SetWindowText(hostname); //WRITE
GetDlgItem(IDC_ORGANIZATION)->SetWindowText(username);
CString str;
str.Format("%d,%3dKB",mem_stat.dwTotalPhys/1024/1000,mem_stat.dwTotalPhys/1024-mem_stat.dwTotalPhys/1024/1000*1000);
GetDlgItem(IDC_MEMPHYS)->SetWindowText(str);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAboutDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
CStatic *pMailto=(CStatic*)GetDlgItem(IDC_MAILTO);
pMailto->GetWindowRect(&rect);
ScreenToClient(&rect);
if(rect.PtInRect(point))
{
HCURSOR cursor=AfxGetApp()->LoadCursor(IDC_MAIL_CURSOR);
SetCursor(cursor);
}
CDialog::OnMouseMove(nFlags, point);
}
void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
CStatic *p=(CStatic*)GetDlgItem(IDC_MAILTO);
p->GetWindowRect(&rect);
ScreenToClient(&rect);
if(rect.PtInRect(point))
{
ShellExecute(NULL, "open", "mailto:leomarswu@163.com?subject=反馈&Body=如果您有什么建议请在此写入!", NULL, NULL, SW_SHOWNORMAL);
}
CDialog::OnLButtonDown(nFlags, point);
}
以下代码加入到starliuView.cpp里
void CNotepadView::OnFormatFont()
{
// TODO: Add your command handler code here
//字体修改实现;
LOGFONT lf;
CFont *font=this->GetEditCtrl().GetFont(); //GET当前字体;
if(font==NULL) //if当前无字体,创建默认的字体;
{
font =new CFont;
font->CreatePointFont(120,"Fixedsys");
font->GetLogFont(&lf);
delete font;
}
else
{
font->GetLogFont(&lf);
}
CFontDialog cf(&lf);
if(cf.DoModal()==IDOK)
{
this->m_Font.DeleteObject();
this->m_Font.CreateFontIndirect(&lf);
this->SetFont(&this->m_Font);
}
}
void CNotepadView::OnFormatReturn()
{
// TODO: Add your command handler code here
//自动换行实现
bChk=!bChk;
if(!bChk)
{
ShowScrollBar(SB_HORZ,true);
}
else
{
ShowScrollBar(SB_HORZ,false);
}
}
void CNotepadView::OnUpdateFormatReturn(CCmdUI* pCmdUI) //update UI handler
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(bChk);
}
热心网友 时间:2024-10-17 09:07
首先用AppWizard 建个单文档界面的,在最后一页把View 的基类选成CEditView.(这步你应该会)
然后在资源编辑器中 工具栏中添加 按钮, 用ClassWizard 建出View 对它的响应函数(这步你应该会)
在其中:
TCHAR szCurLine[257];
for(int i =0;i<GetEditCtrl().GetLineCount();i++)
{
szCurLine[ GetEditCtrl().GetLine(i,szCurLine, 256) ] ='\0'; //手动添加 字符串结束标志
//在这里szCurLine 的内容就是第i 行的文本了.
}