habe mich mit dem Thema Tab-Control und grafische Umsetzung eines Seitenmenüs beschäftigt und möchte gerne folgendes Beispiel posten. Angeregt durch diverse GUI-Kreationen im engl. Forum, bzw. Anwendungen wie FireFox, Vivaldi ... habe ich ein paar ahk-controls zweckentfremdet. Kodierung ist UTF-8 mit der Segoe UI-Fontfamilie, wegen den Unicode-Symbolen im SideMenu-Text. Farb/Fontspielereien sind möglich mit eigenen Werten... viel Spaß!
Code: Select all
;SideMenu 2018-12-03 moefr01 ==================================================
;shows vertical menu on the left to switch tabarea
;==============================================================================
#NoEnv
#Persistent
#SingleInstance Force
SetBatchLines -1
SendMode Input
SetWorkingDir %A_ScriptDir%
OnMessage(0x200, "OnMouseMove") ;detect mousemove over control
ColorG = 444444 ;gui-backgroundcolor
ColorB = 696969 ;tab-backgroundcolor
ColorT = CCCCCC ;textcolor
ColorH = FF8000 ;hovercolor
Font = Segoe UI Semibold ;textfont
FontS = 12 ;fontsize
;GUI ==========================================================================
Gui, Color, %ColorG%
Gui, Font
Gui, Font, s%FontS%, %Font%
;sidebutton 1 =================================================================
Gui, Add, Progress, x10 y13 w120 h22 vRectH1 Background%ColorB% Disabled Hidden
Gui, Add, Progress, x10 y13 w120 h22 vRectC1 Background%ColorB% Disabled Hidden
Gui, Add, Text, x10 y11 w120 h22 0x200 c%ColorT% BackgroundTrans vBASIC gBASIC, ` BASIC
;sidebutton 2 =================================================================
Gui, Add, Progress, x10 y36 w120 h22 vRectH2 Background%ColorB% Disabled Hidden
Gui, Add, Progress, x10 y36 w120 h22 vRectC2 Background%ColorB% Disabled Hidden
Gui, Add, Text, x10 y34 w120 h22 0x200 c%ColorT% BackgroundTrans vSETTINGS gSETTINGS, ` SETTINGS
;sidebutton 3 =================================================================
Gui, Add, Progress, x10 y59 w120 h22 vRectH3 Background%ColorB% Disabled Hidden
Gui, Add, Progress, x10 y59 w120 h22 vRectC3 Background%ColorB% Disabled Hidden
Gui, Add, Text, x10 y57 w120 h22 0x200 c%ColorT% BackgroundTrans vVIEW gVIEW, ` VIEW
;tab-backgroundarea ===========================================================
Gui, Add, Progress, x131 y13 w392 h178 Disabled Background%ColorB%
Gui, Add, Pic, x105 y10 w26 h178 BackgroundTrans, schattenlinks.png
Gui, Add, Tab2, x131 y0 w0 h0 -Wrap vMyTab, Tab1|Tab2|Tab3
;TAB1 =========================================================================
Gui, Tab, Tab1
Gui, Add, Text, x140 y16 BackgroundTrans, BASIC ...................................................................... (TAB1)
Gui, Add, Pic, Icon161 x200 y100 w64 h64 BackgroundTrans, shell32.dll
Gui, Add, Pic, Icon161 x270 y100 w64 h64, shell32.dll
;TAB2 =========================================================================
Gui, Tab, Tab2
Gui, Add, Text, x140 y16 BackgroundTrans, SETTINGS .............................................................. (TAB2)
Gui, Font, s10
Gui, Add, Text, x140 y60 w350 h20 BackgroundTrans, ` This is an example text with a transparent background
Gui, Add, Text, x140 y90 w350 h20, ` This is an example text with backgroundcolor of the GUI
Gui, Add, Edit, x140 y120 w350 h20 -E0x200 hwndeditbox
DllCall("user32\SendMessage", "ptr", editbox, "uint", 0x1501, "int", 1, "str", "EditBox example...", "int")
Gui, Font, s%FontS%
;TAB3 =========================================================================
Gui, Tab, Tab3
Gui, Add, Text, x140 y16 BackgroundTrans, VIEW ...................................................................... (TAB3)
Gui, Font, s10
Gui, Add, Button, x420 y140 w80 h30 gExit, Exit
Gui, Font, s%FontS%
Gui, Show, x100 y100 w534 h204, SideMenu
WinSet, Redraw
Return
Exit:
ExitApp
BASIC:
GuiControl, Choose, MyTab, Tab1
GuiControl, Show, RectC1
GuiControl, Hide, RectC2
GuiControl, Hide, RectC3
Return
SETTINGS:
GuiControl, Choose, MyTab, Tab2
GuiControl, Show, RectC2
GuiControl, Hide, RectC1
GuiControl, Hide, RectC3
Return
VIEW:
GuiControl, Choose, MyTab, Tab3
GuiControl, Show, RectC3
GuiControl, Hide, RectC2
GuiControl, Hide, RectC1
Return
; hover query =================================================================
OnMouseMove()
{
global
If (A_GuiControl = "BASIC")
{
If hoverexit1
Return
GuiControl, Show, RectH1
Gui, Font, c%ColorH%
GuiControl, Font, BASIC
hoverexit1 := True
} Else If hoverexit1 {
GuiControl, Hide, RectH1
Gui, Font, c%ColorT%
GuiControl, Font, BASIC
hoverexit1 := False
}
If (A_GuiControl = "SETTINGS")
{
If hoverexit2
Return
GuiControl, Show, RectH2
Gui, Font, c%ColorH%
GuiControl, Font, SETTINGS
hoverexit2 := True
} Else If hoverexit2 {
GuiControl, Hide, RectH2
Gui, Font, c%ColorT%
GuiControl, Font, SETTINGS
hoverexit2 := False
}
If (A_GuiControl = "VIEW")
{
If hoverexit3
Return
GuiControl, Show, RectH3
Gui, Font, c%ColorH%
GuiControl, Font, VIEW
hoverexit3 := True
} Else If hoverexit3 {
GuiControl, Hide, RectH3
Gui, Font, c%ColorT%
GuiControl, Font, VIEW
hoverexit3 := False
}
Return
}
; create shadow from hex-code =================================================
OnLoad() {
Static Init := OnLoad()
shadow := "89504E470D0A1A0A0000000D494844520000001A000000B208060000005C05DF4D0000000467"
. "414D410000B18F0BFC6105000000097048597300001D8600001D86015DA21381000000187445"
. "5874536F667477617265007061696E742E6E657420342E312E34134068C40000075D49444154"
. "785EED5CF973154510CE7B89378A8A31BEE4BDDD99DD7D2F31281EF1460DA880A5E57DE27DE3"
. "8565496979E185E085A2A82546E450041104EFFBBEFF2CBF9EEDDDB7EF88A5A67B7ECA573595"
. "AAEDAE7C35333D3DDD333DAF671AFF1125B43237351049EFE8E8E89ED56A759FF4930ECA6118"
. "EE8D76A0B57680BFA9A02F49920392A1A45A0FC3C3F99B384A20D9ABD1681C82DE34E2303C99"
. "BF8BA344F3120441C518735462CC42FE2E8EF2687FFF8C388E6BE8D109E8D185FC5D1C6E7E1A"
. "4160A35A746A14468BF9BB2CC6C6C6F6C0B01D1445511DBD991F85E10D2C124589D6CEC8C8C8"
. "2CB2369A9FC898252C1385B338F4E650B423306CE7C4C62C6599289CC561A11E861E1D0D920B"
. "E2D02E639928CA954A65DFE15A6D300EE2311BD84B30470FB24C14E5390303FBE5A66DCC1598"
. "A3E52C1345EFF0F0F0FE58A821798424B05763E89E6499287AF33514610D19733DDA4A96C961"
. "7C7CBC8F3C7652ABC530EDF124B437A147CFB1580EC5C51A05D11998A3DBA2C0AC66B118D2C5"
. "3A38380B73340C6358801EDD01B2352C178323A2ED21098251102C425B1A85762DCBC5E0BC02"
. "5A7FE615B086EE8531BCCE72319468FBA6AD1BEDC8C4DAF3626B97C118D6B15C0C1DEE07BD79"
. "004337C17231949AEE2738164377317AF310C8D6B35C0CCECFD5ABD521F27318BA4B41F4087A"
. "B691E56228C3EA66C018AA98A3E341407EEE310CDD66968BC1F939585C5037E64458DC62F273"
. "5168DE65B9185A1C2AB60872A82BD0AB2D2C17830B4A607506EE672E86EE3A90ACC4DFAD2C17"
. "431F866D663D0822CCD1691494C4C63E83397A9FE532C83D7792C498A3D32D7B6E106D671519"
. "90E72622ECAE09E6681EBCC22D207901C6B0835564D0758B30E645FCFD9055644044704107D3"
. "1601B2336D18628BB06BD076B18A0CB2BD08C33702AF407BD19D98A357226377B38A0CB2BD88"
. "22540CD722CCD1DD98A3B5681FB18A0CB2BD2809925118C3D9989F7B6008AFA17DC22A22C837"
. "3D58DDECE2A687DE7DCA3A22709B1E8CC0C5DC58B0E7627EEE03C91B3086CF5847049DBB2B62"
. "6EB47520FA9C754490EFAE944EA227E763D8EE8721BC09A22F58470479DEDABA8D9BB760DE5F"
. "B28E08DC363E02A2240C8F81315C445904C8D6A3575FB18E088AE94A162F3C8C9EBD8DBF5FB3"
. "8E08D278A15E77F1020C228F17E2D07CC33A22280F202FC23AAAC2BC8F83D55D86617B1486B0"
. "1164DFB28E085C024644E80D0526978368397AB5499CA8E510238D801E87216C46AFBE631D11"
. "38220C5B31027A0244EF80E87BD611415BA815E5A1960A11855A58472771A8F514866F0B16EC"
. "0FAC2382D698CEDA6B40B40273F51E887E641D11B82419BECE601D9D02826BD19BA7F1772BE6"
. "E927D611412FE6672611B5058FDBC489A8476D69FF2A18C2360CE1CFAC23823C4A75442E4A35"
. "2E4A55238221A4E170689F05D176F8BA5F5847048E08C3E7C26110DD08220A873F10278221B4"
. "C7DDCF33D1AFAC23024794C5DD58B037A7446607E64A8EA83DC007511EE08B13150E6CD34CC2"
. "98D520DA09A2DF586DEA68239A8F7F7E2B882893D0218269D3150111E5298B1A5121377A8988"
. "E0547F67B5A983882837CA8840B204EE07B991D9A54294256158B0B7A7449688FE60B5A9A39D"
. "A898EDA91161F8CE7244A17D1924BB95895C5A9911FDC96A53071165F92B88163091CB5FD588"
. "2851860BBACB11217F15256AC9C88D5998F7488B28BB33A21E81C465E4E2448D4AC5A5FE4414"
. "0779EAFFB10A119D777B21F2D3A3E2A9895F22F3AA230AED5FAC36756444F99D843E51D2BCFC"
. "30E93990381142ADF4C0C90F51E13A679AE8DF609AE87F8388BCAD23CF4485A1D374417E9C6A"
. "713F6A1EAE2B6F7CDE889AC1892E51210AF246A41740B684C4D2441D21B176A4AA1EE413D160"
. "9388D296627E243B74DE13317F396CD041A49DFEBB730679226F071A5D88F48E680A874E2991"
. "F4E916DDFC1788E6E19FD3E996FC315A5662A07E30582482F71E0791CE5127901FDE3AA2E2E1"
. "AD3411E6A7DB71B4CEB9B7B703F6D6C216A3726550BC04990BD356BB04C9EF8FE019F4AF7588"
. "A8E3A24AFA46CCDBD55BCB656268AF0291CA6562D9D7F5A8ABAD6B12E95DF8FABBC2FE874B79"
. "59A2629901C8F4CA0C26299CD8005F275B38E1AB14C45B71CB24E53A76020B56B65C077E8E9E"
. "01B517204DC020640B90880846A05F524544306DFD2231AC21F70204DE61368C41ADECCD5B21"
. "5F9A99F3318D3B6B281C6AB08A0C8A792C25CC6AC5962D39529EF519978CB18A0C8A19455BEA"
. "B293556440441836FD125FA05BF1847CD132E0A2D5BC9246AB0C1B982C88142F2C6F8DED144B"
. "E5E9B568974848BEF8BF3D4071CF1940B689E5627044EE8146DCF2406303CBC5D02D6E507972"
. "D25EE6ABF7880624D92E3B27DF65B1F9B15C0C93D67CB35C0CDE9E6EE57B12E6C83D4673479E"
. "0A8FD1BA6F150ACFEBFC3D1804BAD542CA3F81045A1CABE6A34E97F9B1BF537DA65A7443AA0F"
. "6FDB837DB5A7C4FE1E47BB45EBE1B977C7893105292C1247732D214801D195FC5D1C79D9BC33"
. "71C51F19C8F359B23C9A27FE2E0E6779B45DA047AA3F044170AF14EBD5FA10591F7F5381B71F"
. "EBF0F6F3230422CB7E54651AD3F08A9E9EBF017B3F2AA104EDB0200000000049454E44AE4260"
. "82"
FileWriteHex(shadow, "shadow.png")
}
FileWriteHex(Input, Output) {
File := FileOpen(Output, "w")
Loop, % StrLen(Input) // 2 {
File.WriteUChar("0x" . SubStr(Input, (2 * A_Index) - 1, 2))
}
File.Close()
FileDelete, shadow.png
}
moefr01