Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SIMULATE A CARD TURNING

Status
Not open for further replies.

NotSoVisual

Technical User
Aug 29, 2003
203
MX
I have seen "turning pages" with variable content(mostly images) in "photo album" programs. I would like do something similar: have a hand turn a playing card/receipe/study card over that is face down on a form. I imagined using a picture box with 3-4 pictures in an animation. However I have NO idea how a) Manage the variable data (and 3-4 distortions) of fvariety of cards in a deck. b) the the host of possible card backs and C) what to do instead if the cards were text as in receipes or Flip cards. Any help would be appreciated.

 
One cheap and cheerful way of doing it is to change the width of a picture box. You need a timer and a picture box for this to work. You decrease the width of the picture box until it is at 0 then you change the picture and then you increase the size again.
 
Here's a simple example of one possible technique. You'll need a form with three pictureboxes (Picture1, Picture2 and picPage) and a command button. Picture1 should contain the image that goes on one side of the flip, Picture2 should contain the second image. In this example you don't need to worry if the images are the same size; it all gets automatically scaled for you:
[tt]
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Enum ctDirection
ctForward = 1
ctBackward = -1
End Enum

Private Const ScaleMax As Long = 100

Private Sub Command1_Click()
Turn ctForward
Turn ctBackward
End Sub

Private Sub Form_Load()
' Arbitarily select a scale mode for picPage
picPage.ScaleWidth = ScaleMax
picPage.ScaleHeight = ScaleMax
picPage.AutoRedraw = True
End Sub

Private Sub Turn(ctDir As ctDirection)
Dim lTurn As Long
Dim iSource As Image

Dim Start As Long
Dim Finish As Long


If ctDir = 1 Then
Start = 0
Finish = ScaleMax
Else
Start = ScaleMax
Finish = 0
End If

For lTurn = Start To Finish Step ctDir
picPage.Cls ' Clear previous image
If lTurn < (ScaleMax) \ 2 + 1 Then
picPage.PaintPicture Picture1.Picture, lTurn, 0, (ScaleMax) \ 2 + 1 - lTurn, ScaleMax
Else
picPage.PaintPicture Picture2.Picture, (ScaleMax) \ 2, 0, lTurn - (ScaleMax) \ 2, ScaleMax
End If
picPage.Refresh ' Give picture chance to actually display new image
Sleep 10 ' brief delay
Next
End Sub
 
Please excuse me for not trying these but I am leaving on a small side trip for the weekend (here in Yucatan Mexico) but had to check mail before I left) I am SO IMPRESSED at the quickness and apparent quality of responses to my first post ever. Thank-you all! Hasta Lunes en la noche!

 
To Strongm, Your code is Great. I tried yours first because it was so COMPLETE . Ran it and it worked as you. Now it remains for me to learn what is actually going on. One concern I am trying to resolve: If pic1 ix x units wide you have Picpage as 2x wide by necessity because the rotation takes place on the right vertical . I had envisioned a rotaion on the center vertical axis. Yours' would be fine for a picture album, I will continue to try and understand.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top