Jump to content

How to make a grid


DesireDenied
 Share

Recommended Posts

#include <GUIConstants.au3>

$box = 6
$i = 0


$Form1 = GUICreate("", 118, 140, 197, 137)
$Label1 = GUICtrlCreateLabel("How to?", 8, 8, 100, 17, BitOR($SS_CENTER,$SS_SUNKEN))

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 35, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 41, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 47, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 53, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 59, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 65, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 71, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 77, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 83, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 89, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 95, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 101, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 107, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 113, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 119, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

    $x = 0
For $i = 0 To 32
    $square1 =  GUICtrlCreateLabel("", 8+$x, 125, $box, $box,$SS_SUNKEN)
                GUICtrlSetBkColor(-1, 0xFF0000)
    $i = $i + 1
    $x = $x + $box
Next

GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $square1
            GUICtrlSetBkColor($square1, 0x0000FF)
    EndSwitch
WEndoÝ÷ Ù³ÑR[öî®

Link to comment
Share on other sites

already solved my problem in this way

Global $x, $y, 
Global $step = 8
Global $box = 8
Dim $square[193][193]

For $x = 0 To 32*6 Step 6
For $y = 0 To 32*6 Step 6
    $square[$x][$y] = GUICtrlCreateLabel("",8+$x, 35+$y, $box, $box, $SS_SUNKEN)
    GUICtrlSetBkColor(-1, 0xFF0000)
    $step = $step+8
Next
Next
Edited by DesireDenied
Link to comment
Share on other sites

Hi,

But anyways hope it helps..

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

Global $Label[273][2], $lx = 8, $ly = 35, $box = 6

$Form1 = GUICreate("", 118, 140, 197, 137)
$Label1 = GUICtrlCreateLabel("How to?", 8, 8, 100, 17, BitOR($SS_CENTER,$SS_SUNKEN))
For $i = 1 To 272
    $Label[$i][0] = GUICtrlCreateLabel("", $lx, $ly, $box, $box,$SS_SUNKEN)
    GUICtrlSetOnEvent(-1, "Labels")
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetTip(-1, "Square: " & $i & @LF & "Color: Red")
    $lx += $box
    If mod($i, 17) = 0 Then 
        $lx = 8
        $ly += $box
    EndIf
Next
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1)
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
WEnd

Func Labels()
    For $i = 1 To 272
        If @GUI_CtrlId = $Label[$i][0] Then
            If $Label[$i][1] = 0 Then
                $Label[$i][1] = 1
                GUICtrlSetBkColor($Label[$i][0], 0x0000FF)
                GUICtrlSetTip($Label[$i][0], "Square: " & $i & @LF & "Color: Blue")
            Else 
                $Label[$i][1] = 0
                GUICtrlSetBkColor($Label[$i][0], 0xFF0000)
                GUICtrlSetTip($Label[$i][0], "Square: " & $i & @LF & "Color: Red")
            EndIf
        EndIf
    Next    
EndFunc

Func Close()
    Exit
EndFunc

Cheers

Edit changed the amount of labels to match the same amount as your original.

Edit again: I liked argumentum post below for the tooltip idea so I added tooltips to the labels

PS. argumentum The button change color you did doesn't work for me, but your tooltips work well :)

Edited by smashly
Link to comment
Share on other sites

#include <GUIConstants.au3>

$Form1 = GUICreate("", 118, 140, 197, 137)
$Label1 = GUICtrlCreateLabel("How to?", 8, 8, 100, 17, BitOR($SS_CENTER,$SS_SUNKEN))
GUISetState(@SW_SHOW)

Const $Width = 8
FOR $Row = 35 TO 16 * $Width STEP $Width
    FOR $Column = 8 TO 13 * $Width STEP $Width
    Assign("Square"&Execute($Column -8) / 8 &"_"&Execute($Row - 35) / 8 , GUICtrlCreateLabel("", $Column, $Row, 8, 8,$SS_SUNKEN) )
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetTip(-1,"Square"&Execute($Column -8) / 8 &"_"&Execute($Row - 35) / 8 )
    NEXT
NEXT

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Eval("square1_1")
            GUICtrlSetBkColor(Eval("square1_1"), 0x0000FF)
        Case Eval("square3_3")
            GUICtrlSetBkColor(Eval("square3_3"), 0x0000FF)
    EndSwitch
WEnd
Exit
well, maybe this helps you in your code, is all I can do, best of luck

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...