转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
★★★敬请留意★★★:和微软一模一样的记事本的源代码(1)         ★★★★

★★★敬请留意★★★:和微软一模一样的记事本的源代码(1)

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1194 更新时间:2009/4/23 18:57:52

Private Declare Function htmlhelp Lib _
 "hhctrl.ocx" Alias "HtmlHelpA" _
 (ByVal hwndCaller As Long, _
ByVal pszFile As String, ByVal _
uCommand As Long, ByVal dwData As Long) As Long

Dim Changed As Boolean

Dim Button As Integer
Private Type Rect
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Type POINTAPI
    X As Long
    Y As Long
End Type


Private Type PageSetupDlg
    lStructSize As Long
    hwndOwner As Long
    hDevMode As Long
    hDevNames As Long
    FLAGS As Long
    ptPaperSize As POINTAPI
    rtMinMargin As Rect
    rtMargin As Rect
    hInstance As Long
    lCustData As Long
    lpfnPageSetupHook As Long
    lpfnPagePaintHook As Long
    lpPageSetupTemplateName As String
    hPageSetupTemplate As Long
End Type

Private Declare Function PageSetupDlg Lib "comdlg32.dll" Alias "PageSetupDlgA" _
(pPagesetupdlg As PageSetupDlg) As Long
Dim PageSetup As PageSetupDlg
Dim Pflag As Long
Dim Pmode As Long
Dim Psize As POINTAPI

Private Sub Form_Load()
Form1.Caption = "NoTitled-notePad"

mnuUndo.Caption = "撤消(&U)" + Chr(9) + "Ctrl+Z"
mnuJian.Caption = "剪切(&T)" + Chr(9) + "Ctrl+X"
mnuCopy.Caption = "复制(&C)" + Chr(9) + "Ctrl+C"
mnuPaste.Caption = "粘贴(&P)" + Chr(9) + "Ctrl+V"
mnuJian.Enabled = False
mnuUndo.Enabled = False
mnuCopy.Enabled = False

mnuDelete.Enabled = False
If Clipboard.GetText() <> "" Then
    mnuPaste.Enabled = True
Else
    mnuPaste.Enabled = False
End If
''''Text1.SelAlignment = Null
Changed = False

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Changed = True Then
   
    Button = MsgBox(Form1.Caption + "file has changed," + Chr(13) + "do you save?", vbYesNoCancel + vbExclamation)
   
    If Button = vbYes Then
        mnuSave_Click
        End
    ElseIf Button = vbNo Then
       End
    End If
    Cancel = True
   
Else
    End
End If

End Sub

Private Sub Form_resize()
Text1.Top = ScaleTop
Text1.Left = ScaleLeft
Text1.Width = ScaleWidth
Text1.Height = ScaleHeight

End Sub


Private Sub mnuAbout_Click()
Form4.Show
End Sub

Private Sub mnuAll_Click()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub

Private Sub mnuCline_Click()

mnuCline.Checked = Not mnuCline.Checked
If mnuCline.Checked = True Then
    Text1.RightMargin = 0
Else
    Text1.RightMargin = 2500
End If
End Sub

Private Sub mnuCopy_Click()

SendKeys "^{insert}"


End Sub

Private Sub mnuDate_Click()
Dstring = FormatDateTime(Now, 4) + Space(2) + FormatDateTime(Now, 2)
SendKeys Dstring
End Sub

Private Sub mnuDelete_Click()
Text1.SelText = ""
End Sub

Private Sub mnuExit_Click()


If Changed = True Then
   
    Button = MsgBox(Form1.Caption + "file has changed," + Chr(13) + "do you save?", vbYesNoCancel + vbExclamation)
   
    If Button = vbYes Then
        mnuSave_Click
    ElseIf Button = vbNo Then
       End
    End If
   
Else
    End
End If

   
End Sub

Private Sub mnuFind_Click()
Form2.Show
End Sub

Private Sub mnuFont_Click()
CommonDialog1.FontName = Text1.SelFontName
CommonDialog1.FLAGS = FontsConstants.cdlCFScreenFonts
CommonDialog1.FontStrikethru = Text1.SelStrikeThru
CommonDialog1.FontBold = Text1.SelBold
CommonDialog1.FontItalic = Text1.SelItalic
CommonDialog1.FontUnderline = Text1.SelUnderline
CommonDialog1.FontSize = Text1.SelFontSize
CommonDialog1.FontStrikethru = Text1.SelStrikeThru
CommonDialog1.Color = Text1.SelColor
CommonDialog1.ShowFont
''''Text1.SelFontName = CommonDialog1.FontName
''''Text1.SelStrikeThru = CommonDialog1.FontStrikethru
''''Text1.SelBold = CommonDialog1.FontBold
''''Text1.SelColor = CommonDialog1.Color
''''Text1.SelItalic = CommonDialog1.FontItalic
''''Text1.SelUnderline = CommonDialog1.FontUnderline
''''Text1.SelFontSize = CommonDialog1.FontSize
''''Text1.SelStrikeThru = CommonDialog1.FontStrikethru

Text1.Font.Bold = CommonDialog1.FontBold
Text1.Font.Italic = CommonDialog1.FontItalic
Text1.Font.Name = CommonDialog1.FontName
Text1.Font.Size = CommonDialog1.FontSize


End Sub

Private Sub mnuGoto_Click()
Form3.Show
''''Form3.SetFocus = Form3.Text1.Text
End Sub

