Created
October 4, 2024 09:58
-
-
Save jNizM/28776c1c97f966c72658e63fdc0f6e7d to your computer and use it in GitHub Desktop.
ahk example gui with left slider menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
UseGDIP() | |
IBStyles := Map() | |
IBStyles["slider"] := [ [0xFF1F1F1F,, 0xFFF7F7F7, 0, 0xFF1F1F1F, 1] ; normal | |
, [0x803C3C3C,, 0xFFF7F7F7, 0, 0x803C3C3C, 1] ; hover | |
, [0x8075768F,, 0xFFF7F7F7, 0, 0x8075768F, 1] ; pressed | |
, [0x806265A2,, 0xFFF7F7F7, 0, 0x806265A2, 1] ] ; disabled (default) | |
Main := Gui() | |
Main.MarginX := 0 | |
Main.MarginY := 0 | |
Main.BackColor := "F7F7F7" | |
Main.SetFont("s11 w400", "Segoe UI") | |
CreateImageButton("SetDefGuiColor", 0xFF1F1F1F) | |
PIC1 := Main.AddPicture("xm ym w150 h390 0x4E") | |
CreateGradient(PIC1.Hwnd, ["0x1F1F1F", "0x1F1F1F"]*) | |
Btn01 := Main.AddButton("xm ym w150 h32 0x100", " Menu 1") | |
Btn01.OnEvent("Click", Button_Click) | |
Btn01.Enabled := false | |
CreateImageButton(Btn01, 0, IBStyles["slider"]*) | |
Btn02 := Main.AddButton("xm y+0 w150 h32 0x100", " Menu 2") | |
Btn02.OnEvent("Click", Button_Click) | |
CreateImageButton(Btn02, 0, IBStyles["slider"]*) | |
Main.AddText("xm ym+355 w150 h1 Background5A5A5A") | |
Main.AddText("xm y+1 w150 h34 0x201 Background1F1F1F", "v1.0.1").SetFont("s10 cE6E6E6") | |
MainTab := Main.AddTab2("xp yp w0 h0 -Wrap Choose1", ["1", "2", "3", "4"]) | |
MainTab.UseTab() | |
MainTab.UseTab("1") | |
Main.SetFont("s13 w400", "Segoe UI") | |
Main.AddText("xm+155 ym w500 h32 0x200", " Menu 1") | |
Main.AddText("xm+155 ym+32 w502 h1 BackgroundD8D8D8") | |
Main.AddText("x+0 yp w5 h1 BackgroundF7F7F7") | |
Main.SetFont("s10 w400", "Segoe UI") | |
Main.AddListbox("xm+155 ym+40 w120 r20", ["a", "b", "c"]) | |
Main.AddEdit("xm+280 ym+39 w375 h345 0x800", "a`nb") | |
MainTab.UseTab("2") | |
Main.SetFont("s13 w400", "Segoe UI") | |
Main.AddText("xm+155 ym w500 h32 0x200", " Menu 2") | |
Main.AddText("xp y+0 w502 h1 Section BackgroundD8D8D8") | |
Main.OnEvent("Close", (*) => ExitApp) | |
SystemParametersInfo(False) | |
Main.Show("AutoSize") | |
;GuiDisableCloseButton(Main.Hwnd) | |
SystemParametersInfo(True) | |
Button_Click(GuiCtrlObj, *) | |
{ | |
switch GuiCtrlObj.Text | |
{ | |
case " Menu 1": | |
{ | |
Btn01.Enabled := false | |
Btn02.Enabled := true | |
MainTab.Choose(1) | |
} | |
case " Menu 2": | |
{ | |
Btn01.Enabled := true | |
Btn02.Enabled := false | |
MainTab.Choose(2) | |
} | |
default: | |
MsgBox False | |
} | |
} | |
SystemParametersInfo(bool := 0) | |
{ | |
static SPI_SETCLIENTAREAANIMATION := 0x1043 | |
if !(DllCall("user32\SystemParametersInfo", "UInt", SPI_SETCLIENTAREAANIMATION, "UInt", 0, "Int", bool, "UInt", 0)) | |
throw OSError() | |
return true | |
} | |
GuiDisableCloseButton(Handle) | |
{ | |
static SC_CLOSE := 0xF060 | |
static MF_GRAYED := 0x00000001 | |
static MF_DISABLED := 0x00000002 | |
hMenu := DllCall("user32\GetSystemMenu", "Ptr", Handle, "Int", False, "Ptr") | |
DllCall("user32\EnableMenuItem", "Ptr", hMenu, "UInt", SC_CLOSE, "UInt", MF_GRAYED | MF_DISABLED) | |
return DllCall("user32\DrawMenuBar", "Ptr", Handle) | |
} | |
#Include ..\_libs\UseGDIP.ahk | |
#Include ..\_libs\CreateImageButton.ahk | |
#Include ..\_libs\CreateGradient.ahk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment