Jump to content

_GuiCreateGrid()


MrCreatoR
 Share

Recommended Posts

Hi to all, i get the idea for this function from this topic, and it seems that this work fine.

;===============================================================================
; Function Name:    _GuiCreateGrid()
; Description:      Create grid on the screen, using GUI windows.
;
; Parameter(s):     $GridWidth = The Width of the grid, $GridHeight = The Height of the grid,
;                   $GridLineHeightWidth = This Parametr defines what Width/Height will be of all lines,
;                   $GridRange = Range between each line (Frequency/Interval), $GridColor = The color of grid,
;                   $TopMost = Defines if the grid will have Top Most attribute.
;
; Requirement(s):   AutoIt 3.2.2.0.
; Return Value(s):  If the total number of lines is more then 1024,
;                   or the parameter $GridRange less then 10, then @Error set to 1 and returned "" (empty string).
; Limit(s):         1) Maximum allowed lines in grid is 1024 (because Maximum number of GUI windows is 1024).
;                   2) The grid is limited to 10 pixels range between each line (not less then 10 pixels range).
; 
; Author(s):        G.Sandler a.k.a CreatoR (MsCreatoR)
;===============================================================================
Func _GuiCreateGrid($GridWidth=@DesktopWidth, $GridHeight=@DesktopHeight, $GridLineHeightWidth=1, $GridRange=20, $GridColor=Default, $TopMost=0)
    If $GridLineHeightWidth < 1 Then $GridLineHeightWidth = 1
    Local $LeftLinesNum = Round($GridWidth/$GridRange)
    Local $ToptLinesNum = Round($GridHeight/$GridRange)
    Local $i, $FirstLinePos, $TopMostStyle = 0, $MainTopPos = Default, $MainLeftPos = Default, $TopLinesAdd = 0, $LeftLinesAdd = 0
    If $TopMost = 1 Then $TopMostStyle = 0x00000008
    If $GridWidth = @DesktopWidth Then
        $MainLeftPos = 0
        $LeftLinesAdd += 2
    EndIf
    If $GridHeight = @DesktopHeight Then
        $MainTopPos = 0
        $TopLinesAdd += 2
    EndIf
    
    If ($LeftLinesNum + $LeftLinesAdd) + ($ToptLinesNum + $TopLinesAdd) >= 1024 Or $GridRange < 10 Then Return SetError(1, 0, "")
    
    $FirstLinePos = (@DesktopWidth/2) - ($GridWidth/2)
    For $i = 1 To $LeftLinesNum + $LeftLinesAdd
        $CurrentGui = GUICreate("Grid Width", $GridLineHeightWidth, $GridHeight, $FirstLinePos, $MainTopPos, 0x80880000, 0x00000080+$TopMostStyle)
        GUISetBkColor($GridColor, $CurrentGui)
        GUISetState(@SW_SHOW, $CurrentGui)
        $FirstLinePos += $GridRange
    Next

    $FirstLinePos = (@DesktopHeight/2) - ($GridHeight/2) - $GridRange
    For $i = 1 To $ToptLinesNum + $TopLinesAdd
        $CurrentGui = GUICreate("Grid Height", $GridWidth, $GridLineHeightWidth, $MainLeftPos, $FirstLinePos, 0x80880000, 0x00000080+$TopMostStyle)
        GUISetBkColor($GridColor, $CurrentGui)
        GUISetState(@SW_SHOW, $CurrentGui)
        $FirstLinePos += $GridRange
    Next