Private Sub mnuHelpTopic_Click()

''''App.HelpFile = "e:\notepad\note.CHM"
''''SendKeys "{F1}"
''''yeah = shellExecute(Form1.hwnd, "open", "e:\notepad\note.CHM", Null, Null, SW_SHOWNORMAL)
''''Shell "e:\notepad\note.chm", vbNormalFocus
''''Shell "hh " + App.Path + "\note.chm", vbNormalFocus
''''Shell "e:\notepad\note.CHM", vbNormalFocus
htmlhelp hwnd, "d:\notepad\note.CHM", 0, 0
End Sub

Private Sub mnuJian_Click()

SendKeys "+{del}"


End Sub

Private Sub mnuline7_Click(Index As Integer)
Dim i As Integer
CommonDialog1.ShowOpen

End Sub

Private Sub mnuNew_Click()
If Changed = True Then
   
    Button = MsgBox(Form1.Caption + "file has changed," + Chr(13) + "do you save?", vbYesNoCancel + vbExclamation)
   
    If Button = vbYes Then
        mnuSave_Click
    End If
End If
Text1.Text = ""
Form1.Caption = "NoTitled-notePad"
Changed = False
End Sub

 

Private Sub mnuNext_Click()

If Gstring <> "" Then
    Form2.Visible = False
    Form2.Command1_Click
Else
    Form2.Visible = True
End If

End Sub

Private Sub mnuOpen_Click()
If Changed = True Then
   
    Button = MsgBox(Form1.Caption + "file has changed," + Chr(13) + "do you save?", vbYesNoCancel + vbExclamation)
   
    If Button = vbYes Then
        mnuSave_Click
    End If
End If
CommonDialog1.ShowOpen
file = CommonDialog1.FileName

If file <> "" Then
Form1.Caption = file
Open file For Input As #1
    If Not EOF(file) Then Text1.Text = Input(LOF(1), #1)
Close #1
Changed = False
End If
End Sub

Private Sub mnuPage_Click()

   
 With PageSetup
     .lStructSize = Len(PageSetup)
       .hwndOwner = hwnd
     
  PageSetupDlg PageSetup
        Pflag = .FLAGS
        Psize = .ptPaperSize
        Pmode = .hDevMode
     End With
       ''''Pflag = PageSetupDlg(PageSetup)
      
''''Text1.SetFocus
End Sub

Private Sub mnuPaste_Click()
SendKeys "+{insert}"
End Sub

Private Sub mnuPrint_Click()
CommonDialog1.FLAGS = Pmode
''''If Text1.SelLength = 0 Then
 ''''   CommonDialog1.FLAGS = cdlPDReturnDC + cdlPDAllPages
''''Else
   '''' CommonDialog1.FLAGS = cdlPDReturnDC + cdlPDSelection
''''End If
CommonDialog1.ShowPrinter
On Error GoTo trip
Printer.Print ""

If CommonDialog1.hDC > 0 Then Text1.Print CommonDialog1.hDC
Printer.EndDoc


trip: End Sub

Private Sub mnuReplace_Click()
FrmReplace.Show
End Sub

Private Sub mnuSave_Click()
If Form1.Caption = "NoTitled-notePad" Then

CommonDialog1.DialogTitle = "save"
CommonDialog1.ShowSave
file = CommonDialog1.FileName
    If file <> "" Then
    Form1.Caption = file
    Open file For Output As #1
    Print #1, Text1.Text
    Close #1
    End If

Else
    file = Form1.Caption
    Open file For Output As #1
    Print #1, Text1.Text
    Close #1
End If
End Sub

Private Sub mnuSaveAs_Click()
CommonDialog1.DialogTitle = "save as "
CommonDialog1.ShowSave
file = CommonDialog1.FileName
If file <> "" Then
    Form1.Caption = file
    Open file For Output As #1
    Print #1, Text1.Text
    Close #1
End If
End Sub

Private Sub mnuUndo_Click()
SendKeys "^{z}"
End Sub

Private Sub Text1_Change()
Changed = True
mnuUndo.Enabled = True

End Sub

 

Private Sub Text1_SelChange()
If Text1.SelLength <> 0 Then
    mnuJian.Enabled = True
    mnuCopy.

[1] [2]  下一页


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台