Newbie Q: reg. MFC dlg resource & Vista UAC shield icon

I'm new to C++ and having trouble using the Button_SetElevationRequiredState Macro to decorate two button controls on an MFC dialog resource so that they show the elevation shield icon on Vista systems. The application is currently being compiled using MFC and Visual Studio 2005. I have an OnInitDialog() override for the dialog "BOOL CMyDialog::OnInitDialog()" which calls an ::EnableControl member function that takes an input number identifying the control and a boolean (to enable or disable the control). I've added the macro to the existing ::EnableControl code as indicated below in the commented section:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CODEPS_VOID CMyDialog::EnableControl (PS_INT nID, PS_BOOL enable)
{
    HWND phWnd;
    GetDlgItem(nID, &phWnd);
    
// NEW CODE BELOW HERE ***************************************
    // Decorate button control with elevation shield icon for Vista.    
    if ( (nID == IDC_BUTTON_APPLY_LICENSE_KEY) || (nID == IDC_BUTTON_REMOVE_LICENSE) )
        Button_SetElevationRequiredState ( phWnd,  TRUE );
// END NEW CODE **********************************************
    if (enable == PS_TRUE)
        ::EnableWindow(phWnd, TRUE);
    else
        ::EnableWindow(phWnd, FALSE);
}

Our CM team uses Windows Server 2003 build systems and Visual Studio 2005 and are very hesistant to upgrade anything without a full review of the impact to all our product builds (which is understandable). I see that the definition of the macro in the Commctrl.h header file requires the code to be compiled on a Vista or 2008 Server system (Windows 6 system) so I've tried setting up my own build system on a Vista Enterprise system with VS2005 to compile the code. I thought that would do the trick but I'm still not getting the shield icon to display on the button control when I run the application on a Vista system. (At this point, I'm not even trying to actually get the application to call the elevation dialog when the button is clicked, I'm just trying to decorate the button control itself with the shield icon.)

What am I doing wrong here? Is this the correct place to call the macro? Am I calling it correctly?
Someone on another forum pointed out that "the application must be manifested to use comctl32.dll version 6".

As soon as I added the attribute below to the embedded manifest file everything worked as expected. Thanks again!

1
2
3
4
5
  <dependency>
    <dependentAssembly>
     <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
Topic archived. No new replies allowed.