hi.
using vb 2010, win forms.
and using a screen reader, jaws for windows from
http://www.freedomscientific.com.
okay, going to past the form code from the first form, frmMain.
okay.
Marvin.
Imports System.IO
Public Class frmMain
Private request As DialogResult
Dim dlgSaveDialog1 As New SaveDialog()
'private variables for printing, etc
Private FontColor As Color = Color.Black
Private FontSize As Integer = 12
Private FontFamily As String = "Times New Roman"
Private FontStyle As FontStyle = Drawing.FontStyle.Regular
'place to save the current filename
Public fileName As String
Private Sub mnuFileOpenToolStripMenuItem_Click(sender As Object, e As
System.EventArgs) Handles mnuFileOpenToolStripMenuItem.Click
Dim newWindow As New frmWindow
Dim textFile As StreamReader
'create a new document window(MDI Child)
newWindow.Show()
newWindow.MDIParent = Me
'get the filename and open the file
request = newWindow.dlgOpenFileDialog1.ShowDialog()
If (request = DialogResult.Ok) then
newWindow.FileName = newWindow.dlgOpenFileDialog1.FileName
textFile = File.OpenText(newWindow.FileName)
newWindow.txtDocument.Text = textFile.ReadToEnd
textFile.Close()
End If
If newWindow.dlgOpenFileDialog1.ShowDialog() =
System.Windows.Forms.DialogResult.OK then
newWindow.txtDocument.LoadFile(newWindow.dlgOpenFileDialog1.FileName)
newWindow.FileName = newWindow.dlgOpenFileDialog1.FileName
'Name the new window Title Bar
newWindow.Text = newWindow.fileName
Else
MessageBox.Show("No File Was Opened, User Likely Clicked Cancel Or
Closed The Dialog.")
End If
End Sub
Private Sub mnuFileNewToolStripMenuItem_Click(sender As Object, e As
System.EventArgs) Handles mnuFileNewToolStripMenuItem.Click
Dim newWindow as New frmWindow
'create a new document window (MDI Child)
newWindow.Show()
newWindow.MdiParent = Me
End Sub
Private Sub mnuFileQuitToolStripMenuItem_Click(sender As Object, e As
System.EventArgs) Handles mnuFileQuitToolStripMenuItem.Click
'check the user really wants to close the App
Dim reply As DialogResult = _
MessageBox.Show("Quit Text Editor?", "Simple Text Editor", _
MessageBoxButtons.OkCancel, MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button2)
If reply = windows.forms.DialogResult.OK then
Me.Close()
End If
End Sub
Private Sub frmMain_Load(sender As Object, e As System.EventArgs)
Handles Me.Load
'start the timer for date/time display in status strip
tmrTimer1.Start()
'resize the rich text box to fill the window
txtDocument.size = Me.Size
End Sub
Private Sub tmrTimer1_Tick(sender As Object, e As System.EventArgs)
Handles tmrTimer1.Tick
'update the date/time display in the status strip
tslDateTime.Text = Date.Now
End Sub
Private Sub mnuHelpAboutToolStripMenuItem_Click(sender As Object, e As
System.EventArgs) Handles mnuHelpAboutToolStripMenuItem.Click
'display the About form as Modal
frmAbout.ShowDialog()
End Sub
Private Sub mnuFormatFontColorToolStripMenuItem_Click(sender As
Object, e As System.EventArgs) Handles
mnuFormatFontColorToolStripMenuItem.Click
'call the color dialog box and set the font colour
dlgColorDialog1.ShowDialog()
txtDocument.ForeColor = dlgColorDialog1.Color
End Sub
Private Sub mnuFormatFontStyleToolStripMenuItem_Click(sender As
Object, e As System.EventArgs) Handles
mnuFormatFontStyleToolStripMenuItem.Click
'call the font style dialog box and set the font style
dlgFontDialog1.ShowDialog()
txtDocument.Font = dlgFontDialog1.Font
End Sub
Private Sub mnuFileSaveToolStripMenuItem1_Click(sender As Object, e As
System.EventArgs) Handles mnuFileSaveToolStripMenuItem1.Click
Dim newWindow As New frmWindow
'if an open file save it with the same name
'otherwise get the filename and then save the file
If newWindow.dlgSaveFileDialog1 .ShowDialog() =
System.Windows.Forms.DialogResult.OK then
newWindow.txtDocument.LoadFile(newWindow.dlgSaveFileDialog1.FileName)
newWindow.FileName = newWindow.dlgSaveFileDialog1.FileName
'Name the new window Title Bar
newWindow.Text = newWindow.fileName
Else
MessageBox.Show("No File Was Saved, User Likely Clicked Cancel Or
Closed The Dialog.")
End If
End Sub
Private Sub mnuEditSelectAllToolStripMenuItem_Click(sender As Object,
e As System.EventArgs) Handles mnuEditSelectAllToolStripMenuItem.Click
'mark all text in the document as selected
txtDocument.SelectAll()
End Sub
Private Sub mnuFileSaveAsToolStripMenuItem_Click(sender As Object, e
As System.EventArgs) Handles mnuFileSaveAsToolStripMenuItem.Click
'get the filename using the save dialog box then save the
file
dlgSaveDialog1.ShowDialog()
txtDocument.SaveFile(dlgSaveDialog1.FileName)
fileName = dlgSaveDialog1.filename
'change the titlebar to the new file name
Me.Text = fileName
End Sub
Private Sub mnuEditCutToolStripMenuItem_Click(sender As Object, e As
System.EventArgs) Handles mnuEditCutToolStripMenuItem.Click
'cut the selected text to the clipboard
txtDocument.Cut()
End Sub
Private Sub mnuEditCopyToolStripMenuItem_Click(sender As Object, e As
System.EventArgs) Handles mnuEditCopyToolStripMenuItem.Click
'copy the selected text to the clipboard
txtDocument.Copy()
End Sub
Private Sub mnuEditPasteToolStripMenuItem_Click(sender As Object, e As
System.EventArgs) Handles mnuEditPasteToolStripMenuItem.Click
'if the clipboard contains text paste this into the document
If Clipboard.ContainsText(TextDataFormat.Rtf) then
txtDocument.paste()
End If
End Sub
Private Sub pdPrinter_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles pdPrinter.PrintPage
'set the print color via the graphics brush
Dim PrintColor As New SolidBrush(FontColor)
'print the document (textbox contents)
e.Graphics.DrawString(txtDocument.Text, New Font(FontFamily, FontSize, _
FontStyle),
PrintColor, RectangleF.op_Implicit(e.PageBounds))
End Sub
Private Sub mnuFilePrintToolStripMenuItem_Click(sender As Object, e As
System.EventArgs) Handles mnuFilePrintToolStripMenuItem.Click
'set the printer dialog box controls
dlgPrintDialog1.AllowSomePages = True
dlgPrintDialog1.Document = pdPrinter
dlgPrintDialog1.PrinterSettings = pdPrinter.PrinterSettings
'display the dialog box
request = dlgPrintDialog1.ShowDialog
'print if user clicked "Print"
If (request = Windows.Forms.DialogResult.OK) then
pdPrinter.Print()
End If
End Sub
Private Sub mnuPrintPreviewToolStripMenuItem_Click(sender As Object, e
As System.EventArgs) Handles mnuPrintPreviewToolStripMenuItem.Click
'point the preview to the document to be printed
dlgPrintDialog1.Document = pdPrinter
'preview the printed document
dlgPrintPreviewDialog1.ShowDialog()
End Sub
End Class