SideMenu - Menüvariante mit TAB2-control

Veröffentliche deine funktionierenden Skripte und Funktionen

Moderator: jNizM

User avatar
moefr01
Posts: 115
Joined: 25 Nov 2015, 09:01
Location: Germany

SideMenu - Menüvariante mit TAB2-control

03 Dec 2018, 09:52

Liebe AHKler ;) ,

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
}
Über Code-Optimierungen/konstruktive Kritik würde ich mich sehr freuen.
:wave: moefr01
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: SideMenu - Menüvariante mit TAB2-control

03 Dec 2018, 10:18

Sehr gut gemacht! :+1: :bravo:

Wenn ich die Zeile mit FileDelete bewege, und GuiClose mit einbaue,

Code: Select all

Exit:
GuiClose:
  FileDelete, schattenlinks.png
ExitApp
dann brauchts am ende noch

Code: Select all

FileWriteHex(shadow, "schattenlinks.png")
und alles klappt.

Ich konnte den schatten links erst mal nicht sehen, und beim schließen des fensters lief das script weiter.

Hervorragende Arbeit! Danke fürs Teilen.
User avatar
moefr01
Posts: 115
Joined: 25 Nov 2015, 09:01
Location: Germany

Re: SideMenu - Menüvariante mit TAB2-control

03 Dec 2018, 13:05

Danke wolf_II ...das mit dem GuiClose war mir bewusst, ich wollte ein paar Zeilen sparen und die Schließmethode über den TAB3-ExitButton als Bsp. veranschaulichen.
Sorry, das mit dem Schatten war ein Schnellschuss :crazy: .... hier nun der korrigierte code:

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
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, shadow.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:
GuiClose:
FileDelete, shadow.png
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()
}
Vielleicht findet sich ja jemand, der eine Funktion/Klasse daraus bastelt :think:
User avatar
Frosti
Posts: 426
Joined: 27 Oct 2017, 14:30
Contact:

Re: SideMenu - Menüvariante mit TAB2-control

03 Dec 2018, 15:47

Wie wäre es die png Datei nicht als Datei zunächst auf die Festplatte zu speichern? Dafür gibt es doch dieses Skript Image2Include.ahk glaube ich. Ansonsten finde ich Dein Skript sehr angenehm zu lesen, weil Du alles konsequent eingerückt hast.
User avatar
moefr01
Posts: 115
Joined: 25 Nov 2015, 09:01
Location: Germany

Re: SideMenu - Menüvariante mit TAB2-control

04 Dec 2018, 08:39

Danke Frosti für die Blumen und den Tipp mit dem embedded png ;)
Habe den code s.u. entsprechend angepasst...
Danke Laszlo für MCode() und SKAN für den png-converter :thumbup: :thumbup:

Code: Select all

