Sign in to follow this  
Followers 0
MyEarth

Create a grid using GUICtrlCreateGraphic

3 posts in this topic

Hello :D

Like title and math is my worst enemy. Pratically at the end i'd like a function with the parameters for single square size, like "create a grid of 10x10 pixel every squares" not the number of the total squares

A sort of example of a grid using GUICtrlCreateGraphic

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$hWidth = 200
$hHeight = 200

$hGui = GUICreate("", $hWidth, $hHeight, -1, -1)

GUICtrlCreateGraphic(0, 0, $hWidth, $hHeight)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $hHeight / 3)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00000)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, $hWidth, $hHeight / 3)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $hHeight * 2 / 3)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00000)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, $hWidth, $hHeight * 2 / 3)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $hWidth / 3, 0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00000)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, $hWidth / 3, $hHeight)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $hWidth * 2 / 3, 0)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00000)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, $hWidth * 2 / 3, $hHeight)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Thanks for the help

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$iWidth = 600
$iHeight = 400

$hGui = GUICreate("", $iWidth, $iHeight, -1, -1)
Create_GRID($iWidth, $iHeight)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Create_GRID($iWidth, $iHeight, $iGrid_w = 20, $iGrid_h = 20, $iColorW = 0x00000, $iColorH = 0x00000)
    Local $x, $y
    GUICtrlCreateGraphic(0, 0, $iWidth, $iHeight)

    For $x = 0 To $iWidth / $iGrid_w
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $x * $iGrid_w, 0)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $iColorW)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $x * $iGrid_w, $iHeight)
    Next

    For $y = 0 To $iHeight / $iGrid_h
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $y * $iGrid_h)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $iColorH)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $iWidth, $y * $iGrid_h)
    Next
EndFunc
 

 

 

Br,

UEZ

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks Mr.UEZ ;)

1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0