home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
- Begin VB.Form Form1
- ClientHeight = 7620
- ClientLeft = 60
- ClientTop = 330
- ClientWidth = 8010
- LinkTopic = "Form1"
- ScaleHeight = 7620
- ScaleWidth = 8010
- StartUpPosition = 3 'Windows Default
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 6600
- Top = 375
- _ExtentX = 847
- _ExtentY = 847
- _Version = 327680
- FontSize = 1.17491e-38
- End
- Begin VB.Frame Frame2
- Caption = "Copied Image"
- BeginProperty Font
- Name = "Trebuchet MS"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 3420
- Left = 120
- TabIndex = 3
- Top = 4050
- Width = 6135
- Begin VB.PictureBox Picture2
- Height = 2955
- Left = 150
- ScaleHeight = 2895
- ScaleWidth = 5790
- TabIndex = 4
- Top = 345
- Width = 5850
- End
- End
- Begin VB.CommandButton Command1
- Caption = "Copy Image"
- BeginProperty Font
- Name = "Trebuchet MS"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 615
- Left = 6435
- TabIndex = 1
- Top = 6810
- Width = 1455
- End
- Begin VB.Frame Frame1
- Caption = "Original Picture"
- BeginProperty Font
- Name = "Trebuchet MS"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 3435
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 6135
- Begin VB.PictureBox Picture1
- Height = 2940
- Left = 150
- ScaleHeight = 2880
- ScaleWidth = 5805
- TabIndex = 2
- Top = 360
- Width = 5865
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Const GMEM_MOVEABLE = &H2
- Const GMEM_ZEROINIT = &H40
- Const GENERIC_READ = &H80000000
- Const GENERIC_WRITE = &H40000000
- Const OPEN_EXISTING = 3
- Const FILE_ATTRIBUTE_NORMAL = &H80
- Const CREATE_NEW = 1
- Const CREATE_ALWAYS = 2
- Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal dest As Any, ByVal Src As Any, _
- ByVal length As Long)
-
- Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _
- ByVal dwBytes As Long) As Long
- Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
- Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
- Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
- Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
- (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, _
- ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Any, _
- ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, _
- ByVal hTemplateFile As Long) As Long
- Private Declare Function ReadFileLong Lib "kernel32" Alias "ReadFile" (ByVal hFile As Long, _
- lpBuffer As Long, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, _
- ByVal lpOverlapped As Any) As Long
- Private Declare Function WriteFileLong Lib "kernel32" Alias "WriteFile" (ByVal hFile As Long, _
- lpBuffer As Long, ByVal nNumberOfBytesToWrite As Long, _
- lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Any) As Long
- Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, _
- lpFileSizeHigh As Long) As Long
- Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
- Dim filePointer As Long
- Private Sub Command1_Click()
- Dim memHandle As Long
- Dim memPointer As Long
- Dim fileName As String
- Dim retValue As Long
- Dim nBytes As Long
- Dim fileSize As Long
- Dim origStr As String
- Dim strSize As Long
- Dim textStr As String
-
- On Error GoTo noFileName
- CommonDialog1.cancelerror = True
- CommonDialog1.showopen
- fileName = CommonDialog1.fileName
- Picture1.Picture = LoadPicture(fileName)
- filePointer = CreateFile(fileName, GENERIC_READ Or GENERIC_WRITE, 0&, 0&, OPEN_EXISTING, _
- FILE_ATTRIBUTE_NORMAL, 0&)
- fileSize = GetFileSize(filePointer, 0)
- memHandle = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, fileSize)
- memPointer = GlobalLock(memHandle)
- retValue = ReadFileLong(filePointer, ByVal memPointer, fileSize, nBytes, 0&)
- CloseHandle (filePointer)
- MsgBox "Image copied. Click on OK to save it on disk."
-
- 'New file
- CommonDialog1.showopen
- fileName = CommonDialog1.fileName
- filePointer = CreateFile(fileName, GENERIC_READ Or GENERIC_WRITE, 0&, 0&, CREATE_ALWAYS, _
- FILE_ATTRIBUTE_NORMAL, 0&)
- retValue = WriteFileLong(filePointer, ByVal memPointer, fileSize, nBytes, 0&)
- CloseHandle (filePointer)
- GlobalUnlock (memHandle)
- GlobalFree (memHandle)
- Picture2.Picture = LoadPicture(fileName)
- Exit Sub
- noFileName:
- End Sub
-