Can you use CMFCVisualManager with a dialog based application?

白昼怎懂夜的黑 提交于 2019-12-10 16:47:51

问题


Can you use CMFCVisualManager with a dialog based application to change the applications appearance? If so how is it done?

The idea is to change the shape, colour etc. of controls such as push buttons using the MFC Feature Pack released with MSVC 2008.


回答1:


No, can't be done, at least not if you're talking about the Feature Pack version. Version 10 of the BCGSoft libraries do have this functionality, see for example: http://www.bcgsoft.com/bcgcontrolbarpro-versions.htm and http://www.bcgsoft.com/images/SkinnedBuiltInDlgs.jpg. The MFC feature pack is more or less the previous version of the BCGSoft libraries, MS bought a license from them.




回答2:


You need to add the Common Controls manifest to your project resources. Here is the code for the manifest file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
 version="1.0.0.0"
 processorArchitecture="X86"
 name="Program Name"
 type="win32"
/>
<description>Description of Program</description>
<dependency>
 <dependentAssembly>
 <assemblyIdentity
   type="win32"
   name="Microsoft.Windows.Common-Controls"
   version="6.0.0.0"
   processorArchitecture="X86"
   publicKeyToken="6595b64144ccf1df"
   language="*"
 />
 </dependentAssembly>
</dependency>
</assembly>



回答3:


I think you can have some MFC-feature-pack features by implementing OnApplicationLook on your base CDialog (check Step 4 on this page). It might be better to implement the whole OnApplicationLook method, but you can test your application simply by adding this to OnInitDialog:

CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver);
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));
CDockingManager::SetDockingMode(DT_SMART);
RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE);



回答4:


This is the least amount of code to enable the Visual Styles. You should be able to pop your CDialog into the frame easily. The IDR_MAINFRAME is a menu resource.

class CMFCApplication2Dlg : public CFrameWndEx
{
    CMFCMenuBar bar;
public:
    CMFCApplication2Dlg() : CFrameWndEx()
    {
        LoadFrame(IDR_MAINFRAME);
        bar.Create(this);
    }
};

class CMFCApplication2App : public CWinAppEx
{
public:
    virtual BOOL InitInstance()
    {
        CWinAppEx::InitInstance();

        CMFCVisualManagerOffice2007::SetStyle(
            CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);

        CMFCVisualManager::SetDefaultManager(
            RUNTIME_CLASS(CMFCVisualManagerOffice2007));

        SetRegistryKey(_T("Local AppWizard-Generated Applications"));

        m_pMainWnd = new CMFCApplication2Dlg();

        m_pMainWnd->ShowWindow(SW_SHOW);
        m_pMainWnd->UpdateWindow();

        return TRUE;
    }
};

CMFCApplication2App theApp;


来源:https://stackoverflow.com/questions/72573/can-you-use-cmfcvisualmanager-with-a-dialog-based-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!