home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / movetext / movtxt.frm (.txt) next >
Visual Basic Form  |  1991-07-08  |  11KB  |  235 lines

  1. Form1
  2. DragDrop Demonstration Program
  3. Form1
  4. Picture4
  5. Picture4
  6. Picture1
  7. Picture1
  8. Text1
  9. Text1
  10. Text1
  11. Picture2
  12. Picture2
  13. Text2
  14. Text2
  15. Text2
  16. Picture3
  17. Picture3
  18. Text3
  19. Text3
  20. Text3
  21. Command1
  22. This Button Does Nothing
  23. Label1
  24. NUse The Grey Box At The Left Of The Text Control To DragDrop The Text Control.
  25. Form_Clicku
  26. MouseX
  27. Picture1_Click
  28. Picture1_MouseDown
  29. Button|
  30. Shift
  31. MouseYI
  32. Picture1
  33. Widthv
  34. Text1
  35. Form_DragDrop
  36. Source
  37. TextOffset
  38. Text2_Change#
  39. Text2_DragOverk
  40. State
  41. MousePointer@
  42. Text2_DragDropp
  43. DropIt
  44. WhichOne
  45. Action
  46. Text1_Change
  47. Picture1_DragOverO
  48. Picture2_Click
  49. Picture2_DragOver
  50. Picture1_DragDrop,
  51. Picture2_DragDrop
  52. Picture2_MouseDown<
  53. Picture2R
  54. Text2
  55. Picture2_MouseUp
  56. Text1_DragDropy
  57. Text1_DragOver
  58. Picture3
  59. Text3
  60. False
  61. Visible
  62. Label1_Click
  63.     SaveWidth
  64. Form_DragOver'
  65. Form_DragDrop1
  66. TextC
  67. Overlapp
  68. Cancel
  69. CheckIt
  70. Height
  71.     DestRight
  72. DestBot
  73. Form1c
  74. Picture4
  75. Picture4_Click
  76. Picture4_DragDrop
  77. XLeft
  78. XRight
  79. YLeft
  80. Check1
  81. Check2
  82. Picture3_Click
  83. Picture3_DragDrop
  84. Picture3_MouseDown
  85. Text3_Change
  86. Text3_DragDropF
  87. Command1
  88. Command1_ClickY
  89. Command1_DragDrop
  90. Label1_DragDrop
  91. Label1
  92. @    Form_Load
  93. CurrentX
  94. CurrentY
  95.  DRAGDROP DEMONSTRATION PROGRAMO
  96.  Keith Funk (CIS ID 72240, 2020)
  97.  Rev. 1.0 July, 1991
  98.  This program demonstrates a way to use a Picture Controll
  99.  to initiate what appears to be the dragging of a Text
  100.  Control. Some such method is required because Textr
  101.  Controls cannot in themselves be DragDropped since they
  102.  don't have a MouseDown Event associated with them..
  103.  In addition, it shows some code that prevents a control
  104.  from being dropped on top of another control. T
  105.  The program works like this. The user press the mouse
  106.  over a picture box (say Picture1). Picture1_MouseDown
  107.  saves the current cursor location then expands the widthh
  108.  of the picture so that it encompasses the text box to
  109.  its right (the one the user wants to drag). When he e
  110.  begins dragging, it *looks* like he is actually dragging
  111.  the text box. MouseDown also initiates dragging.d
  112.  Every control -and- the form can react to a Drop Event.
  113.  If a control detects a DragDrop, it converts the cursor
  114.  X/Y co-ords (which are relative to the top, left of the
  115.  control) so that they are relative to the top, left off
  116.  the form and then Calls the Form's DragDrop Event..
  117.  The form's DragDrop Event calls the Overlap function to
  118.  to check if any part of the dragged control covers anyy
  119.  part of another control. It then Calls the Sub DropIt
  120.  and either tells it to cancel the drag because of ann
  121.  overlap or to move the picture control and its associated
  122.  text control to the new location if there is no overlap..
  123.  There is one exception to a control not being allowed too
  124.  overlap another control. The user is allowed to dragg
  125.  a control and drop it on top of itself. This lets him
  126.  make small adjustments to the controls position.s
  127.  Sub DropIt resets the picture control's width back to its
  128.  original width and then either exits if the drag is m
  129.  cancelled or uses the Move command to move the picturer
  130.  box and text box to the new location.
  131.  A note about the Const TextOffset. The picture controls
  132.  used for dragging where created with a width of 200
  133.  twips. Their associated text controls were placed soo
  134.  that they overlap the picture controls by 20 twips.
  135.  Thus, the offset is 180 twips. This was done so thatt
  136.  only a single vertical line separates the two controls.
  137.  The large picture control, the label control and thee
  138.  command button are included simply to demonstrate the
  139.  code that prevents overlapping controls..
  140. ==> Location of Mouse Pointer at start of drag drop.
  141.  Values are relative to the top, left corner
  142.  of the control on which the mouse was pressed.o
  143. ==> Distance between the left edge of a pictured
  144.  control and the left edge of its associated
  145.  text control.
  146. Picture1_MouseDown
  147. ==> Save the current location of the cursor.
  148. ==> Expand the picture control to encompass itss
  149.  associated text control, so it looks to
  150.  the user like he is dragging the text control.o
  151. ==> Initiate dragging.
  152. Text2_DragDrop
  153. DropIt
  154. This routine is called by Form1_DragDrop. It shrinks the
  155. picture control back to its original width. If the
  156. requested Action is "OK" then it Moves the picture control
  157. and its associated text control to the new loaction.
  158. If the Action is "Cancel", the Move is not performed..
  159. Picture1&
  160. Cancel
  161. ==> Put the top, left corner of theh
  162.  control in the same position relative
  163.  to the cursor as it was before the move.s
  164. Picture2&
  165. Cancel
  166. Picture3&
  167. Cancel
  168. Picture1_DragDrop
  169. Picture2_DragDrop
  170. Picture2_MouseDown
  171. Text1_DragDrop
  172. Form_DragDrop
  173. The DragDrop Procs for *all* controls call this routine.
  174. Before doing so, these Procs convert their Mouse X/Y
  175. co-ords so that they are relative to the top, left
  176. corner of the *form*.a
  177. This routine calls the Overlap function for each control
  178. on the form to see if the control being moved overlaps
  179. the control. If it does, the DragDrop is cancelled. AA
  180. special case is the text controls that can be DragDropped.
  181. They can be dropped on themselves.
  182. This routine then calls the routine DropIt which performss
  183. the Move..
  184. Cancel
  185. Cancel
  186. Cancel
  187. Cancel
  188. Cancel
  189. Cancel
  190. ==> Don't check for overlap if the Source controlh
  191.  is the picture control associated with thet
  192.  destination text control. That is, let thee
  193.  user DragDrop a control on itself. 
  194. Picture1
  195. Cancel
  196. Picture2
  197. Cancel
  198. Picture3
  199. Cancel
  200. Overlap
  201. This function checks if any part of the Source control
  202. (the one being DragDropped) overlaps any part of another
  203. control. If it does, then the function returns True.
  204. Otherwise it returns False..
  205. ==> Allow a picture to be dropped on itself.
  206. ==> Top left and top right of the Source control.-
  207. ==> Check if the top edge of source intersects the
  208.  left edge of dest.e
  209. => top left of Source.
  210. - Check if the top,left corner of the source isu
  211.  inside the dest.h
  212. - Check if the bottom edge of source intersectse
  213.  the left edge of dest.o
  214. - Check if the bottom,left corner of the sourcet
  215.  is inside the dest.
  216. ==> This routine determine if two lines interest.e
  217. ==> This routine checks if a point is inside a rectangle.
  218. Picture4_DragDrop
  219. Cancel#
  220. Picture3_DragDrop
  221. Picture3_MouseDown
  222. Text3_DragDrop
  223. Command1_DragDrop
  224. Label1_DragDrop
  225. ==> X + Label1.Left and Y + Label1.Top are used to
  226.  convert the cursor location from being relative
  227.  to the control's top, left corner to being 
  228.  relative to the form's top, left corner because
  229.  that's the X/Y that the Move command (see DropItD
  230.  Sub) requires. 
  231. Form_Load
  232. ==> Let the user know what the square at the top, 
  233.  right of the form is.
  234. Picture Control"u
  235.