[Class] ImageButton

Post your working scripts, libraries and tools
User avatar
Klark92
Posts: 155
Joined: 18 Jan 2015, 19:33

Re: [Class] ImageButton

03 Feb 2017, 18:44

Hi again tmplinshi buddy :)
Guys I solved bad fading problem...

Put that Code Before "Gui, Show":

Code: Select all

DllCall("SystemParametersInfo", UInt, SPI_SETCLIENTAREAANIMATION := 0x1043, UInt, 0, UInt, 0)
and put that code After "Gui, Show":

Code: Select all

DllCall("SystemParametersInfo", UInt, SPI_SETCLIENTAREAANIMATION := 0x1043, UInt, 0, UInt, 1)
Example:

Code: Select all

DllCall("SystemParametersInfo", UInt, SPI_SETCLIENTAREAANIMATION := 0x1043, UInt, 0, UInt, 0)
Gui, Show,, Image Buttons
DllCall("SystemParametersInfo", UInt, SPI_SETCLIENTAREAANIMATION := 0x1043, UInt, 0, UInt, 1)
it closes animation effects before Gui is creating... then we change it to default state....

:clap:
Smart Kombo 1.0 | One of the best Knight Online's key combo program...
tmplinshi
Posts: 1281
Joined: 01 Oct 2013, 14:57

Re: [Class] ImageButton

03 Feb 2017, 22:28

Nice work Klark92! Tested and worked. :thumbup:
User avatar
Klark92
Posts: 155
Joined: 18 Jan 2015, 19:33

Re: [Class] ImageButton

04 Feb 2017, 05:19

I made a alot research, it worthed :)
Smart Kombo 1.0 | One of the best Knight Online's key combo program...
just me
Posts: 5656
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

04 Feb 2017, 06:05

Hi Klark92,

good catch. It might be useful for other/common controls, too. I think you should add it to Tutorials/Tips&Tricks.
User avatar
Klark92
Posts: 155
Joined: 18 Jan 2015, 19:33

Re: [Class] ImageButton

04 Feb 2017, 11:19

Sure, its done and I made it easy to use, you can put that code only top of the script :) Check it out if you need...

https://autohotkey.com/boards/viewtopic.php?f=7&t=27743
Smart Kombo 1.0 | One of the best Knight Online's key combo program...
User avatar
jNizM
Posts: 2341
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: [Class] ImageButton

18 May 2017, 08:19

Hey just me..

Next to .Create(handle, opt*) a .Change(handle, opt*) would be nice to change the buttons later.

Ref: https://autohotkey.com/boards/viewtopic ... 22#p148722
[AHK] 1.1.30.01 x64 Unicode | [WIN] 10 Pro (Version 1803) x64 | [GitHub] Profile
Donations are appreciated if I could help you
just me
Posts: 5656
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

25 May 2017, 10:38

User avatar
masato
Posts: 15
Joined: 08 Sep 2015, 13:38

Re: [Class] ImageButton

10 Jul 2017, 11:18

Hey, quick question:
It takes roughly a second to create one button (it's actually around 700ms).
When creating multiple buttons, the wait can become pretty long. Is it expected behaviour, or am I doing something wrong?

Either way, this is amazing!
User avatar
gregster
Posts: 1491
Joined: 30 Sep 2013, 06:48

Re: [Class] ImageButton

10 Jul 2017, 11:53

I don't remember a noticeable pause... (I might be wrong, I will check later).

In the meantime, you could post your script, or at least a part that demonstrates your problem
lemasato

Re: [Class] ImageButton

10 Jul 2017, 16:18

gregster wrote:I don't remember a noticeable pause... (I might be wrong, I will check later).
In the meantime, you could post your script, or at least a part that demonstrates your problem

Code: Select all

#SingleInstance Force
#NoEnv
SetBatchLines, -1

btnCount := 10
IBClrStyles := [ [0, 0x80FFFFFF, , 0xD3000000, 0, , 0x80FFFFFF, 1]      ; normal
			   , [0, 0x80E6E6E6, , 0xD3000000, 0, , 0x80E6E6E6, 1]      ; hover
			   , [0, 0x80CCCCCC, , 0xD3000000, 0, , 0x80CCCCCC, 1]      ; pressed
			   , [0, 0x80F3F3F3, , 0x000078D7, 0, , 0x80F3F3F3, 1] ]    ; disabled (defaulted)

startTime := A_TickCount
Progress, , ,% "Now creating " btnCount " ImageButtons",% "Class_ImageButton Delay Calculator"
Loop %btnCount% {
	btnPos := (A_Index=1)?("xm ym w100 h20"):("xm y+0 wp hp")
	progressPercent := A_Index*(100/10)

	Gui, Add, Button,% btnPos " hWndHBtn" A_Index,% A_Index
	ImageButton.Create(HBtn%A_Index%, IBClrStyles*)

	Progress,% progressPercent
}
Progress, Off
; Gui, Show
MsgBox,% "Result: " A_TickCount-startTime "ms"
.		 "`nto render " btnCount " ImageButtons."
ExitApp

#Include Class_ImageButton.ahk
The example above takes me around 8300ms to complete.
Also, the Sample script takes me around 3300ms.
jNizM's Windows 10 Settings Concept takes me around 4200ms
User avatar
gregster
Posts: 1491
Joined: 30 Sep 2013, 06:48

Re: [Class] ImageButton

10 Jul 2017, 18:20

lemasato wrote:The example above takes me around 8300ms to complete.
Also, the Sample script takes me around 3300ms.
jNizM's Windows 10 Settings Concept takes me around 4200ms
Wow, that's slow. Your example showed me (at first run) 435ms, in consecutive runs around 220ms. jNizm's seems as fast (almost instantly), the sample script the same.
So I guess, there is something going really wrong on your system. I tested with a refurbished pc (at least 5 years old) and Windows 7 (64bit Home Premium) and AHK 1.1.26 Unicode 64bit - most probably not the fastest computer out there :)
Are you using some Antivirus prog like AVAST (which is notorious for intervening with AHK)? Not sure, but there might be some benchmark scripts already around for AHK - are you experiencing such delays or other strange problems also with other AHK scripts or totally different programs?
But anyway, your times are so much off... Still, I am going to test it on some older and much slower machines - but I guess that they won't be anything slow like yours... hopefully someone else will chime in with some possible insight.

