Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Volume Mixer icon size is too large
    primarykey
    data
    text
    <p>In the Windows Volume Mixer, when your application plays sounds, it adds your application's icon and a custom volume slider to adjust volume specific to that application... nice! However, when you use a large-sized icon for your application (especially important in high-DPI when Windows scales your icons for the Taskbar, etc.), the icon in the Volume Mixer doesn't scale correctly. Specifically, the following code is what I use to set the application's icon:</p> <pre><code>// set icons the normal way cWnd.SetIcon( theApp.LoadIcon( res_id ), FALSE ); cWnd.SetIcon( theApp.LoadIcon( res_id ), TRUE ); // set hi-res if available OSVERSIONINFO osv; osv.dwOSVersionInfoSize = sizeof( osv ); if ( GetVersionEx( &amp;osv ) ) { // if we're Vista or more recent, use hi-def icons if ( osv.dwMajorVersion &gt;= 6 ) { HICON hIcon = (HICON)::LoadImage( theApp.m_hInstance, MAKEINTRESOURCE( res_id ), IMAGE_ICON, 256, 256, LR_SHARED ); if ( hIcon ) { cWnd.SetIcon( hIcon, TRUE ); } } } </code></pre> <p>The culprit is the "hi-res if available" part. If I include that, the Taskbar icon looks great but the Volume Mixer isn't scaled and looks terrible. If I exclude that, the Taskbar icon looks bad (terrible scaling) but the Volume Mixer at least is the right size:</p> <p><img src="https://i.stack.imgur.com/wvxDP.png" alt="Desktop Scaling 125% with 256x256 icon set"> <img src="https://i.stack.imgur.com/WeoQ9.png" alt="Desktop Scaling 125% with regular icons"></p> <p>Has anyone found a solution that makes it so that BOTH icons look good?</p> <p><strong>EDIT</strong>: In my icon file, I have the following resolutions: 256x256, 48x48, 32x32, 24x24, and 16x16, all 32-bit. The 256x256 one is PNG compressed, the others are raw. All of the sizes look great at the resolutions they are in the file (I was trying to put the ICO here or in imgur but apparently neither allow icons). Additionally I have tried including some 8-bit images but that doesn't seem to change things.</p> <p><strong>EDIT</strong>: I'm using <code>GetDeviceCaps( hdc, LOGPIXELSX )</code> (and Y) to determine the Desktop scaling. Normally desktop scaling is 100% and I get the normal 96 result. But more and more I'm seeing computers default to 125%. This can be changed via right-click Desktop, Personalize, other: Display... there's a slider there (requires log out/in for change).</p> <p><strong>EDIT</strong>: I also want to point out that the Tray ICON suffers a similar scaling issue fate when in high-DPI modes (that is, when using <code>Shell_NotifyIcon</code>). In this case, however, I'm able to use <code>GetDeviceCaps( hdc, LOGPIXELSX )</code> to determine what Windows wants.. if I have the size, provide it directly, otherwise provide the 256x256 one and Windows <em>does</em> scale it correctly.</p> <p><strong>EDIT</strong>: Sadness ensues. This problem may be a Windows issue. While capturing images for demonstration purposes, I noticed the Volume Mixer icon <em>itself</em> looks poor. For comparison: <img src="https://i.stack.imgur.com/6fulA.png" alt="Volume Mixer Comparison"></p> <p><strong>FINAL EDIT</strong>: As described below, the workaround for the issue is to scale the icons. So, the final code that works is to load a pointer to the <code>LoadIconWithScaleDown</code> function from <code>Comctl32.dll</code> (not shown) and use that if it was available, or fall back to the "regular/old" way:</p> <pre><code>HICON hIcon = 0; if ( FAILED( comctl32Loader.LoadIconWithScaleDown( theApp.m_hInstance, MAKEINTRESOURCE( res_id ), GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), &amp;hIcon ) ) ) { hIcon = theApp.LoadIcon( res_id ); } cWnd.SetIcon( hIcon, FALSE ); if ( FAILED( comctl32Loader.LoadIconWithScaleDown( theApp.m_hInstance, MAKEINTRESOURCE( res_id ), GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), &amp;hIcon ) ) ) { hIcon = theApp.LoadIcon( res_id ); } cWnd.SetIcon( hIcon, TRUE ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload