Clear as mud? Let's go over this a bit more slowly.
1 - Create Enum structures
Drawing the lines with GDI+ will require five parameters. (That is, for the particular version of the "overloaded" GDI+ DrawLine method we will use.) The first is a Pen object and the other four are the x and y coordinates of the start and end of the lines. You can provide a convenient way to specify all of these using meaningful names by including Enum structures at the top of your code. The actual values (the default is pixels, not in twips as in VB 6 - another change) will vary according to how you have drawn your form and you may have to adjust them to draw the lines where they look good in your form. Here's the Enum that worked for me:
2 - Create a GDI+ graphics object in the form and a Pen object
If you're following along, this is the section of code where your program is now crashing when you try to run it. Specifically, it's not finding linWin in the statement:
linWin(iWin).Visible = True
You can simply delete this statement. The replacement with GDI+ takes a few more lines.
[Old code -- place the GDI+ declarations and Case structure after this]
If iWin >= 0 Then
' Display the appropriate win line on the playing grid
[The GDI+ declarations]
' Set up Win Line graphics
Dim g As Graphics
' Sets g to a Graphics object representing the drawing surface
' of the form g is a member of.
g = Me.CreateGraphics
Dim myPen As New Pen(Color.Red)
myPen.Width = 5
3 - Draw the appropriate win line with a Case structure
Here's where the Enum's defined earlier pay off. The Case structure simply tests iWin and then uses the DrawLine method. Here's the first two (of eight required) selections to give you the idea. The entire Case structure is in the downloadable source code.
[The first few lines of the Case structure -- see the entire source listing for the rest]
Select Case iWin
Case 0
g.DrawLine(myPen, _
XPoint.RightSide, YPoint.FirstRow, _
XPoint.LeftSide, YPoint.FirstRow)
Case 1
g.DrawLine(myPen, _
XPoint.RightSide, YPoint.SecondRow, _
XPoint.LeftSide, YPoint.SecondRow)
Next page >
Working Code At Last? >
Page 1,
2,
3,
4,
5,
6,
7,
8,
9