⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 用VB6开发的读写rtf文档的源码,支持插入表格,图片及多字体样式
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "cnRTFProvider测试程序"
   ClientHeight    =   1695
   ClientLeft      =   120
   ClientTop       =   420
   ClientWidth     =   5040
   LinkTopic       =   "Form1"
   ScaleHeight     =   1695
   ScaleWidth      =   5040
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "RTF输出示例"
      Height          =   375
      Left            =   225
      TabIndex        =   0
      Top             =   675
      Width           =   1365
   End
   Begin VB.Label Label1 
      Caption         =   $"Form1.frx":0000
      Height          =   1410
      Left            =   1755
      TabIndex        =   1
      Top             =   135
      Width           =   3075
   End
   Begin VB.Image Image1 
      Height          =   465
      Left            =   225
      Picture         =   "Form1.frx":00D4
      Top             =   90
      Width           =   1320
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'#########################################################################
'★★★★★         http://www.cnpopsoft.com [华普软件]         ★★★★★
'★★★★★             VB专业论文与源码荟萃                    ★★★★★
'#########################################################################

Option Explicit

Private Sub Command1_Click()
    Dim doc As New cnRTFProvider.cRTFDocument
    Dim i As Long

    '文本段示例
    doc.AddParagraph
    doc.LastParagraph.AddText vbCrLf & "文本段示例:" & vbCrLf
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.LastText.FontName = "黑体"
    doc.LastParagraph.LastText.FontSizeFixup = fs10_小四

    doc.AddParagraph , , 20, , 1.5, , 12
    doc.LastParagraph.AddText ("RTF技术扩展 - 如何实现完美的分页打印" & vbCrLf)
    doc.LastParagraph.LastText.FontName = "Trebuchet MS"
    doc.LastParagraph.LastText.FontSizeFixup = fs10_小四
    doc.LastParagraph.LastText.ForeColor = clr06_大红
    doc.LastParagraph.LastText.Bold = True
    
    doc.AddParagraph , , 20, , 1.5, , 9
    doc.LastParagraph.AddText ("摘要:")
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.AddText ("本文给出了一种完美实现RTF文件分页打印的方法,并根据此方法实现了RTF文件的打印预览及打印。" & _
        "通过本方法实现的RTF文件的WYSIWYG(所见即所得)显示、分页预览及分页打印三者在效果上完全一致,解决了以前预览与打印存在偏差的问题," & _
        "无论在分页速度和效果上均取得了突破。同时,本方法还解决了分页效果与打印机相关的问题,做到了完全的设备无关。效果图如下:")
    '插入图片
    doc.AddPicture App.Path & "\Demo.jpg", , , alm2_居中对齐
    
    doc.AddParagraph , , 20, , 1.5, , 9
    doc.LastParagraph.AddText ("关键字:")
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.AddText ("RTF、Rich Text Format、分页、打印。")
    
    '项目符号示例
    doc.AddParagraph
    doc.LastParagraph.AddText vbCrLf & "项目符号示例:" & vbCrLf
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.LastText.FontName = "黑体"
    doc.LastParagraph.LastText.FontSizeFixup = fs10_小四
    For i = 1 To 15
        doc.LastParagraph.AddText "项目符号示例" & i & vbCrLf
        doc.LastParagraph.LastText.ListType = i
    Next

    '表格示例
    doc.AddParagraph
    doc.LastParagraph.AddText vbCrLf & "表格示例:" & vbCrLf
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.LastText.FontName = "黑体"
    doc.LastParagraph.LastText.FontSizeFixup = fs10_小四
    doc.AddTable 6, 2, ral0_默认对齐
    doc.LastTable.AddRow
    doc.LastTable.LastRow.AddCell , , cct2_图片, MergeStart:=True
    Dim pic As New cRTFPicture
    pic.FileName = App.Path & "\LOGO.gif"
    doc.LastTable.LastCell.Data = pic
    doc.LastTable.LastCell.Alignment = alm2_居中对齐
    doc.LastTable.LastRow.AddCell Merge:=True
    doc.LastTable.AddRow
    doc.LastTable.LastRow.AddCell , , , , 1, clt2_百分比
    doc.LastTable.LastCell.Text = "hdc"
    doc.LastTable.LastCell.FontSizeFixup = fs12_小五
    doc.LastTable.LastCell.Bold = True
    doc.LastTable.LastRow.AddCell , , , , 4, clt2_百分比
    doc.LastTable.LastCell.Text = "渲染设备句柄。"
    doc.LastTable.AddRow
    doc.LastTable.LastRow.AddCell , , , , 1, clt2_百分比
    doc.LastTable.LastCell.Text = "hdcTarget"
    doc.LastTable.LastRow.AddCell , , , , 4, clt2_百分比
    doc.LastTable.LastCell.Text = "目标设备句柄。"
    doc.LastTable.AddRow
    doc.LastTable.LastRow.AddCell , , , , 1, clt2_百分比
    doc.LastTable.LastCell.Text = "rc"
    doc.LastTable.LastRow.AddCell , , , , 4, clt2_百分比
    doc.LastTable.LastCell.Text = "渲染区域,单位:缇。"
    doc.LastTable.AddRow
    doc.LastTable.LastRow.AddCell , , , , 1, clt2_百分比
    doc.LastTable.LastCell.Text = "rcPage"
    doc.LastTable.LastRow.AddCell , , , , 4, clt2_百分比
    doc.LastTable.LastCell.Text = "渲染设备的整体区域,单位:缇。"
    doc.LastTable.AddRow
    doc.LastTable.LastRow.AddCell , , , , 1, clt2_百分比
    doc.LastTable.LastCell.Text = "chrg"
    doc.LastTable.LastRow.AddCell , , cct1_段落, , 4, clt2_百分比
    Dim para As New cRTFParagraph
    para.AddText "CHARRANGE "
    para.LastText.ForeColor = clr02_蓝色
    para.AddText "结构体,表示用于格式化的文本范围。"
    doc.LastTable.LastCell.Data = para
    doc.LastTable.LastCell.NoWrap = True
    
    '下划线示例
    doc.AddParagraph
    doc.LastParagraph.AddText vbCrLf & "下划线示例:" & vbCrLf
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.LastText.FontName = "黑体"
    doc.LastParagraph.LastText.FontSizeFixup = fs10_小四
    For i = 1 To 17
        doc.LastParagraph.AddText "下划线示例" & i & vbCrLf
        doc.LastParagraph.LastText.UnderLineType = i
    Next

    '文本动画示例
    doc.AddParagraph
    doc.LastParagraph.AddText vbCrLf & "文本动画示例:" & vbCrLf
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.LastText.FontName = "黑体"
    doc.LastParagraph.LastText.FontSizeFixup = fs10_小四
    doc.LastParagraph.AddText "文本动画示例   七彩霓虹" & vbCrLf
    doc.LastParagraph.LastText.AnimType = ani1_七彩霓虹
    doc.LastParagraph.AddText "文本动画示例   闪烁背景" & vbCrLf
    doc.LastParagraph.LastText.AnimType = ani2_闪烁背景
    doc.LastParagraph.AddText "文本动画示例   礼花绽放" & vbCrLf
    doc.LastParagraph.LastText.AnimType = ani3_礼花绽放
    doc.LastParagraph.AddText "文本动画示例   乌龙纹柱" & vbCrLf
    doc.LastParagraph.LastText.AnimType = ani4_乌龙纹柱
    doc.LastParagraph.AddText "文本动画示例   赤水情深" & vbCrLf
    doc.LastParagraph.LastText.AnimType = ani5_赤水情深
    doc.LastParagraph.AddText "文本动画示例   亦真亦幻" & vbCrLf & vbCrLf
    doc.LastParagraph.LastText.AnimType = ani6_亦真亦幻
    
    '文本特效示例
    doc.AddParagraph
    doc.LastParagraph.AddText vbCrLf & "文本特效示例:" & vbCrLf
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.LastText.FontName = "黑体"
    doc.LastParagraph.LastText.FontSizeFixup = fs10_小四
    doc.LastParagraph.AddText "文本特效示例   字符阴影" & vbCrLf
    doc.LastParagraph.LastText.CharShadow = True
    doc.LastParagraph.AddText "文本特效示例   浮雕效果" & vbCrLf
    doc.LastParagraph.LastText.Embo = emb1_浮雕效果
    doc.LastParagraph.AddText "文本特效示例   雕刻效果" & vbCrLf
    doc.LastParagraph.LastText.Embo = emb2_雕刻效果
    doc.LastParagraph.AddText "文本特效示例   高亮显示" & vbCrLf
    doc.LastParagraph.LastText.Highlight = True
    doc.LastParagraph.LastText.HighlightColor = clr07_黄色
    doc.LastParagraph.AddText "文本特效示例   轮廓" & vbCrLf
    doc.LastParagraph.LastText.OutLine = True
    doc.LastParagraph.AddText "文本特效示例   阴影" & vbCrLf
    doc.LastParagraph.LastText.Shadow = True
    doc.LastParagraph.AddText "文本特效示例   删除线" & vbCrLf
    doc.LastParagraph.LastText.Strike = True
    doc.LastParagraph.AddText "文本特效示例   双删除线" & vbCrLf
    doc.LastParagraph.LastText.StrikeD = True
    
    '字体示例
    doc.AddParagraph
    doc.LastParagraph.AddText vbCrLf & "字体示例:" & vbCrLf
    doc.LastParagraph.LastText.Bold = True
    doc.LastParagraph.LastText.FontName = "黑体"
    doc.LastParagraph.LastText.FontSizeFixup = fs10_小四
    doc.AddParagraph
    For i = 5 To 30 Step 2
        doc.LastParagraph.AddText "字体示例 字体大小" & i & vbCrLf
        doc.LastParagraph.LastText.FontSize = i
    Next

    '设置页眉
    doc.PageHead = "cnRTFProvider Demo"
    doc.PageHeadAlign = alm1_左端对齐
    
    '设置页脚
    doc.PageFooter = "华普软件 - www.cnpopsoft.com"
    doc.PageFooterAlign = alm1_左端对齐
    
    '保存为文件
    doc.Save App.Path & "\Demo.rtf"
    MsgBox "已经成功输出到文件:" & App.Path & "\Demo.rtf"
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -