MFC in Orcas comes with several important changes, such as support for Vista specific command button and split button. I have put together a small demo application displaying a command button with the tex Say “Hello Vista” and the note “Click on this button to show a “Hello Vista” message!”.
The command button is still a CButton, but with the style BS_COMMANDLINK (or BS_DEFCOMMANDLINK for a default command button) set. To set the note you should use the SetNote() method. Additional GetNote() and GetNoteLength() methods are available for it. Here is a screenshot:
However, there are several problems with the Orcas March CTP that I want to mention (and I hope these will fixed for the next beta version).
When you create a project, add a command button and try to compile, the resource compiler will say that BS_COMMANDLINK is not recognized. The style is defined in commctrl.h like this:
#if _WIN32_WINNT >= 0x0600
// BUTTON STATE FLAGS
#define BST_DROPDOWNPUSHED 0x0400
// BUTTON STYLES
#define BS_SPLITBUTTON 0x0000000CL
#define BS_DEFSPLITBUTTON 0x0000000DL
#define BS_COMMANDLINK 0x0000000EL
#define BS_DEFCOMMANDLINK 0x0000000FL
Trying to define _WIN32_WINNT as 0x0600 either in the project properties or in stdafx.h (if you use precompiled headers) does not help. You have to redeclare the styles whether in resource.h or in the .rc file, but as soon as the IDE modifies them, the code you put there is gone. This is a real bummer, and I’m still looking for the best solution. If I find it, I’ll post it here.
The methods that are available for the command button are defined only for UNICODE builds for Vista, as can be seen in afxwin.h:
#if ( _WIN32_WINNT >= 0x0600 ) && defined(UNICODE)
CString GetNote() const;
_Check_return_ BOOL GetNote(_Out_z_cap_(*pcchNote) LPTSTR lpszNote, _Inout_ UINT* pcchNote) const;
BOOL SetNote(_In_z_ LPCTSTR lpszNote);
UINT GetNoteLength() const;
BOOL GetSplitInfo(_Out_ PBUTTON_SPLITINFO pInfo) const;
BOOL SetSplitInfo(_In_ PBUTTON_SPLITINFO pInfo);
UINT GetSplitStyle() const;
BOOL SetSplitStyle(_In_ UINT nStyle);
BOOL GetSplitSize(_Out_ LPSIZE pSize) const;
BOOL SetSplitSize(_In_ LPSIZE pSize);
CImageList* GetSplitImageList() const;
BOOL SetSplitImageList(_In_ CImageList* pSplitImageList);
TCHAR GetSplitGlyph() const;
BOOL SetSplitGlyph(_In_ TCHAR chGlyph);
BOOL SetDropDownState(_In_ BOOL fDropDown);
// Sets whether the action associated with the button requires elevated permissions.
// If elevated permissions are required then the button should display an elevated icon.
HICON SetShield(_In_ BOOL fElevationRequired);
#endif // ( _WIN32_WINNT >= 0x600 ) && defined(UNICODE)
However, if you look in MSDN, method SetShield is not found (though you can find the BCM_SETSHIELD window message). Instead SetElevationRequired() is listed as a member of CButton. This method does not actually exists. Moreover, the people that wrote the documentation don’t seem to know the difference between BOOL and bool (explained here). This method takes a BOOL and returns a BOOL, but MSDN says it returns
true if the method is successful; otherwise false
Using SetShield() with TRUE, displays a shield icon on the button, as shown here:
I hope the issues I mentioned above will be address very soon.