Lines on GUI's Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
roysubs
Posts: 257
Joined: 29 Sep 2018, 16:37

Lines on GUI's

20 Apr 2020, 02:33

I guess there are probably ways to add BMP / PNG to GUI's. That would also be interesting to know the command to do that, but I'm mostly curious if there is a simple facility to include a solid line (mostly horizontal or vertical for my purposes) on a GUI to separate different regions (without having to get into the complexity of supplying a BMP).

I guess that a horizontal line could be emulated by a series of underscores "____" but it's not ideal due to the whitespace above the underscores (i.e. can't make the lines box a height or 2 or 3 pixels). For a vertical line I don't know how that might be achieved.

Is there a "Draw" facility for GUI's to specify a line (providing starting coordinate then end coordinate say) in this way?
swagfag
Posts: 3972
Joined: 11 Jan 2017, 17:59

Re: Lines on GUI's

20 Apr 2020, 02:45

i usually use smushed down groupboxes of varying widths and heights
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Lines on GUI's

20 Apr 2020, 03:06

Code: Select all

vert := 0, hor := 1

Gui, +ToolWindow
GuiDrawLine(5,5,100,hor)
GuiDrawLine(5,5,100,vert)
GuiDrawLine(5,100+5,100,hor)
GuiDrawLine(100+5,5,100,vert)

GuiDrawLine(5,120,120,hor)
GuiDrawLine(5,145,120,hor)
GuiDrawLine(5,165,120,hor)
Gui,Show,h200 w150,GUI
Return

GuiDrawLine(X,Y,len,VH="1") {
   if VH
      Gui, Add, Text, x%X% y%Y% w%len% 0x10 ; add a horizontal line ( 0x10 = SS_ETCHEDHORZ )
   Else
      Gui, Add, Text, x%X% y%Y% h%len% 0x11 ; add a vertical line ( 0x11 = SS_ETCHEDVERT )
}
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
User avatar
Hellbent
Posts: 1058
Joined: 23 Sep 2017, 13:34

Re: Lines on GUI's  Topic is solved

20 Apr 2020, 03:08

Progress controls also work well as lines.

Code: Select all

#SingleInstance, Force

Gui,1:+AlwaysOnTop -DPIScale
Gui,1:Color,222222

Draw_Outline(1,10,10,280,130,"336699",2)
Draw_Outline(1,20,20,260,110,"ffff00",1)
Draw_Line(1,30,30,190,10,"880000")
Draw_Line(1,30,50,1,60,"Teal")
Draw_Line(1,40,50,200,2,"Aqua")
Draw_Outline(1,50,60,200,60,"Silver",1)

Gui,1:Show,w300 h150, Lines

return
GuiClose:
GuiContextMenu:
*ESC::
	ExitApp
;#############################################################################################################
;#############################################################################################################
;#############################################################################################################
Draw_Outline(Gui_Name,x,y,w,h,Color:="Black",thickness:=1){
	x2:=X+W-thickness
	Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y " w" W " h" thickness " Background" Color 
	Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y " w" thickness " h" H " Background" Color 
	Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y+H-thickness " w" W " h" thickness " Background" Color 
	Gui,% Gui_Name ":Add",Progress,% "x" X+W-thickness " y" Y " w" thickness " h" H " Background" Color 	
}
Draw_Line(Gui_Name,x,y,w,h,color){
	Gui,% Gui_Name ":Add",Progress,% "x" X " y" Y " w" W " h" H " Background" Color 
}

;#############################################################################################################
;#############################################################################################################
;#############################################################################################################
just me
Posts: 7225
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lines on GUI's

20 Apr 2020, 05:53

Code: Select all

#NoEnv
Gui, Margin, 50, 50
Gui, Add, Pic, w300 h1 +0x40, % "HBITMAP:" . CreateUniDIB(0x0000FF) ; SS_REALSIZECONTROL = 0x40
Gui, Show, , Test
Return

GuiClose:
ExitApp

; ==================================================================================================================================
; Modified version of a function by SKAN, 01-Apr-2014, autohotkey.com/boards/viewtopic.php?t=3203
; Creates an uni-colored bitmap of 1 * 1 pixels.
; ==================================================================================================================================
CreateUniDIB(Color) {
   VarSetCapacity(BMBITS, 4, 0)
   , Numput(Color, BMBITS, "UInt")
   , HBM := DllCall("CreateBitmap", "Int", 1, "Int", 1, "UInt", 1, "UInt", 24, "Ptr", 0, "UPtr")
   , HBM := DllCall("CopyImage", "Ptr", HBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008, "UPtr")
   , DllCall("SetBitmapBits", "Ptr", HBM, "UInt", 4, "Ptr", &BMBITS)
   Return HBM
}

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], casperharkin, Gancito, Karrsen, Lorik, Paiter and 34 guests