📄 ftestapp.frm
字号:
' Just show built-in dialog for local open...
oFramer.ShowDialog dsoDialogOpen
If Err.Number Then
MsgBox "Unable to open document." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
End If
End Sub
Private Sub mnuFileWebOpen_Click()
Dim sFile As String, sProgId As String
Dim fReadOnly As Boolean
Dim oWeb As FWebOpen
On Error Resume Next
' If they are opening from a web, ask for URL and if we should open read-write...
Set oWeb = New FWebOpen
oWeb.Show vbModal, Me
sFile = oWeb.URL
sProgId = oWeb.ProgID
fReadOnly = Not oWeb.OpenWriteAccess
Unload oWeb
' If they gave a URL, try to open it (with custom progid if given)...
If Len(sFile) Then
oFramer.Open sFile, fReadOnly, sProgId
End If
If Err.Number Then
MsgBox "Unable to open document." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
End If
End Sub
Private Sub mnuFileClose_Click()
On Error Resume Next
oFramer.Close
End Sub
Private Sub mnuFileQuit_Click()
mnuFileClose_Click
Unload Me
End Sub
Private Sub mnuFileSave_Click()
On Error Resume Next
oFramer.Save
If Err.Number Then
MsgBox "Unable to save document." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
End If
End Sub
Private Sub mnuFileSaveAs_Click()
Dim vbPrompt As VbMsgBoxResult
On Error Resume Next
' Just show built-in dialog for local save...
oFramer.ShowDialog dsoDialogSave
If Err.Number Then
MsgBox "Unable to save document." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
Else
' If we saved the file, get the (new) doc path for display...
lbCurrentFile.Caption = "Current File: " & oFramer.DocumentFullName
End If
End Sub
Private Sub mnuFileSaveCopyAs_Click()
On Error Resume Next
oFramer.ShowDialog dsoDialogSaveCopy
If Err.Number Then
MsgBox "Unable to save copy of document." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
End If
End Sub
Private Sub mnuFileSaveWeb_Click()
Dim sFile As String
Dim vbPrompt As VbMsgBoxResult
On Error Resume Next
' If they are opening from a web, ask for URL and if we should open read-write...
sFile = InputBox("Type the full URL to the location to save to (e.g., http://server/folder/mydoc.doc):", "Save to URL", "http://")
If (Len(sFile) > 10) Then
vbPrompt = MsgBox("If the file exists, do you want to overwrite it?", vbQuestion Or vbYesNo, "Overwrite?")
oFramer.Save sFile, (vbPrompt = vbYes)
End If
If Err.Number Then
MsgBox "Unable to save document." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
Else
' If we saved the file, get the (new) doc path for display...
lbCurrentFile.Caption = "Current File: " & oFramer.DocumentFullName
End If
End Sub
Private Sub mnuFilePageSetup_Click()
On Error Resume Next
oFramer.ShowDialog dsoDialogPageSetup
If Err.Number Then
MsgBox "Unable to show page setup." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
End If
End Sub
Private Sub mnuFilePrintPreview_Click()
On Error Resume Next
oFramer.PrintPreview
If Err.Number Then
MsgBox "Unable to go into print preview." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
Else
EnableItems False
End If
End Sub
Private Sub mnuFilePrint_Click(Index As Integer)
On Error Resume Next
Dim oPrintSettings As FPrinterSettings
Dim sPrinter As String
Dim iCopies As Integer
Dim fPrompt As Boolean
Dim vOutput, vFrom, vTo
' We will display custom print dialog for "Print to Target"...
If (Index = 2) Then
Set oPrintSettings = New FPrinterSettings
oPrintSettings.Show vbModal, Me
' Get the specific printer user wants to print to...
sPrinter = oPrintSettings.PrinterName
iCopies = oPrintSettings.Copies
fPrompt = oPrintSettings.DisplayPrintDialog
If oPrintSettings.PrintToFile Then
vOutput = oPrintSettings.OutputFile
End If
If oPrintSettings.PrintPages Then
vFrom = oPrintSettings.FromPage
vTo = oPrintSettings.ToPage
End If
Unload oPrintSettings
Set oPrintSettings = Nothing
' Now print it (unless no printer name returned, which indicates cancel)...
If (Len(sPrinter) And (iCopies > 0)) Then
oFramer.PrintOutEx fPrompt, sPrinter, iCopies, vFrom, vTo, vOutput
End If
Else
fPrompt = (Index > 0)
oFramer.PrintOut fPrompt
End If
If Err.Number Then
MsgBox "Unable to print document." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
End If
End Sub
Private Sub mnuFileProperties_Click()
On Error Resume Next
oFramer.ShowDialog dsoDialogProperties
If Err.Number Then
MsgBox "Unable to show properties page." & vbCrLf & _
"(" & Str(Err.Number) & "): " & Err.Description, _
vbCritical, "Error"
Err.Clear
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Show Menu Items
'
Private Sub mnuShowCaption_Click()
On Error Resume Next
oFramer.Titlebar = Not mnuShowCaption.Checked
mnuShowCaption.Checked = oFramer.Titlebar
End Sub
Private Sub mnuShowMenubar_Click()
On Error Resume Next
oFramer.Menubar = Not mnuShowMenubar.Checked
mnuShowMenubar.Checked = oFramer.Menubar
End Sub
Private Sub mnuShowToolbar_Click()
On Error Resume Next
oFramer.Toolbars = Not mnuShowToolbar.Checked
mnuShowToolbar.Checked = oFramer.Toolbars
End Sub
Private Sub mnuBorderStyle_Click(Index As Integer)
Dim i As Long, j As Long
On Error Resume Next
oFramer.BorderStyle = Index
j = oFramer.BorderStyle
For i = 0 To 3
mnuBorderStyle(i).Checked = False
If (i = j) Then mnuBorderStyle(i).Checked = True
Next
End Sub
Private Sub mnuDisableItem_Click(Index As Integer)
On Error Resume Next
oFramer.EnableFileCommand(Index) = mnuDisableItem(Index).Checked
mnuDisableItem(Index).Checked = Not oFramer.EnableFileCommand(Index)
End Sub
Private Sub mnuCustomCaption_Click()
Dim sCustomCaption As String
sCustomCaption = InputBox("Provide a custom caption for the framer titlebar:", "Caption")
If (Len(sCustomCaption)) Then
oFramer.Caption = sCustomCaption
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Framer Control Events
'
Private Sub oFramer_BeforeDocumentClosed(ByVal Document As Object, Cancel As Boolean)
Dim vbPrompt As VbMsgBoxResult
'oFramer.ExecOleCommand &H7003, False 'UnLock
'oFramer.ExecOleCommand &H7003, True 'Lock
On Error Resume Next
' If file is dirty, ask user if they want to save before close...
If oFramer.IsDirty Then
vbPrompt = MsgBox("Would you like to save the file before closing it?", vbQuestion Or vbYesNoCancel, "Save Changes?")
If vbPrompt = vbCancel Then
Cancel = True
ElseIf vbPrompt = vbYes Then
' If file is read-only or new/unsaved file...
If oFramer.IsReadOnly Or _
Len(oFramer.DocumentFullName) = 0 Then
' Show SaveAs dialog...
oFramer.ShowDialog dsoDialogSave
Else ' Else save with no dialog...
oFramer.Save
End If
End If
End If
End Sub
Private Sub oFramer_OnFileCommand(ByVal Item As DSOFramer.dsoFileCommandType, Cancel As Boolean)
' Here is where you can override Framer Control File menu items. We
' will override the Open and SaveAs to prompt user if they want to save to
' web as well as get new document name on successful SaveAs...
If Item = dsoFileOpen Then
mnuFileOpen_Click ' We'll do our own Open routine...
Cancel = True ' Cancel default since we handled it
ElseIf Item = dsoFileSaveAs Then
mnuFileSaveAs_Click ' We'll do our own SaveAs routine...
Cancel = True ' Cancel default since we handled it
End If
End Sub
Private Sub oFramer_OnDocumentOpened(ByVal File As String, ByVal Document As Object)
' When item is added/opened, enable items on form...
EnableItems True
If Len(File) Then
lbCurrentFile.Caption = "Current File: " & File
Else
lbCurrentFile.Caption = "Current File: Unsaved Document"
End If
End Sub
Private Sub oFramer_OnDocumentClosed()
' When item is closed, disable some items on form...
EnableItems False
lbCurrentFile.Caption = "Current File: [None]"
End Sub
Private Sub oFramer_OnPrintPreviewExit()
' Re-enable menu items after preview.
EnableItems True
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' EnableItems
'
Private Sub EnableItems(fEnable As Boolean)
mnuFileClose.Enabled = fEnable
mnuFileSave.Enabled = fEnable
mnuFileSaveAs.Enabled = fEnable
mnuFileSaveCopyAs.Enabled = fEnable
mnuFileSaveWeb.Enabled = fEnable
mnuFilePageSetup.Enabled = fEnable
mnuFilePrintPreview.Enabled = fEnable
mnuFilePrint(0).Enabled = fEnable
mnuFilePrint(1).Enabled = fEnable
mnuFilePrint(2).Enabled = fEnable
mnuFileProperties.Enabled = fEnable
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -