Results 1 to 12 of 12

Thread: [RESOLVED] How to select two pictureboxes during a single event

Hybrid View

  1. #1
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    Re: [RESOLVED] How to select two pictureboxes during a single event

    Well, I don't know if it might be of any use in the future, but since I modified the code in post #6 to draw the cards (using DrawImage with a bitmap of each card) instead of pictureboxes for each individual card, I may as well post it.
    I've already described some of the changes done in post #9.
    This is still based on the original code, which has a history back to VB3 so doesn't use classes. The code could benefit a lot I think by redoing it, taking advantage of the object oriented design that wasn't available back in VB3 days (at least not in VB3).
    To reiterate and expand on the changes done to post #6 example to this:
    1. Remove all the pictureboxes. Create a structure with a bitmap and rectangle to take the place of the pictureboxes. Create two arrays of those structure, the same dimension (52 cards, and 8 stacks) that we used previously.
    2. Add new double linked list links to the Card_Type, to maintain the Z-Order (drawing order) of the bitmaps, which is also used in reverse order to determine which image was clicked on.
    3. Add the routine that searches the Z-Order list in reverse to determine which card or stack was clicked on. (only care about home stacks, other stacks are ignored).
    4. Add a routine to initially link all the cards and stacks to the Z-Order list, and another routine to move a card to the top of the Z-Order (last to be drawn).
    5. Add a routine for the paint event to call, to draw all the stacks and cards on the form.
    (the drawing and mouse events could easily be moved to another control, such as a panel or picturebox, with very little change to the code other than modifying the reference names).
    6. Set the Form's DoubleBuffered property.
    7. Added a timer to regulate the drawing speed, and a function for the timer to call to do one step of the card animation.
    The step code wasn't changed, but the loop it was in at the bottom of the Send_any_Free_Cards_Home sub was removed, and the step code put in the new function for the timer to call to do the one step. The function returns false, until all the animation is done, at which time the timer will stop, until started the next time animation is to be done.

    If you tried the code in post #6, and compare the running of that code against this, there shouldn't be much of a difference visually, or the way it looks and feels compared to the Pictureboxes version. The main way to tell them apart when first running, is that the transit stacks (cells), are pictureboxes with 3D borders in the picturebox version, and just a white drawn rectangle in the non-picturebox version. Also, in the non-picturebox version, later in the game, you'll see the Normal Stacks, aka the tableau columns, base positions are also outlined in white, where as I didn't bother to use pictureboxes for those positions, nor draw rectangles there, in the pictureboxes version.

    So, in spite of its VB3 design, I'll post this version just for contrast in how the card images are managed between the two implementations.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width