home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 2 / WIN95_2.bin / utils / envelop / envelop.6 / Tools / Bootcamp / concepts / dragdrop / dragdrop.eto < prev    next >
Encoding:
Text File  |  1996-07-08  |  7.6 KB  |  276 lines

  1. Type PagingForm From SampleMasterForm
  2.   Dim PagingControl1 As New PagingControl
  3.   Dim TxtPageNumber As New TextBox
  4.   Dim Label1 As New Label
  5.   Dim ImgBitmapDisplay As New Image
  6.   Dim BitmapSource As New Bitmap
  7.   Dim BitmapList As New ListBox
  8.   Dim CurrentPage As Integer
  9.   Dim BtnReadMe As New Button
  10.  
  11.   ' METHODS for object: PagingForm
  12.   Sub TxtPageNumber_KeyPress(keyAscii As Integer)
  13.     Select Case keyAscii
  14.       Case 48 To 57 ' Integers 0-9
  15.       Case 8 ' Backspace
  16.       Case Else
  17.         keyAscii = 0
  18.     End Select
  19.   End Sub
  20.  
  21.   Sub ResetApplication_Click
  22.     TxtPageNumber.Text = ""
  23.     BitmapList.Clear
  24.     BitmapSource.FileName = ""
  25.     CurrentPage = 0
  26.     ImgBitmapDisplay.Refresh
  27.     TxtPageNumber.SetFocus
  28.   End Sub
  29.  
  30.   Sub DragAndDrop(source As XferData, x As Single, y As Single, state As OleDropState, effect As OleDropEffect)
  31.     If state == 4 Then 
  32.       Dim file_name, file_type As String
  33.       file_name = source.FileName
  34.       file_type = UCase(Right(file_name, 3))
  35.       If file_type == "BMP" Then 
  36.         BitmapList.AddItem(file_name)
  37.         BitmapSource.FileName = file_name
  38.         ImgBitmapDisplay.Refresh
  39.         CurrentPage = BitmapList.ListCount
  40.       End If
  41.       effect = 0
  42.     End If
  43.   End Sub
  44.  
  45.   Sub PagingControl1_ValidateNext()
  46.     If Not FoundBitmaps Then Exit Sub
  47.   
  48.     Select Case CurrentPage
  49.       Case BitmapList.ListCount ' Lastpage
  50.         CurrentPage = 1
  51.       Case Else
  52.         CurrentPage = CurrentPage + 1
  53.     End Select
  54.   
  55.     ' Routine to get the filename from the list and set the bitmap filename
  56.     UpdateDisplay
  57.   End Sub
  58.  
  59.   Sub UpdateDisplay
  60.     dim file_name As String
  61.     Dim list_entry As Integer
  62.   
  63.     ' Update the bitmap filename based on the filename in the list
  64.     ' at the currentpage position. ListBox entries start with 0
  65.     list_entry = CurrentPage - 1
  66.     BitmapSource.FileName = BitmapList.List(list_entry)
  67.     ImgBitmapDisplay.Refresh
  68.     TxtPageNumber.Text = CurrentPage
  69.   End Sub
  70.  
  71.   Sub PagingControl1_ValidateBack()
  72.     If Not FoundBitmaps Then Exit Sub
  73.   
  74.     Select Case CurrentPage
  75.       Case 1 ' Firstpage
  76.         CurrentPage = BitmapList.ListCount
  77.       Case Else
  78.         CurrentPage = CurrentPage - 1
  79.     End Select
  80.   
  81.     ' Routine to get the filename from the list and set the bitmap filename
  82.     UpdateDisplay
  83.   End Sub
  84.  
  85.   Sub PagingControl1_ValidateGoTo()
  86.     Dim max_page, cur_page As Integer
  87.   
  88.     If Not FoundBitmaps Then Exit Sub
  89.   
  90.     If TxtPageNumber.Text == "" Then 
  91.       InfoBox.Message("", "No number found in Page Number box!")
  92.       Exit Sub
  93.     End If
  94.   
  95.     max_page = BitmapList.ListCount
  96.     cur_page = Val(TxtPageNumber.Text)
  97.   
  98.     ' Need to validate the number that has been entered
  99.     Select Case cur_page
  100.       Case Is > max_page
  101.         InfoBox.Message("", "The page number is greater than the last page number " & max_page & ".")
  102.       Case Is <= 0
  103.         InfoBox.Message("", "The page number can not be less than or equal to 0.")
  104.       Case Else
  105.         CurrentPage = cur_page
  106.         UpdateDisplay
  107.     End Select
  108.   
  109.   End Sub
  110.  
  111.   Function FoundBitmaps() As Boolean
  112.     If BitmapList.ListCount == 0 Then 
  113.       InfoBox.Message("", "No pages to turn to.")
  114.       FoundBitmaps = False
  115.     Else 
  116.       FoundBitmaps = True
  117.     End If
  118.   End Function
  119.  
  120.   Sub Resize()
  121.     With PagingControl1
  122.       PagingControl1.Move(ScaleWidth - .Width, ScaleHeight - .Height, .Width, .Height)
  123.     End With
  124.     With ImgBitmapDisplay
  125.       ImgBitmapDisplay.Move(.Left, .Top, ScaleWidth - (2 * .Left), ScaleHeight - (2 * .Top))
  126.     End With
  127.     BtnReadMe.Left = ScaleWidth - BtnReadMe.Width - ImgBitmapDisplay.Left
  128.     Refresh
  129.   End Sub
  130.  
  131.   Sub BtnReadMe_Click()
  132.     Dim msg, cr As String
  133.   
  134.     cr = Chr(13) & Chr(10)
  135.   
  136.     msg = "Usage:"
  137.     msg = msg & cr & "From the Windows FileManager, drop bitmap"
  138.     msg = msg & cr & "files [.BMP] onto this form to add them to the"
  139.     msg = msg & cr & "page display list."
  140.     InfoBox.Message("", msg)
  141.   End Sub
  142.  
  143. End Type
  144.  
  145. Type PagingControl From Form
  146.   Dim BtnCancel As New Button
  147.   Dim BtnBack As New Button
  148.   Dim BtnNext As New Button
  149.   Dim BtnGoTo As New Button
  150.   Event ValidateNext()
  151.   Event ValidateBack()
  152.   Event ValidateCancel()
  153.   Event ValidateGoTo()
  154.  
  155.   ' METHODS for object: PagingControl
  156.   Sub BtnNext_Click()
  157.     SendEvent ValidateNext
  158.   End Sub
  159.  
  160.   Sub BtnCancel_Click()
  161.     SendEvent ValidateCancel
  162.   End Sub
  163.  
  164.   Sub BtnBack_Click()
  165.     SendEvent ValidateBack
  166.   End Sub
  167.  
  168.   Sub Resize()
  169.     Dim width, height as Single
  170.     Dim hMarg, vMarg as Single
  171.   
  172.     width = ScaleWidth / 4
  173.     hMarg = width / 10
  174.     width = width - hMarg
  175.     vMarg = hMarg / 2
  176.   
  177.     height = BtnCancel.Height
  178.     BtnCancel.Move(hMarg, vMarg, width, height)
  179.     BtnBack.Move(width + 2 * hMarg, vMarg, width, height)
  180.     BtnNext.Move(2 * width + 2 * hMarg, vMarg, width, height)
  181.     BtnGoTo.Move(3 * width + 3 * hMarg, vMarg, width, height)
  182.   
  183.     Height = height + (Height - ScaleHeight) + 2 * vMarg
  184.   End Sub
  185.  
  186.   Sub BtnGoTo_Click()
  187.     SendEvent ValidateGoTo
  188.   End Sub
  189.  
  190. End Type
  191.  
  192. Begin Code
  193. ' Reconstruction commands for object: PagingForm
  194. '
  195.   With PagingForm
  196.     .Caption := "Drag and Drop Example"
  197.     .DragMode := "No Drag"
  198.     .Move(4065, 1845, 5505, 6675)
  199.     .FileDrop := True
  200.     .CurrentPage := 0
  201.     .SampleDir := "C:\envelop\bootcamp\concepts\hyper\"
  202.     .SampleName := "hyper"
  203.     With .PagingControl1
  204.       .Caption := "PagingControl1"
  205.       .Move(1185, 5580, 4200, 405)
  206.       .Visible := True
  207.       With .BtnCancel
  208.         .Caption := "Cancel"
  209.         .Move(105, 52, 945, 300)
  210.       End With  'PagingForm.PagingControl1.BtnCancel
  211.       With .BtnBack
  212.         .Caption := "Back"
  213.         .Move(1155, 52, 945, 300)
  214.       End With  'PagingForm.PagingControl1.BtnBack
  215.       With .BtnNext
  216.         .Caption := "Next"
  217.         .Move(2100, 52, 945, 300)
  218.       End With  'PagingForm.PagingControl1.BtnNext
  219.       With .BtnGoTo
  220.         .Caption := "Go To"
  221.         .Move(3150, 52, 945, 300)
  222.       End With  'PagingForm.PagingControl1.BtnGoTo
  223.     End With  'PagingForm.PagingControl1
  224.     With .TxtPageNumber
  225.       .Move(1950, 150, 795, 330)
  226.     End With  'PagingForm.TxtPageNumber
  227.     With .Label1
  228.       .Caption := "Page Number:"
  229.       .DragMode := "No Drag"
  230.       .Move(300, 150, 1500, 300)
  231.     End With  'PagingForm.Label1
  232.     With .ImgBitmapDisplay
  233.       .Caption := "ImgBitmapDisplay"
  234.       .DragMode := "LeftMouse"
  235.       .Move(300, 600, 4785, 4785)
  236.       .Picture := PagingForm.BitmapSource
  237.     End With  'PagingForm.ImgBitmapDisplay
  238.     With .BitmapSource
  239.     End With  'PagingForm.BitmapSource
  240.     With .BitmapList
  241.       .Move(0, 0, 30, 30)
  242.       .Visible := False
  243.       .Sorted := False
  244.     End With  'PagingForm.BitmapList
  245.     With .BtnReadMe
  246.       .Caption := "ReadMe"
  247.       .Move(4035, 150, 1050, 300)
  248.     End With  'PagingForm.BtnReadMe
  249.     With .helpfile
  250.       .FileName := "C:\envelop\bootcamp\concepts\hyper\hyper.hlp"
  251.     End With  'PagingForm.helpfile
  252.   End With  'PagingForm
  253. ' Reconstruction commands for object: PagingControl
  254. '
  255.   With PagingControl
  256.     .Caption := "Page Turning Buttons"
  257.     .Move(9795, 10260, 4515, 815)
  258.     With .BtnCancel
  259.       .Caption := "Cancel"
  260.       .Move(109, 54, 988, 300)
  261.     End With  'PagingControl.BtnCancel
  262.     With .BtnBack
  263.       .Caption := "Back"
  264.       .Move(1208, 54, 988, 300)
  265.     End With  'PagingControl.BtnBack
  266.     With .BtnNext
  267.       .Caption := "Next"
  268.       .Move(2197, 54, 988, 300)
  269.     End With  'PagingControl.BtnNext
  270.     With .BtnGoTo
  271.       .Caption := "Go To"
  272.       .Move(3296, 54, 988, 300)
  273.     End With  'PagingControl.BtnGoTo
  274.   End With  'PagingControl
  275. End Code
  276.