Edit: On one laptop with Win10 32bit (around ten years old), your script clocks in around 500ms (first run) and 330ms in following runs...
User avatar
masato
Posts: 15
Joined: 08 Sep 2015, 13:38

Re: [Class] ImageButton

12 Jul 2017, 10:07

Spoiler

EDIT: NEVERMIND. FOUND THE CULPRIT: Too many fonts installed.
Realised I hadn't re-installed my fonts yet. Thought it might be related...
And here it is. Having too many fonts slow down ImageButton.

Is there any workaround for this?
Got it. At exactly 719 fonts, I get 400ms.
Once it reaches 720, it goes to 5500ms.
Why is this?


I have uploaded an archive containing exactly 720 fonts, in case anyone would like to experiment
User avatar
RazorHalo
Posts: 17
Joined: 21 Dec 2015, 21:23

Re: [Class] ImageButton

06 Sep 2017, 22:55

Hi, I'm using the ImageButton Class with icons that have a transparent background. It works flawlessly. But now I'm using it in conjunction with the FileInstall method to used image resources in the compiled script as described in this thread.
https://autohotkey.com/boards/viewtopic ... d308be1b40

Only problem is when using ImageButton with the compiled version I lose the transparency of the icon Just ends up being a black backgound. This also happens with transparent .png's They keep their transparency when just referencing them as a picture, but lose it when used with Imagebutton.

Image

Anyone have an idea of what might cause this? or a way to fix it?
just me
Posts: 5656
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

07 Sep 2017, 02:48

I have no idea how to fix it. You have to pass a HBITMAP handle to the function. If you got this handle from FI_GetImage() it has been converted twice (GDI+ bitmap -> GDI bitmap and GDI bitmap -> GDI+ bitmap) before it is drawn. This might cause a loss of information.
AlexD9111

Re: [Class] ImageButton

20 Feb 2018, 02:06

Hi

When I change my buttons size, the gradient color don't follow the button, it stay on the initial state.
do you know if there is a way to refresh colors on a button ?

if I call again the class, text on button disapears.
just me
Posts: 5656
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

20 Feb 2018, 05:20

You have two options:
  • Restore the button's caption before you call ImageButton.Create() again.
  • If you're on Win Vista+, change the class code:

    Code: Select all

          ; Hide buttons's caption
          ; ControlSetText, , , ahk_id %HWND%  <<<<< comment this line out
    
AlexD9111

Re: [Class] ImageButton

21 Feb 2018, 03:31

Thank you it works
only one prob is memory, old images are not erased
User avatar
jNizM
Posts: 2341
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: [Class] ImageButton

19 Apr 2018, 03:03

Is it possible to add Icons (dll-name + icon-id) into ImageButtons as option? Like the Windows Settings menu.
Image
[AHK] 1.1.30.01 x64 Unicode | [WIN] 10 Pro (Version 1803) x64 | [GitHub] Profile
Donations are appreciated if I could help you
just me
Posts: 5656
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [Class] ImageButton

20 Apr 2018, 03:20

Hi jNizM,

the class is designed to fill the whole control with colors or a bitmap. To draw an additional icon would require to change the parameters. I'm not interested in doing that.

Please PM me, if you have further questions.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: hyaray, zapal and 34 guests