home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / olympus / ik32_15t / vb4.shr / CUTPASTE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-07-22  |  10.6 KB  |  343 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Clipboard Copy & Paste"
  5.    ClientHeight    =   4575
  6.    ClientLeft      =   1140
  7.    ClientTop       =   2010
  8.    ClientWidth     =   8775
  9.    Height          =   5265
  10.    Left            =   1080
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   4575
  16.    ScaleWidth      =   8775
  17.    Top             =   1380
  18.    Width           =   8895
  19.    Begin VB.Frame Frame5 
  20.       Caption         =   "PicBuf Destination Selection"
  21.       Height          =   555
  22.       Left            =   5865
  23.       TabIndex        =   15
  24.       Top             =   3960
  25.       Width           =   2775
  26.       Begin VB.OptionButton optSelectiondest 
  27.          Caption         =   "Selection"
  28.          Height          =   255
  29.          Left            =   1440
  30.          TabIndex        =   0
  31.          Top             =   240
  32.          Width           =   1215
  33.       End
  34.       Begin VB.OptionButton optSelectAlldest 
  35.          Caption         =   "All"
  36.          Height          =   255
  37.          Left            =   120
  38.          TabIndex        =   1
  39.          Top             =   240
  40.          Value           =   -1  'True
  41.          Width           =   1215
  42.       End
  43.    End
  44.    Begin VB.Frame Frame4 
  45.       Caption         =   "PicBuf Source Selection"
  46.       Height          =   555
  47.       Left            =   3000
  48.       TabIndex        =   12
  49.       Top             =   3960
  50.       Width           =   2775
  51.       Begin VB.OptionButton optSelectAllsrc 
  52.          Caption         =   "All"
  53.          Height          =   255
  54.          Left            =   120
  55.          TabIndex        =   14
  56.          Top             =   240
  57.          Value           =   -1  'True
  58.          Width           =   1215
  59.       End
  60.       Begin VB.OptionButton optSelectionsrc 
  61.          Caption         =   "Selection"
  62.          Height          =   255
  63.          Left            =   1440
  64.          TabIndex        =   13
  65.          Top             =   240
  66.          Width           =   1215
  67.       End
  68.    End
  69.    Begin VB.Frame Frame3 
  70.       Caption         =   "PicBuf Destination"
  71.       Height          =   990
  72.       Left            =   5850
  73.       TabIndex        =   9
  74.       Top             =   2880
  75.       Width           =   2775
  76.       Begin VB.CommandButton cmdPicBufdestPaste 
  77.          Caption         =   "Paste from clipboard"
  78.          Height          =   555
  79.          Left            =   1440
  80.          TabIndex        =   11
  81.          Top             =   240
  82.          Width           =   1215
  83.       End
  84.       Begin VB.CommandButton cmdPicBufdestCopy 
  85.          Caption         =   "Copy to clipboard"
  86.          Height          =   555
  87.          Left            =   120
  88.          TabIndex        =   10
  89.          Top             =   240
  90.          Width           =   1215
  91.       End
  92.    End
  93.    Begin VB.Frame Frame2 
  94.       Caption         =   "PicBuf Source"
  95.       Height          =   990
  96.       Left            =   3000
  97.       TabIndex        =   5
  98.       Top             =   2880
  99.       Width           =   2775
  100.       Begin VB.CommandButton cmdPicBufsrcCopy 
  101.          Caption         =   "Copy to clipboard"
  102.          Height          =   555
  103.          Left            =   120
  104.          TabIndex        =   7
  105.          Top             =   240
  106.          Width           =   1215
  107.       End
  108.       Begin VB.CommandButton cmdPicBufsrcPaste 
  109.          Caption         =   "Paste from clipboard"
  110.          Height          =   555
  111.          Left            =   1440
  112.          TabIndex        =   6
  113.          Top             =   240
  114.          Width           =   1215
  115.       End
  116.    End
  117.    Begin VB.Frame Frame1 
  118.       Caption         =   "Picture Box"
  119.       Height          =   975
  120.       Left            =   120
  121.       TabIndex        =   2
  122.       Top             =   2880
  123.       Width           =   2775
  124.       Begin VB.CommandButton cmdPicCopy 
  125.          Caption         =   "Copy to clipboard"
  126.          Height          =   540
  127.          Left            =   120
  128.          TabIndex        =   4
  129.          Top             =   240
  130.          Width           =   1215
  131.       End
  132.       Begin VB.CommandButton cmdPicPaste 
  133.          Caption         =   "Paste from clipboard"
  134.          Height          =   540
  135.          Left            =   1440
  136.          TabIndex        =   3
  137.          Top             =   240
  138.          Width           =   1215
  139.       End
  140.    End
  141.    Begin VB.PictureBox Picture1 
  142.       Height          =   2775
  143.       Left            =   120
  144.       ScaleHeight     =   2715
  145.       ScaleWidth      =   2715
  146.       TabIndex        =   8
  147.       Top             =   0
  148.       Width           =   2775
  149.    End
  150.    Begin ik32Lib.Picbuf PicbufDest 
  151.       Height          =   2775
  152.       Left            =   5880
  153.       TabIndex        =   17
  154.       Top             =   0
  155.       Width           =   2775
  156.       _Version        =   65536
  157.       _ExtentX        =   4895
  158.       _ExtentY        =   4895
  159.       _StockProps     =   253
  160.    End
  161.    Begin ik32Lib.Picbuf PicbufSrc 
  162.       Height          =   2775
  163.       Left            =   3000
  164.       TabIndex        =   16
  165.       Top             =   0
  166.       Width           =   2775
  167.       _Version        =   65536
  168.       _ExtentX        =   4895
  169.       _ExtentY        =   4895
  170.       _StockProps     =   253
  171.    End
  172.    Begin MSComDlg.CommonDialog CommonDialog1 
  173.       Left            =   120
  174.       Top             =   3960
  175.       _Version        =   65536
  176.       _ExtentX        =   847
  177.       _ExtentY        =   847
  178.       _StockProps     =   0
  179.    End
  180.    Begin VB.Menu ikFile 
  181.       Caption         =   "File"
  182.       Begin VB.Menu ikPictureBoxLoad 
  183.          Caption         =   "Load to Picture Box"
  184.       End
  185.       Begin VB.Menu ikPicBufLoadsrc 
  186.          Caption         =   "Load to PicBuf Source"
  187.       End
  188.       Begin VB.Menu ikPicBufLoaddest 
  189.          Caption         =   "Load to PicBuf Destination"
  190.       End
  191.       Begin VB.Menu ikExit 
  192.          Caption         =   "Exit"
  193.          Shortcut        =   ^X
  194.       End
  195.    End
  196.    Begin VB.Menu mnuReload 
  197.       Caption         =   "&Reload"
  198.    End
  199. Attribute VB_Name = "Form1"
  200. Attribute VB_Creatable = False
  201. Attribute VB_Exposed = False
  202. Option Explicit
  203. Dim strPicBoxFilename As String
  204. 'Description: This module determines which option
  205. 'button has been chosen, and then performs a copy,
  206. 'to the clipboard
  207. Private Sub cmdPicBufdestCopy_Click()
  208. On Error GoTo ImageError
  209.     Dim i As Integer
  210.     i = optSelectAlldest.Value
  211.     Picbufdest.CopyClipboard i
  212. Exit Sub
  213. ImageError:
  214. If Err = 20306 Then
  215.     MsgBox "To Copy an image to the clipboard, there must be an image loaded in the Picbuf control."
  216. End If
  217. End Sub
  218. 'Description: Here, the code decides which option
  219. 'button has been chosen, and then pastes to the
  220. 'clipboard accordingly
  221. Private Sub cmdPicBufdestPaste_Click()
  222.     Dim i As Integer
  223.     i = optSelectAlldest.Value
  224.     Picbufdest.PasteClipboard i
  225.     If optSelectionsrc.Value = True Then
  226.         Picbufsrc.Rect
  227.     End If
  228.     If optSelectiondest.Value = True Then
  229.         Picbufdest.Rect
  230.     End If
  231. End Sub
  232. 'Description: This module determines which option
  233. 'button has been chosen, and then performs a copy,
  234. 'to the clipboard
  235. Private Sub cmdPicBufsrcCopy_Click()
  236. On Error GoTo ImageError
  237.     Dim i As Integer
  238.     i = optSelectAllsrc.Value
  239.     Picbufsrc.CopyClipboard i
  240. Exit Sub
  241. ImageError:
  242. If Err = 20306 Then
  243.     MsgBox "To Copy an image to the clipboard, there must be an image loaded in the Picbuf control."
  244. End If
  245. End Sub
  246. 'Description: Here, the code decides which option
  247. 'button has been chosen, and then pastes to the
  248. 'clipboard accordingly
  249. Private Sub cmdPicBufsrcPaste_Click()
  250.     Dim i As Integer
  251.     i = optSelectAllsrc.Value
  252.     Picbufsrc.PasteClipboard i
  253.     If optSelectionsrc.Value = True Then
  254.         Picbufsrc.Rect
  255.     End If
  256.     If optSelectiondest.Value = True Then
  257.         Picbufdest.Rect
  258.     End If
  259. End Sub
  260. Private Sub cmdPicCopy_Click()
  261. Clipboard.SetData Picture1.Picture, vbCFDIB
  262. End Sub
  263. 'Description: Here, the code pastes to the picture
  264. 'control
  265. Private Sub cmdPicPaste_Click()
  266.     Picture1.Picture = Clipboard.GetData(vbCFDIB)
  267. End Sub
  268. 'Description: This code sets properties for the
  269. 'Picbuf control
  270. Private Sub Form_Load()
  271.     'Set PicBuf options
  272.     InitPicbuf Picbufsrc, True, "Marybeth.tif"
  273.     InitPicbuf Picbufdest, True, "winlogo1.bmp"
  274.     strPicBoxFilename = App.Path + "\..\images\bambi1.bmp"
  275.     Picture1.Picture = LoadPicture(strPicBoxFilename)
  276.     Picbufsrc.ForeColor = 255
  277.     Picbufdest.ForeColor = 255
  278.     SetSelect Picbufsrc, 0, 0, 100, 100
  279.     SetSelect Picbufdest, 0, 0, 100, 100
  280. End Sub
  281. 'Description: This module simply uses the end
  282. 'command the exit the program
  283. Private Sub ikExit_Click()
  284. IKOD_FileExit
  285. End Sub
  286. 'Description: When this menu option is chosen, a
  287. 'filename is determined using the Common Dialog
  288. 'Control. Then it is loaded into the Picbuf.
  289. Private Sub ikPicBufLoaddest_Click()
  290. Dim NameOfFile As String
  291. 'Call code to use common dialog
  292. Call IKOD_FileOpen(CommonDialog1, Picbufdest, 0, NameOfFile)
  293. If NameOfFile <> "" Then
  294.     'Use name from common dialog to load image
  295.     Picbufdest.Filename = NameOfFile
  296.     Picbufdest.Load
  297. End If
  298. End Sub
  299. 'Description: When this menu option is chosen, a
  300. 'filename is determined using the Common Dialog
  301. 'Control. Then it is loaded into the Picbuf.
  302. Private Sub ikPicBufLoadsrc_Click()
  303. Dim NameOfFile As String
  304. 'Call code to use common dialog
  305. Call IKOD_FileOpen(CommonDialog1, Picbufsrc, 0, NameOfFile)
  306. If NameOfFile <> "" Then
  307.     'Use name from common dialog to load image
  308.     Picbufsrc.Filename = NameOfFile
  309.     Picbufsrc.Load
  310. End If
  311. End Sub
  312. 'Description: Here, we use the Common Dialog Control
  313. 'to select an image file, and then load it with
  314. 'the Picture Control.
  315. Private Sub ikPictureBoxLoad_Click()
  316. CommonDialog1.Filter = "all files|*.*|BMP|*.bmp"
  317. CommonDialog1.FilterIndex = 2
  318. CommonDialog1.Action = 1
  319. If CommonDialog1.Filename <> "" Then
  320.     strPicBoxFilename = CommonDialog1.Filename
  321.     Picture1.Picture = LoadPicture(strPicBoxFilename)
  322. End If
  323. End Sub
  324. Private Sub mnuReload_Click()
  325.     Picture1.Picture = LoadPicture(strPicBoxFilename)
  326.     Picbufsrc.Load
  327.     Picbufdest.Load
  328.     optSelectAllsrc.Value = True
  329.     optSelectAlldest.Value = True
  330. End Sub
  331. Private Sub optSelectAlldest_Click()
  332. Picbufdest.Refresh
  333. End Sub
  334. Private Sub optSelectAllsrc_Click()
  335. Picbufsrc.Refresh
  336. End Sub
  337. Private Sub optSelectiondest_Click()
  338. Picbufdest.Rect 1
  339. End Sub
  340. Private Sub optSelectionsrc_Click()
  341. Picbufsrc.Rect 1
  342. End Sub
  343.