*/
Looking for work? Check out our jobs area.
*/

View \FORM1.FRM

Splitting/restoring large files in VB4

Submitted By: Unknown
Rating: (Not rated) (Rate It)


VERSION 4.00
Begin VB.Form Form1
   Caption         =   "Example how to copy a file with API32-calls"
   ClientHeight    =   2565
   ClientLeft      =   2310
   ClientTop       =   2835
   ClientWidth     =   6630
   Height          =   2970
   Left            =   2250
   LinkTopic       =   "Form1"
   ScaleHeight     =   171
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   442
   Top             =   2490
   Width           =   6750
   Begin VB.PictureBox Picture1
      Height          =   495
      Left            =   240
      Picture         =   "Form1.frx":0000
      ScaleHeight     =   435
      ScaleWidth      =   855
      TabIndex        =   10
      Top             =   1860
      Visible         =   0   'False
      Width           =   915
   End
   Begin VB.CommandButton Command4
      Cancel          =   -1  'True
      Caption         =   "&Exit"
      Height          =   345
      Left            =   4980
      TabIndex        =   9
      Top             =   2100
      Width           =   1455
   End
   Begin VB.CommandButton Command1
      Caption         =   "?"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   6060
      TabIndex        =   8
      Top             =   360
      Width           =   375
   End
   Begin VB.CommandButton Command2
      Caption         =   "?"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
         Name            =   "Arial"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   6060
      TabIndex        =   7
      Top             =   840
      Width           =   375
   End
   Begin VB.CommandButton Command3
      Caption         =   "&Copy file"
      Height          =   345
      Left            =   3420
      TabIndex        =   6
      Top             =   2100
      Width           =   1455
   End
   Begin VB.TextBox Text3
      Height          =   315
      Left            =   1260
      TabIndex        =   5
      Top             =   1320
      Width           =   1335
   End
   Begin VB.TextBox Text2
      Height          =   315
      Left            =   1260
      TabIndex        =   4
      Top             =   840
      Width           =   4755
   End
   Begin VB.TextBox Text1
      Height          =   345
      Left            =   1260
      TabIndex        =   3
      Top             =   360
      Width           =   4755
   End
   Begin VB.Label Label3
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "Result:"
      Height          =   255
      Left            =   180
      TabIndex        =   2
      Top             =   1380
      Width           =   990
   End
   Begin VB.Label Label2
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "Copy to:"
      Height          =   255
      Left            =   180
      TabIndex        =   1
      Top             =   900
      Width           =   990
   End
   Begin VB.Label Label1
      Alignment       =   1  'Right Justify
      BackStyle       =   0  'Transparent
      Caption         =   "Copy from:"
      Height          =   255
      Left            =   180
      TabIndex        =   0
      Top             =   420
      Width           =   990
   End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False

Private Sub Command1_Click()
   
    Dim OpenFile As OPENFILENAME
    Dim lReturn As Long
    Dim sFilter As String
   
    OpenFile.lStructSize = Len(OpenFile)
    OpenFile.hwndOwner = Form1.hWnd
    OpenFile.hInstance = App.hInstance
    sFilter = "All Files (*.*)" & Chr(0)
    OpenFile.lpstrFilter = sFilter
    OpenFile.nFilterIndex = 1
    OpenFile.lpstrFile = String(257, 0)
    OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
    OpenFile.lpstrFileTitle = OpenFile.lpstrFile
    OpenFile.nMaxFileTitle = OpenFile.nMaxFile
    OpenFile.lpstrInitialDir = App.Path
    OpenFile.lpstrTitle = "Copy file from..."
    OpenFile.flags = 0
    lReturn = GetOpenFileName(OpenFile)
       
    If lReturn = 0 Then
        MsgBox "The User pressed the Cancel Button"
    Else
        Text1.Text = Trim(OpenFile.lpstrFile)
    End If
   
End Sub

Private Sub Command2_Click()
   
    Dim OpenFile As OPENFILENAME
    Dim lReturn As Long
    Dim sFilter As String
   
   
    OpenFile.lStructSize = Len(OpenFile)
    OpenFile.hwndOwner = Form1.hWnd
    OpenFile.hInstance = App.hInstance
    sFilter = "All Files (*.*)" & Chr(0)
    OpenFile.lpstrFilter = sFilter
    OpenFile.nFilterIndex = 1
    OpenFile.lpstrFile = Text1.Text & String(257 - Len(Text1.Text), 0)
    OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
    OpenFile.lpstrFileTitle = OpenFile.lpstrFile
    OpenFile.nMaxFileTitle = OpenFile.nMaxFile
    OpenFile.lpstrInitialDir = App.Path
    OpenFile.lpstrTitle = "Copy file to..."
    OpenFile.flags = 0
    lReturn = GetOpenFileName(OpenFile)
       
    If lReturn = 0 Then
        MsgBox "The User pressed the Cancel Button"
    Else
        Text2.Text = Trim(OpenFile.lpstrFile)
    End If
   
End Sub



Private Sub Command3_Click()

    Text3.Text = ""
   
    If Text1.Text = Text2.Text Then
        MsgBox "Warning! Same Source and Destination!"
    Else
        Text3.Text = APICopyFile(Text1.Text, Text2.Text)
    End If
   
End Sub

Private Sub Command4_Click()

    MsgBox "Did You know, how I must modify the copy-routine" _
            & vbCrLf & "to split files and save them in more" _
            & vbCrLf & "then one part - contact me under:" _
            & vbCrLf & vbCrLf & "Matthias Z?llner" _
            & vbCrLf & "Compuserve: 100427,3544 " _
            & vbCrLf & vbCrLf & "Thank you very much!"
   
    End
   
End Sub


Private Sub Form_Click()
    'End
End Sub

Private Sub Form_Paint()
    '// Filling the form with the bitmap
    Call TileBitmap(Me, Picture1)
End Sub
Public Function TileBitmap(ByVal theForm As Form, ByVal theBitmap As PictureBox)
    Dim iAcross As Integer
    Dim iDown As Integer
    theBitmap.AutoSize = True
    For iDown = 0 To (theForm.Width  theBitmap.Width) + 1
        For iAcross = 0 To (theForm.Height  theBitmap.Height) + 1
            theForm.PaintPicture theBitmap.Picture, iDown * theBitmap.Width, iAcross * theBitmap.Height, theBitmap.Width, theBitmap.Height
    Next iAcross, iDown
End Function

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.