I am re-doing part of a GUI for my project, The Windows Alias Generator, and decided to switch to MDI. The child forms consists only of RichTextBox1. Here's the generate routine called when the save is clicked:
But because I cannot define richtextbox1.text from the currently active MDI, I cannot use this routine...my question is this: How would I get RichTextBox1.text from the save option in the MDI form?
VB.NET:
Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveAsToolStripMenuItem.Click, SaveToolStripButton.Click
Dim ActiveMDI As Form = Me.ActiveMdiChild
Dim SaveFileDialog As New SaveFileDialog
SaveFileDialog.InitialDirectory = Environment.GetEnvironmentVariable("windir")
SaveFileDialog.Title = "type in an alias name"
SaveFileDialog.Filter = "Alias Files|*.bat"
If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = SaveFileDialog.FileName
awrite32(editor.RichTextBox1.Text, SaveFileDialog.FileName, SaveFileDialog.FileName)
End If
End Sub
End Sub
Sub awrite32(ByVal command As String, ByVal a_name As String, ByVal path As String)
If System.IO.File.Exists(path) Then
Dim result As MsgBoxResult = MsgBox("That alias already exists! Overwrite?", MsgBoxStyle.YesNo)
If result = MsgBoxResult.Yes Then
System.IO.File.Delete(path)
Dim oWrite As New System.IO.StreamWriter(path)
oWrite.WriteLine("@Echo Off")
oWrite.WriteLine("REM Generated by amake32")
oWrite.WriteLine(command)
oWrite.Close()
Dim result2 As MsgBoxResult = MsgBox("Alias " + a_name + " successfully applied. Try it out now?", MsgBoxStyle.YesNo)
If result2 = MsgBoxResult.Yes Then
System.Diagnostics.Process.Start("cmd")
Else
'nothing
End If
Else
MsgBox("Alias was not created because an existing file was found and was not overwritten!")
End If
Else
Dim uWrite As New System.IO.StreamWriter(path)
uWrite.WriteLine("@Echo Off")
uWrite.WriteLine("REM Generated by amake32")
uWrite.WriteLine(command)
uWrite.Close()
Dim result3 As MsgBoxResult = MsgBox("Alias " + a_name + " successfully applied. Try it out now?", MsgBoxStyle.YesNo)
If result3 = MsgBoxResult.Yes Then
System.Diagnostics.Process.Start("cmd")
Else
'nothing
End If
End If
End Sub
But because I cannot define richtextbox1.text from the currently active MDI, I cannot use this routine...my question is this: How would I get RichTextBox1.text from the save option in the MDI form?