How to Draw Lines in a GUI? GuiDrawLine()
http://www.autohotke...p?p=60228#60228
Foreword:
Thanks to Laszlo & PhiLho for invoking
creativity in me. (Please refer the above few posts.)
I hope, someday AHK will have something like:
Gui, Draw, Line,,
Gui, Draw, Box,,
GuiDrawLine(X,Y,LineLength,Horizontal,Gui_Instance_Number)
Note: All the 5 parameters are expected as numbers.
[*:192fqqar]The X Coordinate on the GUI
[*:192fqqar]The Y Coordinate on the GUI
[*:192fqqar]The Length of the line
[*:192fqqar]0 for Vertical Line and 1 for Horizontal Line.
[*:192fqqar]GUI Instance Number 1-99GuiDrawLine(X,Y,Size,VH="",Guin="") {
If (Guin="" OR Guin<1 OR Guin>99)
Guin=1
If VH=
VH=1
Size+=4
Gui, %Guin%:Font, S1
if VH
Gui, %Guin%:Add, Text, x%X% y%Y% w%Size% 0x10
Else
Gui, %Guin%:Add, Text, x%X% y%Y% h%Size% 0x11
Gui, %Guin%:Font, S
Return errorlevel
}
Important Notes:[*:192fqqar]The lines drawn are Text Control so GUI, Font affects it. The functions sets it to lowest! (Thanks to Laszlo!)
[*:192fqqar]For example, if the Font size was 14 when GuiDrawLine() was called, it will be reset to Windows Default Font Size.
[*:192fqqar]You may add line: GUI, Font, s%RequiredFontSize% after calling GuiDrawLine().[*:192fqqar]Again, remember that the lines are Text Control and that there is an upper limit to controls. ( 5000+ ?! ).
[*:192fqqar]I tested a 100 Pixels wide line, and only 96 pixels wide line was drawn.
[*:192fqqar]To overcome this, I have included the line Size+=4 on the function.
[*:192fqqar]One should/may modify it ( to suit needs ) if the lines are not in proper size.[/list]
Experiment 1 :

Gui, 1:+ToolWindow
Gui,1:Margin,0,0
GuiDrawLine(20,20,80)
GuiDrawLine(20,20,80,0)
GuiDrawLine(80, 0,80,0)
GuiDrawLine(0, 80,80)
Gui,1:Show,x10 y10 w100 h100,GUI:1
Gui, 2:+ToolWindow
GuiDrawLine(0,10,100,1,2)
GuiDrawLine(0,90,100,1,2)
GuiDrawLine(10,0,100,0,2)
GuiDrawLine(90,0,100,0,2)
Gui,2:Show,x125 y10 w100 h100,GUI:2
Gui, 3:+ToolWindow
GuiDrawLine(0,33,100,1,3)
GuiDrawLine(0,66,100,1,3)
GuiDrawLine(33,0,100,0,3)
GuiDrawLine(66,0,100,0,3)
Gui,3:Show,x240 y10 w100 h100,GUI:3
Return
; Copy and Paste GuiDrawLine() below
Experiment 2 :

Gui,1:+ToolWindow
Gui,1:Margin,0,0
Gui, 1:Font, s36 Bold , Verdana
Gui, 1:Add, Text, x10 y10 w400, Text Written Before Line Drawing
LineSize=1
y=1
Loop, 65 {
GuiDrawLine(0,Y,LineSize,1,1)
LineSize+=5
y+=6
}
Gui, 1:Font, s36 Bold
Gui, 1:Add, Text, x10 y200 w400 BackgroundTrans, Transparent Text Written After Drawing
Gui,1:Show, ,GUI:1
Return
; Copy and Paste GuiDrawLine() below
Comments / Suggestions are welcome.
