AutoHotkey Community

It is currently May 27th, 2012, 8:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject:
PostPosted: May 14th, 2006, 6:45 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear Laszlo, :)

How to Create a Vertical / Horizontal line in a GUI ?

That was my long standing question. I did not want Bump that topic because it was posted in "Wish List".
So I post my Thanks here.

I would have never imagined that the font size could be less than "8".

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on May 14th, 2006, 7:38 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2006, 7:25 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Vertical and horizontal lines can be drawn also with SplashImage, although they are not part of a Gui. If you want them moveable with your Gui, you have to dock them. And, of course, you can always create an empty, narrow Gui, without caption. Its border provides the lines. Inside a GUI, other narrow controls work, too, but GroupBoxes looked the simplest.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 16th, 2006, 9:46 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Quote:
How to Draw Lines in a GUI? GuiDrawLine()
http://www.autohotkey.com/forum/viewtopic.php?p=60228#60228

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

  1. The X Coordinate on the GUI
  2. The Y Coordinate on the GUI
  3. The Length of the line
  4. 0 for Vertical Line and 1 for Horizontal Line.
  5. GUI Instance Number 1-99
Code:
GuiDrawLine(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:
  1. The lines drawn are Text Control so GUI, Font affects it. The functions sets it to lowest! (Thanks to Laszlo!)

    • For example, if the Font size was 14 when GuiDrawLine() was called, it will be reset to Windows Default Font Size.
    • You may add line: GUI, Font, s%RequiredFontSize% after calling GuiDrawLine().
  2. Again, remember that the lines are Text Control and that there is an upper limit to controls. ( 5000+ ?! ).
  3. I tested a 100 Pixels wide line, and only 96 pixels wide line was drawn.

    • To overcome this, I have included the line Size+=4 on the function.
    • One should/may modify it ( to suit needs ) if the lines are not in proper size.

    Experiment 1 :

    Image
Code:
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 :

    Image
Code:
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.

:D :D :D



Last edited by SKAN on June 16th, 2008, 7:29 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 16th, 2006, 10:10 pm 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
Interesting effect. Now if you want a real challenge you can try to get your head around the line drawing code that shimanov posted a while back (and is used for the window/control highlighting in the AHK Window Info script) - I've been meaning to make a window/control highlighting function, but never enough time :lol:

Reminds me of a line-drawing 3D first person shooting game that I played a few times on my old TI-85 graphics calculator :lol: If it can be done on a calculator with a few MHz of processing power it's only a matter of time before it's done in AHK :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 16th, 2006, 10:33 pm 
Offline

Joined: February 13th, 2006, 10:40 pm
Posts: 389
Location: Utah
Nice Work! I remember reading a post in which groupboxes where used draw boxes and lines, and i couldnt get it to work. This works perfectly! Your TipsNTricks continue to amaze me! Keep up the good work!

_________________
Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 17th, 2006, 10:27 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Very nice and creative use of the SS_ETCHEDHORZ and SS_ETCHEDVERT styles (I give away your "trade secrets"... :-)).

I get undue credit, as I only suggested to use a Picture. My solution has the advantage of allowing to change colors (but using system colors is good too) and the disavantage of necessitating an image file (or some complex trick...).

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 18th, 2006, 8:27 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
evl wrote:
Interesting effect. Now if you want a real challenge you can try to get your head around the line drawing code that shimanov posted a while back (and is used for the window/control highlighting in the AHK Window Info script) - I've been meaning to make a window/control highlighting function, but never enough time :lol:


I guess you are referring to Analytic graphing facility by Shimanov. Or something else?

Shimanov's code :!: :shock:
I am not that good in Scripting! :D



Veovis wrote:
Nice Work! .............This works perfectly! Your TipsNTricks continue to amaze me! Keep up the good work!


Thank you Veovis :D



PhiLho wrote:
Very nice and creative use of the SS_ETCHEDHORZ and SS_ETCHEDVERT styles (I give away your "trade secrets"... :-)).


No secrets!... Just an accidental discovery! I was attempting brute force method to Vertically center text in a Text Control and to my surprise I found this out. ( I'm yet to find a way for Vertically centering text! Or maybe it cannot be done .. :( ... Mr.Chris? )

Philho further wrote:
I get undue credit, as I only suggested to use a Picture. My solution has the advantage of allowing to change colors (but using system colors is good too) and the disavantage of necessitating an image file (or some complex trick...).


These days I've been using your set of Binary Functions for many things. I did attempt to write a function that will create a line.bmp based on window background color.

But we have a better solution now, Simple and Straight ;)

Regards, :)



PS: Please bear with me for delayed reply. I am using replies to *Bump* this topic at appropriate time.

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 21st, 2012, 7:45 am 
Offline

Joined: April 11th, 2012, 9:07 am
Posts: 75
I know this thread is pretty old, just wanted to add another way.

I do it using extremely narrow groupbox, here is the code

Code:
Gui, Add, GroupBox,w300 h10


Add x and y according to your needs. Change height with width to generate vertical lines. I prefer a "double line". So i increase the height of this groupbox to give "double line" effect.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 24th, 2012, 9:07 am 
Offline
User avatar

Joined: February 19th, 2012, 11:21 pm
Posts: 471
Location: KDZ Ereğli, `nTürkiye
Where is the Skan's download link ?

Edit: Yeah that is good function :)

_________________
OS : XP
♫♪♫♪♫♪♫♫♪♫♪♫♪♫♫
Mines :
AHK_L / AHK COMPILED EXE / BIN ICON CHANGER
CHANGE BUTTON'S TEXT COLOR - just me's
VarReadLine() - FIXED (Useful)(Supports Lastlines)
GuiDrawBox() - (Useful)

Who is AREF?
http://www.youtube.com/watch?v=1GVGTdBqRKo


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group