CreateImageButton() - 2024-01-01

Post your working scripts, libraries and tools.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

CreateImageButton() - 2024-01-01

03 Aug 2021, 04:43

Update on 2024-01-01:
  • Changed default color options:
    Gui.Backcolor is used for the background if set, otherwise AHK's Gui default color.
    You can call SetDefGuiColor() and/or SetDefTxtColor() to change the defaults.
    *INIT* has been replaced with *DEF*.
  • Updated sample script.
Update on 2023-07-10:
  • Updated the sample script to meet the requirements of the latest version of the function.
Update on 2023-02-03:
Released v 1.0.00:
  • Added modes 8 and 9 for LinearGradientModeForwardDiagonal and LinearGradientModeBackwardDiagonal. (@jNizM)
  • Added underlined accelerators in the caption. (@robodesign)
  • Other minor changes related to AHK v2 function calls.

Hi,

this is the v2 version of [Class] ImageButton. It's my first attempt to port one of my scripts to v2 beta. I didn't expect to need so much effort, but finally it seems to work. The new 'simplified' AHK object concepts are just annoying compared to v1, but that might be caused by my lack of real OOP knowledge. On the other hand I found that nested functions can be used to replace classes like ImageButton with functions. So I come up with a function to show how it can be done in v2.

I also struggled with porting my UseGDIP() function. It isn't possible to realize an automatic function call with static initializers any more. On the other hand #DllLoad was added to preload Dll files. So I finally came up with this version which must be called once manually
UseGDIP()


So here comes the new function
CreateImageButton()


followed by a short 'how to use' sample
Sample script


Everybody feel free take the code to create own versions.

Have fun!
Last edited by just me on 01 Jan 2024, 06:22, edited 4 times in total.
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

03 Aug 2021, 05:04

thanks, will def be useful if we try to figure out how to convert old scripts

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

03 Aug 2021, 05:57

Very cool :D

Glad to see ya on the v2 forums @just me.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

03 Aug 2021, 06:47

Bootstrap Buttons
Image

Code: Select all

; ===============================================================================================================================

IBStyles := Map()

IBStyles["info"]                   := [[0x80C6E9F4,,, 0, 0x8046B8DA, 1], [0x8086D0E7,,, 0, 0x8046B8DA, 1], [0x8046B8DA,,, 0, 0x8046B8DA, 1], [0xFFF0F0F0,,, 0, 0x8046B8DA, 1]]
IBStyles["success"]                := [[0x80C6E6C6,,, 0, 0x805CB85C, 1], [0x8091CF91,,, 0, 0x805CB85C, 1], [0x805CB85C,,, 0, 0x805CB85C, 1], [0xFFF0F0F0,,, 0, 0x805CB85C, 1]]
IBStyles["warning"]                := [[0x80FCEFDC,,, 0, 0x80F0AD4E, 1], [0x80F6CE95,,, 0, 0x80F0AD4E, 1], [0x80F0AD4E,,, 0, 0x80F0AD4E, 1], [0xFFF0F0F0,,, 0, 0x80F0AD4E, 1]]
IBStyles["critical"]               := [[0x80F0B9B8,,, 0, 0x80D43F3A, 1], [0x80E27C79,,, 0, 0x80D43F3A, 1], [0x80D43F3A,,, 0, 0x80D43F3A, 1], [0xFFF0F0F0,,, 0, 0x80D43F3A, 1]]

IBStyles["info-outline"]           := [[0xFFF0F0F0,,, 0, 0x8046B8DA, 1], [0x80C6E9F4,,, 0, 0x8046B8DA, 1], [0x8086D0E7,,, 0, 0x8046B8DA, 1], [0xFFF0F0F0,,, 0, 0x8046B8DA, 1]]
IBStyles["success-outline"]        := [[0xFFF0F0F0,,, 0, 0x805CB85C, 1], [0x80C6E6C6,,, 0, 0x805CB85C, 1], [0x8091CF91,,, 0, 0x805CB85C, 1], [0xFFF0F0F0,,, 0, 0x805CB85C, 1]]
IBStyles["warning-outline"]        := [[0xFFF0F0F0,,, 0, 0x80F0AD4E, 1], [0x80FCEFDC,,, 0, 0x80F0AD4E, 1], [0x80F6CE95,,, 0, 0x80F0AD4E, 1], [0xFFF0F0F0,,, 0, 0x80F0AD4E, 1]]
IBStyles["critical-outline"]       := [[0xFFF0F0F0,,, 0, 0x80D43F3A, 1], [0x80F0B9B8,,, 0, 0x80D43F3A, 1], [0x80E27C79,,, 0, 0x80D43F3A, 1], [0xFFF0F0F0,,, 0, 0x80D43F3A, 1]]

IBStyles["info-round"]             := [[0x80C6E9F4,,, 8, 0x8046B8DA, 1], [0x8086D0E7,,, 8, 0x8046B8DA, 1], [0x8046B8DA,,, 8, 0x8046B8DA, 1], [0xFFF0F0F0,,, 8, 0x8046B8DA, 1]]
IBStyles["success-round"]          := [[0x80C6E6C6,,, 8, 0x805CB85C, 1], [0x8091CF91,,, 8, 0x805CB85C, 1], [0x805CB85C,,, 8, 0x805CB85C, 1], [0xFFF0F0F0,,, 8, 0x805CB85C, 1]]
IBStyles["warning-round"]          := [[0x80FCEFDC,,, 8, 0x80F0AD4E, 1], [0x80F6CE95,,, 8, 0x80F0AD4E, 1], [0x80F0AD4E,,, 8, 0x80F0AD4E, 1], [0xFFF0F0F0,,, 8, 0x80F0AD4E, 1]]
IBStyles["critical-round"]         := [[0x80F0B9B8,,, 8, 0x80D43F3A, 1], [0x80E27C79,,, 8, 0x80D43F3A, 1], [0x80D43F3A,,, 8, 0x80D43F3A, 1], [0xFFF0F0F0,,, 8, 0x80D43F3A, 1]]

IBStyles["info-outline-round"]     := [[0xFFF0F0F0,,, 8, 0x8046B8DA, 1], [0x80C6E9F4,,, 8, 0x8046B8DA, 1], [0x8086D0E7,,, 8, 0x8046B8DA, 1], [0xFFF0F0F0,,, 8, 0x8046B8DA, 1]]
IBStyles["success-outline-round"]  := [[0xFFF0F0F0,,, 8, 0x805CB85C, 1], [0x80C6E6C6,,, 8, 0x805CB85C, 1], [0x8091CF91,,, 8, 0x805CB85C, 1], [0xFFF0F0F0,,, 8, 0x805CB85C, 1]]
IBStyles["warning-outline-round"]  := [[0xFFF0F0F0,,, 8, 0x80F0AD4E, 1], [0x80FCEFDC,,, 8, 0x80F0AD4E, 1], [0x80F6CE95,,, 8, 0x80F0AD4E, 1], [0xFFF0F0F0,,, 8, 0x80F0AD4E, 1]]
IBStyles["critical-outline-round"] := [[0xFFF0F0F0,,, 8, 0x80D43F3A, 1], [0x80F0B9B8,,, 8, 0x80D43F3A, 1], [0x80E27C79,,, 8, 0x80D43F3A, 1], [0xFFF0F0F0,,, 8, 0x80D43F3A, 1]]

; ===============================================================================================================================

UseGDIP()

MyGui := Gui(, "Bootstrap Buttons")
MyGui.MarginX := 20
MyGui.MarginY := 20
MyGui.SetFont("s11", "Segoe UI")
CreateImageButton("SetDefGuiColor", 0xFFF0F0F0)

; -----------------------------------------------------------------------------

Btn11 := MyGui.AddButton("xm ym w80 h24", "Info")
CreateImageButton(Btn11.Hwnd, 0, IBStyles["info"]*)

Btn12 := MyGui.AddButton("x+20 yp w80 h24", "Success")
CreateImageButton(Btn12.Hwnd, 0, IBStyles["success"]*)

Btn13 := MyGui.AddButton("x+20 yp w80 h24", "Warning")
CreateImageButton(Btn13.Hwnd, 0, IBStyles["warning"]*)

Btn14 := MyGui.AddButton("x+20 yp w80 h24", "Critical")
CreateImageButton(Btn14.Hwnd, 0, IBStyles["critical"]*)

; -----------------------------------------------------------------------------

Btn21 := MyGui.AddButton("x+20 yp w80 h24", "Info")
CreateImageButton(Btn21.Hwnd, 0, IBStyles["info-outline"]*)

Btn22 := MyGui.AddButton("x+20 yp w80 h24", "Success")
CreateImageButton(Btn22.Hwnd, 0, IBStyles["success-outline"]*)

Btn23 := MyGui.AddButton("x+20 yp w80 h24", "Warning")
CreateImageButton(Btn23.Hwnd, 0, IBStyles["warning-outline"]*)

Btn24 := MyGui.AddButton("x+20 yp w80 h24", "Critical")
CreateImageButton(Btn24.Hwnd, 0, IBStyles["critical-outline"]*)

; -----------------------------------------------------------------------------

Btn31 := MyGui.AddButton("xm y+20 w80 h24", "Info")
CreateImageButton(Btn31.Hwnd, 0, IBStyles["info-round"]*)

Btn32 := MyGui.AddButton("x+20 yp w80 h24", "Success")
CreateImageButton(Btn32.Hwnd, 0, IBStyles["success-round"]*)

Btn33 := MyGui.AddButton("x+20 yp w80 h24", "Warning")
CreateImageButton(Btn33.Hwnd, 0, IBStyles["warning-round"]*)

Btn34 := MyGui.AddButton("x+20 yp w80 h24", "Critical")
CreateImageButton(Btn34.Hwnd, 0, IBStyles["critical-round"]*)

; -----------------------------------------------------------------------------

Btn41 := MyGui.AddButton("x+20 yp w80 h24", "Info")
CreateImageButton(Btn41.Hwnd, 0, IBStyles["info-outline-round"]*)

Btn42 := MyGui.AddButton("x+20 yp w80 h24", "Success")
CreateImageButton(Btn42.Hwnd, 0, IBStyles["success-outline-round"]*)

Btn43 := MyGui.AddButton("x+20 yp w80 h24", "Warning")
CreateImageButton(Btn43.Hwnd, 0, IBStyles["warning-outline-round"]*)

Btn44 := MyGui.AddButton("x+20 yp w80 h24", "Critical")
CreateImageButton(Btn44.Hwnd, 0, IBStyles["critical-outline-round"]*)

; -----------------------------------------------------------------------------

Btn51 := MyGui.AddButton("xm y+20 w200 h40", "Info")
CreateImageButton(Btn51.Hwnd, 0, IBStyles["info"]*)

Btn52 := MyGui.AddButton("x+20 yp w200 h40", "Success")
CreateImageButton(Btn52.Hwnd, 0, IBStyles["success"]*)

Btn53 := MyGui.AddButton("x+20 yp w200 h40", "Warning")
CreateImageButton(Btn53.Hwnd, 0, IBStyles["warning"]*)

Btn54 := MyGui.AddButton("x+20 yp w200 h40", "Critical")
CreateImageButton(Btn54.Hwnd, 0, IBStyles["critical"]*)

; -----------------------------------------------------------------------------

Btn61 := MyGui.AddButton("xm y+20 w200 h40", "Info")
CreateImageButton(Btn61.Hwnd, 0, IBStyles["info-outline"]*)

Btn62 := MyGui.AddButton("x+20 yp w200 h40", "Success")
CreateImageButton(Btn62.Hwnd, 0, IBStyles["success-outline"]*)

Btn63 := MyGui.AddButton("x+20 yp w200 h40", "Warning")
CreateImageButton(Btn63.Hwnd, 0, IBStyles["warning-outline"]*)

Btn64 := MyGui.AddButton("x+20 yp w200 h40", "Critical")
CreateImageButton(Btn64.Hwnd, 0, IBStyles["critical-outline"]*)

; -----------------------------------------------------------------------------

Btn71 := MyGui.AddButton("xm y+20 w200 h40", "Info")
CreateImageButton(Btn71.Hwnd, 0, IBStyles["info-round"]*)

Btn72 := MyGui.AddButton("x+20 yp w200 h40", "Success")
CreateImageButton(Btn72.Hwnd, 0, IBStyles["success-round"]*)

Btn73 := MyGui.AddButton("x+20 yp w200 h40", "Warning")
CreateImageButton(Btn73.Hwnd, 0, IBStyles["warning-round"]*)

Btn74 := MyGui.AddButton("x+20 yp w200 h40", "Critical")
CreateImageButton(Btn74.Hwnd, 0, IBStyles["critical-round"]*)

; -----------------------------------------------------------------------------

Btn81 := MyGui.AddButton("xm y+20 w200 h40", "Info")
CreateImageButton(Btn81.Hwnd, 0, IBStyles["info-outline-round"]*)

Btn82 := MyGui.AddButton("x+20 yp w200 h40", "Success")
CreateImageButton(Btn82.Hwnd, 0, IBStyles["success-outline-round"]*)

Btn83 := MyGui.AddButton("x+20 yp w200 h40", "Warning")
CreateImageButton(Btn83.Hwnd, 0, IBStyles["warning-outline-round"]*)

Btn84 := MyGui.AddButton("x+20 yp w200 h40", "Critical")
CreateImageButton(Btn84.Hwnd, 0, IBStyles["critical-outline-round"]*)

; -----------------------------------------------------------------------------

MyGui.Show()

; ===============================================================================================================================

#Include CreateImageButton.ahk
#Include UseGDIP.ahk
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

03 Aug 2021, 07:08

Thanks @jNizM, that helps me understand this a bit more.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

03 Aug 2021, 12:04

@just me When are you expecting UseGdipShutDown to get called?
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

04 Aug 2021, 06:51

@kczx3, when GdipObject will be destroyed on exit.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

04 Aug 2021, 06:52

@jNizM, thanks again. ;)
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

04 Aug 2021, 07:22

I guess I thought swagfag already mentioned that was sort of pointless in your post under the v2 development area.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

04 Aug 2021, 09:11

I'm not that sure.
AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

24 Oct 2021, 13:31

Amazing code, But I found it hard to set up the options, so I created a function.

I made a function to create a simple button.
=> it automatically calculates the background colors for pressed and hovered, and uses RGB values (the A value does not affect the current script)
Does somebody knows how to convert rgb to a gray version, this code did not worked yet.

Code: Select all

; Example how to set it up.
IBStyles["info"] := CreateButtonOptions("Black","White")


CreateButtonOptions(ColorRGB,TextColor:="",Rounded:=0,BorderWidth:= 1,BorderColor:= "",TargetColor:=""){
StartColor := ARBG_FromRBG(ColorRGB)
TargetColor := TargetColor="" ? "" : ARBG_FromRBG(TargetColor)
TextColor := TextColor = "" ? "" : ARBG_FromRBG(TextColor)
Rounded := Rounded
BorderColor := BorderWidth=0 ? "" : BorderColor="" ? LightenDarkenColor(ARBG_FromRBG(ColorRGB),-50) : ColorRGB
BorderWidth := BorderWidth
;            PBS_NORMAL    = 1
;	         PBS_HOT       = 2
;	         PBS_PRESSED   = 3
;	         PBS_DISABLED  = 4
;	         PBS_DEFAULTED = 5
;	         PBS_STYLUSHOT = 6
return [[StartColor, TargetColor, TextColor, Rounded, BorderColor, BorderWidth] ; PBS_NORMAL
    , [LightenDarkenColor(StartColor, 50), TargetColor, TextColor, Rounded, BorderColor, BorderWidth] ; PBS_HOT
    , [LightenDarkenColor(StartColor, 100), TargetColor, TextColor, Rounded, BorderColor, BorderWidth] ; PBS_PRESSED
    , [LightenDarkenColor(StartColor, 30,1), TargetColor, TextColor, Rounded, BorderColor, BorderWidth]] ; PBS_DISABLED
}

