home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / PGUIDE / OLECONT / OLECONT.BAS < prev    next >
Encoding:
BASIC Source File  |  1997-01-30  |  4.2 KB  |  134 lines

  1. Attribute VB_Name = "ModOLECont"
  2. Option Explicit
  3.  
  4. Public MDINew As Integer
  5.  
  6. Sub NewObject()
  7.     MDINew = True
  8.     NewOleForm
  9.     If ParentForm.ActiveForm.OLE1.OLEType = vbOLENone Then
  10.         Unload ParentForm.ActiveForm
  11.     End If
  12. End Sub
  13.  
  14. Sub DisplayInstructions()
  15.     ' ╔∙├≈╛╓▓┐▒Σ┴┐
  16.     Dim MsgText
  17.     Dim PB
  18.     ' │⌡╩╝╗»╢╬┬Σ▒Ω╝╟▒Σ┴┐
  19.     PB = Chr(10) & Chr(13) & Chr(10) & Chr(13)
  20.     ' ╧╘╩╛╓╕╡╝
  21.     MsgText = "╥¬▓σ╚δ╥╗╕÷╨┬╢╘╧≤ú¼┤╙í░╬─╝■í▒▓╦╡Ñ╓╨╤í╘±í░╨┬╜¿í▒├ⁿ┴εú¼▓ó┤╙í░▓σ╚δ╢╘╧≤í▒╢╘╗░┐≥╓╨╤í╘±╥╗╕÷╢╘╧≤íú"
  22.     MsgText = MsgText & PB & "╥╗╡⌐─·╙├í░┴φ┤µ╬¬í▒├ⁿ┴ε▒ú┤µ┴╦╥╗╕÷╥╤▓σ╚δ╡─╢╘╧≤ú¼─·┐╔╥╘╦µ║≤╩╣╙├í░╬─╝■í▒▓╦╡Ñ╓╨╡─í░┤≥┐¬í▒├ⁿ┴ε▓Θ┐┤╢╘╧≤íú"
  23.     MsgText = MsgText & PB & "╥¬▒α╝¡╢╘╧≤ú¼╘≥╦½╗≈╕├╢╘╧≤ú¼┐╔╧╘╩╛│÷┤┤╜¿╢╘╧≤╡─╙ª╙├│╠╨≥╡─▒α╝¡╗╖╛│íú"
  24.     MsgText = MsgText & PB & "╙├╩≤▒Ω╙╥╝ⁿ╡Ñ╗≈╢╘╧≤ú¼┐╔╥╘╧╘╩╛╕├╢╘╧≤╡─╬╜┤╩íú"
  25.     MsgText = MsgText & PB & "╩╣╙├í░╕┤╓╞í▒íóí░╔╛│²í▒║═í░╤í╘±╨╘╒│╠∙í▒├ⁿ┴ε└┤╕┤╓╞íó╔╛│²║═╒│╠∙╢╘╧≤íú"
  26.     MsgText = MsgText & PB & "╤í╘±í░╕ⁿ╨┬í▒├ⁿ┴ε└┤╕ⁿ╨┬┐╔▓σ╚δ╢╘╧≤╡──┌╚▌íú"
  27.     MsgBox MsgText, 64, "OLE ╚▌╞≈┐╪╝■╤▌╩╛╓╕╡╝"
  28. End Sub
  29.  
  30. Sub NewOleForm()
  31.     Dim Newform As New ChildForm
  32.     Newform.Show
  33.     ' ╚τ╣√╙├╗º┤╙í░╬─╝■í▒▓╦╡Ñ╤í╘±í░╨┬╜¿í▒├ⁿ┴εú¼╓╗╧╘╩╛í░▓σ╚δ╢╘╧≤í▒╢╘╗░┐≥
  34.     If MDINew Then
  35.         ParentForm.ActiveForm.OLE1.InsertObjDlg
  36.     End If
  37.     
  38.     UpdateCaption
  39. End Sub
  40.  
  41. Sub OpenObject()
  42.     MDINew = False
  43.     NewOleForm
  44.     OpenSave ("Open")
  45.     If ParentForm.ActiveForm.OLE1.OLEType = vbOLENone Then
  46.         Unload ParentForm.ActiveForm
  47.     End If
  48. End Sub
  49.  
  50. ' ┤≥┐¬╨┬╬─╝■╜½╓╗╙δ░ⁿ║¼╙╨╨º OLE Automation ╢╘╧≤╡─╬─╝■╥╗╞≡╣ñ╫≈íú
  51. ' ╥¬┐┤╒Γ╕÷╣ñ╫≈ú¼╘┌╙ª╙├│╠╨≥╘╦╨╨╩▒░┤╧┬┴╨╣²│╠╜°╨╨
  52. ' 1) ┤╙í░╬─╝■í▒▓╦╡Ñú¼╤í╘±í░╨┬╜¿í▒▓ó╓╕╢¿╥╗╕÷╢╘╧≤
  53. ' 2) ▒α╝¡╢╘╧≤▓ó┤╙í░╬─╝■í▒▓╦╡Ñ╓╨╤í╘±í░┴φ┤µ╬¬í▒
  54. ' 3) ╡Ñ╗≈╢╘╧≤╡─í░▓╦╡Ñ┐╪╓╞í▒┐≥╣╪▒╒╦ⁿ
  55. ' 4) ┤╙í░╬─╝■í▒▓╦╡Ñú¼╤í╘±í░┤≥┐¬í▒▓ó╤í╘±╕╒╕╒▒ú┤µ╡─╬─╝■
  56. Sub OpenSave(Action As String)
  57.     Dim Filenum
  58.     Filenum = FreeFile
  59.     ' ╔Φ╓├╣½╣▓╢╘╗░┐≥╡─╤í╧ε║═╣²┬╦╞≈
  60.     ParentForm.ActiveForm.CommonDialog1.Filter = _
  61.       "┐╔▓σ╚δ╢╘╧≤ (*.OLE)|*.OLE|╦∙╙╨╬─╝■ (*.*)|*.*"
  62.     ParentForm.ActiveForm.CommonDialog1.FilterIndex = 1
  63.   
  64.     ParentForm.ActiveForm.OLE1.FileNumber = Filenum
  65.  
  66. On Error Resume Next
  67.  
  68.     Select Case Action
  69.         Case "Save"
  70.             ' ╧╘╩╛í░┴φ┤µ╬¬í▒╢╘╗░┐≥
  71.             ParentForm.ActiveForm.CommonDialog1.ShowSave
  72.             If Err Then
  73.                 ' ╤í╘±í░╚í╧√í▒
  74.                 If Err = 32755 Then
  75.                     Exit Sub
  76.                 Else
  77.                     MsgBox "╩╣╙├í░┴φ┤µ╬¬í▒╢╘╗░┐≥╩▒│÷╧╓╬┤╓¬╡─┤φ╬≤íú"
  78.                 End If
  79.             End If
  80.             ' ┤≥┐¬▓ó▒ú┤µ╬─╝■
  81.             Open ParentForm.ActiveForm.CommonDialog1.filename For Binary As Filenum
  82.             If Err Then
  83.                 MsgBox (Error)
  84.                     Exit Sub
  85.             End If
  86.                 ParentForm.ActiveForm.OLE1.SaveToFile Filenum
  87.             If Err Then MsgBox (Error)
  88.  
  89.         Case "Open"
  90.             ' ╧╘╩╛í░┤≥┐¬╬─╝■í▒╢╘╗░┐≥
  91.             ParentForm.ActiveForm.CommonDialog1.ShowOpen
  92.             If Err Then
  93.                 ' ╤í╘±í░╚í╧√í▒
  94.                 If Err = 32755 Then
  95.                     Exit Sub
  96.                 Else
  97.                     MsgBox "╩╣╙├í░┤≥┐¬╬─╝■í▒╢╘╗░┐≥╩▒│÷╧╓╬┤╓¬╡─┤φ╬≤íú"
  98.                 End If
  99.             End If
  100.             ' ┤≥┐¬╬─╝■
  101.             Open ParentForm.ActiveForm.CommonDialog1.filename For Binary As Filenum
  102.             If Err Then
  103.                 Exit Sub
  104.             End If
  105.             ' ╧╘╩╛╔│┬⌐╣Γ▒Ω
  106.             Screen.MousePointer = 11
  107.             ParentForm.ActiveForm.OLE1.ReadFromFile Filenum
  108.             If (Err) Then
  109.                 If Err = 30015 Then
  110.                     MsgBox "╢╘╧≤╬▐╨º"
  111.                 Else
  112.                     MsgBox Error$
  113.                 End If
  114.                 Unload ParentForm.ActiveForm
  115.             End If
  116.             ' ╚τ╣√┤≥┐¬╩▒╬┤╖ó╔·┤φ╬≤ú¼╘≥╝ñ╗ε╢╘╧≤
  117.             ParentForm.ActiveForm.OLE1.DoVerb -1
  118.  
  119.         ' ╔Φ╓├┤░╠σ╩⌠╨╘ú¼OLE ╚▌╞≈┐╪╝■╡▒╟░░ⁿ║¼╥╗╕÷╢╘╧≤
  120.         UpdateCaption
  121.         ' ╗╓╕┤╣Γ▒Ω
  122.         Screen.MousePointer = 0
  123.     End Select
  124.   
  125.     Close Filenum
  126. End Sub
  127.  
  128. Sub UpdateCaption()
  129.     ' ╔Φ╓├┤░╠σ╩⌠╨╘ú¼╡▒╟░░ⁿ║¼╥╗╕÷╢╘╧≤
  130.     ParentForm.ActiveForm.Caption = ParentForm.ActiveForm.OLE1.Class + " ╢╘╧≤"
  131.     On Error Resume Next
  132. End Sub
  133.  
  134.