Win10 Custom Scaling | SetMenuIcon() Exception "Icons must be 16x16 pixels in size."

Win10 Custom Scaling | SetMenuIcon() Exception "Icons must be 16x16 pixels in size."

BlackBox_
Advisor Advisor
670 Views
4 Replies
Message 1 of 5

Win10 Custom Scaling | SetMenuIcon() Exception "Icons must be 16x16 pixels in size."

BlackBox_
Advisor
Advisor

I have a user that increased their Window 10 Display, Custom Scaling (Text Height) % in OS Settings, that is now prompting them with an "Icons must be 16x16 pixels in size." SetMenuIcon() exception at AutoCAD/Civil 3D launch:

 

SetMenuIcon(blockMenuItem, "Block", "RCDATA_16_BLOCK");

 

Putting this in a Try-Catch block is simple enough - but AutoCAD application still does not load the icons - even though they're coming from internal ACAD.cuix icons (or the respective native icon resources) via SetMenuIcon() call with native "RCDATA_16_*" icons.

 

The native Commands in CUI (Ribbon, Menu, Toolbar, etc) still load fine - which means it is okay to use the native icon resources - but they won't load for SetMenuItem()?

 

Windows Custom Scaling isn't exactly new, so someone has to have seen something on how to fix this (besides just disable Custom Scaling); I'm just not finding anything useful to resolve this.

 

Please advise.


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
671 Views
4 Replies
Replies (4)
Message 2 of 5

BlackBox_
Advisor
Advisor

Apologies, for any confusion: 

 

SetMenuIcon() is simply a custom Method to call Utils.GetAcadResourceIcon("RCDATA_16_*") within a try-catch block that would still allow my custom MenuItems to be loaded & operational even without the icon.

 

The Utils.GetAcadResourceIcon("RCDATA_16_*") call is what's raising the exception. 

 

private static void SetMenuIcon(MenuItem menu, string name, string icon)
        {
            Document doc = acDocs.MdiActiveDocument;

            if (doc == null)
                return;

            Editor ed = doc.Editor;

            try
            {
                menu.Icon = Utils.GetAcadResourceIcon(icon);
            }
            catch
            {
                ed.WriteMessage("\n** Exception: \"{0}\" menu: Resource icon \"{1}\" missing \n",
                    name, icon);
            }
        }


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 3 of 5

BlackBox_
Advisor
Advisor

In a test:

 

Clicking Windows button (WinKey), typing Display, click on Display Settings, scroll down to and click on Advanced Scaling Settings, then enter 110 into the Custom Scaling textbox (& restarting workstation for setting to take effect). 

 

... Using Civil 3D 2021.2, I am able to confirm that Utils.GetAcadResourceIcon() is incorrectly identifying that the resource icon does not exist, when same "RCDATA_16_*" icons are being used in the native Ribbon panels (that's where I got the icon names in the first place).

 

Not sure how/why, but it's *as if* the Utils.GetAcadResourceIcon() call is somehow getting the actual "RCDATA_16_*" resource icon (16x16) x 1.10 (110%) OS Custom Scaling == 17.6x17.6 pixels and throwing the Exception?

 

Any help would be greatly appreciated.


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 4 of 5

BlackBox_
Advisor
Advisor

(Jokingly said) - What does Autodesk have against older users wanting to use Windows Custom Scaling  to make things easier to read? Haha


Joking aside, in a debug session it appears that Utils.GetAcadResourceIcon("RCDATA_16_*") calls return Null instead of the Icon as expected.

Can someone please confirm that this is in fact an API bug?

Regardless of what user elects to set any Windows Custom Scaling, the API should still return a valid resource icon (given the applicable parent CUIx is loaded that provides said resource icon), no?

This is happening in 2019-Current versions.

Please advise.


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 5 of 5

TerryDotson
Mentor
Mentor

You've got to watch .NET operations involving images (and of course fonts in datagridview, etc).  For example I had a tool that was assembling downloaded images in a tile fashion.  On certain end user machines it was making a mess of it until I looked closely at the end users results.  It turns out that .NET was scaling the source image tiles by the custom scaling (150%).  I simply had to put some size constraints in using DrawImage(Bmp,Rectangle) instead of DrawImage(Bmp,InsPnt).  Got to watch .NET and Windows, don't think AutoCAD is doing anything.