Thread: Newbee Q: reg. MFC dlg button & Vista UAC shield icon

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    3

    Question Newbee Q: reg. MFC dlg button & 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:

    Code:
    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?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You don't have to build on a Vista machine. You just need an SDK that can target Vista, build with _WIN32_WINNT >= 0x0600, and "the application must be manifested to use comctl32.dll version 6".

    If Vista isn't the only OS your app will be running on, I would also check that you are actually running on Vista.

    gg

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    3

    Talking

    Thanks! I think it's the manifest I'm missing.

  4. #4
    Registered User
    Join Date
    Dec 2008
    Posts
    3

    Lightbulb That was it!

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

    Code:
      <dependency>
        <dependentAssembly>
         <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
        </dependentAssembly>
      </dependency>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM

Tags for this Thread