LightenDarkenColor(colRBG, amt := 0, Gray := 0) {
    oColors := { Black: 0x000000, Silver: 0xC0C0C0, Gray: 0x808080, White: 0xFFFFFF, Maroon: 0x800000, Red: 0xFF0000, Purple: 0x800080, Fuchsia: 0xFF00FF, Green: 0x008000, Lime: 0x00FF00, Olive: 0x808000, Yellow: 0xFFFF00, Navy: 0x000080, Blue: 0x0000FF, Teal: 0x008080, Aqua: 0x00FFFF }
    if oColors.HasOwnProp(colRBG) {
        colRBG := oColors.%ColRBG%
    }
    r := Max(Min((colRBG >> 16) + amt, 255), 0)
    b := Max(Min(((colRBG >> 8) & 0x00FF) + amt, 255), 0)
    g := Max(Min((colRBG & 0x0000FF) + amt, 255), 0)

    if Gray {
        ;   r := (r + b + g)/3
        ;   b := r
        ;   g := r
    }
    newColorRBG := g | (b << 8) | (r << 16)
    return newColorRBG
}

; ===============================================================================================================================

/********************************************
 * ARGB(A,RGB)
 * 
 * returns the ARGB value from RGB
 * 
 * 
 */
ARBG_FromRBG(colRBG, A := 0) {
    oColors := { Black: 0x000000, Silver: 0xC0C0C0, Gray: 0x808080, White: 0xFFFFFF, Maroon: 0x800000, Red: 0xFF0000, Purple: 0x800080, Fuchsia: 0xFF00FF, Green: 0x008000, Lime: 0x00FF00, Olive: 0x808000, Yellow: 0xFFFF00, Navy: 0x000080, Blue: 0x0000FF, Teal: 0x008080, Aqua: 0x00FFFF }
    if oColors.HasOwnProp(colRBG) {
        colRBG := oColors.%ColRBG%
    }
    A := A & 0xFF, colRBG := colRBG & 0xFFFFFF
    return ((colRBG | (A << 24)) & 0xFFFFFFFF)
}
iseahound
Posts: 1434
Joined: 13 Aug 2016, 21:04
Contact:

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

25 Oct 2021, 09:09

automatic function call with static initializers any more.
Hi have you considered using static __New()?
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

26 Oct 2021, 04:35

@iseahound, it doesn't solve the problem: viewtopic.php?f=82&t=94482
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

04 Jan 2022, 06:25

Hey 'just me',