EndFuncoÝ÷ Ù8^)¢µú+­©àz±z["±·jëü±ëbµ«%zË-éõÒØb³¥·¯z¼¬½éߢ¹²}«-r©º×«Â¬¶WRÆ yìZ^ý¶®¶­sd÷D¶W6WBgV÷C·¶W67ÒgV÷C²ÂgV÷CµVBgV÷C² ¥ôwV7&VFTw&BFW6·F÷vGFÂFW6·F÷VvBÂ"Â#RÂs2¤bW'&÷"FVà ×6t&÷bÂgV÷C´W'&÷"b333²gV÷C²ÂgV÷CµFW&Rv2âW'&÷"7&VFRFRw&C²Ö×VÒÆÆ÷vVBÆæW2âw&B2#BâââgV÷C²fײ5"fײgV÷C´æBFRw&B2ÆÖFVBFòVÇ2&ævR&WGvVVâV6ÆæRæ÷BÆW72FVâVÇ2&ævRgV÷C²fײ5"fײ5"fײgV÷C´ô²ÒÒb3c#²UBgV÷C² W@¤VæD` ¥vÆR 6ÆVW¥tVæ@ ¤gVæ2VB W@¤VæDgVæ0
Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Don't you mean Grid

oops... :whistle:

Thanks, i have changed the first post, but how do i change the name of the topic?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • Moderators

LOL... nice job... very unique.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 1 month later...

for some reason the grid's lines that are going up and down are a little bit too far down on the y axis...

is there any way I can fix that? here is the source:

#include <GuiConstants.au3>
#include <Grids.au3>
HotKeySet("{esc}", "Quit")
$Main = GUICreate("Graph", 500, 500)


_GuiCreateGrid(250, 250, 2, 10, 0xAA780C, 1)

If @error Then
    MsgBox(16, "Error!", "There was an error to create the grid; maximum allowed lines in grid is 1024..." & @CR & "And the grid is limited to 10 pixels range between each line (not less then 10 pixels range)" & @CR & @CR & "OK --> EXIT")
    Exit
EndIf

GUISetState(@SW_SHOW, $Main)
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $XLine[0]
            GUIDelete($XLine[0])
            
    Case Else
        ;;;
    EndSelect
WEnd

Func Quit()
    Exit
EndFunc

and here is a pic of the problem:

post-14325-1177902381_thumb.jpg

What goes around comes around... Payback's a bitch.

Link to comment
Share on other sites

  • 7 months later...

oops... :)

Thanks, i have changed the first post, but how do i change the name of the topic?

When you edit your original post you can change the title etc at the top. It took me a long time to realize that and I even asked Admin if they could change a title for me before I found it.

I think it might be better to say

$CurrentGui = GUICreate("Grid Height", $GridWidth, $GridLineHeightWidth, $MainLeftPos, $FirstLinePos,$WS_POPUP , 0x00000080+$TopMostStyle);0x80880000

I.e. use $WS_POPUP rather than $WS_POPUPWINDOW because then you can have lines which are much narrower.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Very nice i decided to make transparency on the lines i also added splashtexton saying "Creating grid..." heres my code.

Func _GuiCreateGrid($GridWidth=@DesktopWidth, $GridHeight=@DesktopHeight, $GridLineHeightWidth=1, $GridRange=20, $GridColor=Default, $TopMost=0,$transparency=255)
    splashtexton("","Creating grid...",80,50,-1,-1,1+2)
    If $GridLineHeightWidth < 1 Then $GridLineHeightWidth = 1
    Local $LeftLinesNum = Round($GridWidth/$GridRange)
    Local $ToptLinesNum = Round($GridHeight/$GridRange)
    Local $i, $FirstLinePos, $TopMostStyle = 0, $MainTopPos = Default, $MainLeftPos = Default, $TopLinesAdd = 0, $LeftLinesAdd = 0
    If $TopMost = 1 Then $TopMostStyle = 0x00000008
    If $GridWidth = @DesktopWidth Then
        $MainLeftPos = 0
        $LeftLinesAdd += 2
    EndIf
    If $GridHeight = @DesktopHeight Then
        $MainTopPos = 0
        $TopLinesAdd += 2
    EndIf
   
    If ($LeftLinesNum + $LeftLinesAdd) + ($ToptLinesNum + $TopLinesAdd) >= 1024 Or $GridRange < 10 Then Return SetError(1, 0, "")
   
    $FirstLinePos = (@DesktopWidth/2) - ($GridWidth/2)
    For $i = 1 To $LeftLinesNum + $LeftLinesAdd
        $CurrentGui = GUICreate("Grid Width", $GridLineHeightWidth, $GridHeight, $FirstLinePos, $MainTopPos, 0x80880000, 0x00000080+$TopMostStyle)
        GUISetBkColor($GridColor, $CurrentGui)
        GUISetState(@SW_SHOW, $CurrentGui)
        winsettrans($currentgui,"",$transparency)
        $FirstLinePos += $GridRange
    Next

    $FirstLinePos = (@DesktopHeight/2) - ($GridHeight/2) - $GridRange
    For $i = 1 To $ToptLinesNum + $TopLinesAdd
        $CurrentGui = GUICreate("Grid Height", $GridWidth, $GridLineHeightWidth, $MainLeftPos, $FirstLinePos, 0x80880000, 0x00000080+$TopMostStyle)
        GUISetBkColor($GridColor, $CurrentGui)
        GUISetState(@SW_SHOW, $CurrentGui)
        winsettrans($currentgui,"",$transparency)
        $FirstLinePos += $GridRange
    Next
    splashoff()
EndFunc
Edited by EagleClaw

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

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...