home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code2 / q_cards / form1.frm (.txt) < prev    next >
Visual Basic Form  |  1993-04-30  |  18KB  |  354 lines

  1. Form1
  2. QCard.DLL Demo
  3. Form1,
  4. Timer1
  5. Dra&wing
  6. DrawCard
  7.     Draw&Card
  8. DealCard
  9.     &DealCard
  10. DrawBack
  11.     Draw&Back
  12. DrawSymbol
  13. Draw&Symbol
  14. RemoveCard
  15. &RemoveCard
  16. MenuExit
  17. E&xit
  18. Information
  19. &Information
  20. CardInformation
  21. &CardInformation
  22. Dragging
  23.     &Dragging
  24. MenuDoDrag
  25. D&oDrag
  26. MenuHelp
  27. &Help
  28. m    MenuHowTo
  29. Ho&w To...
  30. n    MenuAbout
  31. A&bout
  32. Form_Click
  33. DealCard
  34. Form1
  35.     Form_Loadi
  36. InitializeDecke
  37. Form_MouseDown
  38. Buttons
  39. Shift
  40. View_Click
  41. DealCard_Click
  42. DrawBack_Click(
  43. DrawBack~
  44. MenuExit_Click
  45. DrawSymbol_Click
  46. DrawSymbol
  47. EraseCard_Click
  48. DrawCard&
  49. Timer1
  50. EnabledE
  51. TRUEr
  52. Timer1_TimerA
  53.     EraseCard
  54. FALSEC
  55.     CARDWIDTHu
  56. CARDHEIGHT
  57. DrawCard_Click
  58. RemoveCard
  59. RemoveCard_Click.
  60. CardInformation_ClickY
  61.     bDragging
  62. Form_MouseMove[
  63. Form_MouseUpq
  64. GetCardColorQ
  65. GetCardValue
  66. GetCardSuit
  67. GetCardX|
  68. GetCardY
  69. IsCardVisible
  70. Width2
  71. Height
  72.     ScaleMode
  73. ScaleTop
  74.     ScaleLeft
  75. Information_Click
  76. ScaleWidth
  77. ScaleHeight>
  78.     bDragDemo
  79. SPACER
  80. MenuDoDrag_Click
  81. AdjustCardBlocked
  82. ActiveCard
  83. PointInCard
  84. nActiveCardH
  85. SetActiveCard
  86. InitDrag
  87. DoDrag)
  88. EndDrag
  89. OldY5
  90. Dragging_Click
  91. ReturnDrag
  92. PointInFreeCard
  93. Screen#
  94. MousePointer.
  95. InitDeck
  96. Form_Paint
  97. SetCardDisabled,
  98. Picture1
  99. nReturn
  100. PointInCardTop~
  101. Form_DblClick
  102. nClickedCard
  103. GlobalXf
  104. GlobalY
  105. DblClkX[
  106.     DblClickX
  107.     DblClickY
  108. nSpacer
  109. OFFSET
  110. BlockCardsf
  111.     BlockDrag
  112. OffsetX
  113. OffsetY
  114. EndBlockDrag
  115. bSingleDraggingc
  116. bBlockDragging
  117. bBlockDrag
  118. SetDefaultValues
  119. ReturnBlockDragr
  120.     DragCardsN
  121. Form2
  122. upperbound!
  123. lowerbound
  124. Lefte
  125. fresh
  126. GetFreeDestination
  127. GetCardBlocked
  128. nEndDrag
  129. nTemp
  130.     AbortDrag
  131. nSourceCard
  132.     nDestCard9
  133.     CardArray
  134. Counter
  135. cxSpacer|
  136. SetUser3
  137. SetUser4
  138. nStatus
  139. nArrayID
  140.     nArrayPos
  141. nItems'
  142. GetUser4
  143. GetUser3+
  144. nNewXD
  145. nNewY
  146. nSourceArrayV
  147. nSourceArrayPosq
  148. nDestArray
  149. nSourceColor
  150. nDestColor
  151. o_Click
  152. nSourceArrayID
  153. nDestArrayID
  154. nDeltaX
  155. nDeltaY
  156. nSourceX|
  157. nSourceY
  158. nUnused
  159. SetCardBlocked
  160.     dlbClickY
  161.     DlbClickX
  162. nThisSourceCard
  163. nThisDestCard
  164. bMouseMoved7
  165. process
  166. clicks
  167. similarR
  168. MenuHowTo_Click
  169. Helpn
  170. MenuAbout_Click
  171. About
  172. AutoRedraw
  173. nDrawSelection
  174. SelectCase
  175. nInformationCard
  176. DoText
  177. nCard
  178. MenuHelp_Click
  179.  This program demonstrates some of the function callss
  180.  of QCard.DLL. In an effort to keep all code under
  181.  their respective Event Procedures, I have not usedd
  182.  any Sub procedures of my own. Using a few Sub proceduress
  183.  would considerably clean up the "spaghetti" nature of
  184.  some of the dragging events.t
  185.  This demo is not complete in that it does not repaint
  186.  it's window properly. I was more interested in demonsrating
  187.  function calls rather than creating a usable product.
  188.  declare a few counters 
  189.  declare some test switchesn
  190.  declare some card identifiers
  191.  to save mouse position for double click event
  192.  set up a two dimensional arrayy
  193.  four arrays to hold the numbers of thee
  194.  cards in each piled
  195.  set up a counter to go along with each pile
  196. Form_Load
  197.  try to fire up the DLLL
  198.  a FALSE return value indicates problems
  199. Sorry. Another application is using QCards.DLL
  200.  set ScaleMode to Pixel(3) so form and DLL use the
  201.  same coordinatess
  202.  make form full screen width
  203.  make some initial assigns
  204. DealCard_Click
  205.  deal cards in a diagonal line
  206. DrawBack_Click
  207.  draw six piles of cards offsetting by 2 pixels up and overr
  208. MenuExit_Click
  209. DrawSymbol_Click
  210.  draw in one of each of the three symbolss
  211. Timer1_Timer
  212.  remove cards one at a timee
  213.  don't forget to take them off in reverse orderr
  214.  or you will have a mess
  215. DrawCard_Click
  216.  draw the cards using DrawCard
  217.  this does not update any of the propertiess
  218.  of the cardst
  219. RemoveCard_Click
  220.  deal 13 cards and enable the timer sub which will remove them
  221. CardInformation_Click
  222.  pick a random cardi
  223.  pick a random locationt
  224. Int((upperbound - lowerbound + 1) * Rnd + lowerbound))
  225.  set current information card for Paint eventt
  226.  deal the card
  227.  draw in the text informationr
  228. MenuDoDrag_Click
  229.  clear out any old card properties
  230.  draw in symbols
  231.  each pile has it's own array identifying the cardss
  232.  each pile has a counter to maintain the pilee
  233.  each card uses it's User3 and User4 properties to
  234.  store which array it belongs to and what position
  235.  it's in within the array. This makes dragging and
  236.  dropping easier
  237.  deal first pile and set up array
  238.  card's position in array
  239.  array ID 
  240.  block all cards except the one on top
  241.  there are 13 cards per pile
  242.  card's position in array
  243.  array IDc
  244.  card's position in array
  245.  array IDc
  246.  card's position in array
  247.  array IDc
  248. Form_MouseDown
  249.  InitDrag returns the number of the card that contains the
  250.  mouse, as well as setting up the drag operation
  251.  save mouse x and y position for double click eventt
  252.  no card selecteds
  253.  save old position for later use
  254.  if the drag is invalidh
  255.  if card is not blocked, it is a single drag
  256.  if it's blocked, it means were doing a block drag
  257. Form_MouseMove
  258.  if just a single card, it's number was set with InitDrag call
  259.  determine which pile we are dealing withr
  260.  determine the position of the first card in dragn
  261.  how many cards are we movinge
  262.  create an array to hold the numbers of the cards to movee
  263.  and fill the array starting at 0e
  264.  put a temporary block on the last card being draggeda
  265.  pass the BlockDrag sub the actual array, referencing it's
  266.  first element. This acts as a "pointer" to the rest ofs
  267.  the elements in the array in memory
  268.  let the MouseUp event know that it is ok to
  269.  reference the Temp(0) array for this instance
  270. Form_MouseUp
  271.  most of the code here involves relocating cards
  272.  to their new homes/arrays
  273.  end the drag operation and
  274.  find out who we are dropping in on
  275.  do some color testing
  276.  only allow drop if source and destination colors are the same
  277.  and if nSourceCard is not the last card in it's pile.
  278.  if nDestCard is 0, the Source Card was dropped at an invalid location
  279.  if not a valid drop site, return drag
  280.  valid single drag/drop... proceed with relocation
  281.  which array did we come fromt
  282.  reduce our old array countert
  283.  which array are we joining
  284.  add another to it's counter
  285.  block our new neighbor
  286.  install our new arrayID and positiong
  287.  align with left side of card above us
  288.  and down OFFSET (16)o
  289.  unblock last card in old array
  290.  add ourselves to new arrayr
  291.  we can reuse the Temp() array from MouseMovee
  292.  as long as MouseMove actually occurredc
  293.  end the drag and find out the destination card
  294.  do some color testing
  295.  only allow drop if source and destination colors are the same
  296.  and nSourceCard is not the last card in it's pile
  297.  if not a valid drop site, return drag
  298.  remove temporary block on last card in block drag array
  299.  which array did we come from
  300.  reduce our old array counter
  301.  which array are we joining
  302.  block our new neighbor
  303.  this bit of code demonstrates how you can "fool" a drag operation
  304.  to drag the item to a specific location. Usually, you pass the 
  305.  BlockDrag sub the x,y location of the mouse. If you first determine
  306.  your current mouse position in relation to the object you are dragging 
  307.  you can add that difference (nDeltaX, nDeltaY) to the position youi
  308.  want to drag to, and pass those points to BlockDrag. We want to align
  309.  with the left side of DestCard and down OFFSET (16) pixels from its top
  310.  install our new arrayIDs and positionsn
  311.  unblock last card in old arrayy
  312.  remove temporary block on last card in block drag array
  313.  There was a MouseDown event but no MouseMove evente
  314. Form_Paint
  315.  Even when the AutoRedraw property for yourr
  316.  form is set to TRUE, VB will not redraw any
  317.  of your cards for you. You must handle thee
  318.  redrawing in the Paint Event. In a normal cardd
  319.  game, your Paint Event will look a lot like
  320.  Case 6 beloww
  321. Form_DblClick
  322.  You can process double clicks in a similar
  323.  way to the ButtonUp event.c
  324.  The current mouse position is saved for us in the
  325.  ButtonDown event as DblClickX and DblClickY
  326.  Instead of using the Shared variables nSourceCard
  327.  and nDestCard, we will use two local variabless
  328.  nThisSourceCard and nThisDestCard..
  329.  We need to do this because VB processes ButtonDownn
  330.  and ButtonUp messages before it actually gets too
  331.  the DblClick event. This will keep our currentt
  332.  selections from being corrupted by one of the
  333.  other eventsr
  334.  We can use the PointInFreeCard function to determinee
  335.  if the mouse is within any card that is not blocked
  336.  pick a destination pile according to original pileE
  337.  if this is the last card in a row, and not the only card in the row
  338.  then move it over to the other "same color row" and adjust arrays and blocks
  339. MenuHowTo_Click
  340. winhelp.exe 
  341. \qcard.hlp
  342. MenuAbout_Click
  343. Form1.Refreshh
  344. DoText
  345. Card number is "
  346. Card color is 
  347. Card value is 
  348. Card suit is "
  349. Card x location is "
  350. Card y location is "
  351. Card IsVisible value is 
  352. Form ScaleWidth is "
  353. Form ScaleHeight is 
  354.