There is a display problem with the font Segoe MDL2 Assets. Is this something that can be fixed?
Home symbol is Chr(0xE80F) (see: https://docs.microsoft.com/en-us/windows/apps/design/style/segoe-ui-symbol-font)

Image
First Button is a default Button
The 2nd one is a ImageButton

greets
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

05 Jan 2022, 05:49

Moin @jNizM,

happy new year! Does it work with v1?
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

05 Jan 2022, 05:52

Frohes Neues auch dir 🥳
Dont work with v1 too. Just the Symbols are displyed. Whole Text (a-Z) are just squares

Also Numbers and other ascii chars are displayed as squares
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

07 Jan 2022, 07:52

Looks like GDI+ cannot work with this font.
I tried it with a simple gui with GdipCreateFontFamilyFromName("Segoe MDL2 Assets"), GdipCreateFont() and GdipDrawString() and it also showed only squares.


edit
ms wrote:Unlike with Segoe UI Symbol, the icons in the Segoe MDL2 Assets font are not intended for use in-line with text. This means that some older "tricks" like the progressive disclosure arrows no longer apply.
Thanks M$

Left "Segoe UI Symbol" with ImageButton | Right "Segoe MDL2 Assets" with Text controls
Image
Wanted to archive a Windows 11 Like Menu
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

07 Jan 2022, 08:58

@jNizM, thanks for reporting. Would you please provide the source code for your examples?
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

07 Jan 2022, 09:17

"Segoe MDL2 Assets" is a pure icon font and has no glyphs for Alpha-numerals. (in fact the first char is 0xE001)
@jNizM : You should've checked the font in charmap.exe before going through the trouble.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: 2.0-beta.1: CreateImageButton() - 2021-08-03 alpha.1

07 Jan 2022, 09:28

sure

Code: Select all

UseGDIP()
Tool()

Tool()
{
	IBStyles := [ [0x80F0F0F0,, 0xFF000000, 4, 0x80F0F0F0, 1]
				, [0x80CFCFCF,, 0xFF000000, 4, 0x80CFCFCF, 1]
				, [0x80DCDCDC,, 0xFF666666, 4, 0x80DCDCDC, 1]
				, [0x80EAEAEA,, 0xFF0078D7, 4, 0x80EAEAEA, 1] ]

	Main := Gui("")
	Main.MarginX := 0
	Main.MarginY := 0
	;Main.BackColor := "F3F3F3"


	; == Segoe UI Symbol (pre Win 10)
	Main.SetFont("s14", "Segoe UI Symbol")
	Main.AddButton("xm+3 ym+4  w250 h36 0x100", Chr(0xE10F) " Segoe UI Symbol")

	IB01 := Main.AddButton("xm+3 y+4 w250 h36 0x100 vIB01", " " Chr(0xE10F) "   Home")
	IB01.OnEvent("Click", TabSelect)
	CreateImageButton(IB01.Hwnd, 0, IBStyles*)

	IB02 := Main.AddButton("xm+3 y+4 w250 h36 0x100 vIB02", " " Chr(0xE115) "   Settings")
	IB02.OnEvent("Click", TabSelect)
	CreateImageButton(IB02.Hwnd, 0, IBStyles*)

	IB03 := Main.AddButton("xm+3 y+4 w250 h36 0x100 vIB03", " " Chr(0xE1D0) "   Calc")
	IB03.OnEvent("Click", TabSelect)
	CreateImageButton(IB03.Hwnd, 0, IBStyles*)



	; == Segoe MDL2 Assets (with Win 10)   https://docs.microsoft.com/en-us/windows/apps/design/style/segoe-ui-symbol-font
	Main.SetFont("s14", "Segoe MDL2 Assets")
	Main.AddButton("x+10 ym+4  w250 h36 0x100", Chr(0xE80F) " Segoe MDL2 Assets")

	IB04 := Main.AddButton("xp y+4 w250 h36 vIB04 0x100", " " Chr(0xE80F) "   Home")
	IB04.OnEvent("Click", TabSelect)
	CreateImageButton(IB04.Hwnd, 0, IBStyles*)

	Main.AddText("xp y+5 w250 h36 0x200", " " Chr(0xE713) . "   Settings")

	Main.AddText("xp y+4 w250 h36 0x200", " " Chr(0xE8EF) . "   Calc")



	; == Segoe Fluent Icons (with Win 11)   https://docs.microsoft.com/en-us/windows/apps/design/style/segoe-fluent-icons-font
	Main.SetFont("s14", "Segoe Fluent Icons")
	Main.AddButton("x+10 ym+4  w250 h36 0x100", Chr(0xE80F) " Segoe Fluent Icons")

	IB05 := Main.AddButton("xp y+4 w250 h36 vIB05 0x100", " " Chr(0xE80F) "   Home")
	IB05.OnEvent("Click", TabSelect)
	CreateImageButton(IB05.Hwnd, 0, IBStyles*)

	Main.AddText("xp y+5 w250 h36 0x200", " " Chr(0xE713) . "   Settings")

	Main.AddText("xp y+4 w250 h36 0x200", " " Chr(0xE8EF) . "   Calc")




	T3 := Main.AddTab3("xm ym-2 w0 h0 -Wrap Choose1 AltSubmit", ["1", "2", "3", "4"])
	Main.Show("w800 h400")

	TabSelect(BtnCtrl, *)
	{
		static TCM_GETITEMCOUNT := 0x1304

		/* todo
		T3.Choose(k := SubStr(BtnCtrl.Name, 4, 1))

		loop SendMessage(TCM_GETITEMCOUNT, 0, 0, T3.hWnd)
		{
			; ...
		}
		*/
	}

}


#Include CreateImageButton.ahk
@SKAN I noticed that. I'm just surprised that it works with the normal button or text control, but not with GDIP.

Wanted to create a Windows 11 like Settings Menu
Image
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: bqnwne937, sanmaodo, wilkster and 17 guests