您的位置:首页 > 其它

用资源文件做捆绑工具(控件加入资源文件)

2009-11-16 21:09 281 查看
 

-------------------------------------------------- 在窗体中---------------------------------------------------------------------

'*************************************************************************
'**模 块 名:显示农历 - Form1
'**说    明:魔灵圣域 2008 - 2009(C) by 郭卫(icecept)
'**创 建 人:郭卫(icecept)
'**日    期:2008-12-31 12:12:14
'**修 改 人:郭卫
'**日    期:2008-12-31 12:12:14
'**描    述: http://hi.baidu.com/icecept  http://hi.csdn.net/icecet
'**版    本:V1.0.12                             QQ:543375508
'*************************************************************************
Option Explicit

Private Sub CnCalendar1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
        MsgBox "mouseup"
    End If
End Sub

Private Sub Command1_Click()
    MsgBox ("选定日期属相: " + CnCalendar1.GetChineseAnimal(CnCalendar1.Value))
End Sub

Private Sub Command2_Click()
    MsgBox ("选定日期农历年: " + CnCalendar1.GetChineseYear(CnCalendar1.Value))
End Sub

Private Sub Command3_Click()
    MsgBox ("选定日期农历月: " + CnCalendar1.GetChineseMonth(CnCalendar1.Value))
End Sub

Private Sub Command4_Click()
    MsgBox ("选定日期农历日: " + CnCalendar1.GetChineseDay(CnCalendar1.Value))
End Sub

Private Sub Command5_Click()
    MsgBox ("选定日期农历日期: " + CnCalendar1.GetChineseDate(CnCalendar1.Value))
End Sub

Private Sub Command6_Click()
    MsgBox ("选定日期: " + CStr(CnCalendar1.Value))
End Sub

Private Sub Command7_Click()
    MsgBox CnCalendar1.GetConstellation(CnCalendar1.Value)
End Sub

Private Sub Form_Load()
    If App.PrevInstance Then
        MsgBox "该程序已经运行!"
        End
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Unload Form2
End Sub

Private Sub mnuabout_Click()
    Dim about As String
    about = "作者:郭卫,昵称:魔灵。喜欢用Visual Basic编程序的平面设计师,从中学时代就酷爱编程,"
    about = about & "从Gwbasic到Visual Basic,创作了不少的作品。并且我还特别喜"
    about = about & "欢平面设计,熟练使用photoshop和coreldraw,并创作了不少的作品."
    about = about & "作品有记事薄(类似于写字板)、华容道(20局的游戏)、企业商品"
    about = about & "管理、程序自动保存、整点报时等一批软件,"
    about = about & "如果大家对我的程序感兴趣,请与我联系." & vbCrLf & "QQ:543375508"
    about = about & vbCrLf & "E-mail:icecept@163.com"
    about = about & vbCrLf & "魔灵圣域之情感世界 http://icecept.blog.sohu.com"
    MsgBox about, vbOKOnly Or vbInformation, "作者信息"
End Sub

Private Sub yongfa_Click()
    Form2.Show vbModal
End Sub

-------------------------------------------------- 在模块中---------------------------------------------------------------------

Option Explicit
'延时
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub main()
    If Dir(CheckFilePath(App.Path) & "CnCalendar.ocx") = vbNullString Then
        Call ResShiFang(CheckFilePath(App.Path) & "CnCalendar.ocx")
        Sleep 1000
        Shell "regsvr32 " & CheckFilePath(App.Path) & "CnCalendar.ocx /s", vbNormalFocus '注册控件,无弹出对话框
    End If
    Form1.Show
End Sub

Private Sub ResShiFang(vDataFileName As String)
    Dim DataFile() As Byte
    DataFile = LoadResData(101, "CUSTOM") '从资源文件读入文件内容
    Open vDataFileName For Binary As #1 '建立数据文件,以二进制方式打开
    Put #1, , DataFile
    Close #1    '写完后关闭文件
End Sub

Function CheckFilePath(Path As String) As String
    '检查档位文件是否在根目录下
    If Right(Path, 1) <> "/" Then
        CheckFilePath = Path & "/"
    Else
        CheckFilePath = Path
    End If
End Function


附件: 控件加入资源文件.rar

永远的魔灵<icecept> by 郭卫
http://icecept.jimdo.com
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