|
-
May 24th, 2013, 09:56 AM
#1
Thread Starter
New Member
Clicking on a Control Array of Shapes
Hello Everyone!
I'm trying to help a friend make Connect 4 in VB6 but I'm running into a problem with handling the event of someone clicking on one of the circles. The goal is that when a person clicks on a circle the Subroutine is called with the index as an argument, but for some reason the code doesn't run.
Below is my code:
Code:
Private Sub Shape1_Click(ByVal Index As Integer)
MsgBox (Index) 'Will be replaced with functioning code upon bugfix
End Sub
Thanks to everyone in advance!
-
May 24th, 2013, 10:34 AM
#2
Re: Clicking on a Control Array of Shapes
You cannot click on a shape....place a same-color label on top of it and use the label's click event. (Of course, the label will be a square and won't completely cover the same area as the circle, but this is the easiest and quickest way to do it).
EDIT: You can also use pictureboxes with circular images in them. Many ways to do this, but there is no direct clicking on a shape control (That "I" know of)
Last edited by SamOscarBrown; May 24th, 2013 at 10:39 AM.
-
May 24th, 2013, 12:05 PM
#3
Re: Clicking on a Control Array of Shapes
 Originally Posted by ahjohnston25
... but for some reason the code doesn't run.
Below is my code:
Code:
Private Sub Shape1_Click(ByVal Index As Integer)
MsgBox (Index) 'Will be replaced with functioning code upon bugfix
End Sub
You can make it run by adding the following code to your Form:
Code:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Shp As Control
For Each Shp In Controls
If TypeOf Shp Is Shape Then
If Shp.Left <= X And X <= (Shp.Left + Shp.Width) Then
If Shp.Top <= Y And Y <= (Shp.Top + Shp.Height) Then
Shape1_Click Shp.Index
Exit Sub
End If
End If
End If
Next
End Sub
BTW, I think Sam's idea is less hassle!
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
May 24th, 2013, 03:21 PM
#4
Re: Clicking on a Control Array of Shapes
AH
Just to confirm Sam's EDIT .. he was correct.
As more of a geek-speak way of explaining, the Shape control does not support any Events,
and Click is an Event.
Spoo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|