黑客动画吧记事本源代码

对不起,我不是用这个RichTextBox1做的,我是用text做的。
但是查找和格式还没能实现。希望,那位高手指教一下。

第1个回答  2007-02-10
VB.net编程方法:

'新建文件

Private Sub mnuNew_Click()

RichTextBox1.Text = "" '清空文本框

FileName = "未命名"

Me.Caption = FileName

End Sub

'打开文件

Private Sub mnuOpen_Click()

CommonDialog1.Filter="文本文档(*.txt) *.txt RTF文档(*.rtf) *.rtf 所有文件(*.*) *.*"

CommonDialog1.ShowOpen

RichTextBox1.Text = "" '清空文本框

FileName = CommonDialog1.FileName

RichTextBox1.LoadFile FileName

Me.Caption = "超级记事本:" & FileName

End Sub

'保存文件

Private Sub mnuSave_Click()

CommonDialog1.Filter="文本文档(*.txt) *.txt RTF文档(*.rtf) *.rtf 所有文件(*.*) *.*"

CommonDialog1.ShowSave

FileType = CommonDialog1.FileTitle

FiType = LCase(center(FileType, 3))

FileName = CommonDialog1.FileName

Select Case FiType

Case "txt"

RichTextBox1.SaveFile FileName, rtfText

Case "rtf"

RichTextBox1.SaveFile FileName, rtfRTF

Case "*.*"

RichTextBox1.SaveFile FileName

End Select

Me.Caption = "超级记事本:" & FileName

End Sub

'退出

Private Sub mnuExit_Click()

End

End Sub

'复制

Private Sub mnuCopy_Click()

Clipboard.Clear

Clipboard.SetText RichTextBox1.SelText

End Sub

'剪切

Private Sub mnuCut_Click()

Clipboard.Clear

Clipboard.SetText RichTextBox1.SelText

RichTextBox1.SelText = ""

End Sub

'全选

Private Sub mnuSelectAll_Click()

RichTextBox1.SelStart = 0

RichTextBox1.SelLength = Len(RichTextBox1.Text)

End Sub

'粘贴

Private Sub mnuPaste_Click()

RichTextBox1.SelText = Clipboard.GetText

End Sub

'查找

Private Sub mnuFind_Click()

sFind = InputBox("请输入要查找的字、词:", "查找内容", sFind)

RichTextBox1.Find sFind

End Sub

'继续查找

Private Sub mnuFindOn_Click()

RichTextBox1.SelStart = RichTextBox1.SelStart+RichTextBox1.SelLength + 1

RichTextBox1.Find sFind, , Len(RichTextBox1)

End Sub

'使用说明

Private Sub mnuReadme_Click()

On Error GoTo handler

RichTextBox1.LoadFile "Readme.txt",rtfText'请写好Readme.txt文件并存入程序所在文件夹中

Me.Caption = "超级记事本:" & "使用说明"

Exit Sub

handler:

MsgBox "使用说明文档可能已经被移除,请与作者联系。", vbOKOnly, " 错误信息"

End Sub

VC++编程方法:

首先用VC++创建一个MFC AppWizard(exe)单文档工程,名字Notepad。在Advanced里面File extension(文件扩展名)里面写txt就是关联txt文件,在Base class里面要选CEditView类(意思是基于这个类派生出你用的类)

其实这样生成的就是一个记事本了,但是和原来的记事本还是有区别的

所以我们还要添加点功能,这样才能起到让新人了解VC++的目的

1、我们先加一个设置字体

在 CNotepadView类里面定义字体(就是public) CFont m_Font;

定义消息处理函数:

void CNotepadView::OnFormatFont()
{
// TODO: Add your command handler code here

LOGFONT lf;
CFont *font=this->GetEditCtrl().GetFont();
if(font==NULL)
{
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);
}
}

2、设置字体

在 CNotepadView类里面定义 BOOL bChk;

消息处理函数

void CNotepadView::OnFormatReturn()
{
// TODO: Add your command handler code here

bChk=!bChk;
if(!bChk)
{
ShowScrollBar(SB_HORZ,true);
}
else
{
ShowScrollBar(SB_HORZ,false);
}
}
下面是源代码RAR压缩包

http://mysky66.51.net/Notepad.rar
黑客动画吧记事本源代码不会轻易公开的,那个记事本也不太好,界面也不好,其实破解也很容易的,但是意义不大。本回答被网友采纳
第2个回答  2007-02-06
.......