最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - Winapi: Modify DPI scaled standard cursor bitmap - Stack Overflow

programmeradmin0浏览0评论

A C++ Windows application desires to annotate the cursor bitmap with a small colored icon which conveys context dependent information, i.e. while hovering specific items. User preferences are to be respected, thus the system cursor must be modified instead of using an application specific cursor.

  • If the modified bitmap exists a new cursor can be created by a CreateIconIndirect API call.

  • We can create the modified bitmap by pixel manipulation of the original cursor bitmap.

  • We have access to the HCURSOR handle, e.g. by calling GetCursor (alternatives like LoadImage give similar results).

  • By searching the internet I found a possible solutions for obtaining the original bitmap, here the problem arises:

  • We use GetIconInfo (or GetIconInfoExW) to retrieve its color HBITMAP and use GetObject to retrieve the BITMAP.

  • The returned bitmap always has the dimensions 32x32, regardless of the DPI or the user's cursor scaling settings.

  • An alternative is using DrawIconEx onto a memory DC, however it seems to crudely upscale the 32x32 raster image and has inaccurate transparency pixels. Incurring loss of quality by upscaling a small raster image is not an option!

How can we get the exact cursor bitmap which is drawn onto the screen?

发布评论

评论列表(0)

  1. 暂无评论