;SideMenu 2018-12-04 moefr01 ==================================================
;shows vertical menu on the left to switch tabarea with embedded png (shadow)
;Thanks to SKAN for https://autohotkey.com/board/topic/21213-how-to-convert-image-data-jpegpnggif-to-hbitmap/page-2#entry139257
;Thanks to Laszlo for http://www.autohotkey.com/forum/viewtopic.php?p=135302#135302
;==============================================================================
#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
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 h175 Disabled Background%ColorB%
shadow =
(Join
89504E470D0A1A0A0000000D494844520000001A000000B208060000005C
05DF4D0000000467414D410000B18F0BFC6105000000097048597300001D
8600001D86015DA213810000001874455874536F66747761726500706169
6E742E6E657420342E312E34134068C40000075D49444154785EED5CF973
154510CE7B89378A8A31BEE4BDDD99DD7D2F31281EF1460DA880A5E57DE2
7DE38565496979E185E085A2A82546E450041104EFFBBEFF2CBF9EEDDDB7
EF88A5A67B7ECA573595AAEDAE7C35333D3DDD333DAF671AFF1125B43237
351049EFE8E8E89ED56A759FF4930ECA6118EE8D76A0B57680BFA9A02F49
920392A1A45A0FC3C3F99B384A20D9ABD1681C82DE34E2303C99BF8BA344
F3120441C518735462CC42FE2E8EF2687FFF8C388E6BE8D109E8D185FC5D
1C6E7E1A4160A35A746A14468BF9BB2CC6C6C6F6C0B01D1445511DBD991F
85E10D2C124589D6CEC8C8C82CB2369A9FC898252C1385B338F4E650B423
306CE7C4C62C6599289CC561A11E861E1D0D920BE2D02E639928CA954A65
DFE15A6D300EE2311BD84B30470FB24C14E5390303FBE5A66DCC1598A3E5
2C1345EFF0F0F0FE58A821798424B05763E89E6499287AF33514610D1973
3DDA4A96C9617C7CBC8F3C7652ABC530EDF124B437A147CFB1580EC5C51A
05D11998A3DBA2C0AC66B118D2C53A38380B73340C6358801EDD01B2352C
178323A2ED21098251102C425B1A85762DCBC5E0BC025A7FE615B086EE85
31BCCE72319468FBA6AD1BEDC8C4DAF3626B97C118D6B15C0C1DEE07BD79
004337C17231949AEE2738164377317AF310C8D6B35C0CCECFD5ABD521F2
7318BA4B41F4087AB691E56228C3EA66C018AA98A3E341407EEE310CDD66
968BC1F939585C5037E64458DC62F2735168DE65B9185A1C2AB60872A82B
D0AB2D2C17830B4A607506EE672E86EE3A90ACC4DFAD2C17431F866D663D
0822CCD1691494C4C63E83397A9FE532C83D7792C498A3D32D7B6E106D67
151990E72622ECAE09E6681EBCC22D207901C6B0835564D0758B30E645FC
FD9055644044704107D31601B2336D18628BB06BD076B18A0CB2BD08C337
02AF407BD19D98A357226377B38A0CB2BD8822540CD722CCD1DD98A3B568
1FB18A0CB2BD2809925118C3D9989F7B6008AFA17DC22A22C8373D58DDEC
E2A687DE7DCA3A22709B1E8CC0C5DC58B0E7627EEE03C91B3086CF584704
9DBB2B626EB47520FA9C754490EFAE944EA227E763D8EE8721BC09A22F58
470479DEDABA8D9BB760DE5FB28E08DC363E02A2240C8F81315C445904C8
D6A3575FB18E088AE94A162F3C8C9EBD8DBF5FB38E08D278A15E77F1020C
228F17E2D07CC33A22280F202FC23AAAC2BC8F83D55D86617B1486B01164
DFB28E085C024644E80D0526978368397AB5499CA8E510238D801E87216C
46AFBE631D1138220C5B31027A0244EF80E87BD611415BA815E5A1960A11
855A58472771A8F514866F0B16EC0FAC2382D698CEDA6B40B40273F51E88
7E641D11B82419BECE601D9D02826BD19BA7F1772BE6E927D611412FE667
2611B5058FDBC489A8476D69FF2A18C2360CE1CFAC23823C4A75442E4A35
2E4A55238221A4E170689F05D176F8BA5F5847048E08C3E7C26110DD0822
0A873F10278221B4C7DDCF33D1AFAC23024794C5DD58B037A7446607E64A
8EA83DC007511EE08B13150E6CD34CC298D520DA09A2DF586DEA68239A8F
7F7E2B882893D0218269D3150111E5298B1A5121377A8988E0547F67B5A9
83882837CA8840B204EE07B991D9A54294256158B0B7A7449688FE60B5A9
A39DA898EDA91161F8CE7244A17D1924BB95895C5A9911FDC96A53071165
F92B88163091CB5FD5882851860BBACB11217F15256AC9C88D5998F7488B
28BB33A21E81C465E4E2448D4AC5A5FE44140779EAFFB10A119D777B21F2
D3A3E2A9895F22F3AA230AED5FAC36756444F99D843E51D2BCFC30E93990
381142ADF4C0C90F51E13A679AE8DF609AE87F8388BCAD23CF4485A1D374
417E9C6A713F6A1EAE2B6F7CDE889AC1892E51210AF246A41740B684C4D2
441D21B176A4AA1EE413D1609388D296627E243B74DE13317F396CD041A4
9DFEBB730679226F071A5D88F48E680A874E2991F4E916DDFC1788E6E19F
D3E996FC315A5662A07E30582482F71E0791CE5127901FDE3AA2E2E1AD34
11E6A7DB71B4CEB9B7B703F6D6C216A3726550BC04990BD356BB04C9EF8F
E019F4AF7588A8E3A24AFA46CCDBD55BCB656268AF0291CA6562D9D7F5A8
ABAD6B12E95DF8FABBC2FE874B7959A2629901C8F4CA0C26299CD8005F27
5B38E1AB14C45B71CB24E53A76020B56B65C077E8E9E01B517204DC02064
0B90880846A05F524544306DFD2231AC21F70204DE61368C41ADECCD5B21
5F9A99F3318D3B6B281C6AB08A0C8A792C25CC6AC5962D39529EF519978C
B18A0C8A19455BEAB293556440441836FD125FA05BF1847CD132E0A2D5BC
9246AB0C1B982C88142F2C6F8DED144BE5E9B568974848BEF8BF3D4071CF
1940B689E5627044EE8146DCF2406303CBC5D02D6E507972D25EE6ABF788
0624D92E3B27DF65B1F9B15C0C93D67CB35C0CDE9E6EE57B12E6C83D4673
479E0A8FD1BA6F150ACFEBFC3D1804BAD542CA3F81045A1CABE6A34E97F9
B1BF537DA65A7443AA0F6FDB837DB5A7C4FE1E47BB45EBE1B977C7893105
292C1247732D214801D195FC5D1C79D9BC3371C51F19C8F359B23C9A27FE
2E0E6779B45DA047AA3F044170AF14EBD5FA10591F7F5381B71FEBF0F6F3
230422CB7E54651AD3F08A9E9EBF017B3F2AA104EDB0200000000049454E
44AE426082
)
; Laszlo's MCode() ============================================================
nSize := StrLen(shadow) // 2
VarSetCapacity(Buffer, nSize)
Loop % nSize
  NumPut("0x" . SubStr(shadow, 2 * A_Index - 1, 2), Buffer, A_Index-1, "Char")
