Page 6 of 10

Re: [Class] ImageButton

Posted: 03 Feb 2017, 18:44
by Klark92
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:

Re: [Class] ImageButton

Posted: 03 Feb 2017, 22:28
by tmplinshi
Nice work Klark92! Tested and worked. :thumbup:

Re: [Class] ImageButton

Posted: 04 Feb 2017, 05:19
by Klark92
I made a alot research, it worthed :)

Re: [Class] ImageButton

Posted: 04 Feb 2017, 06:05
by just me
Hi Klark92,

good catch. It might be useful for other/common controls, too. I think you should add it to Tutorials/Tips&Tricks.

Re: [Class] ImageButton

Posted: 04 Feb 2017, 11:19
by Klark92
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

Re: [Class] ImageButton

Posted: 18 May 2017, 08:19
by jNizM
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

Re: [Class] ImageButton

Posted: 25 May 2017, 10:38
by just me

Re: [Class] ImageButton

Posted: 10 Jul 2017, 11:18
by masato
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!

Re: [Class] ImageButton

Posted: 10 Jul 2017, 11:53
by gregster
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

Re: [Class] ImageButton

Posted: 10 Jul 2017, 16:18
by lemasato
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

Re: [Class] ImageButton

Posted: 10 Jul 2017, 18:20
by gregster
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...

Re: [Class] ImageButton

Posted: 12 Jul 2017, 10:07
by masato
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

Re: [Class] ImageButton

Posted: 06 Sep 2017, 22:55
by RazorHalo
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?

Re: [Class] ImageButton

Posted: 07 Sep 2017, 02:48
by just me
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.

Re: [Class] ImageButton

Posted: 20 Feb 2018, 02:06
by AlexD9111
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.

Re: [Class] ImageButton

Posted: 20 Feb 2018, 05:20
by just me
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
    

Re: [Class] ImageButton

Posted: 21 Feb 2018, 03:31
by AlexD9111
Thank you it works
only one prob is memory, old images are not erased

Re: [Class] ImageButton

Posted: 21 Feb 2018, 04:33
by just me

Re: [Class] ImageButton

Posted: 19 Apr 2018, 03:03
by jNizM
Is it possible to add Icons (dll-name + icon-id) into ImageButtons as option? Like the Windows Settings menu.
Image

Re: [Class] ImageButton

Posted: 20 Apr 2018, 03:20
by just me
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.