[Class] ImageButton - 1.5.00.00 - 20201230
Re: [Class] ImageButton
ok, thanks for reply.
Re: [Class] ImageButton
Is it possible to use Windows system icons with this class? For instance, Icon239 from Global iconPath := A_WinDir "\system32\shell32.dll"
Re: [Class] ImageButton
NVM, I see that you simply add the picture first and then call the Create method so that should work fine.
Re: [Class] ImageButton
Hi kczx3, did you solve your problem?
Re: [Class] ImageButton
Not really. I decided it wasn't really worth it though. I think I was just trying to force a use case for this to see it work.
Re: [Class] ImageButton
Trying to run the sample code, I am getting the error at line 72 in #include file
Line Text: Class ImageButton {
Error: This line does not contain a recognized action.
I have never worked with classes in ahk before. Any idea what causes this error?
Line Text: Class ImageButton {
Error: This line does not contain a recognized action.
I have never worked with classes in ahk before. Any idea what causes this error?
Re: [Class] ImageButton
I guess you have to update your AHK.
Re: [Class] ImageButton
Wow, okay, that worked. Haha, thanks for the fast response and easy solution.
Re: [Class] ImageButton
Hi just me,
Thanks again for this fantastic script! It works great and I use it in most of my projects.
Since creating buttons takes surprisingly (at least to me) quite a bit of memory (something like 50-80 Kb per button, as seen through Task Manager, which can add up very fast), I use the function you shared in the following post to release memory when a button is not needed anymore:
https://autohotkey.com/boards/viewtopic ... 287#p44287
That works great. However, in a script with multiple gui's, is there a faster way to destroy all the buttons on a given gui apart from looping that function through all its buttons? If I simply destroy the gui, the memory from the ImageButtons is not released.
Thanks again!
Thanks again for this fantastic script! It works great and I use it in most of my projects.
Since creating buttons takes surprisingly (at least to me) quite a bit of memory (something like 50-80 Kb per button, as seen through Task Manager, which can add up very fast), I use the function you shared in the following post to release memory when a button is not needed anymore:
https://autohotkey.com/boards/viewtopic ... 287#p44287
That works great. However, in a script with multiple gui's, is there a faster way to destroy all the buttons on a given gui apart from looping that function through all its buttons? If I simply destroy the gui, the memory from the ImageButtons is not released.
Thanks again!
Re: [Class] ImageButton
Hi lblb,
the class doesn't store any information about the buttons or the parent GUIs. So the answer is: No!
the class doesn't store any information about the buttons or the parent GUIs. So the answer is: No!
Re: [Class] ImageButton
Hi just me,
Excellent! A clear answer, even if it doesn't make my life easier, is always appreciated!
Thanks again for all your contributions here and everywhere else, I've certainly learned a lot from and been inspired by your work.
Excellent! A clear answer, even if it doesn't make my life easier, is always appreciated!
Thanks again for all your contributions here and everywhere else, I've certainly learned a lot from and been inspired by your work.
Re: [Class] ImageButton
Hello!
I have been using ImageButton with great success, but i bumped into a problem when trying to use a custom font. Im using the method described here: https://autohotkey.com/board/topic/31031-portable-font/
I have DllCall( "GDI32.DLL\AddFontResourceEx", Str,"VCR_OSD_MONO_1.001.ttf",UInt,(FR_PRIVATE:=0x10), Int,0) at the top of my script and when i add my button the script finds the font and uses it correctly. However when i call ImageButton with:
Opt1 := [1, "BLACK", , 0x7890F0, , , 0x7890F0, 1]
ImageButton.Create(HBT%A_Index%, Opt1)
It returns nothing, as if it was never called. If i use a standard Windows font ImageButton works great.
Is there anyway to get ImageButton to work with a font used in this way? Installing it in Windows directly is not an option sadly.
Thanks in advance
I have been using ImageButton with great success, but i bumped into a problem when trying to use a custom font. Im using the method described here: https://autohotkey.com/board/topic/31031-portable-font/
I have DllCall( "GDI32.DLL\AddFontResourceEx", Str,"VCR_OSD_MONO_1.001.ttf",UInt,(FR_PRIVATE:=0x10), Int,0) at the top of my script and when i add my button the script finds the font and uses it correctly. However when i call ImageButton with:
Opt1 := [1, "BLACK", , 0x7890F0, , , 0x7890F0, 1]
ImageButton.Create(HBT%A_Index%, Opt1)
It returns nothing, as if it was never called. If i use a standard Windows font ImageButton works great.
Is there anyway to get ImageButton to work with a font used in this way? Installing it in Windows directly is not an option sadly.
Thanks in advance
Re: [Class] ImageButton
Just add MsgBox, % ImageButton.LastError after ImageButton.Create(...). What does it show?
Re: [Class] ImageButton
It returns Couldn't get buttons font!
Can i maybe hardcode the font somehow?
Can i maybe hardcode the font somehow?
Re: [Class] ImageButton
I have no experience with temporarily added private fonts. Would you please change the ImageButton.Create() method as follows
and tell me what the MsgBoxes are showing?
Code: Select all
; Get the button's font
GDIPFont := 0
HFONT := DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", WM_GETFONT, "Ptr", 0, "Ptr", 0, "Ptr")
MsgBox, 0, %A_ThisFunc%, HFONT: %HFONT% - A_LastError: %A_LastError% ; <<<<< added
DC := DllCall("User32.dll\GetDC", "Ptr", HWND, "Ptr")
DllCall("Gdi32.dll\SelectObject", "Ptr", DC, "Ptr", HFONT)
DllCall("Gdiplus.dll\GdipCreateFontFromDC", "Ptr", DC, "PtrP", PFONT)
MsgBox, 0, %A_ThisFunc%, PFONT: %PFONT% - A_LastError: %A_LastError% ; <<<<< added
DllCall("User32.dll\ReleaseDC", "Ptr", HWND, "Ptr", DC)
If !(PFONT)
Return This.SetError("Couldn't get button's font!")
Re: [Class] ImageButton
They show
HFONT: 520754222 - A_LastError: 0
PFONT: 0 - A_LastError: 0
HFONT changes with every reload but PFONT remains 0
HFONT: 520754222 - A_LastError: 0
PFONT: 0 - A_LastError: 0
HFONT changes with every reload but PFONT remains 0
Re: [Class] ImageButton
So it seems to be a GDI+ problem with private fonts. All I could find is that GDI+ distinguishes between InstalledFontCollection and PrivateFontCollection classes. Would you please run the following changed version
Code: Select all
; Get the button's font
GDIPFont := 0
HFONT := DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", WM_GETFONT, "Ptr", 0, "Ptr", 0, "Ptr")
MsgBox, 0, %A_ThisFunc%, HFONT: %HFONT% - A_LastError: %A_LastError% ; <<<<< added
DC := DllCall("User32.dll\GetDC", "Ptr", HWND, "Ptr")
DllCall("Gdi32.dll\SelectObject", "Ptr", DC, "Ptr", HFONT)
Status := DllCall("Gdiplus.dll\GdipCreateFontFromDC", "Ptr", DC, "PtrP", PFONT)
MsgBox, 0, %A_ThisFunc%, PFONT: %PFONT% - A_LastError: %A_LastError% - Status: %Status% ; <<<<< added, changed
DllCall("User32.dll\ReleaseDC", "Ptr", HWND, "Ptr", DC)
If !(PFONT)
Return This.SetError("Couldn't get button's font!")
Re: [Class] ImageButton
PFONT: 0 - A_LastError: 0 - Status: 16
Re: [Class] ImageButton
Interesting! From the GDI+ Status enumeration:
I don't know how to fix this.NotTrueTypeFont = 16
Re: [Class] ImageButton
Hmm, I was under the impression that if the file extension is .ttf, it is a TrueTypeFont. Ill keep searching and see if i can figure something out
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 190 guests