hData := DllCall("GlobalAlloc", UInt,2, UInt, nSize)
pData := DllCall("GlobalLock",  UInt,hData)
DllCall("RtlMoveMemory", UInt, pData, UInt, &Buffer, UInt,nSize)
DllCall("GlobalUnlock", UInt, hData)
DllCall("ole32\CreateStreamOnHGlobal", UInt, hData, Int, True, UIntP, pStream)
DllCall("LoadLibrary", Str,"gdiplus")
VarSetCapacity(si, 16, 0), si := Chr(1)
DllCall("gdiplus\GdiplusStartup", UIntP, pToken, UInt, &si, UInt, 0)
DllCall("gdiplus\GdipCreateBitmapFromStream", UInt, pStream, UIntP, pBitmap)
DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", UInt, pBitmap, UIntP, hBitmap, UInt, 0)
Gui, Add, Text,     x105 y10 w26 h178 +0xE BackgroundTrans hWndPic1            ; +0xE is SS_BITMAP
SendMessage, (STM_SETIMAGE:=0x172), (IMAGE_BITMAP:=0x0), hBitmap, , ahk_id %Pic1%
DllCall("gdiplus\GdipDisposeImage", UInt, pBitmap)
DllCall("gdiplus\GdiplusShutdown", UInt, pToken)
DllCall(NumGet(NumGet(1*pStream)+8), UInt, pStream)
; =============================================================================
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 h200, SideMenu
WinSet, Redraw
Return
;Exit =========================================================================
Exit:
GuiClose:
ExitApp
;Basic-Click ==================================================================
BASIC:
GuiControl, Choose, MyTab, Tab1
GuiControl, Show,   RectC1
GuiControl, Hide,   RectC2
GuiControl, Hide,   RectC3
Return
;SETTINGS-Click ===============================================================
SETTINGS:
GuiControl, Choose, MyTab, Tab2
GuiControl, Show,   RectC2
GuiControl, Hide,   RectC1
GuiControl, Hide,   RectC3
Return
;VIEW-Click ===================================================================
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
}
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: SideMenu - Menüvariante mit TAB2-control

