C
Carl
Hi there guys
I'm currently developing a word processor, based around a rich text box
and a common dialog control, using visual basic 6, and have come across
a couple of problems, I would be very grateful if anyone could help
out.
Firstly the word processor uses both command button and drop down menus
As part of the project each of the buttons/menu options has to be
enabled/disabled appropriately. Is there a more modular way of
enabling/disabling buttons/menu selections, as i'm currently writing
huge amounts of code for each button/menu selection state. For
example:
Private Sub Form_Load()
Call LoadButtons
End Sub
Private Sub LoadButtons()
cmdPaste.Enabled = False
cmdSave.Enabled = False
cmdCut.Enabled = False
cmdCopy.Enabled = False
cmdClearClip.Enabled = False
cmdFont.Enabled = False
cmdExit.Enabled = True
cmdOpen.Enabled = True
cmdNew.Enabled = True
End Sub
There are another five sets of these button state routines, all of
which need to be called at various times.
Secondly, using the common dialog control I have run into an error when
trying to save. The documents are only saved in the format requested
(either txt or rtf) if I manually add the .txt or .rtf at the end of
the file name in the save window. If I dont enter the file extentions
the files are saved as "File" ie the icon with a window inside. Below
is the code used to save documents:
Private Sub Save()
On Error GoTo SaveError
With cdlDialog
.CancelError = True
.Filter = "Text Files (*.txt)|*.txt|Rich Text Files (*.rtf)|*.rtf"
.FilterIndex = 2
.ShowSave
End With
If cdlDialog.FilterIndex = 1 And _
FontChange = True Then
MsgBox "Will result in a loss of format", vbInformation
End If
rtbInput.SaveFile cdlDialog.FileName
MsgBox "File saved as " & cdlDialog.FileName
SaveChange = False
Exit Sub
SaveError:
Dim intRetVal As Integer
intRetVal = MsgBox("The file has not been saved. Try again",
vbRetryCancel + vbQuestion)
If intRetVal = vbRetry Then
Resume
Else
cmdExit.SetFocus
End If
End Sub
Thanks again for any help
I'm currently developing a word processor, based around a rich text box
and a common dialog control, using visual basic 6, and have come across
a couple of problems, I would be very grateful if anyone could help
out.
Firstly the word processor uses both command button and drop down menus
As part of the project each of the buttons/menu options has to be
enabled/disabled appropriately. Is there a more modular way of
enabling/disabling buttons/menu selections, as i'm currently writing
huge amounts of code for each button/menu selection state. For
example:
Private Sub Form_Load()
Call LoadButtons
End Sub
Private Sub LoadButtons()
cmdPaste.Enabled = False
cmdSave.Enabled = False
cmdCut.Enabled = False
cmdCopy.Enabled = False
cmdClearClip.Enabled = False
cmdFont.Enabled = False
cmdExit.Enabled = True
cmdOpen.Enabled = True
cmdNew.Enabled = True
End Sub
There are another five sets of these button state routines, all of
which need to be called at various times.
Secondly, using the common dialog control I have run into an error when
trying to save. The documents are only saved in the format requested
(either txt or rtf) if I manually add the .txt or .rtf at the end of
the file name in the save window. If I dont enter the file extentions
the files are saved as "File" ie the icon with a window inside. Below
is the code used to save documents:
Private Sub Save()
On Error GoTo SaveError
With cdlDialog
.CancelError = True
.Filter = "Text Files (*.txt)|*.txt|Rich Text Files (*.rtf)|*.rtf"
.FilterIndex = 2
.ShowSave
End With
If cdlDialog.FilterIndex = 1 And _
FontChange = True Then
MsgBox "Will result in a loss of format", vbInformation
End If
rtbInput.SaveFile cdlDialog.FileName
MsgBox "File saved as " & cdlDialog.FileName
SaveChange = False
Exit Sub
SaveError:
Dim intRetVal As Integer
intRetVal = MsgBox("The file has not been saved. Try again",
vbRetryCancel + vbQuestion)
If intRetVal = vbRetry Then
Resume
Else
cmdExit.SetFocus
End If
End Sub
Thanks again for any help