dahall / AeroWizard

Library for easy creation of custom and Aero Wizards. Aero Wizard strictly follows Microsoft guidelines and uses Visual Styles to get visual theming.
MIT License
112 stars 32 forks source link

NextButtonShieldEnabled should throw if turned on and CommonControls version is less than 6.0 #86

Closed tcostin closed 4 years ago

tcostin commented 4 years ago

A typical .Net WinForms app gets a default manifest that does not specify version 6.0 of CommonControls, which is required for showing shield icon on buttons. If this is not done, the property fails silently when set to True - everything appears to works fine, but the call to SendMessage does nothing.

My testing suggests that it's not possible to fix this situation within the library itself. One can add a Win32 manifest to the DLL and specify CommonControls v6, but this doesn't fix the issue unless the primary EXE specifies this as well (both versions of the DLL get loaded into the process space, but the EXE's version probably takes precedence for WinForm bindings to CommCtl controls).

I suggest the following approach: check the CommonControls version sometime during AeroWizard startup (a static class initializer is probably best). If the check fails and user code attempts to set the above property to 'True', it should throw PlatformNotSupportedException (and detail the situation).

tcostin commented 4 years ago

For the record, this is the snippet that must be embedded in the manifest:

<dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>
dahall commented 4 years ago

Have you tried not using the manifest in your main exe and just calling Application.EnableVisualStyles(); before loading the main form?

dahall commented 4 years ago

Also, looking through my posts, I actually removed a check for Application.RenderWithVisualStyles that threw an exception as some customers wanted a graceful failure if visual styles were disabled. Sorry. If this is causing you problems, you can handle this condition in your host form.