04 Dec 2018, 09:28

Das wird entweder auf AHK 64 bit oder 32 bit nicht funktionieren.
MCode mit Lazlos Funktion kann immer nur eine Zielbitzahl ansprechen es sei denn du verwendest die Funktion mehrmals und wählst mit einem if aus welche Version verwendet werden soll.
Recommends AHK Studio
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: SideMenu - Menüvariante mit TAB2-control

04 Dec 2018, 12:03

Hat da jemand "Klasse" gesagt?

Code: Select all

#NoEnv
#SingleInstance Force
SetWorkingDir, %A_ScriptDir%
SetControlDelay, -1
SetBatchLines, -1

    Test := new SideMenu
    Test.AddTab("  BASIC")
    Test.AddTab("  SETTINGS")
    Test.AddTab("  VIEW")
    Test.Show(200, 50)

return ; end of auto-execute section

GuiClose:
ExitApp



;===============================================================================
class SideMenu { ; shows vertical menu on the left to switch tabarea
;===============================================================================

    ;{ class variables
    static Font := "Segoe UI Semibold"  ; font name
    static FontSize := 12               ; font size
    static ColorGui := "444444"         ; gui color background
    static ColorTab := "696969"         ; tab color background
    static ColorTxt := "CCCCCC"         ; text color
    static ColorHov := "FF8000"         ; hover color
    static TButtons := []               ; store all the Buttons
    static TButtonx := []               ;} cross over fast access

    __New() { ; SideMenu GUI
        Gui, SideMenu: New, LabelGui, SideMenu
        Gui, Color, % this.ColorGui
        Gui, Font, % "s" this.FontSize, % this.Font
        Gui, Add, Progress, % "x131 y13 w392 h178 Background" this.ColorTab
        Gui, Add, Tab2, x131 y0 w0 h0, 1|2|3
        Gui, Tab ; reset needed

        OnMessage(0x200, this.WM_MOUSEMOVE.Bind(this))
    }

    AddTab(Caption) { ; populate GUI with 'fake' Buttons and tabs
        static n := 0
        y := 23 * ++n - 10

        ; side button
        Gui, Add, Progress, % "x10 w120 h22 y" y " HWNDhProg Hidden Disabled"
            . " c" this.ColorGui " Background" this.ColorTab
        Gui, Add, Text, % "x10 w120 h22 0x200 y" y " HWNDhText"
            . " c" this.ColorTxt " BackgroundTrans", %Caption%
        this.TButtons[n] := {hProg: hProg, hText: hText, Caption: Caption}
        this.TButtonx[hText] := n
        Txt_onClick := this.SwitchTab.Bind(this)
        GuiControl, +g, %hText%, % Txt_onClick

        ; tab
        Gui, Tab, %n%
        Gui, Add, Text, x140 y16 BackgroundTrans, %Caption% ....................
        Gui, Tab ; reset needed
    }

    SwitchTab(hWnd) { ; 'fake' buttons come here
        n := this.TButtonx[hWnd]
        GuiControl, Choose, SysTabControl321, %n%

        for i, Btn in this.TButtons {
            act := Btn.Active := (i = n) ; set state
            GuiControl, % act ? "Show" : "Hide", % Btn.hProg
            GuiControl,, % Btn.hText, % Btn.Caption
        }
    }

    Show(x, y) { ; Tada
        this.SwitchTab(this.TButtons[1].hText)
        Gui, Add, Pic, x105 y10 w26 h178 BackgroundTrans, shadow.png
        Gui, Show, x%x% y%y%
    }

    WM_MOUSEMOVE() { ; mouse_move events
        static prev_Hover := ""

        _Ctrl := _hWnd := 0
        MouseGetPos,,,, _Ctrl
        GuiControlGet, _hWnd, hWnd, %_Ctrl%

        if (Hover := this.TButtonx[_hWnd]) != prev_Hover {
            prev_Hover := Hover
            for i, Btn in this.TButtons {
                showMe := (Btn.Active || i = Hover) ? "Show" : "Hide"
                GuiControl, %showMe% , % Btn.hProg
                Gui, Font, % "c" ((i = Hover) ? this.ColorHov : this.ColorTxt)
                GuiControl, Font, % Btn.hText
            }
        }
    }

} ; end of class
User avatar
moefr01
Posts: 115
Joined: 25 Nov 2015, 09:01
Location: Germany

