Gui control alignment is difficult to understand

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roysubs
Posts: 426
Joined: 29 Sep 2018, 16:37

Gui control alignment is difficult to understand

17 Nov 2018, 04:54

If someone could have a look at this code and advise me, I just don't know how to get things to align properly. Would really appreciate some help on this. This is fully running code (will also run from CodeQuickTester to see the questions) and I'm just having a real problem getting alignment with the width of the box, and with how it places text hiking it up on lines if I change the font size etc. I don't see how these placements are useful or logical. Just putting the full code so that it's all self-explanatory in the code, hoping this is really simple for someone that uses the Gui controls a lot.

In the below I say that w1000 does fit well with the window, and that's right, but is there a way to control the absolute width of the window itself, so that I can say, set the absolute width to 1000, and then set text to wrap inside w980 then I always guarantee a good fit?

(Also, when I select this code and pull down the "Select code" option in the phpBB interface, AutoHotkey is no longer listed so I can't highlight this code. Any idea why that is?)

CustomMsgBoxHeader("", "Black")
CustomMsgBoxLine("w800", "First line, all single font, can be long, and will wrap around when the line gets too long, use same parameter order as the Gui control itself to avoid confusion... Weirdly, although I set w800, the wrap around point is much shorter than the width of the message box, does anyone know how to get this to work logically? If I remove the w800, the window is wider than the screen and goes off screen with all text on a single line!?!? If I set w1000, the fit is good, but I don't understand how to control dialogue width vs wXXX, it's really unclear`n`n", "cWhite s10", "Verdana") ; Since black background, have to set white in first line
CustomMsgBoxLineWithTitle("x10", "Title Text A", "cRed s20 Bold", "Verdana", "x+10 w800", "Use a smaller font but the text is hiked up and not in line with start of the line!? Quite ugly.", "cWhite s9 Normal", "")
CustomMsgBoxLineWithTitle("x10", "Title Text B", "cRed s20 Bold", "Tahoma", "x+50", "Same with this line", "cWhite s15 Normal", "")
CustomMsgBoxLine("x10", "not working well ...", "cWhite s9 Normal", "Verdana")
CustomMsgBoxFooter("War of the Ring AutoHelper")
ExitApp

; Based on
; https://autohotkey.com/board/topic/9327 ... ul-msgboxs
; unlike the original dialogue, I changed the ordering to match how the Gui control receives values, i.e. options, text, fontoptions, font

CustomMsgBoxHeader(IcoFile="", WindowColor="") ; Set icon and color, put icon before destroy or it won't pick up
{
Menu, Tray, Icon, %IcoFile%, 1, 1
Gui, 66:Destroy
Gui, 66:Color, %WindowColor%
}

CustomMsgBoxLine(MsgOptions1="", Msg1="", FontOptions1="", Font1="") ;
{
Gui, 66:Font, %FontOptions1%, %Font1%
Gui, 66:Add, Text, %MsgOptions1%, %Msg1%
}

CustomMsgBoxLineWithTitle(MsgOptions1="", Msg1="", FontOptions1="", Font1="", MsgOptions2="", Msg2="", FontOptions2="", Font2="")
{
Gui, 66:Font, %FontOptions1%, %Font1%
Gui, 66:Add, Text, %MsgOptions1%, %Msg1%
Gui, 66:Font, %FontOptions2%, %Font2%
Gui, 66:Add, Text, %MsgOptions2%, %Msg2%
}

CustomMsgBoxFooter(Title="")
{
GuiControlGet, Text, 66:Pos, Static1
Gui, 66:Add, Button, % "Default y+10 w75 g66OK xp+" (TextW / 2) - 38, OK
Gui, 66:-MinimizeBox
Gui, 66:-MaximizeBox

; SoundPlay, *-1
Gui, 66:Show , , %Title%
Gui, 66:+LastFound
WinWaitClose
Gui, 66:Destroy
return
}

66OK:
Gui,66:Destroy
return
roysubs
Posts: 426
Joined: 29 Sep 2018, 16:37

Re: Gui control alignment is difficult to understand

17 Nov 2018, 08:03

I thought this might be a really easy question to answer, but if I'm asking this question in the wrong way, please let me know?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, nacken012, septrinus and 223 guests