當前位置:編程學習大全網 - 源碼下載 - 黑客動畫吧記事本源代碼

黑客動畫吧記事本源代碼

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壓縮包

/Notepad.rar

黑客動畫吧記事本源代碼不會輕易公開的,那個記事本也不太好,界面也不好,其實破解也很容易的,但是意義不大。

  • 上一篇:C# 文本框只能輸入數字
  • 下一篇:如何通過PC端連接Android設備進行adb調試
  • copyright 2024編程學習大全網