Re: SideMenu - Menüvariante mit TAB2-control

05 Dec 2018, 11:57

echt klasse die Klasse :clap: ... danke wolf_II.
Mir ist aufgefallen, dass sich der ButtonText beim hovern und bei dem markierten Button immer grauselig darstellt, also habe ich folgendes hinzugefügt (siehe >>>>):

Code: Select all

....
        if (Hover := this.TButtonx[_hWnd]) != prev_Hover {
            prev_Hover := Hover
            for i, Btn in this.TButtons {
 >>>>        GuiControl, -Redraw, % Btn.hProg
                showMe := (Btn.Active || i = Hover) ? "Show" : "Hide"
 >>>>        GuiControl, +Redraw, % Btn.hProg
                GuiControl, %showMe% , % Btn.hProg
                Gui, Font, % "c" ((i = Hover) ? this.ColorHov : this.ColorTxt)
                GuiControl, Font, % Btn.hText
....
... aber jetzt flackerst beim hovern der Buttons. Hast Du 'ne Idee das zu verhindern? :?:
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: SideMenu - Menüvariante mit TAB2-control

05 Dec 2018, 13:37

Hier versuch ich die currentColor zu speichern, und mit der neuen zu vergleichen.
Sinnvoll wäre es, auch die Farben zu initialisieren, AHK vergibt an dieser stelle und erlaubt on-the-fly Erweiterung des Objektes.

Code: Select all

        if (Hover := this.TButtonx[_hWnd]) != prev_Hover {
            prev_Hover := Hover
            for i, Btn in this.TButtons {
                showMe := (Btn.Active || i = Hover) ? "Show" : "Hide"
                GuiControl, %showMe% , % Btn.hProg
                Color := (i = Hover) ? this.ColorHov : this.ColorTxt
                if (Btn.Color != Color) {
                    Gui, Font, % "c" Btn.Color := Color
                    GuiControl, Font, % Btn.hText
                    GuiControl,, % Btn.hText, % Btn.Caption
                }
            }
        }
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: SideMenu - Menüvariante mit TAB2-control

05 Dec 2018, 14:26

Zusatz: Ich hab keine Ahnung wo das grauselige herkommt. Ich denke mir, daß womöglich wiederholte Anwendung von GuiControl, Font der Grund sein könnte. Wenn das stimmt, überschreibt die letzte Zeile im innersten If den Text, und es sollte der Effekt des doppelten Font verschwinden.
Meine Theorie werde ich mal testen.

Es scheint auszureichen nur die letzte Zeile in innersten If zu nehmen. Den Krempel mit on-the-fly ... Farben ... , alles nicht nötig.

Code: Select all

            for i, Btn in this.TButtons {
                showMe := (Btn.Active || i = Hover) ? "Show" : "Hide"
                GuiControl, %showMe% , % Btn.hProg
                Gui, Font, % "c" ((i = Hover) ? this.ColorHov : this.ColorTxt)
                GuiControl, Font, % Btn.hText
                GuiControl,, % Btn.hText, % Btn.Caption ; <-- hier ???
            }
Erst mal mehr testen.
User avatar
moefr01
Posts: 115
Joined: 25 Nov 2015, 09:01
Location: Germany

Re: SideMenu - Menüvariante mit TAB2-control

06 Dec 2018, 12:32

mit +ReDraw in der Textvergabe hat das Flackern ein Ende ... :thumbup:

Code: Select all

...
GuiControl, +ReDraw, % Btn.hText, % Btn.Caption ; <-- hier ???
...
... aber der Buttontext aller Buttons erscheint etwas fetter bei Hoverbeginn :think: , bei Buttonklick wird der Buttontext wieder angenehm schlank.

Return to “Skripte und Funktionen”

Who is online

Users browsing this forum: No registered users and 34 guests