Aaron Ballman wrote:
Put the following code in the Window.Paint event:
someCardObject.DrawFaceUp( g, 25, 25 )
That'll draw the card at 25, 25 (relative to the window's upper left
of the client area).
HTH!
Thank you, thank you, thank you! It's working _great_, but there is
one unexpected bit of behavior (maybe two) taking place: (1) the new
graphic is being drawn _under_ what is already drawn there (in a sense
that's good, because I want to be able to draw cleanly overlapping
cards), when I would have expected it to be drawn _on top of_ what's
there, and (2) I seem to have created a clone of an already-existing
graphical object (because I have two Aces of Spades visible)..
Simple illustration coming up. To your War cards program, I added a
Pushbutton with this code in its Action event:
Dim I As Integer
DoGraphics = True
For I = 0 to 240 Step 20
MyRank = 0
MySuit = 3
MyX = I
MyY = 85
WarWindow.Refresh
MsgBox "Pause"
Next I
DoGraphics = False
(DoGraphics is a public Boolean, and MyRank, MySuit, MyX, and MyY are
all public Integers.)
Then I put this in the WarWindow.Paint event:
If DoGraphics Then
mPlayerCard.Rank = MyRank
mPlayerCard.Suit = MySuit
mPlayerCard.DrawFaceUp( g, MyX, MyY )
End If
Run the program, click once on the top of the stack (necessary so that
the mPlayerCard object is created), click on the PushButton, and click
repeatedly on the "OK" button on the MsgBox.
The Ace of Spades _does_ appear in the proper place, But (surprise!)
overlapping it are the two cards on the left (the bottom one of which
has also changed to the Ace of Spades, but that's another topic) and
even under the printed words "Opponent won!" (or, as the case may be,
"Player won!").
As you click repeatedly on the "OK" button on the MsgBox, the Ace of
Spades overlapped by the other two face-up cards moves cleanly to the
right, remaining _under_ both the other two cards and the printing, and
continues moving until it has completely passed also _under_ the stack
of cards on the right! There is no mess-up in the drawing (nothing
needs to be erased): it looks _exactly_ as if the one card were being
slid _under_ the other cards as it moves from left to right.
I think I can probably figure out myself why the Ace of Spades looks as
if it were cloned (there continues to be an Ace of Spades on the bottom
left of the original display), but I'm surprised that the new card
appears _under_ (not on top of) everything else that has previously been
drawn.
Is there an easy explanation of what is going on?
Barry Traver
P.S. I searched for the word "opaque" in the Language Reference, but
didn't turn up anything relevant. Is there some similar property here
that may be involved?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|