HBITMAP - HICON for Image Handles - help needed.
Image Handles doc page is here.
Affects
- Gui.AddPicture (and GuiCtrl.Value when setting a Picture control's content).
- IL_Add
- LoadPicture
- SB.SetIcon
- ImageSearch
- TraySetIcon or Menu.SetIcon
“HBITMAP” and “HICON” are giving me trouble. Code is below.
Comments (10)
-
repo owner -
reporter - edited description
- changed title to HBITMAP - HICON for Image Handles - help needed.
- marked as task
-
reporter - edited description
-
repo owner Passing the * suffix was not being properly processed, but this included many bugs and I’ve attempted to fix them all.
Properly scaling with h-1 was also not working.
Please give it another try and see if it’s fixed.
-
reporter Test code (not working):
Pics := [] ; Find some pictures to display. Loop Files, A_WinDir "\Web\Wallpaper\*.jpg", "R" { ; Load each picture and add it to the array. Pics.Push(LoadPicture(A_LoopFileFullPath)) } if (!Pics.Length) { ; If this happens, edit the path on the Loop line above. MsgBox("No pictures found! Try a different directory.") ExitApp } ; Add the picture control, preserving the aspect ratio of the first picture. MyGui := Gui() Pic := MyGui.Add("Picture", "w600 h-1 +Border", "HBITMAP:*" Pics[1]) MyGui.Show() Loop { ; Switch pictures! Pic.Value := "HBITMAP:*" Pics[Mod(A_Index, Pics.Length)+1] Sleep 3000 }
-
reporter Error:
Uncaught Keysharp exception: Message: C:\Users\HP6300\Documents\repos\keysharp_debug\keysharp\bin\debug\net6.0-windows\HBITMAP:*{"Handle":"Keysharp.Core.Common.GdiHandleHolder","ImageType":"0"} What: Keysharp.Core.Common.ImageHelper.LoadImage() Extra: File: C:\Users\HP6300\Documents\repos\keysharp_debug\keysharp\Keysharp.Core\Common\Images\ImageHelper.cs Line: 197 Stack: at Keysharp.Core.Common.ImageHelper.LoadImage(String filename, Int32 w, Int32 h, Object iconindex) in C:\Users\HP6300\Documents\repos\keysharp_debug\keysharp\Keysharp.Core\Common\Images\ImageHelper.cs:line 197
-
repo owner There were some bugs, which I fixed.
But also, this test code needs one small change. The AHK version of LoadPicture() takes a reference argument, which we are not supporting. So like our other functions which take reference arguments, we are instead returning a map which has an entry of the same name as the reference parameter. In this case, it’s “Handle”.
So replace
LoadPicture(A_LoopFileFullPath)
withLoadPicture(A_LoopFileFullPath)[”Handle”]
That should work with my latest commit.
-
reporter Works beautifully! Kudos! Going to close.
-
reporter - changed status to resolved
Nicely done!
-
reporter - changed status to closed
Closed.
- Log in to comment
These are present in Keysharp.Core.Common.ImageHelper.LoadImage(), which all of those functions eventually call.
Are you filing this just because you didn’t find it in the code, or because you ran a test and it failed?
If it’s the former, please close this ticket. If it’s the latter, please provide a test script to reproduce the problem.
Thanks.