Sign in to follow this  
Followers 0
MikelSevrel

Can a grid be created?

9 posts in this topic

#1 ·  Posted (edited)

I've been everywhere, and I cannot figure out if there is a way to draw a grid suitable for a calendar. I've looked at some other apps, like the Sodoku scripts, but I don't understand how they actually render the grid. Any help would be appreciated. I just need to figure out how to make a 6x7 grid, and I can't do it. :o

Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites



You could use GUICtrlCreateMonthCal....

Another option would be a graphic control and lines.

Share this post


Link to post
Share on other sites

something like:

#include <GUIConstants.au3>
Global $grid[7][8]

GUICreate("my gui",400,450,-1,-1)
for $x = 1 to 6
    for $y = 1 to 7
        $grid[$x][$y] = GUICtrlCreateInput("",$x * 50, $y * 50,50,50)
    next
next
GUISetState()

do
$msg = GUIGetMsg()

until $msg = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$guititle = "test gui"
$GUIHANDLE = GUICreate($guititle,400,400)
For $X = 20 to 380 Step 20
    GUICtrlCreateLabel("", 0, $X, 400, 2) 
    GUICtrlSetBkColor(-1, 0x000000)
Next
For $X = 20 to 380 Step 20
    GUICtrlCreateLabel("", $X, 0, 2, 400) 
    GUICtrlSetBkColor(-1, 0x000000)
Next
GUISetState(@SW_SHOW, $GUIHANDLE)
While 1
    $m = GUIGetMsg()
    Select
        Case $m = $gui_event_close
            Exit
    EndSelect
WEnd

i'm sure there's better ways, might give you an ides

Edited by pecloe

Share this post


Link to post
Share on other sites

Thanks, those scripts work great. :o


Coming soon....

Share this post


Link to post
Share on other sites

Now the pronblem is getting the informatioon into the input boxes. Can someone take a look at this and tell me what i'm doing wrong?

;rakudave
#include <GUIConstants.au3>
#include <Date.au3>
#include <Array.au3>
Global $grid[7][8]
Dim $num = 1


GUICreate("my gui", 450, 400, -1, -1)
$month = @MON
$year = @YEAR


For $x = 1 To 7
    For $y = 1 To 6
        $grid[$y][$x] = GUICtrlCreateInput("", $x * 50, $y * 50, 50, 50, $ES_READONLY)
    Next
Next
$daysinmonth = _DateDaysInMonth($year, $month)
$days = _DateToDayOfWeek($year, $month, 1)

For $i = 1 To $days
    GUICtrlSetData($grid[1][$days], $num)
    $num = $num + 1
    If $num >= $daysinmonth Then ExitLoop
Next

For $d = 2 To 6 
    For $i = 1 To 7
        GUICtrlSetData($grid[$d][$i], $num)
        $num = $num + 1
        If $num >= $daysinmonth Then ExitLoop
    Next
    If $num >= $daysinmonth Then ExitLoop
Next

GUISetState()

Do
    $msg = GUIGetMsg()
    
Until $msg = $GUI_EVENT_CLOSE

Coming soon....

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Is there any way to make this read only, while still keeping the borders the same?

;;rakudave
#include <GUIConstants.au3>
#include <Date.au3>
#include <Array.au3>
Global $grid[7][8]
Dim $num = 1


GUICreate("my gui", 450, 400, -1, -1)
$month = @MON
$year = @YEAR


For $x = 1 To 7
    For $y = 1 To 6
        $grid[$y][$x] = GUICtrlCreateEdit("", $x * 50, $y * 50, 50, 50, $ES_READONLY, $ES_MULTILINE)
        GUICtrlSetBkColor($grid[$y][$x], 0xFFFFFF)
    Next
Next
$daysinmonth = _DateDaysInMonth($year, $month)
$days = _DateToDayOfWeek($year, $month, 1)
For $i = 1 To $days
    GUICtrlSetData($grid[1][$days], $num)
    GUICtrlSetBkColor($grid[1][$days], 0xDDDDDD)
    GUICtrlSetStyle ($grid[1][$days],$WS_DLGFRAME,$ES_READONLY)
    If $num = @MDAY Then GUICtrlSetBkColor($grid[1][$days], 0xEEEEEE)
    If $num = @MDAY Then GUICtrlSetData($grid[1][$days], $num & @CRLF & @CRLF   & " Today")
    $num = $num + 1
    $days = $days + 1
    If $num >= $daysinmonth Then ExitLoop
Next

For $d = 2 To 6
    For $i = 1 To 7
        GUICtrlSetData($grid[$d][$i], $num)
        GUICtrlSetBkColor($grid[$d][$i], 0xDDDDDD)
        GUICtrlSetStyle($grid[$d][$i],$WS_DLGFRAME)
        If $num = @MDAY Then GUICtrlSetBkColor($grid[$d][$i], 0xEEEEEE)
        If $num = @MDAY Then GUICtrlSetData($grid[$d][$i], $num & @CRLF & @CRLF & " Today")
        $num = $num + 1
        If $num >= $daysinmonth Then ExitLoop
    Next
    If $num >= $daysinmonth Then ExitLoop
Next

GUISetState()

Do
    $msg = GUIGetMsg()
    
Until $msg = $GUI_EVENT_CLOSE
Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites

WS_DLGFRAME, $ES_READONLY are common styles. Use BitOr() to combine styles.

Change these lines:

GUICtrlSetStyle ($grid[1][$days],$WS_DLGFRAME,$ES_READONLY)
GUICtrlSetStyle($grid[$d][$i],$WS_DLGFRAME)
to:

GUICtrlSetStyle ($grid[1][$days], BitOr($WS_DLGFRAME,$ES_READONLY))
GUICtrlSetStyle ($grid[$d][$i], BitOr($WS_DLGFRAME,$ES_READONLY))

Share this post


Link to post
Share on other sites

Ahh, thank you very much.


Coming soon....

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