home *** CD-ROM | disk | FTP | other *** search
- Type PagingForm From SampleMasterForm
- Dim PagingControl1 As New PagingControl
- Dim TxtPageNumber As New TextBox
- Dim Label1 As New Label
- Dim ImgBitmapDisplay As New Image
- Dim BitmapSource As New Bitmap
- Dim BitmapList As New ListBox
- Dim CurrentPage As Integer
- Dim BtnReadMe As New Button
-
- ' METHODS for object: PagingForm
- Sub TxtPageNumber_KeyPress(keyAscii As Integer)
- Select Case keyAscii
- Case 48 To 57 ' Integers 0-9
- Case 8 ' Backspace
- Case Else
- keyAscii = 0
- End Select
- End Sub
-
- Sub ResetApplication_Click
- TxtPageNumber.Text = ""
- BitmapList.Clear
- BitmapSource.FileName = ""
- CurrentPage = 0
- ImgBitmapDisplay.Refresh
- TxtPageNumber.SetFocus
- End Sub
-
- Sub DragAndDrop(source As XferData, x As Single, y As Single, state As OleDropState, effect As OleDropEffect)
- If state == 4 Then
- Dim file_name, file_type As String
- file_name = source.FileName
- file_type = UCase(Right(file_name, 3))
- If file_type == "BMP" Then
- BitmapList.AddItem(file_name)
- BitmapSource.FileName = file_name
- ImgBitmapDisplay.Refresh
- CurrentPage = BitmapList.ListCount
- End If
- effect = 0
- End If
- End Sub
-
- Sub PagingControl1_ValidateNext()
- If Not FoundBitmaps Then Exit Sub
-
- Select Case CurrentPage
- Case BitmapList.ListCount ' Lastpage
- CurrentPage = 1
- Case Else
- CurrentPage = CurrentPage + 1
- End Select
-
- ' Routine to get the filename from the list and set the bitmap filename
- UpdateDisplay
- End Sub
-
- Sub UpdateDisplay
- dim file_name As String
- Dim list_entry As Integer
-
- ' Update the bitmap filename based on the filename in the list
- ' at the currentpage position. ListBox entries start with 0
- list_entry = CurrentPage - 1
- BitmapSource.FileName = BitmapList.List(list_entry)
- ImgBitmapDisplay.Refresh
- TxtPageNumber.Text = CurrentPage
- End Sub
-
- Sub PagingControl1_ValidateBack()
- If Not FoundBitmaps Then Exit Sub
-
- Select Case CurrentPage
- Case 1 ' Firstpage
- CurrentPage = BitmapList.ListCount
- Case Else
- CurrentPage = CurrentPage - 1
- End Select
-
- ' Routine to get the filename from the list and set the bitmap filename
- UpdateDisplay
- End Sub
-
- Sub PagingControl1_ValidateGoTo()
- Dim max_page, cur_page As Integer
-
- If Not FoundBitmaps Then Exit Sub
-
- If TxtPageNumber.Text == "" Then
- InfoBox.Message("", "No number found in Page Number box!")
- Exit Sub
- End If
-
- max_page = BitmapList.ListCount
- cur_page = Val(TxtPageNumber.Text)
-
- ' Need to validate the number that has been entered
- Select Case cur_page
- Case Is > max_page
- InfoBox.Message("", "The page number is greater than the last page number " & max_page & ".")
- Case Is <= 0
- InfoBox.Message("", "The page number can not be less than or equal to 0.")
- Case Else
- CurrentPage = cur_page
- UpdateDisplay
- End Select
-
- End Sub
-
- Function FoundBitmaps() As Boolean
- If BitmapList.ListCount == 0 Then
- InfoBox.Message("", "No pages to turn to.")
- FoundBitmaps = False
- Else
- FoundBitmaps = True
- End If
- End Function
-
- Sub Resize()
- With PagingControl1
- PagingControl1.Move(ScaleWidth - .Width, ScaleHeight - .Height, .Width, .Height)
- End With
- With ImgBitmapDisplay
- ImgBitmapDisplay.Move(.Left, .Top, ScaleWidth - (2 * .Left), ScaleHeight - (2 * .Top))
- End With
- BtnReadMe.Left = ScaleWidth - BtnReadMe.Width - ImgBitmapDisplay.Left
- Refresh
- End Sub
-
- Sub BtnReadMe_Click()
- Dim msg, cr As String
-
- cr = Chr(13) & Chr(10)
-
- msg = "Usage:"
- msg = msg & cr & "From the Windows FileManager, drop bitmap"
- msg = msg & cr & "files [.BMP] onto this form to add them to the"
- msg = msg & cr & "page display list."
- InfoBox.Message("", msg)
- End Sub
-
- End Type
-
- Type PagingControl From Form
- Dim BtnCancel As New Button
- Dim BtnBack As New Button
- Dim BtnNext As New Button
- Dim BtnGoTo As New Button
- Event ValidateNext()
- Event ValidateBack()
- Event ValidateCancel()
- Event ValidateGoTo()
-
- ' METHODS for object: PagingControl
- Sub BtnNext_Click()
- SendEvent ValidateNext
- End Sub
-
- Sub BtnCancel_Click()
- SendEvent ValidateCancel
- End Sub
-
- Sub BtnBack_Click()
- SendEvent ValidateBack
- End Sub
-
- Sub Resize()
- Dim width, height as Single
- Dim hMarg, vMarg as Single
-
- width = ScaleWidth / 4
- hMarg = width / 10
- width = width - hMarg
- vMarg = hMarg / 2
-
- height = BtnCancel.Height
- BtnCancel.Move(hMarg, vMarg, width, height)
- BtnBack.Move(width + 2 * hMarg, vMarg, width, height)
- BtnNext.Move(2 * width + 2 * hMarg, vMarg, width, height)
- BtnGoTo.Move(3 * width + 3 * hMarg, vMarg, width, height)
-
- Height = height + (Height - ScaleHeight) + 2 * vMarg
- End Sub
-
- Sub BtnGoTo_Click()
- SendEvent ValidateGoTo
- End Sub
-
- End Type
-
- Begin Code
- ' Reconstruction commands for object: PagingForm
- '
- With PagingForm
- .Caption := "Drag and Drop Example"
- .DragMode := "No Drag"
- .Move(4065, 1845, 5505, 6675)
- .FileDrop := True
- .CurrentPage := 0
- .SampleDir := "C:\envelop\bootcamp\concepts\hyper\"
- .SampleName := "hyper"
- With .PagingControl1
- .Caption := "PagingControl1"
- .Move(1185, 5580, 4200, 405)
- .Visible := True
- With .BtnCancel
- .Caption := "Cancel"
- .Move(105, 52, 945, 300)
- End With 'PagingForm.PagingControl1.BtnCancel
- With .BtnBack
- .Caption := "Back"
- .Move(1155, 52, 945, 300)
- End With 'PagingForm.PagingControl1.BtnBack
- With .BtnNext
- .Caption := "Next"
- .Move(2100, 52, 945, 300)
- End With 'PagingForm.PagingControl1.BtnNext
- With .BtnGoTo
- .Caption := "Go To"
- .Move(3150, 52, 945, 300)
- End With 'PagingForm.PagingControl1.BtnGoTo
- End With 'PagingForm.PagingControl1
- With .TxtPageNumber
- .Move(1950, 150, 795, 330)
- End With 'PagingForm.TxtPageNumber
- With .Label1
- .Caption := "Page Number:"
- .DragMode := "No Drag"
- .Move(300, 150, 1500, 300)
- End With 'PagingForm.Label1
- With .ImgBitmapDisplay
- .Caption := "ImgBitmapDisplay"
- .DragMode := "LeftMouse"
- .Move(300, 600, 4785, 4785)
- .Picture := PagingForm.BitmapSource
- End With 'PagingForm.ImgBitmapDisplay
- With .BitmapSource
- End With 'PagingForm.BitmapSource
- With .BitmapList
- .Move(0, 0, 30, 30)
- .Visible := False
- .Sorted := False
- End With 'PagingForm.BitmapList
- With .BtnReadMe
- .Caption := "ReadMe"
- .Move(4035, 150, 1050, 300)
- End With 'PagingForm.BtnReadMe
- With .helpfile
- .FileName := "C:\envelop\bootcamp\concepts\hyper\hyper.hlp"
- End With 'PagingForm.helpfile
- End With 'PagingForm
- ' Reconstruction commands for object: PagingControl
- '
- With PagingControl
- .Caption := "Page Turning Buttons"
- .Move(9795, 10260, 4515, 815)
- With .BtnCancel
- .Caption := "Cancel"
- .Move(109, 54, 988, 300)
- End With 'PagingControl.BtnCancel
- With .BtnBack
- .Caption := "Back"
- .Move(1208, 54, 988, 300)
- End With 'PagingControl.BtnBack
- With .BtnNext
- .Caption := "Next"
- .Move(2197, 54, 988, 300)
- End With 'PagingControl.BtnNext
- With .BtnGoTo
- .Caption := "Go To"
- .Move(3296, 54, 988, 300)
- End With 'PagingControl.BtnGoTo
- End With 'PagingControl
- End Code
-