Using the HANDLE returned by LoadImageA in WNDCLASSEXA (instead of HICON)

69 views Asked by At

I'm new to both Rust and win32 (using windows-rs), and have been trying to understand both. However, I'm running into issues setting the icon for the window class I'm trying to create. The example leaves the hIcon field of the WNDCLASSA it sets up blank. While I've already conquered the issue of using resource files to reference the icons, I must still load the icon and get a handle to it in order to use it. Several examples and other sources reference using LoadIconA but, as noted on the page, the function has been superseded by LoadImageA.

The issue arises when I replace my use of LoadIconA with LoadImageA - While the former returns an HICON, the latter simply returns a HANDLE. If I understand the Windows docs correctly, both HICON and HANDLE are both themselves integer handles used by the operating system to reference the loaded image. How do I make use of the HANDLE returned by LoadImageA in places where Rust expects an HICON? Is there some way to cast between these two types?

0

There are 0 answers