SDI实现多视图并切换视图

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.****.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

 

 

 

 

 

    Visual Studio 2010的新特性里面Ribbon界面是一个很重要的东西,Ribbon界面非常易用和高效,也不去强调和证明它将成为未来应用程序界面的一种趋势。为了让我们的应用程序“Ready for Windows 7”,我们有必要根据实际的情况需要,为我们的应用程序添加Ribbon界面。

 为了推广Ribbon界面,为了讨好程序员们,让程序员可以轻松地为各种应用程序创建Ribbon界面,微软真是不遗余力,不断地推出新的Ribbon界面接口。为了可以让所有基于C++的普通Windows应用程序都可以添加Ribbon界面,微软在Windows 7 SDK中,又推出了基于COM的接口——Scenic Ribbon API。

  利用Scenic Ribbon API,我们可以更加灵活方便地为各种Windows应用程序添加Ribbon界面,改善应用程序的用户体验。在接下来的文章中,我们就介绍一下如何利用这种新的方式为普通Windows应用程序添加Ribbon界面。

  我们都知道,Ribbon界面是随着Office 2007一同发布的。在过去的几年中,微软不断地吸取用户对Ribbon界面的反馈,不断地对其进行改进,到了Windows 7,微软正式加入了命名为Scenic Ribbon的第二代Ribbon界面,即取代第一代Ribbon的升级版本。随着Scenic Ribbon成为Windows 7的一部分以及微软所提供的Scenic Ribbon API,这意味着今后第三方程序开发者能在自己开发的应用程序中免费用上这种界面形式。Scenic Ribbon作为第二代Ribbon界面,所适用的是所有的Windows应用程序,和前代有所不同是理所当然的。例如,由于最初Ribbon界面是Office专用,因此使用Ribbon界面的Office 2007程序窗口左上角都有一个比较显眼的Office图标按钮。当应用到其他程序之后,这个图标显然不能继续存在,因此在Scenic Ribbon中,这个位置就被相应应用程序自身的图标所取代。另外,为了满足各种应用程序的需要,Scenic Ribbon还添加了部分Ribbon控件,使得Ribbon界面的控件更加丰富,能够应对各种应用程序对Ribbon界面控件的需要。值得一提的是,Office作为Ribbon界面的开山鼻祖,到了Office的下一个版本Office 2010,也全面使用了Scenic Ribbon以替代第一代Ribbon界面。

   同时微软在VisualC++2010也提供了Ribbon资源设计器,使Ribbon开发更加简单快捷。

 Scenic Ribbon API是一套基于COM的非托管API。通过这套API,我们可以为所有基于Windows的非托管应用程序创建Ribbon界面面板,添加Ribbon控件,处理Ribbon控件的各种动作,执行某种业务逻辑等等。而至于Ribbon界面的布局,各个控件的位置和属性等,则是通过基于XAML的xml文件来进行定义和描述的。编译器会将这个XML文件编译成相应的资源文件,头文件和二进制的BML文件。而Scenic Ribbon API最终会读取这些描述控件信息的文件并创建Ribbon界面。在业务逻辑层,Scenic Ribbon API提供了相应的Execute函数来处理所有控件的消息,在其中我们可以完成相应的业务逻辑。

在Windows 7中,微软还为我们提供了用于为非托管代码(Native)应用程序创建Ribbon界面的Scenic Ribbon API的解决方案。另外,针对基于WPF的托管代码应用程序,微软还将提供另外的基于WPF的Ribbon界面解决方案。

Firefox 3.7已经采用Windows7的Ribbon界面。

   下面我们亲自来动手构建一个基于VisualC++2010开发windows7的tabelt pc应用的WindowsRibbon范例

    1.帅气的VS2010启动画面,启动VS2010

SDI实现多视图并切换视图

    2.创建inkdoc的MFC工程

SDI实现多视图并切换视图

 

3.MFC向导1

SDI实现多视图并切换视图

4.MFC向导2,选择中文界面,多文档程序,以及windows7风格

SDI实现多视图并切换视图

5.MFC向导3,跳过

 

SDI实现多视图并切换视图

6.MFC向导4,创建文档格式,文件名

SDI实现多视图并切换视图

7.MFC向导5。跳过

SDI实现多视图并切换视图

8.MFC向导6,选择Ribbon

SDI实现多视图并切换视图

9.MFC向导7,设置高级选项

SDI实现多视图并切换视图

10.MFC设置8,设置CFORMVIEW,

SDI实现多视图并切换视图

 

11.打印提示,不理睬,直接跳过

SDI实现多视图并切换视图

 

 

 

12.VisualC++2010自带的Ribbon编辑器

SDI实现多视图并切换视图

 

 

 

 13.操作与工具箱控件一样操作,设置按钮属性

SDI实现多视图并切换视图

 

 

 

 

 14.设置按钮

SDI实现多视图并切换视图

 

15.设置按钮属性,

SDI实现多视图并切换视图

 

16.为按钮添加事件

SDI实现多视图并切换视图

 

 

 

 

17.类似菜单的操作

SDI实现多视图并切换视图

 

 

18.在Formview,选择对话框,插入flash控件,然后为flash添加MFC   activeX  类向导

SDI实现多视图并切换视图

 

 

19.插入flash控件类

SDI实现多视图并切换视图

 

 

 

帅的惊动了****的windows7的tabelt pc应用的WindowsRibbon范例的效果图

 

SDI实现多视图并切换视图

 

 

 

 

SDI实现多视图并切换视图

 

 

 

 

 

 

 

 

SDI实现多视图并切换视图

 

 

SDI实现多视图并切换视图

 

 

 

SDI实现多视图并切换视图

 

 

 

 

SDI实现多视图并切换视图

 

 

 

tablet PC的轨迹核心代码如下

  1. #include <windows.h>     
  2. #include <comdef.h>     
  3. #include <msinkaut.h>     
  4. #include <msinkaut_i.c>  //包含windows SDK  for windows7的核心tabletpc头文件     
  5. #include "resource.h"     
  6.     
  7.     
  8. const TCHAR*    gc_szAppName = TEXT("Basic Recognition");     
  9.     
  10. // 建立轨迹指针,识别指针,轨迹画板指针     
  11. IInkCollector *     g_pIInkCollector    = NULL;     
  12. IInkDisp *          g_pIInkDisp         = NULL;     
  13. IInkRecognizerContext *   g_pIInkRecoContext  = NULL;     
  14.       
  15. //定义初始化变量     
  16. const LPOLESTR gc_pwsInputScopes[] = {     
  17.     L"(!IS_DEFAULT)",     
  18.     L"(!IS_URL)",     
  19.     L"(!IS_FILE_FULLFILEPATH)",     
  20.     L"(!IS_FILE_FILENAME)",     
  21.     L"(!IS_EMAIL_USERNAME)",     
  22.     L"(!IS_EMAIL_SMTPEMAILADDRESS)",     
  23.     L"(!IS_LOGINNAME)",     
  24.     L"(!IS_PERSONALNAME_FULLNAME)",     
  25.     L"(!IS_PERSONALNAME_PREFIX)",     
  26.     L"(!IS_PERSONALNAME_GIVENNAME)",     
  27.     L"(!IS_PERSONALNAME_MIDDLENAME)",     
  28.     L"(!IS_PERSONALNAME_SURNAME)",     
  29.     L"(!IS_PERSONALNAME_SUFFIX)",     
  30.     L"(!IS_ADDRESS_FULLPOSTALADDRESS)",     
  31.     L"(!IS_ADDRESS_POSTALCODE)",     
  32.     L"(!IS_ADDRESS_STREET)",     
  33.     L"(!IS_ADDRESS_STATEORPROVINCE)",     
  34.     L"(!IS_ADDRESS_CITY)",     
  35.     L"(!IS_ADDRESS_COUNTRYNAME)",     
  36.     L"(!IS_ADDRESS_COUNTRYSHORTNAME)",     
  37.     L"(!IS_CURRENCY_AMOUNTANDSYMBOL)",     
  38.     L"(!IS_CURRENCY_AMOUNT)",     
  39.     L"(!IS_DATE_FULLDATE)",     
  40.     L"(!IS_DATE_MONTH)",     
  41.     L"(!IS_DATE_DAY)",     
  42.     L"(!IS_DATE_YEAR)",     
  43.     L"(!IS_DATE_MONTHNAME)",     
  44.     L"(!IS_DATE_DAYNAME)",     
  45.     L"(!IS_DIGITS)",     
  46.     L"(!IS_NUMBER)",     
  47.     L"(!IS_ONECHAR)",     
  48.     L"(!IS_TELEPHONE_FULLTELEPHONENUMBER)",     
  49.     L"(!IS_TELEPHONE_COUNTRYCODE)",     
  50.     L"(!IS_TELEPHONE_AREACODE)",     
  51.     L"(!IS_TELEPHONE_LOCALNUMBER)",     
  52.     L"(!IS_TIME_FULLTIME)",     
  53.     L"(!IS_TIME_HOUR)",     
  54.     L"(!IS_TIME_MINORSEC)",     
  55.     L"((0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?-? ?)?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?-? ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9)",     
  56.     L"(!IS_PERSONALNAME_FULLNAME)|((!IS_PERSONALNAME_PREFIX)? +(!IS_PERSONALNAME_GIVENNAME)+ +(!IS_PERSONALNAME_MIDDLENAME)* +(!IS_PERSONALNAME_SURNAME)+)",     
  57.     L"MN(0|1|2|3|4|5|6|7|8|9)(0|1|2|3|4|5|6|7|8|9)(A|B)(!IS_DIGITS)(X|Y)((0|1)*)"    
  58. };     
  59.     
  60.     
  61. const LONG gc_lMaxInputScopeMenuItemLength = 40;     
  62.     
  63. // 定义笔势常量     
  64. const InkApplicationGesture gc_igtSingleStrokeGestures[] = {     
  65.     IAG_Scratchout, IAG_Triangle, IAG_Square, IAG_Star, IAG_Check,     
  66.     IAG_Circle, IAG_DoubleCircle, IAG_Curlicue, IAG_DoubleCurlicue,     
  67.     IAG_SemiCircleLeft, IAG_SemiCircleRight,     
  68.     IAG_ChevronUp, IAG_ChevronDown, IAG_ChevronLeft,     
  69.     IAG_ChevronRight, IAG_Up, IAG_Down, IAG_Left, IAG_Right, IAG_UpDown, IAG_DownUp,     
  70.     IAG_LeftRight, IAG_RightLeft, IAG_UpLeftLong, IAG_UpRightLong, IAG_DownLeftLong,     
  71.     IAG_DownRightLong, IAG_UpLeft, IAG_UpRight, IAG_DownLeft, IAG_DownRight, IAG_LeftUp,     
  72.     IAG_LeftDown, IAG_RightUp, IAG_RightDown, IAG_Tap     
  73. };     
  74.     
  75. const UINT gc_nRecommendedForMixedMode[] = {     
  76.         0 /*Scratchout*/, 3/*Star*/, 6/*Double Circle*/,     
  77.         7 /*Curlicue*/, 8 /*Double Curlicue*/, 25 /*Down-Left Long*/ };     
  78.     
  79. const InkApplicationGesture gc_igtMultiStrokeGestures[] = {     
  80.     IAG_ArrowUp, IAG_ArrowDown, IAG_ArrowLeft,     
  81.     IAG_ArrowRight, IAG_Exclamation, IAG_DoubleTap     
  82. };     
  83.     
  84.     
  85. const _ATL_FUNC_INFO IInkRecognitionEventsImpl<CAdvRecoApp>::mc_AtlFuncInfo =     
  86.         {CC_STDCALL, VT_EMPTY, 3, {VT_UNKNOWN, VT_VARIANT, VT_I4}};     
  87.     
  88. const _ATL_FUNC_INFO IInkCollectorEventsImpl<CAdvRecoApp>::mc_AtlFuncInfo[2] = {     
  89.         {CC_STDCALL, VT_EMPTY, 3, {VT_UNKNOWN, VT_UNKNOWN, VT_BOOL|VT_BYREF}},     
  90.         {CC_STDCALL, VT_EMPTY, 4, {VT_UNKNOWN, VT_UNKNOWN, VT_VARIANT, VT_BOOL|VT_BYREF}}     
  91. };     
  92.     
  93. const TCHAR gc_szAppName[] = TEXT("****专家尹成的程序,http://blog.****.net/yincheng01");     
  94. /////////////////////////////////////////////////////////     
  95. //     
  96.     
  97. //清除Com指针     
  98. /////////////////////////////////////////////////////////     
  99. void Cinkdoc::CleanUp()  // Release all objects     
  100. {     
  101.     if (g_pIInkRecoContext != NULL)     
  102.     {     
  103.         g_pIInkRecoContext->Release();     
  104.         g_pIInkRecoContext = NULL;     
  105.     }     
  106.     
  107.     if (g_pIInkDisp != NULL)     
  108.     {     
  109.         g_pIInkDisp->Release();     
  110.         g_pIInkDisp = NULL;     
  111.     }     
  112.     
  113.     if (g_pIInkCollector != NULL)     
  114.     {     
  115.         g_pIInkCollector->Release();     
  116.         g_pIInkCollector = NULL;     
  117.     }     
  118. }     
  119. void Cinkdoc::Reco()  //识别  
  120. {     
  121.   //获取识别结果,并显示最优化识别结果     
  122.                    
  123.                 HCURSOR hCursor = ::SetCursor(::LoadCursor(NULL, IDC_WAIT));     
  124.                //获取轨迹指针用于识别     
  125.                 IInkStrokes* pIInkStrokes = NULL;     
  126.                 HRESULT hr = g_pIInkDisp->get_Strokes(&pIInkStrokes);     
  127.                 if (SUCCEEDED(hr))     
  128.                 {     
  129.                      
  130.                     hr = g_pIInkRecoContext->putref_Strokes(pIInkStrokes);     
  131.                     if (SUCCEEDED(hr))     
  132.                     {    //利用识别指针获取识别结果     
  133.                     
  134.                         IInkRecognitionResult* pIInkRecoResult = NULL;     
  135.                         InkRecognitionStatus RecognitionStatus;     
  136.                         hr = g_pIInkRecoContext->Recognize(&RecognitionStatus, &pIInkRecoResult);     
  137.                         if (SUCCEEDED(hr) && (pIInkRecoResult!= NULL))     
  138.                         {     
  139.                            
  140.                             BSTR bstrBestResult = NULL;     
  141.                             hr = pIInkRecoResult->get_TopString(&bstrBestResult);     
  142.                             pIInkRecoResult->Release();     
  143.                             pIInkRecoResult = NULL;     
  144.     
  145.                          
  146.                             if (SUCCEEDED(hr) && bstrBestResult)     
  147.                             {     
  148.                                 MessageBoxW(hwnd, bstrBestResult,     
  149.                                             L"识别结果", MB_OK);     
  150.                                 SysFreeString(bstrBestResult);     
  151.                             }     
  152.                         }     
  153.                       
  154.                         g_pIInkRecoContext->putref_Strokes(NULL);     
  155.                     }     
  156.                     pIInkStrokes->Release();     
  157.                 }     
  158.             
  159.                 ::SetCursor(hCursor);     
  160. }     
  161.   
  162. void Cinkdoc::start()  // 开始创建    
  163. {     
  164.      
  165.            //并创建com指针接口     
  166.             HRESULT hr;     
  167.     
  168.               
  169.                 
  170.             hr = CoCreateInstance(CLSID_InkRecognizerContext,     
  171.                                   NULL, CLSCTX_INPROC_SERVER,     
  172.                                   IID_IInkRecognizerContext,     
  173.                                   (void **) &g_pIInkRecoContext);     
  174.             if (FAILED(hr))     
  175.             {     
  176.                     
  177.                 return -1;     
  178.             }     
  179.     
  180.                
  181.             hr = CoCreateInstance(CLSID_InkCollector,     
  182.                                   NULL, CLSCTX_INPROC_SERVER,     
  183.                                   IID_IInkCollector,     
  184.                                   (void **) &g_pIInkCollector);     
  185.             if (FAILED(hr))     
  186.                 return -1;     
  187.     
  188.                 
  189.             hr = g_pIInkCollector->get_Ink(&g_pIInkDisp);     
  190.             if (FAILED(hr))     
  191.                 return -1;     
  192.     
  193.                
  194.             hr = g_pIInkCollector->put_hWnd((long)this->hwnd);     
  195.             if (FAILED(hr))     
  196.                 return -1;     
  197.     
  198.             hr = g_pIInkCollector->put_Enabled(VARIANT_TRUE);     
  199.             if (FAILED(hr))     
  200.                 return -1;     
  201.      
  202. }    
  203.   
  204.   
  205.   
  206.   
  207.   
  208.   
  209.   
  210. //笔势事件     
  211. HRESULT Cinkdoc::OnGesture(     
  212.         IInkCursor* /*pIInkCursor*/,     
  213.         IInkStrokes* pInkStrokes,     
  214.         VARIANT vGestures,     
  215.         VARIANT_BOOL* pbCancel     
  216.         )     
  217. {     
  218.     if (((VT_ARRAY | VT_DISPATCH) != vGestures.vt) || (NULL == vGestures.parray))     
  219.         return E_INVALIDARG;     
  220.     if (0 == vGestures.parray->rgsabound->cElements)     
  221.         return E_INVALIDARG;     
  222.     
  223.    / /数组中的手势应该是排序的承认     
  224.     / /置信水平。此示例拿起最高之一。     
  225.     / /注意:当在InkAndGesture收集模式,除了预期的手势     
  226.     / /应用程序也有可能是带着身份证IAG_NoGesture手势对象     
  227.     / /此应用程序时,如果取消与ISG_NoGesture对象     
  228.     / /最高水平的信心数组(第一项)。     
  229.     InkApplicationGesture idGesture = IAG_NoGesture;     
  230.     IDispatch** ppIDispatch;     
  231.     HRESULT hr = ::SafeArrayAccessData(vGestures.parray, (void HUGEP**)&ppIDispatch);     
  232.     if (SUCCEEDED(hr))     
  233.     {     
  234.         CComQIPtr<IInkGesture> spIInkGesture(ppIDispatch[0]);     
  235.         if (spIInkGesture != NULL)     
  236.         {     
  237.             hr = spIInkGesture->get_Id(&idGesture);     
  238.         }     
  239.         ::SafeArrayUnaccessData(vGestures.parray);     
  240.     }     
  241.     
  242.   / /加载资源字符串表的姿态名称     
  243.     UINT idGestureName;     
  244.     bool bAccepted;     // will be true, if the gesture is known to this application     
  245.     if (IAG_NoGesture != idGesture)     
  246.     {     
  247.         bAccepted = GetGestureName(idGesture, idGestureName);     
  248.     }     
  249.     else         
  250.     {     
  251.         bAccepted = false;     
  252.         idGestureName = 0;     
  253.     }     
  254.     
  255.   //如果当前的收集模式ICM_GestureOnly或者如果我们接受     
  256.     //的姿态,手势的中风将被删除从墨迹对象,     
  257.     //因此,窗口需要在招'区更新。     
  258.     if (ID_MODE_GESTURES == m_nCmdMode || true == bAccepted)     
  259.     {     
  260.         // Get the rectangle to update.     
  261.         RECT rc;     
  262.         CComPtr<IInkRectangle> spIInkRect;     
  263.         if (m_spIInkRenderer != NULL     
  264.             && pInkStrokes != NULL     
  265.             && SUCCEEDED(pInkStrokes->GetBoundingBox(IBBM_Default, &spIInkRect))     
  266.             && SUCCEEDED(spIInkRect->GetRectangle(&rc.top, &rc.left,     
  267.                                                   &rc.bottom, &rc.right)))     
  268.         {     
  269.                
  270.             HDC hdc = m_wndInput.GetDC();     
  271.             if (NULL != hdc)     
  272.             {     
  273.                 if (FAILED(m_spIInkRenderer->InkSpaceToPixel((long)hdc, &rc.left, &rc.top))     
  274.                     || FAILED(m_spIInkRenderer->InkSpaceToPixel((long)hdc, &rc.right,     
  275.                                                                 &rc.bottom)))     
  276.                 {     
  277.                        
  278.                     m_wndInput.GetClientRect(&rc);     
  279.                 }     
  280.                 ReleaseDC(hdc);     
  281.             }     
  282.             else    
  283.             {     
  284.                
  285.                 m_wndInput.GetClientRect(&rc);     
  286.             }     
  287.         }     
  288.         else    
  289.         {     
  290.                
  291.             m_wndInput.GetClientRect(&rc);     
  292.         }     
  293.     
  294.         m_wndInput.InvalidateRect(&rc);     
  295.     }     
  296.     else // if something's failed,     
  297.           
  298.     {     
  299.            
  300.         *pbCancel = VARIANT_TRUE;     
  301.         idGestureName = IDS_GESTURE_UNKNOWN;     
  302.     }     
  303.     
  304.         
  305.     m_wndResults.SetGestureName(idGestureName);     
  306.     m_wndResults.Invalidate();     
  307.     
  308.     return hr;     
  309. }     
  310.     
  311. // Recognition event handlers 识别器事件     
  312. HRESULT Cinkdoc::OnRecognitionWithAlternates(     
  313.         IInkRecognitionResult* pIInkRecoResult,     
  314.         VARIANT /*vCustomParam*/,     
  315.         InkRecognitionStatus /*RecognitionStatus*/    
  316.         )     
  317. {     
  318.     if (NULL == pIInkRecoResult)     
  319.         return E_INVALIDARG;     
  320.     
  321.     
  322.     m_wndResults.ResetResults();     
  323.     
  324.     // Get the best lCount results     
  325.     HRESULT hr;     
  326.     CComPtr<IInkRecognitionAlternates> spIInkRecoAlternates;     
  327.     hr = pIInkRecoResult->AlternatesFromSelection(     
  328.         0,                                
  329.         -1,                               
  330.         CRecoOutputWnd::mc_iNumResults,      
  331.         &spIInkRecoAlternates             
  332.         );     
  333.     
  334.        
  335.     LONG lCount = 0;     
  336.     if (SUCCEEDED(hr) && SUCCEEDED(spIInkRecoAlternates->get_Count(&lCount)))     
  337.     {     
  338.         
  339.         IInkRecognitionAlternate* pIInkRecoAlternate = NULL;     
  340.         for (LONG iItem = 0; (iItem < lCount) && (iItem < CRecoOutputWnd::mc_iNumResults); iItem++)     
  341.         {     
  342.             
  343.             if (SUCCEEDED(spIInkRecoAlternates->Item(iItem, &pIInkRecoAlternate)))     
  344.             {     
  345.                 BSTR bstr = NULL;     
  346.                 if (SUCCEEDED(pIInkRecoAlternate->get_String(&bstr)))     
  347.                 {     
  348.                     m_wndResults.m_bstrResults[iItem].Attach(bstr);     
  349.                 }     
  350.                 pIInkRecoAlternate->Release();     
  351.             }     
  352.         }     
  353.     }     
  354.     
  355.     // Update the output window with the new results     
  356.     m_wndResults.Invalidate();     
  357.     
  358.     return S_OK;     
  359. }     
  360.     
  361. //识别结果获取     
  362. LRESULT Cinkdoc::OnRecognizer(     
  363.         WORD /*wNotifyCode*/,     
  364.         WORD wID,     
  365.         HWND /*hWndCtl*/,     
  366.         BOOL/*bHandled*/    
  367.         )     
  368. {     
  369.     if (m_spIInkRecognizers == NULL || wID == m_nCmdRecognizer)     
  370.         return 0;     
  371.     
  372.       
  373.     HRESULT hr;     
  374.     CComPtr<IInkRecognizer> spIInkRecognizer;     
  375.     if (ID_RECOGNIZER_DEFAULT == wID)     
  376.     {     
  377.             
  378.         hr = m_spIInkRecognizers->GetDefaultRecognizer(0, &spIInkRecognizer);//获取默认识别器设置之     
  379.     }     
  380.     else    
  381.     {     
  382.         hr = m_spIInkRecognizers->Item(wID - ID_RECOGNIZER_FIRST, &spIInkRecognizer);//否则获取第一个识别器设置之     
  383.     }     
  384.     
  385.        
  386.     if (SUCCEEDED(hr) && UseRecognizer(spIInkRecognizer))     
  387.     {     
  388.           
  389.         UpdateMenuRadioItems(mc_iSubmenuRecognizers, wID, m_nCmdRecognizer);     
  390.         m_bstrCurRecoName.Empty();     
  391.         spIInkRecognizer->get_Name(&m_bstrCurRecoName);     
  392.         UpdateStatusBar();     
  393.           
  394.         m_nCmdRecognizer = wID;     
  395.     }     
  396.     
  397.     return 0;     
  398. }     
  399. //输入获取     
  400. LRESULT Cinkdoc::OnInputScopeCoerce(     
  401.         WORD /*wNotifyCode*/,     
  402.         WORD wID,     
  403.         HWND /*hWndCtl*/,     
  404.         BOOL/*bHandled*/    
  405.         )     
  406. {     
  407.     
  408.     if (m_spIInkRecoContext == NULL )     
  409.         return 0;     
  410.     if (m_spIInkStrokes != NULL)     
  411.     {     
  412.         m_spIInkRecoContext->putref_Strokes(NULL);     
  413.     }     
  414.     
  415.     
  416.     if (FAILED(m_spIInkRecoContext->put_RecognitionFlags (m_bCoerceInputScope?IRM_None:IRM_Coerce)))     
  417.     {     
  418.         MessageBox(TEXT("获取结果失败!"),     
  419.                        gc_szAppName, MB_ICONERROR | MB_OK);     
  420.         // Re-attach the stroke collection to the context     
  421.         if (m_spIInkStrokes != NULL)     
  422.         {     
  423.             m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);     
  424.         }     
  425.             return 0;     
  426.         }     
  427.     m_bCoerceInputScope = !m_bCoerceInputScope;     
  428.     
  429.     // 收集笔迹     
  430.     if (m_spIInkStrokes != NULL)     
  431.     {     
  432.         m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);     
  433.     }     
  434.     
  435.     // 更新识别结果     
  436.     CComVariant vCustomData;    // no custom data     
  437.     m_spIInkRecoContext->BackgroundRecognizeWithAlternates(vCustomData);     
  438.     
  439.      
  440.     
  441.     return 0;     
  442. }      
#include <windows.h>   #include <comdef.h>   #include <msinkaut.h>   #include <msinkaut_i.c>  //包含windows SDK  for windows7的核心tabletpc头文件   #include "resource.h"       const TCHAR*    gc_szAppName = TEXT("Basic Recognition");     // 建立轨迹指针,识别指针,轨迹画板指针   IInkCollector *     g_pIInkCollector    = NULL;   IInkDisp *          g_pIInkDisp         = NULL;   IInkRecognizerContext *   g_pIInkRecoContext  = NULL;       //定义初始化变量   const LPOLESTR gc_pwsInputScopes[] = {       L"(!IS_DEFAULT)",       L"(!IS_URL)",       L"(!IS_FILE_FULLFILEPATH)",       L"(!IS_FILE_FILENAME)",       L"(!IS_EMAIL_USERNAME)",       L"(!IS_EMAIL_SMTPEMAILADDRESS)",       L"(!IS_LOGINNAME)",       L"(!IS_PERSONALNAME_FULLNAME)",       L"(!IS_PERSONALNAME_PREFIX)",       L"(!IS_PERSONALNAME_GIVENNAME)",       L"(!IS_PERSONALNAME_MIDDLENAME)",       L"(!IS_PERSONALNAME_SURNAME)",       L"(!IS_PERSONALNAME_SUFFIX)",       L"(!IS_ADDRESS_FULLPOSTALADDRESS)",       L"(!IS_ADDRESS_POSTALCODE)",       L"(!IS_ADDRESS_STREET)",       L"(!IS_ADDRESS_STATEORPROVINCE)",       L"(!IS_ADDRESS_CITY)",       L"(!IS_ADDRESS_COUNTRYNAME)",       L"(!IS_ADDRESS_COUNTRYSHORTNAME)",       L"(!IS_CURRENCY_AMOUNTANDSYMBOL)",       L"(!IS_CURRENCY_AMOUNT)",       L"(!IS_DATE_FULLDATE)",       L"(!IS_DATE_MONTH)",       L"(!IS_DATE_DAY)",       L"(!IS_DATE_YEAR)",       L"(!IS_DATE_MONTHNAME)",       L"(!IS_DATE_DAYNAME)",       L"(!IS_DIGITS)",       L"(!IS_NUMBER)",       L"(!IS_ONECHAR)",       L"(!IS_TELEPHONE_FULLTELEPHONENUMBER)",       L"(!IS_TELEPHONE_COUNTRYCODE)",       L"(!IS_TELEPHONE_AREACODE)",       L"(!IS_TELEPHONE_LOCALNUMBER)",       L"(!IS_TIME_FULLTIME)",       L"(!IS_TIME_HOUR)",       L"(!IS_TIME_MINORSEC)",       L"((0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?-? ?)?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?-? ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9) ?(0|1|2|3|4|5|6|7|8|9)",       L"(!IS_PERSONALNAME_FULLNAME)|((!IS_PERSONALNAME_PREFIX)? +(!IS_PERSONALNAME_GIVENNAME)+ +(!IS_PERSONALNAME_MIDDLENAME)* +(!IS_PERSONALNAME_SURNAME)+)",       L"MN(0|1|2|3|4|5|6|7|8|9)(0|1|2|3|4|5|6|7|8|9)(A|B)(!IS_DIGITS)(X|Y)((0|1)*)"  };       const LONG gc_lMaxInputScopeMenuItemLength = 40;     // 定义笔势常量   const InkApplicationGesture gc_igtSingleStrokeGestures[] = {       IAG_Scratchout, IAG_Triangle, IAG_Square, IAG_Star, IAG_Check,       IAG_Circle, IAG_DoubleCircle, IAG_Curlicue, IAG_DoubleCurlicue,       IAG_SemiCircleLeft, IAG_SemiCircleRight,       IAG_ChevronUp, IAG_ChevronDown, IAG_ChevronLeft,       IAG_ChevronRight, IAG_Up, IAG_Down, IAG_Left, IAG_Right, IAG_UpDown, IAG_DownUp,       IAG_LeftRight, IAG_RightLeft, IAG_UpLeftLong, IAG_UpRightLong, IAG_DownLeftLong,       IAG_DownRightLong, IAG_UpLeft, IAG_UpRight, IAG_DownLeft, IAG_DownRight, IAG_LeftUp,       IAG_LeftDown, IAG_RightUp, IAG_RightDown, IAG_Tap   };     const UINT gc_nRecommendedForMixedMode[] = {           0 /*Scratchout*/, 3/*Star*/, 6/*Double Circle*/,           7 /*Curlicue*/, 8 /*Double Curlicue*/, 25 /*Down-Left Long*/ };     const InkApplicationGesture gc_igtMultiStrokeGestures[] = {       IAG_ArrowUp, IAG_ArrowDown, IAG_ArrowLeft,       IAG_ArrowRight, IAG_Exclamation, IAG_DoubleTap   };       const _ATL_FUNC_INFO IInkRecognitionEventsImpl<CAdvRecoApp>::mc_AtlFuncInfo =           {CC_STDCALL, VT_EMPTY, 3, {VT_UNKNOWN, VT_VARIANT, VT_I4}};     const _ATL_FUNC_INFO IInkCollectorEventsImpl<CAdvRecoApp>::mc_AtlFuncInfo[2] = {           {CC_STDCALL, VT_EMPTY, 3, {VT_UNKNOWN, VT_UNKNOWN, VT_BOOL|VT_BYREF}},           {CC_STDCALL, VT_EMPTY, 4, {VT_UNKNOWN, VT_UNKNOWN, VT_VARIANT, VT_BOOL|VT_BYREF}}   };     const TCHAR gc_szAppName[] = TEXT("****专家尹成的程序,http://blog.****.net/yincheng01");   /////////////////////////////////////////////////////////   //     //清除Com指针   /////////////////////////////////////////////////////////   void Cinkdoc::CleanUp()  // Release all objects   {       if (g_pIInkRecoContext != NULL)       {           g_pIInkRecoContext->Release();           g_pIInkRecoContext = NULL;       }         if (g_pIInkDisp != NULL)       {           g_pIInkDisp->Release();           g_pIInkDisp = NULL;       }         if (g_pIInkCollector != NULL)       {           g_pIInkCollector->Release();           g_pIInkCollector = NULL;       }   }   void Cinkdoc::Reco()  //识别{     //获取识别结果,并显示最优化识别结果                                    HCURSOR hCursor = ::SetCursor(::LoadCursor(NULL, IDC_WAIT));                  //获取轨迹指针用于识别                   IInkStrokes* pIInkStrokes = NULL;                   HRESULT hr = g_pIInkDisp->get_Strokes(&pIInkStrokes);                   if (SUCCEEDED(hr))                   {                                          hr = g_pIInkRecoContext->putref_Strokes(pIInkStrokes);                       if (SUCCEEDED(hr))                       {    //利用识别指针获取识别结果                                             IInkRecognitionResult* pIInkRecoResult = NULL;                           InkRecognitionStatus RecognitionStatus;                           hr = g_pIInkRecoContext->Recognize(&RecognitionStatus, &pIInkRecoResult);                           if (SUCCEEDED(hr) && (pIInkRecoResult!= NULL))                           {                                                        BSTR bstrBestResult = NULL;                               hr = pIInkRecoResult->get_TopString(&bstrBestResult);                               pIInkRecoResult->Release();                               pIInkRecoResult = NULL;                                                        if (SUCCEEDED(hr) && bstrBestResult)                               {                                   MessageBoxW(hwnd, bstrBestResult,                                               L"识别结果", MB_OK);                                   SysFreeString(bstrBestResult);                               }                           }                                               g_pIInkRecoContext->putref_Strokes(NULL);                       }                       pIInkStrokes->Release();                   }                             ::SetCursor(hCursor);   }   void Cinkdoc::start()  // 开始创建  {                 //并创建com指针接口               HRESULT hr;                                           hr = CoCreateInstance(CLSID_InkRecognizerContext,                                     NULL, CLSCTX_INPROC_SERVER,                                     IID_IInkRecognizerContext,                                     (void **) &g_pIInkRecoContext);               if (FAILED(hr))               {                                     return -1;               }                              hr = CoCreateInstance(CLSID_InkCollector,                                     NULL, CLSCTX_INPROC_SERVER,                                     IID_IInkCollector,                                     (void **) &g_pIInkCollector);               if (FAILED(hr))                   return -1;                               hr = g_pIInkCollector->get_Ink(&g_pIInkDisp);               if (FAILED(hr))                   return -1;                              hr = g_pIInkCollector->put_hWnd((long)this->hwnd);               if (FAILED(hr))                   return -1;                 hr = g_pIInkCollector->put_Enabled(VARIANT_TRUE);               if (FAILED(hr))                   return -1;      }  //笔势事件   HRESULT Cinkdoc::OnGesture(           IInkCursor* /*pIInkCursor*/,           IInkStrokes* pInkStrokes,           VARIANT vGestures,           VARIANT_BOOL* pbCancel           )   {       if (((VT_ARRAY | VT_DISPATCH) != vGestures.vt) || (NULL == vGestures.parray))           return E_INVALIDARG;       if (0 == vGestures.parray->rgsabound->cElements)           return E_INVALIDARG;        / /数组中的手势应该是排序的承认       / /置信水平。此示例拿起最高之一。       / /注意:当在InkAndGesture收集模式,除了预期的手势       / /应用程序也有可能是带着身份证IAG_NoGesture手势对象       / /此应用程序时,如果取消与ISG_NoGesture对象       / /最高水平的信心数组(第一项)。       InkApplicationGesture idGesture = IAG_NoGesture;       IDispatch** ppIDispatch;       HRESULT hr = ::SafeArrayAccessData(vGestures.parray, (void HUGEP**)&ppIDispatch);       if (SUCCEEDED(hr))       {           CComQIPtr<IInkGesture> spIInkGesture(ppIDispatch[0]);           if (spIInkGesture != NULL)           {               hr = spIInkGesture->get_Id(&idGesture);           }           ::SafeArrayUnaccessData(vGestures.parray);       }       / /加载资源字符串表的姿态名称       UINT idGestureName;       bool bAccepted;     // will be true, if the gesture is known to this application       if (IAG_NoGesture != idGesture)       {           bAccepted = GetGestureName(idGesture, idGestureName);       }       else           {           bAccepted = false;           idGestureName = 0;       }       //如果当前的收集模式ICM_GestureOnly或者如果我们接受       //的姿态,手势的中风将被删除从墨迹对象,       //因此,窗口需要在招'区更新。       if (ID_MODE_GESTURES == m_nCmdMode || true == bAccepted)       {           // Get the rectangle to update.           RECT rc;           CComPtr<IInkRectangle> spIInkRect;           if (m_spIInkRenderer != NULL               && pInkStrokes != NULL               && SUCCEEDED(pInkStrokes->GetBoundingBox(IBBM_Default, &spIInkRect))               && SUCCEEDED(spIInkRect->GetRectangle(&rc.top, &rc.left,                                                     &rc.bottom, &rc.right)))           {                            HDC hdc = m_wndInput.GetDC();               if (NULL != hdc)               {                   if (FAILED(m_spIInkRenderer->InkSpaceToPixel((long)hdc, &rc.left, &rc.top))                       || FAILED(m_spIInkRenderer->InkSpaceToPixel((long)hdc, &rc.right,                                                                   &rc.bottom)))                   {                                            m_wndInput.GetClientRect(&rc);                   }                   ReleaseDC(hdc);               }               else              {                                m_wndInput.GetClientRect(&rc);               }           }           else          {                            m_wndInput.GetClientRect(&rc);           }             m_wndInput.InvalidateRect(&rc);       }       else // if something's failed,               {                    *pbCancel = VARIANT_TRUE;           idGestureName = IDS_GESTURE_UNKNOWN;       }               m_wndResults.SetGestureName(idGestureName);       m_wndResults.Invalidate();         return hr;   }     // Recognition event handlers 识别器事件   HRESULT Cinkdoc::OnRecognitionWithAlternates(           IInkRecognitionResult* pIInkRecoResult,           VARIANT /*vCustomParam*/,           InkRecognitionStatus /*RecognitionStatus*/          )   {       if (NULL == pIInkRecoResult)           return E_INVALIDARG;           m_wndResults.ResetResults();         // Get the best lCount results       HRESULT hr;       CComPtr<IInkRecognitionAlternates> spIInkRecoAlternates;       hr = pIInkRecoResult->AlternatesFromSelection(           0,                                      -1,                                     CRecoOutputWnd::mc_iNumResults,            &spIInkRecoAlternates                   );              LONG lCount = 0;       if (SUCCEEDED(hr) && SUCCEEDED(spIInkRecoAlternates->get_Count(&lCount)))       {                 IInkRecognitionAlternate* pIInkRecoAlternate = NULL;           for (LONG iItem = 0; (iItem < lCount) && (iItem < CRecoOutputWnd::mc_iNumResults); iItem++)           {                         if (SUCCEEDED(spIInkRecoAlternates->Item(iItem, &pIInkRecoAlternate)))               {                   BSTR bstr = NULL;                   if (SUCCEEDED(pIInkRecoAlternate->get_String(&bstr)))                   {                       m_wndResults.m_bstrResults[iItem].Attach(bstr);                   }                   pIInkRecoAlternate->Release();               }           }       }         // Update the output window with the new results       m_wndResults.Invalidate();         return S_OK;   }     //识别结果获取   LRESULT Cinkdoc::OnRecognizer(           WORD /*wNotifyCode*/,           WORD wID,           HWND /*hWndCtl*/,           BOOL& /*bHandled*/          )   {       if (m_spIInkRecognizers == NULL || wID == m_nCmdRecognizer)           return 0;             HRESULT hr;       CComPtr<IInkRecognizer> spIInkRecognizer;       if (ID_RECOGNIZER_DEFAULT == wID)       {                     hr = m_spIInkRecognizers->GetDefaultRecognizer(0, &spIInkRecognizer);//获取默认识别器设置之       }       else      {           hr = m_spIInkRecognizers->Item(wID - ID_RECOGNIZER_FIRST, &spIInkRecognizer);//否则获取第一个识别器设置之       }              if (SUCCEEDED(hr) && UseRecognizer(spIInkRecognizer))       {                   UpdateMenuRadioItems(mc_iSubmenuRecognizers, wID, m_nCmdRecognizer);           m_bstrCurRecoName.Empty();           spIInkRecognizer->get_Name(&m_bstrCurRecoName);           UpdateStatusBar();                   m_nCmdRecognizer = wID;       }         return 0;   }   //输入获取   LRESULT Cinkdoc::OnInputScopeCoerce(           WORD /*wNotifyCode*/,           WORD wID,           HWND /*hWndCtl*/,           BOOL& /*bHandled*/          )   {         if (m_spIInkRecoContext == NULL )           return 0;       if (m_spIInkStrokes != NULL)       {           m_spIInkRecoContext->putref_Strokes(NULL);       }           if (FAILED(m_spIInkRecoContext->put_RecognitionFlags (m_bCoerceInputScope?IRM_None:IRM_Coerce)))       {           MessageBox(TEXT("获取结果失败!"),                          gc_szAppName, MB_ICONERROR | MB_OK);           // Re-attach the stroke collection to the context           if (m_spIInkStrokes != NULL)           {               m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);           }               return 0;           }       m_bCoerceInputScope = !m_bCoerceInputScope;         // 收集笔迹       if (m_spIInkStrokes != NULL)       {           m_spIInkRecoContext->putref_Strokes(m_spIInkStrokes);       }         // 更新识别结果       CComVariant vCustomData;    // no custom data       m_spIInkRecoContext->BackgroundRecognizeWithAlternates(vCustomData);              return 0;   }   

 

 

Ribbon多文档程序代码如下

  1. // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面   
  2. // (“Fluent UI”)。该示例仅供参考,  
  3. // 用以补充《Microsoft 基础类参考》和   
  4. // MFC C++ 库软件随附的相关电子文档。  
  5. // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。  
  6. // 若要了解有关 Fluent UI 许可计划的详细信息,请访问    
  7. // http://msdn.microsoft.com/officeui。  
  8. //  
  9. // 版权所有(C) Microsoft Corporation  
  10. // 保留所有权利。  
  11.   
  12. #include "stdafx.h"  
  13. #include "CalendarBar.h"  
  14. #include "inkdoc.h"  
  15.   
  16. #ifdef _DEBUG  
  17. #define new DEBUG_NEW  
  18. #undef THIS_FILE  
  19. static char THIS_FILE[] = __FILE__;  
  20. #endif  
  21.   
  22. const int nBorderSize = 10;  
  23.   
  24. /////////////////////////////////////////////////////////////////////////////  
  25. // CCalendarBar  
  26.   
  27. CCalendarBar::CCalendarBar()  
  28. {  
  29.     m_nMyCalendarsY = 0;  
  30. }  
  31.   
  32. CCalendarBar::~CCalendarBar()  
  33. {  
  34. }  
  35.   
  36. BEGIN_MESSAGE_MAP(CCalendarBar, CWnd)  
  37.     ON_WM_CREATE()  
  38.     ON_WM_ERASEBKGND()  
  39.     ON_WM_SIZE()  
  40.     ON_WM_PAINT()  
  41.     ON_WM_SETTINGCHANGE()  
  42. END_MESSAGE_MAP()  
  43.   
  44. /////////////////////////////////////////////////////////////////////////////  
  45. // CCalendarBar 消息处理程序  
  46.   
  47. int CCalendarBar::OnCreate(LPCREATESTRUCT lpCreateStruct)  
  48. {  
  49.     if (CWnd::OnCreate(lpCreateStruct) == -1)  
  50.         return -1;  
  51.   
  52.     CRect rectDummy(0, 0, 0, 0);  
  53.     m_wndCalendar.Create(WS_CHILD | WS_VISIBLE, rectDummy, this, 1);  
  54.   
  55.     CBitmap bmp;  
  56.     bmp.LoadBitmap(IDB_PAGES_SMALL_HC);  
  57.   
  58.     m_Images.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 0);  
  59.     m_Images.Add(&bmp, RGB(255, 0, 255));  
  60.   
  61.     return 0;  
  62. }  
  63.   
  64. BOOL CCalendarBar::OnEraseBkgnd(CDC* /*pDC*/)  
  65. {  
  66.     return TRUE;  
  67. }  
  68.   
  69. void CCalendarBar::OnSize(UINT nType, int cx, int cy)  
  70. {  
  71.     CWnd::OnSize(nType, cx, cy);  
  72.   
  73.     int nMyCalendarsHeight = 70;  
  74.   
  75.     if (m_wndCalendar.GetSafeHwnd() != NULL)  
  76.     {  
  77.         m_wndCalendar.SetWindowPos(NULL, nBorderSize, nBorderSize, cx - 2 * nBorderSize, cy - 2 * nBorderSize - nMyCalendarsHeight - 10, SWP_NOZORDER | SWP_NOACTIVATE);  
  78.     }  
  79.   
  80.     m_nMyCalendarsY = cy - nMyCalendarsHeight;  
  81. }  
  82.   
  83. BOOL CCalendarBar::Create(const RECT& rect, CWnd* pParentWnd, UINT nID)  
  84. {  
  85.     return CWnd::Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, rect, pParentWnd, nID);  
  86. }  
  87.   
  88. void CCalendarBar::OnPaint()  
  89. {  
  90.     CPaintDC dc(this); // 用于绘制的设备上下文  
  91.   
  92.     CRect rectClient;  
  93.     GetClientRect(rectClient);  
  94.   
  95.     dc.FillRect(rectClient, &afxGlobalData.brWindow);  
  96.   
  97.     if (rectClient.bottom - m_nMyCalendarsY > 0)  
  98.     {  
  99.         CRect rectMyCalendarsCaption = rectClient;  
  100.         rectMyCalendarsCaption.top = m_nMyCalendarsY;  
  101.         rectMyCalendarsCaption.bottom = rectMyCalendarsCaption.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2;  
  102.   
  103.         COLORREF clrText = CMFCVisualManager::GetInstance()->OnDrawPaneCaption(&dc, NULL, FALSE, rectMyCalendarsCaption, CRect(0, 0, 0, 0));  
  104.   
  105.         CPen* pOldPen = dc.SelectObject(&afxGlobalData.penBarShadow);  
  106.   
  107.         dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.top);  
  108.         dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.top);  
  109.   
  110.         dc.SelectStockObject(BLACK_PEN);  
  111.   
  112.         dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.bottom);  
  113.         dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.bottom);  
  114.   
  115.         dc.SelectObject(pOldPen);  
  116.   
  117.         CRect rectText = rectMyCalendarsCaption;  
  118.         rectText.DeflateRect(10, 0);  
  119.   
  120.         dc.SetBkMode(TRANSPARENT);  
  121.         dc.SetTextColor(clrText);  
  122.   
  123.         CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);  
  124.   
  125.         BOOL bNameValid;  
  126.         CString str;  
  127.   
  128.         bNameValid = str.LoadString(IDS_MYCALENDARS);  
  129.         ASSERT(bNameValid);  
  130.         dc.DrawText(str, rectText, DT_VCENTER | DT_LEFT | DT_SINGLELINE);  
  131.   
  132.         CRect rectCalendar = rectClient;  
  133.         rectCalendar.top = rectMyCalendarsCaption.bottom + 5;  
  134.         rectCalendar.bottom = rectCalendar.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2 - 5;  
  135.   
  136.         dc.FillSolidRect(rectCalendar, RGB(255, 255, 213));  
  137.   
  138.         rectCalendar.DeflateRect(20, 0);  
  139.         m_Images.Draw(&dc, 3, rectCalendar.TopLeft(), 0);  
  140.   
  141.         rectCalendar.left += 20;  
  142.   
  143.         bNameValid = str.LoadString(IDS_CALENDAR);  
  144.         ASSERT(bNameValid);  
  145.   
  146.         dc.SetTextColor(afxGlobalData.clrHotLinkNormalText);  
  147.         dc.DrawText(str, rectCalendar, DT_VCENTER | DT_LEFT | DT_SINGLELINE);  
  148.   
  149.         dc.SelectObject(pOldFont);  
  150.     }  
  151. }  
  152.   
  153.   
  154. // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面   
  155. // (“Fluent UI”)。该示例仅供参考,  
  156. // 用以补充《Microsoft 基础类参考》和   
  157. // MFC C++ 库软件随附的相关电子文档。  
  158. // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。  
  159. // 若要了解有关 Fluent UI 许可计划的详细信息,请访问    
  160. // http://msdn.microsoft.com/officeui。  
  161. //  
  162. // 版权所有(C) Microsoft Corporation  
  163. // 保留所有权利。  
  164.   
  165. // inkdoc.cpp : 定义应用程序的类行为。  
  166. //  
  167.   
  168. #include "stdafx.h"  
  169. #include "afxwinappex.h"  
  170. #include "inkdoc.h"  
  171. #include "MainFrm.h"  
  172.   
  173. #include "ChildFrm.h"  
  174. #include "inkdocDoc.h"  
  175. #include "inkdocView.h"  
  176. #include "CShockwaveFlash.h"  
  177.   
  178. #ifdef _DEBUG  
  179. #define new DEBUG_NEW  
  180. #endif  
  181.   
  182.   
  183. // CinkdocApp  
  184.   
  185. BEGIN_MESSAGE_MAP(CinkdocApp, CWinAppEx)  
  186.     ON_COMMAND(ID_APP_ABOUT, &CinkdocApp::OnAppAbout)  
  187.     // 基于文件的标准文档命令  
  188.     ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew)  
  189.     ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen)  
  190. END_MESSAGE_MAP()  
  191.   
  192.   
  193. // CinkdocApp 构造  
  194.   
  195. CinkdocApp::CinkdocApp()  
  196. {  
  197.     m_bHiColorIcons = TRUE;  
  198.   
  199.     // 支持重新启动管理器  
  200.     m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;  
  201. #ifdef _MANAGED  
  202.     // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则:  
  203.     //     1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。  
  204.     //     2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。  
  205.     System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);  
  206. #endif  
  207.   
  208.     // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式  
  209.     //为 CompanyName.ProductName.SubProduct.VersionInformation  
  210.     SetAppID(_T("inkdoc.AppID.NoVersion"));  
  211.   
  212.     // TODO: 在此处添加构造代码,  
  213.     // 将所有重要的初始化放置在 InitInstance 中  
  214. }  
  215.   
  216. // 唯一的一个 CinkdocApp 对象  
  217.   
  218. CinkdocApp theApp;  
  219.   
  220.   
  221. // CinkdocApp 初始化  
  222.   
  223. BOOL CinkdocApp::InitInstance()  
  224. {  
  225.     // 如果一个运行在 Windows XP 上的应用程序清单指定要  
  226.     // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,  
  227.     //则需要 InitCommonControlsEx()。否则,将无法创建窗口。  
  228.     INITCOMMONCONTROLSEX InitCtrls;  
  229.     InitCtrls.dwSize = sizeof(InitCtrls);  
  230.     // 将它设置为包括所有要在应用程序中使用的  
  231.     // 公共控件类。  
  232.     InitCtrls.dwICC = ICC_WIN95_CLASSES;  
  233.     InitCommonControlsEx(&InitCtrls);  
  234.   
  235.     CWinAppEx::InitInstance();  
  236.   
  237.     // 初始化 OLE 库  
  238.     if (!AfxOleInit())  
  239.     {  
  240.         AfxMessageBox(IDP_OLE_INIT_FAILED);  
  241.         return FALSE;  
  242.     }  
  243.     AfxEnableControlContainer();  
  244.   
  245.     EnableTaskbarInteraction();  
  246.   
  247.   
  248.     // 使用 RichEdit 控件需要  AfxInitRichEdit2()   
  249.     // AfxInitRichEdit2();  
  250.   
  251.     // 标准初始化  
  252.     // 如果未使用这些功能并希望减小  
  253.     // 最终可执行文件的大小,则应移除下列  
  254.     // 不需要的特定初始化例程  
  255.     // 更改用于存储设置的注册表项  
  256.     // TODO: 应适当修改该字符串,  
  257.     // 例如修改为公司或组织名  
  258.     SetRegistryKey(_T("应用程序向导生成的本地应用程序"));  
  259.     LoadStdProfileSettings(4);  // 加载标准 INI 文件选项(包括 MRU)  
  260.   
  261.   
  262.     InitContextMenuManager();  
  263.     InitShellManager();  
  264.   
  265.     InitKeyboardManager();  
  266.   
  267.     InitTooltipManager();  
  268.     CMFCToolTipInfo ttParams;  
  269.     ttParams.m_bVislManagerTheme = TRUE;  
  270.     theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,  
  271.         RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);  
  272.   
  273.     // 注册应用程序的文档模板。文档模板  
  274.     // 将用作文档、框架窗口和视图之间的连接  
  275.     CMultiDocTemplate* pDocTemplate;  
  276.     pDocTemplate = new CMultiDocTemplate(IDR_inkdocTYPE,  
  277.         RUNTIME_CLASS(CinkdocDoc),  
  278.         RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架  
  279.         RUNTIME_CLASS(CinkdocView));  
  280.     if (!pDocTemplate)  
  281.         return FALSE;  
  282.     AddDocTemplate(pDocTemplate);  
  283.   
  284.     // 创建主 MDI 框架窗口  
  285.     CMainFrame* pMainFrame = new CMainFrame;  
  286.     if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))  
  287.     {  
  288.         delete pMainFrame;  
  289.         return FALSE;  
  290.     }  
  291.     m_pMainWnd = pMainFrame;  
  292.     // 仅当具有后缀时才调用 DragAcceptFiles  
  293.     //  在 MDI 应用程序中,这应在设置 m_pMainWnd 之后立即发生  
  294.     // 启用拖/放  
  295.     m_pMainWnd->DragAcceptFiles();  
  296.   
  297.     // 分析标准 shell 命令、DDE、打开文件操作的命令行  
  298.     CCommandLineInfo cmdInfo;  
  299.     ParseCommandLine(cmdInfo);  
  300.   
  301.     // 启用“DDE 执行”  
  302.     EnableShellOpen();  
  303.     RegisterShellFileTypes(TRUE);  
  304.   
  305.   
  306.     // 调度在命令行中指定的命令。如果  
  307.     // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。  
  308.     if (!ProcessShellCommand(cmdInfo))  
  309.         return FALSE;  
  310.     // 主窗口已初始化,因此显示它并对其进行更新  
  311.     pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);  
  312.     pMainFrame->UpdateWindow();  
  313.   
  314.     return TRUE;  
  315. }  
  316.   
  317.   
  318.   
  319. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框  
  320.   
  321. class CAboutDlg : public CDialog  
  322. {  
  323. public:  
  324.     CAboutDlg();  
  325.   
  326. // 对话框数据  
  327.     enum { IDD = IDD_ABOUTBOX };  
  328.   
  329. protected:  
  330.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持  
  331.   
  332. // 实现  
  333. protected:  
  334.     DECLARE_MESSAGE_MAP()  
  335. };  
  336.   
  337. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)  
  338. {  
  339. }  
  340.   
  341. void CAboutDlg::DoDataExchange(CDataExchange* pDX)  
  342. {  
  343.     CDialog::DoDataExchange(pDX);  
  344. }  
  345.   
  346. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)  
  347. END_MESSAGE_MAP()  
  348.   
  349. // 用于运行对话框的应用程序命令  
  350. void CinkdocApp::OnAppAbout()  
  351. {  
  352.     CAboutDlg aboutDlg;  
  353.     aboutDlg.DoModal();  
  354. }  
  355.   
  356. // CinkdocApp 自定义加载/保存方法  
  357.   
  358. void CinkdocApp::PreLoadState()  
  359. {  
  360.     BOOL bNameValid;  
  361.     CString strName;  
  362.     bNameValid = strName.LoadString(IDS_EDIT_MENU);  
  363.     ASSERT(bNameValid);  
  364.     GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT);  
  365. }  
  366.   
  367. void CinkdocApp::LoadCustomState()  
  368. {  
  369. }  
  370.   
  371. void CinkdocApp::SaveCustomState()  
  372. {  
  373. }  
  374.   
  375. // CinkdocApp 消息处理程序  
  376.   
  377.   
  378.   
  379. // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面   
  380. // (“Fluent UI”)。该示例仅供参考,  
  381. // 用以补充《Microsoft 基础类参考》和   
  382. // MFC C++ 库软件随附的相关电子文档。  
  383. // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。  
  384. // 若要了解有关 Fluent UI 许可计划的详细信息,请访问    
  385. // http://msdn.microsoft.com/officeui。  
  386. //  
  387. // 版权所有(C) Microsoft Corporation  
  388. // 保留所有权利。  
  389.   
  390. // inkdocDoc.cpp : CinkdocDoc 类的实现  
  391. //  
  392.   
  393. #include "stdafx.h"  
  394. // SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail  
  395. // and search filter handlers and allows sharing of document code with that project.  
  396. #ifndef SHARED_HANDLERS  
  397. #include "inkdoc.h"  
  398. #endif  
  399.   
  400. #include "inkdocDoc.h"  
  401.   
  402. #include <propkey.h>  
  403.   
  404. #ifdef _DEBUG  
  405. #define new DEBUG_NEW  
  406. #endif  
  407.   
  408. // CinkdocDoc  
  409.   
  410. IMPLEMENT_DYNCREATE(CinkdocDoc, CDocument)  
  411.   
  412. BEGIN_MESSAGE_MAP(CinkdocDoc, CDocument)  
  413. END_MESSAGE_MAP()  
  414.   
  415.   
  416. // CinkdocDoc 构造/析构  
  417.   
  418. CinkdocDoc::CinkdocDoc()  
  419. {  
  420.     // TODO: 在此添加一次性构造代码  
  421.   
  422. }  
  423.   
  424. CinkdocDoc::~CinkdocDoc()  
  425. {  
  426. }  
  427.   
  428. BOOL CinkdocDoc::OnNewDocument()  
  429. {  
  430.     if (!CDocument::OnNewDocument())  
  431.         return FALSE;  
  432.   
  433.     // TODO: 在此添加重新初始化代码  
  434.     // (SDI 文档将重用该文档)  
  435.   
  436.     return TRUE;  
  437. }  
  438.   
  439.   
  440.   
  441.   
  442. // CinkdocDoc 序列化  
  443.   
  444. void CinkdocDoc::Serialize(CArchive& ar)  
  445. {  
  446.     if (ar.IsStoring())  
  447.     {  
  448.         // TODO: 在此添加存储代码  
  449.     }  
  450.     else  
  451.     {  
  452.         // TODO: 在此添加加载代码  
  453.     }  
  454. }  
  455.   
  456. #ifdef SHARED_HANDLERS  
  457.   
  458. // 缩略图的支持  
  459. void CinkdocDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds)  
  460. {  
  461.     // 修改此代码以绘制文档数据  
  462.     dc.FillSolidRect(lprcBounds, RGB(255, 255, 255));  
  463.   
  464.     CString strText = _T("TODO: implement thumbnail drawing here");  
  465.     LOGFONT lf;  
  466.   
  467.     CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));  
  468.     pDefaultGUIFont->GetLogFont(&lf);  
  469.     lf.lfHeight = 36;  
  470.   
  471.     CFont fontDraw;  
  472.     fontDraw.CreateFontIndirect(&lf);  
  473.   
  474.     CFont* pOldFont = dc.SelectObject(&fontDraw);  
  475.     dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK);  
  476.     dc.SelectObject(pOldFont);  
  477. }  
  478.   
  479. // 搜索处理程序的支持  
  480. void CinkdocDoc::InitializeSearchContent()  
  481. {  
  482.     CString strSearchContent;  
  483.     // 从文档数据设置搜索内容。  
  484.     // 内容部分应由“;”分隔  
  485.   
  486.     // 例如:  strSearchContent = _T("point;rectangle;circle;ole object;");  
  487.     SetSearchContent(strSearchContent);  
  488. }  
  489.   
  490. void CinkdocDoc::SetSearchContent(const CString& value)  
  491. {  
  492.     if (value.IsEmpty())  
  493.     {  
  494.         RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid);  
  495.     }  
  496.     else  
  497.     {  
  498.         CMFCFilterChunkValueImpl *pChunk = NULL;  
  499.         ATLTRY(pChunk = new CMFCFilterChunkValueImpl);  
  500.         if (pChunk != NULL)  
  501.         {  
  502.             pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT);  
  503.             SetChunkValue(pChunk);  
  504.         }  
  505.     }  
  506. }  
  507.   
  508. #endif // SHARED_HANDLERS  
  509.   
  510. // CinkdocDoc 诊断  
  511.   
  512. #ifdef _DEBUG  
  513. void CinkdocDoc::AssertValid() const  
  514. {  
  515.     CDocument::AssertValid();  
  516. }  
  517.   
  518. void CinkdocDoc::Dump(CDumpContext& dc) const  
  519. {  
  520.     CDocument::Dump(dc);  
  521. }  
  522. #endif //_DEBUG  
  523.   
  524.   
  525. // CinkdocDoc 命令  
  526. // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面   
  527. // (“Fluent UI”)。该示例仅供参考,  
  528. // 用以补充《Microsoft 基础类参考》和   
  529. // MFC C++ 库软件随附的相关电子文档。  
  530. // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。  
  531. // 若要了解有关 Fluent UI 许可计划的详细信息,请访问    
  532. // http://msdn.microsoft.com/officeui。  
  533. //  
  534. // 版权所有(C) Microsoft Corporation  
  535. // 保留所有权利。  
  536.   
  537. // inkdocView.cpp : CinkdocView 类的实现  
  538. //  
  539.   
  540. #include "stdafx.h"  
  541. #include"CShockwaveFlash.h"  
  542. #include"shockwaveflash1.h"  
  543. // SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail  
  544. // and search filter handlers and allows sharing of document code with that project.  
  545. #ifndef SHARED_HANDLERS  
  546. #include "inkdoc.h"  
  547. #endif  
  548.   
  549. #include "inkdocDoc.h"  
  550. #include "inkdocView.h"  
  551.   
  552. #ifdef _DEBUG  
  553. #define new DEBUG_NEW  
  554. #endif  
  555.   
  556.   
  557. // CinkdocView  
  558.   
  559. IMPLEMENT_DYNCREATE(CinkdocView, CFormView)  
  560.   
  561. BEGIN_MESSAGE_MAP(CinkdocView, CFormView)  
  562.     ON_WM_CONTEXTMENU()  
  563.     ON_WM_RBUTTONUP()  
  564.     ON_EN_CHANGE(IDC_RICHEDIT21, &CinkdocView::OnEnChangeRichedit21)  
  565.     ON_COMMAND(ID_BUTTON3, &CinkdocView::OnButton3)  
  566. END_MESSAGE_MAP()  
  567.   
  568.   
  569.   
  570. CinkdocView::CinkdocView()  
  571.     : CFormView(CinkdocView::IDD)  
  572. {  
  573.     // TODO: 在此处添加构造代码  
  574.     AfxInitRichEdit2();  
  575.   
  576. }  
  577.   
  578. CinkdocView::~CinkdocView()  
  579. {  
  580. }  
  581.   
  582. void CinkdocView::DoDataExchange(CDataExchange* pDX)  
  583. {  
  584.     CFormView::DoDataExchange(pDX);  
  585.   
  586. }  
  587.   
  588. BOOL CinkdocView::PreCreateWindow(CREATESTRUCT& cs)  
  589. {  
  590.     // TODO: 在此处通过修改  
  591.     //  CREATESTRUCT cs 来修改窗口类或样式  
  592.   
  593.     return CFormView::PreCreateWindow(cs);  
  594. }  
  595.   
  596. void CinkdocView::OnInitialUpdate()  
  597. {  
  598.     CFormView::OnInitialUpdate();  
  599.     ResizeParentToFit();  
  600.   
  601. }  
  602.   
  603. void CinkdocView::OnRButtonUp(UINT /* nFlags */, CPoint point)  
  604. {  
  605.     ClientToScreen(&point);  
  606.     OnContextMenu(this, point);  
  607. }  
  608.   
  609. void CinkdocView::OnContextMenu(CWnd* /* pWnd */, CPoint point)  
  610. {  
  611. #ifndef SHARED_HANDLERS  
  612.     theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);  
  613. #endif  
  614. }  
  615.   
  616.   
  617. // CinkdocView 诊断  
  618.   
  619. #ifdef _DEBUG  
  620. void CinkdocView::AssertValid() const  
  621. {  
  622.     CFormView::AssertValid();  
  623. }  
  624.   
  625. void CinkdocView::Dump(CDumpContext& dc) const  
  626. {  
  627.     CFormView::Dump(dc);  
  628. }  
  629.   
  630. CinkdocDoc* CinkdocView::GetDocument() const // 非调试版本是内联的  
  631. {  
  632.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CinkdocDoc)));  
  633.     return (CinkdocDoc*)m_pDocument;  
  634. }  
  635. #endif //_DEBUG  
  636.   
  637.   
  638. // CinkdocView 消息处理程序  
  639.   
  640.   
  641. void CinkdocView::OnEnChangeRichedit21()  
  642. {  
  643.     // TODO:  If this is a RICHEDIT control, the control will not  
  644.     // send this notification unless you override the CFormView::OnInitDialog()  
  645.     // function and call CRichEditCtrl().SetEventMask()  
  646.     // with the ENM_CHANGE flag ORed into the mask.  
  647.   
  648.     // TODO:  Add your control notification handler code here  
  649. }  
  650.   
  651.   
  652. void CinkdocView::OnButton3()  
  653. {  
  654.     MessageBox(TEXT("****著名技术专家尹成的杰作http://blog.****.net/yincheng01"), TEXT("WindowsRibbon范例"), MB_OK);  
  655. }  
  656.   
  657.   
  658. BOOL CinkdocView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)  
  659. {  
  660.       
  661.           
  662.     return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);  
  663. }  
  664. // 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面   
  665. // (“Fluent UI”)。该示例仅供参考,  
  666. // 用以补充《Microsoft 基础类参考》和   
  667. // MFC C++ 库软件随附的相关电子文档。  
  668. // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。  
  669. // 若要了解有关 Fluent UI 许可计划的详细信息,请访问    
  670. // http://msdn.microsoft.com/officeui。  
  671. //  
  672. // 版权所有(C) Microsoft Corporation  
  673. // 保留所有权利。  
  674.   
  675. // MainFrm.cpp : CMainFrame 类的实现  
  676. //  
  677.   
  678. #include "stdafx.h"  
  679. #include "inkdoc.h"  
  680.   
  681. #include "MainFrm.h"  
  682.   
  683. #ifdef _DEBUG  
  684. #define new DEBUG_NEW  
  685. #endif  
  686.   
  687. // CMainFrame  
  688.   
  689. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)  
  690.   
  691. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)  
  692.     ON_WM_CREATE()  
  693.     ON_COMMAND(ID_WINDOW_MANAGER, &CMainFrame::OnWindowManager)  
  694.     ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook)  
  695.     ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook)  
  696.     ON_COMMAND(ID_VIEW_CAPTION_BAR, &CMainFrame::OnViewCaptionBar)  
  697.     ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTION_BAR, &CMainFrame::OnUpdateViewCaptionBar)  
  698.     ON_COMMAND(ID_TOOLS_OPTIONS, &CMainFrame::OnOptions)  
  699.     ON_COMMAND(ID_BUTTON2, &CMainFrame::OnButton2)  
  700.     ON_COMMAND(ID_BUTTON31, &CMainFrame::OnButton31)  
  701.     ON_COMMAND(ID_BUTTON4, &CMainFrame::OnButton4)  
  702.     ON_COMMAND(ID_BUTTON5, &CMainFrame::OnButton5)  
  703.     ON_COMMAND(ID_BUTTON6, &CMainFrame::OnButton6)  
  704.     ON_COMMAND(ID_BUTTON7, &CMainFrame::OnButton7)  
  705.     ON_COMMAND(ID_BUTTON8, &CMainFrame::OnButton8)  
  706.     ON_COMMAND(ID_BUTTON9, &CMainFrame::OnButton9)  
  707. END_MESSAGE_MAP()  
  708.   
  709. // CMainFrame 构造/析构  
  710.   
  711. CMainFrame::CMainFrame()  
  712. {  
  713.     // TODO: 在此添加成员初始化代码  
  714.     theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_WINDOWS_7);  
  715. }  
  716.   
  717. CMainFrame::~CMainFrame()  
  718. {  
  719. }  
  720.   
  721. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)  
  722. {  
  723.     if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)  
  724.         return -1;  
  725.   
  726.     BOOL bNameValid;  
  727.     // 基于持久值设置视觉管理器和样式  
  728.     OnApplicationLook(theApp.m_nAppLook);  
  729.   
  730.     CMDITabInfo mdiTabParams;  
  731.     mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; // 其他可用样式...  
  732.     mdiTabParams.m_bActiveTabCloseButton = TRUE;      // 设置为 FALSE 会将关闭按钮放置在选项卡区域的右侧  
  733.     mdiTabParams.m_bTabIcons = FALSE;    // 设置为 TRUE 将在 MDI 选项卡上启用文档图标  
  734.     mdiTabParams.m_bAutoColor = TRUE;    // 设置为 FALSE 将禁用 MDI 选项卡的自动着色  
  735.     mdiTabParams.m_bDocumentMenu = TRUE; // 在选项卡区域的右边缘启用文档菜单  
  736.     EnableMDITabbedGroups(TRUE, mdiTabParams);  
  737.   
  738.     m_wndRibbonBar.Create(this);  
  739.     m_wndRibbonBar.LoadFromResource(IDR_RIBBON);  
  740.   
  741.     if (!m_wndStatusBar.Create(this))  
  742.     {  
  743.         TRACE0("未能创建状态栏/n");  
  744.         return -1;      // 未能创建  
  745.     }  
  746.   
  747.     CString strTitlePane1;  
  748.     CString strTitlePane2;  
  749.     bNameValid = strTitlePane1.LoadString(IDS_STATUS_PANE1);  
  750.     ASSERT(bNameValid);  
  751.     bNameValid = strTitlePane2.LoadString(IDS_STATUS_PANE2);  
  752.     ASSERT(bNameValid);  
  753.     m_wndStatusBar.AddElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE1, strTitlePane1, TRUE), strTitlePane1);  
  754.     m_wndStatusBar.AddExtendedElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, strTitlePane2, TRUE), strTitlePane2);  
  755.   
  756.     // 启用 Visual Studio 2005 样式停靠窗口行为  
  757.     CDockingManager::SetDockingMode(DT_SMART);  
  758.     // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为  
  759.     EnableAutoHidePanes(CBRS_ALIGN_ANY);  
  760.   
  761.     // 导航窗格将创建在左侧,因此将暂时禁用左侧的停靠:  
  762.     EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT);  
  763.   
  764.     // 创建并设置“Outlook”导航栏:  
  765.     if (!CreateOutlookBar(m_wndNavigationBar, ID_VIEW_NAVIGATION, m_wndTree, m_wndCalendar, 250))  
  766.     {  
  767.         TRACE0("未能创建导航窗格/n");  
  768.         return -1;      // 未能创建  
  769.     }  
  770.   
  771.     // 创建标题栏:  
  772.     if (!CreateCaptionBar())  
  773.     {  
  774.         TRACE0("未能创建标题栏/n");  
  775.         return -1;      // 未能创建  
  776.     }  
  777.   
  778.     // 已创建 Outlook 栏,应允许在左侧停靠。  
  779.     EnableDocking(CBRS_ALIGN_LEFT);  
  780.     EnableAutoHidePanes(CBRS_ALIGN_RIGHT);  
  781.   
  782.     // 启用增强的窗口管理对话框  
  783.     EnableWindowsDialog(ID_WINDOW_MANAGER, ID_WINDOW_MANAGER, TRUE);  
  784.   
  785.     // 将文档名和应用程序名称在窗口标题栏上的顺序进行交换。这  
  786.     // 将改进任务栏的可用性,因为显示的文档名带有缩略图。  
  787.     ModifyStyle(0, FWS_PREFIXTITLE);  
  788.   
  789.     return 0;  
  790. }  
  791.   
  792. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)  
  793. {  
  794.     if( !CMDIFrameWndEx::PreCreateWindow(cs) )  
  795.         return FALSE;  
  796.     // TODO: 在此处通过修改  
  797.     //  CREATESTRUCT cs 来修改窗口类或样式  
  798.   
  799.     cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE  
  800.          | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE | WS_SYSMENU;  
  801.   
  802.     return TRUE;  
  803. }  
  804.   
  805. BOOL CMainFrame::CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth)  
  806. {  
  807.     bar.SetMode2003();  
  808.   
  809.     BOOL bNameValid;  
  810.     CString strTemp;  
  811.     bNameValid = strTemp.LoadString(IDS_SHORTCUTS);  
  812.     ASSERT(bNameValid);  
  813.     if (!bar.Create(strTemp, this, CRect(0, 0, nInitialWidth, 32000), uiID, WS_CHILD | WS_VISIBLE | CBRS_LEFT))  
  814.     {  
  815.         return FALSE; // 未能创建  
  816.     }  
  817.   
  818.     CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*)bar.GetUnderlyingWindow();  
  819.   
  820.     if (pOutlookBar == NULL)  
  821.     {  
  822.         ASSERT(FALSE);  
  823.         return FALSE;  
  824.     }  
  825.   
  826.     pOutlookBar->EnableInPlaceEdit(TRUE);  
  827.   
  828.     static UINT uiPageID = 1;  
  829.   
  830.     // 可浮动,可自动隐藏,可调整大小,但不能关闭  
  831.     DWORD dwStyle = AFX_CBRS_FLOAT | AFX_CBRS_AUTOHIDE | AFX_CBRS_RESIZE;  
  832.   
  833.     CRect rectDummy(0, 0, 0, 0);  
  834.     const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS;  
  835.   
  836.     tree.Create(dwTreeStyle, rectDummy, &bar, 1200);  
  837.     bNameValid = strTemp.LoadString(IDS_FOLDERS);  
  838.     ASSERT(bNameValid);  
  839.     pOutlookBar->AddControl(&tree, strTemp, 2, TRUE, dwStyle);  
  840.   
  841.     calendar.Create(rectDummy, &bar, 1201);  
  842.     bNameValid = strTemp.LoadString(IDS_CALENDAR);  
  843.     ASSERT(bNameValid);  
  844.     pOutlookBar->AddControl(&calendar, strTemp, 3, TRUE, dwStyle);  
  845.   
  846.     bar.SetPaneStyle(bar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);  
  847.   
  848.     pOutlookBar->SetImageList(theApp.m_bHiColorIcons ? IDB_PAGES_HC : IDB_PAGES, 24);  
  849.     pOutlookBar->SetToolbarImageList(theApp.m_bHiColorIcons ? IDB_PAGES_SMALL_HC : IDB_PAGES_SMALL, 16);  
  850.     pOutlookBar->RecalcLayout();  
  851.   
  852.     BOOL bAnimation = theApp.GetInt(_T("OutlookAnimation"), TRUE);  
  853.     CMFCOutlookBarTabCtrl::EnableAnimation(bAnimation);  
  854.   
  855.     bar.SetButtonsFont(&afxGlobalData.fontBold);  
  856.   
  857.     return TRUE;  
  858. }  
  859.   
  860. BOOL CMainFrame::CreateCaptionBar()  
  861. {  
  862.     if (!m_wndCaptionBar.Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, this, ID_VIEW_CAPTION_BAR, -1, TRUE))  
  863.     {  
  864.         TRACE0("未能创建标题栏/n");  
  865.         return FALSE;  
  866.     }  
  867.   
  868.     BOOL bNameValid;  
  869.   
  870.     CString strTemp, strTemp2;  
  871.     bNameValid = strTemp.LoadString(IDS_CAPTION_BUTTON);  
  872.     ASSERT(bNameValid);  
  873.     m_wndCaptionBar.SetButton(strTemp, ID_TOOLS_OPTIONS, CMFCCaptionBar::ALIGN_LEFT, FALSE);  
  874.     bNameValid = strTemp.LoadString(IDS_CAPTION_BUTTON_TIP);  
  875.     ASSERT(bNameValid);  
  876.     m_wndCaptionBar.SetButtonToolTip(strTemp);  
  877.   
  878.     bNameValid = strTemp.LoadString(IDS_CAPTION_TEXT);  
  879.     ASSERT(bNameValid);  
  880.     m_wndCaptionBar.SetText(strTemp, CMFCCaptionBar::ALIGN_LEFT);  
  881.   
  882.     m_wndCaptionBar.SetBitmap(IDB_INFO, RGB(255, 255, 255), FALSE, CMFCCaptionBar::ALIGN_LEFT);  
  883.     bNameValid = strTemp.LoadString(IDS_CAPTION_IMAGE_TIP);  
  884.     ASSERT(bNameValid);  
  885.     bNameValid = strTemp2.LoadString(IDS_CAPTION_IMAGE_TEXT);  
  886.     ASSERT(bNameValid);  
  887.     m_wndCaptionBar.SetImageToolTip(strTemp, strTemp2);  
  888.   
  889.     return TRUE;  
  890. }  
  891.   
  892. // CMainFrame 诊断  
  893.   
  894. #ifdef _DEBUG  
  895. void CMainFrame::AssertValid() const  
  896. {  
  897.     CMDIFrameWndEx::AssertValid();  
  898. }  
  899.   
  900. void CMainFrame::Dump(CDumpContext& dc) const  
  901. {  
  902.     CMDIFrameWndEx::Dump(dc);  
  903. }  
  904. #endif //_DEBUG  
  905.   
  906.   
  907. // CMainFrame 消息处理程序  
  908.   
  909. void CMainFrame::OnWindowManager()  
  910. {  
  911.     ShowWindowsDialog();  
  912. }  
  913.   
  914. void CMainFrame::OnApplicationLook(UINT id)  
  915. {  
  916.     CWaitCursor wait;  
  917.   
  918.     theApp.m_nAppLook = id;  
  919.   
  920.     switch (theApp.m_nAppLook)  
  921.     {  
  922.     case ID_VIEW_APPLOOK_WIN_2000:  
  923.         CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager));  
  924.         m_wndRibbonBar.SetWindows7Look(FALSE);  
  925.         break;  
  926.   
  927.     case ID_VIEW_APPLOOK_OFF_XP:  
  928.         CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP));  
  929.         m_wndRibbonBar.SetWindows7Look(FALSE);  
  930.         break;  
  931.   
  932.     case ID_VIEW_APPLOOK_WIN_XP:  
  933.         CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE;  
  934.         CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));  
  935.         m_wndRibbonBar.SetWindows7Look(FALSE);  
  936.         break;  
  937.   
  938.     case ID_VIEW_APPLOOK_OFF_2003:  
  939.         CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003));  
  940.         CDockingManager::SetDockingMode(DT_SMART);  
  941.         m_wndRibbonBar.SetWindows7Look(FALSE);  
  942.         break;  
  943.   
  944.     case ID_VIEW_APPLOOK_VS_2005:  
  945.         CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005));  
  946.         CDockingManager::SetDockingMode(DT_SMART);  
  947.         m_wndRibbonBar.SetWindows7Look(FALSE);  
  948.         break;  
  949.   
  950.     case ID_VIEW_APPLOOK_VS_2008:  
  951.         CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008));  
  952.         CDockingManager::SetDockingMode(DT_SMART);  
  953.         m_wndRibbonBar.SetWindows7Look(FALSE);  
  954.         break;  
  955.   
  956.     case ID_VIEW_APPLOOK_WINDOWS_7:  
  957.         CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7));  
  958.         CDockingManager::SetDockingMode(DT_SMART);  
  959.         m_wndRibbonBar.SetWindows7Look(TRUE);  
  960.         break;  
  961.   
  962.     default:  
  963.         switch (theApp.m_nAppLook)  
  964.         {  
  965.         case ID_VIEW_APPLOOK_OFF_2007_BLUE:  
  966.             CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue);  
  967.             break;  
  968.   
  969.         case ID_VIEW_APPLOOK_OFF_2007_BLACK:  
  970.             CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);  
  971.             break;  
  972.   
  973.         case ID_VIEW_APPLOOK_OFF_2007_SILVER:  
  974.             CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver);  
  975.             break;  
  976.   
  977.         case ID_VIEW_APPLOOK_OFF_2007_AQUA:  
  978.             CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua);  
  979.             break;  
  980.         }  
  981.   
  982.         CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));  
  983.         CDockingManager::SetDockingMode(DT_SMART);  
  984.         m_wndRibbonBar.SetWindows7Look(FALSE);  
  985.     }  
  986.   
  987.     RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE);  
  988.   
  989.     theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook);  
  990. }  
  991.   
  992. void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI)  
  993. {  
  994.     pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID);  
  995. }  
  996.   
  997. void CMainFrame::OnViewCaptionBar()  
  998. {  
  999.     m_wndCaptionBar.ShowWindow(m_wndCaptionBar.IsVisible() ? SW_HIDE : SW_SHOW);  
  1000.     RecalcLayout(FALSE);  
  1001. }  
  1002.   
  1003. void CMainFrame::OnUpdateViewCaptionBar(CCmdUI* pCmdUI)  
  1004. {  
  1005.     pCmdUI->SetCheck(m_wndCaptionBar.IsVisible());  
  1006. }  
  1007.   
  1008. void CMainFrame::OnOptions()  
  1009. {  
  1010.     CMFCRibbonCustomizeDialog *pOptionsDlg = new CMFCRibbonCustomizeDialog(this, &m_wndRibbonBar);  
  1011.     ASSERT(pOptionsDlg != NULL);  
  1012.   
  1013.     pOptionsDlg->DoModal();  
  1014.     delete pOptionsDlg;  
  1015. }  
// 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面 // (“Fluent UI”)。该示例仅供参考,// 用以补充《Microsoft 基础类参考》和 // MFC C++ 库软件随附的相关电子文档。// 复制、使用或分发 Fluent UI 的许可条款是单独提供的。// 若要了解有关 Fluent UI 许可计划的详细信息,请访问  // http://msdn.microsoft.com/officeui。//// 版权所有(C) Microsoft Corporation// 保留所有权利。#include "stdafx.h"#include "CalendarBar.h"#include "inkdoc.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endifconst int nBorderSize = 10;/////////////////////////////////////////////////////////////////////////////// CCalendarBarCCalendarBar::CCalendarBar(){ m_nMyCalendarsY = 0;}CCalendarBar::~CCalendarBar(){}BEGIN_MESSAGE_MAP(CCalendarBar, CWnd) ON_WM_CREATE() ON_WM_ERASEBKGND() ON_WM_SIZE() ON_WM_PAINT() ON_WM_SETTINGCHANGE()END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CCalendarBar 消息处理程序int CCalendarBar::OnCreate(LPCREATESTRUCT lpCreateStruct){ if (CWnd::OnCreate(lpCreateStruct) == -1)  return -1; CRect rectDummy(0, 0, 0, 0); m_wndCalendar.Create(WS_CHILD | WS_VISIBLE, rectDummy, this, 1); CBitmap bmp; bmp.LoadBitmap(IDB_PAGES_SMALL_HC); m_Images.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 0); m_Images.Add(&bmp, RGB(255, 0, 255)); return 0;}BOOL CCalendarBar::OnEraseBkgnd(CDC* /*pDC*/){ return TRUE;}void CCalendarBar::OnSize(UINT nType, int cx, int cy){ CWnd::OnSize(nType, cx, cy); int nMyCalendarsHeight = 70; if (m_wndCalendar.GetSafeHwnd() != NULL) {  m_wndCalendar.SetWindowPos(NULL, nBorderSize, nBorderSize, cx - 2 * nBorderSize, cy - 2 * nBorderSize - nMyCalendarsHeight - 10, SWP_NOZORDER | SWP_NOACTIVATE); } m_nMyCalendarsY = cy - nMyCalendarsHeight;}BOOL CCalendarBar::Create(const RECT& rect, CWnd* pParentWnd, UINT nID){ return CWnd::Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, rect, pParentWnd, nID);}void CCalendarBar::OnPaint(){ CPaintDC dc(this); // 用于绘制的设备上下文 CRect rectClient; GetClientRect(rectClient); dc.FillRect(rectClient, &afxGlobalData.brWindow); if (rectClient.bottom - m_nMyCalendarsY > 0) {  CRect rectMyCalendarsCaption = rectClient;  rectMyCalendarsCaption.top = m_nMyCalendarsY;  rectMyCalendarsCaption.bottom = rectMyCalendarsCaption.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2;  COLORREF clrText = CMFCVisualManager::GetInstance()->OnDrawPaneCaption(&dc, NULL, FALSE, rectMyCalendarsCaption, CRect(0, 0, 0, 0));  CPen* pOldPen = dc.SelectObject(&afxGlobalData.penBarShadow);  dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.top);  dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.top);  dc.SelectStockObject(BLACK_PEN);  dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.bottom);  dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.bottom);  dc.SelectObject(pOldPen);  CRect rectText = rectMyCalendarsCaption;  rectText.DeflateRect(10, 0);  dc.SetBkMode(TRANSPARENT);  dc.SetTextColor(clrText);  CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);  BOOL bNameValid;  CString str;  bNameValid = str.LoadString(IDS_MYCALENDARS);  ASSERT(bNameValid);  dc.DrawText(str, rectText, DT_VCENTER | DT_LEFT | DT_SINGLELINE);  CRect rectCalendar = rectClient;  rectCalendar.top = rectMyCalendarsCaption.bottom + 5;  rectCalendar.bottom = rectCalendar.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2 - 5;  dc.FillSolidRect(rectCalendar, RGB(255, 255, 213));  rectCalendar.DeflateRect(20, 0);  m_Images.Draw(&dc, 3, rectCalendar.TopLeft(), 0);  rectCalendar.left += 20;  bNameValid = str.LoadString(IDS_CALENDAR);  ASSERT(bNameValid);  dc.SetTextColor(afxGlobalData.clrHotLinkNormalText);  dc.DrawText(str, rectCalendar, DT_VCENTER | DT_LEFT | DT_SINGLELINE);  dc.SelectObject(pOldFont); }}// 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面 // (“Fluent UI”)。该示例仅供参考,// 用以补充《Microsoft 基础类参考》和 // MFC C++ 库软件随附的相关电子文档。// 复制、使用或分发 Fluent UI 的许可条款是单独提供的。// 若要了解有关 Fluent UI 许可计划的详细信息,请访问  // http://msdn.microsoft.com/officeui。//// 版权所有(C) Microsoft Corporation// 保留所有权利。// inkdoc.cpp : 定义应用程序的类行为。//#include "stdafx.h"#include "afxwinappex.h"#include "inkdoc.h"#include "MainFrm.h"#include "ChildFrm.h"#include "inkdocDoc.h"#include "inkdocView.h"#include "CShockwaveFlash.h"#ifdef _DEBUG#define new DEBUG_NEW#endif// CinkdocAppBEGIN_MESSAGE_MAP(CinkdocApp, CWinAppEx) ON_COMMAND(ID_APP_ABOUT, &CinkdocApp::OnAppAbout) // 基于文件的标准文档命令 ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew) ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen)END_MESSAGE_MAP()// CinkdocApp 构造CinkdocApp::CinkdocApp(){ m_bHiColorIcons = TRUE; // 支持重新启动管理器 m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;#ifdef _MANAGED // 如果应用程序是利用公共语言运行时支持(/clr)构建的,则: //     1) 必须有此附加设置,“重新启动管理器”支持才能正常工作。 //     2) 在您的项目中,您必须按照生成顺序向 System.Windows.Forms 添加引用。 System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);#endif // TODO: 将以下应用程序 ID 字符串替换为唯一的 ID 字符串;建议的字符串格式 //为 CompanyName.ProductName.SubProduct.VersionInformation SetAppID(_T("inkdoc.AppID.NoVersion")); // TODO: 在此处添加构造代码, // 将所有重要的初始化放置在 InitInstance 中}// 唯一的一个 CinkdocApp 对象CinkdocApp theApp;// CinkdocApp 初始化BOOL CinkdocApp::InitInstance(){ // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); // 初始化 OLE 库 if (!AfxOleInit()) {  AfxMessageBox(IDP_OLE_INIT_FAILED);  return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(); // 使用 RichEdit 控件需要  AfxInitRichEdit2()  // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4);  // 加载标准 INI 文件选项(包括 MRU) InitContextMenuManager(); InitShellManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,  RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // 注册应用程序的文档模板。文档模板 // 将用作文档、框架窗口和视图之间的连接 CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_inkdocTYPE,  RUNTIME_CLASS(CinkdocDoc),  RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架  RUNTIME_CLASS(CinkdocView)); if (!pDocTemplate)  return FALSE; AddDocTemplate(pDocTemplate); // 创建主 MDI 框架窗口 CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) {  delete pMainFrame;  return FALSE; } m_pMainWnd = pMainFrame; // 仅当具有后缀时才调用 DragAcceptFiles //  在 MDI 应用程序中,这应在设置 m_pMainWnd 之后立即发生 // 启用拖/放 m_pMainWnd->DragAcceptFiles(); // 分析标准 shell 命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 启用“DDE 执行” EnableShellOpen(); RegisterShellFileTypes(TRUE); // 调度在命令行中指定的命令。如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo))  return FALSE; // 主窗口已初始化,因此显示它并对其进行更新 pMainFrame->ShowWindow(SW_SHOWMAXIMIZED); pMainFrame->UpdateWindow(); return TRUE;}// 用于应用程序“关于”菜单项的 CAboutDlg 对话框class CAboutDlg : public CDialog{public: CAboutDlg();// 对话框数据 enum { IDD = IDD_ABOUTBOX };protected: virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持// 实现protected: DECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD){}void CAboutDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX);}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)END_MESSAGE_MAP()// 用于运行对话框的应用程序命令void CinkdocApp::OnAppAbout(){ CAboutDlg aboutDlg; aboutDlg.DoModal();}// CinkdocApp 自定义加载/保存方法void CinkdocApp::PreLoadState(){ BOOL bNameValid; CString strName; bNameValid = strName.LoadString(IDS_EDIT_MENU); ASSERT(bNameValid); GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT);}void CinkdocApp::LoadCustomState(){}void CinkdocApp::SaveCustomState(){}// CinkdocApp 消息处理程序// 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面 // (“Fluent UI”)。该示例仅供参考,// 用以补充《Microsoft 基础类参考》和 // MFC C++ 库软件随附的相关电子文档。// 复制、使用或分发 Fluent UI 的许可条款是单独提供的。// 若要了解有关 Fluent UI 许可计划的详细信息,请访问  // http://msdn.microsoft.com/officeui。//// 版权所有(C) Microsoft Corporation// 保留所有权利。// inkdocDoc.cpp : CinkdocDoc 类的实现//#include "stdafx.h"// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail// and search filter handlers and allows sharing of document code with that project.#ifndef SHARED_HANDLERS#include "inkdoc.h"#endif#include "inkdocDoc.h"#include <propkey.h>#ifdef _DEBUG#define new DEBUG_NEW#endif// CinkdocDocIMPLEMENT_DYNCREATE(CinkdocDoc, CDocument)BEGIN_MESSAGE_MAP(CinkdocDoc, CDocument)END_MESSAGE_MAP()// CinkdocDoc 构造/析构CinkdocDoc::CinkdocDoc(){ // TODO: 在此添加一次性构造代码}CinkdocDoc::~CinkdocDoc(){}BOOL CinkdocDoc::OnNewDocument(){ if (!CDocument::OnNewDocument())  return FALSE; // TODO: 在此添加重新初始化代码 // (SDI 文档将重用该文档) return TRUE;}// CinkdocDoc 序列化void CinkdocDoc::Serialize(CArchive& ar){ if (ar.IsStoring()) {  // TODO: 在此添加存储代码 } else {  // TODO: 在此添加加载代码 }}#ifdef SHARED_HANDLERS// 缩略图的支持void CinkdocDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds){ // 修改此代码以绘制文档数据 dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); CString strText = _T("TODO: implement thumbnail drawing here"); LOGFONT lf; CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); pDefaultGUIFont->GetLogFont(&lf); lf.lfHeight = 36; CFont fontDraw; fontDraw.CreateFontIndirect(&lf); CFont* pOldFont = dc.SelectObject(&fontDraw); dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); dc.SelectObject(pOldFont);}// 搜索处理程序的支持void CinkdocDoc::InitializeSearchContent(){ CString strSearchContent; // 从文档数据设置搜索内容。 // 内容部分应由“;”分隔 // 例如:  strSearchContent = _T("point;rectangle;circle;ole object;"); SetSearchContent(strSearchContent);}void CinkdocDoc::SetSearchContent(const CString& value){ if (value.IsEmpty()) {  RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); } else {  CMFCFilterChunkValueImpl *pChunk = NULL;  ATLTRY(pChunk = new CMFCFilterChunkValueImpl);  if (pChunk != NULL)  {   pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT);   SetChunkValue(pChunk);  } }}#endif // SHARED_HANDLERS// CinkdocDoc 诊断#ifdef _DEBUGvoid CinkdocDoc::AssertValid() const{ CDocument::AssertValid();}void CinkdocDoc::Dump(CDumpContext& dc) const{ CDocument::Dump(dc);}#endif //_DEBUG// CinkdocDoc 命令// 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面 // (“Fluent UI”)。该示例仅供参考,// 用以补充《Microsoft 基础类参考》和 // MFC C++ 库软件随附的相关电子文档。// 复制、使用或分发 Fluent UI 的许可条款是单独提供的。// 若要了解有关 Fluent UI 许可计划的详细信息,请访问  // http://msdn.microsoft.com/officeui。//// 版权所有(C) Microsoft Corporation// 保留所有权利。// inkdocView.cpp : CinkdocView 类的实现//#include "stdafx.h"#include"CShockwaveFlash.h"#include"shockwaveflash1.h"// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail// and search filter handlers and allows sharing of document code with that project.#ifndef SHARED_HANDLERS#include "inkdoc.h"#endif#include "inkdocDoc.h"#include "inkdocView.h"#ifdef _DEBUG#define new DEBUG_NEW#endif// CinkdocViewIMPLEMENT_DYNCREATE(CinkdocView, CFormView)BEGIN_MESSAGE_MAP(CinkdocView, CFormView) ON_WM_CONTEXTMENU() ON_WM_RBUTTONUP() ON_EN_CHANGE(IDC_RICHEDIT21, &CinkdocView::OnEnChangeRichedit21) ON_COMMAND(ID_BUTTON3, &CinkdocView::OnButton3)END_MESSAGE_MAP()CinkdocView::CinkdocView() : CFormView(CinkdocView::IDD){ // TODO: 在此处添加构造代码 AfxInitRichEdit2();}CinkdocView::~CinkdocView(){}void CinkdocView::DoDataExchange(CDataExchange* pDX){ CFormView::DoDataExchange(pDX);}BOOL CinkdocView::PreCreateWindow(CREATESTRUCT& cs){ // TODO: 在此处通过修改 //  CREATESTRUCT cs 来修改窗口类或样式 return CFormView::PreCreateWindow(cs);}void CinkdocView::OnInitialUpdate(){ CFormView::OnInitialUpdate(); ResizeParentToFit();}void CinkdocView::OnRButtonUp(UINT /* nFlags */, CPoint point){ ClientToScreen(&point); OnContextMenu(this, point);}void CinkdocView::OnContextMenu(CWnd* /* pWnd */, CPoint point){#ifndef SHARED_HANDLERS theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);#endif}// CinkdocView 诊断#ifdef _DEBUGvoid CinkdocView::AssertValid() const{ CFormView::AssertValid();}void CinkdocView::Dump(CDumpContext& dc) const{ CFormView::Dump(dc);}CinkdocDoc* CinkdocView::GetDocument() const // 非调试版本是内联的{ ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CinkdocDoc))); return (CinkdocDoc*)m_pDocument;}#endif //_DEBUG// CinkdocView 消息处理程序void CinkdocView::OnEnChangeRichedit21(){ // TODO:  If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO:  Add your control notification handler code here}void CinkdocView::OnButton3(){ MessageBox(TEXT("****著名技术专家尹成的杰作http://blog.****.net/yincheng01"), TEXT("WindowsRibbon范例"), MB_OK);}BOOL CinkdocView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext){          return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);}// 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面 // (“Fluent UI”)。该示例仅供参考,// 用以补充《Microsoft 基础类参考》和 // MFC C++ 库软件随附的相关电子文档。// 复制、使用或分发 Fluent UI 的许可条款是单独提供的。// 若要了解有关 Fluent UI 许可计划的详细信息,请访问  // http://msdn.microsoft.com/officeui。//// 版权所有(C) Microsoft Corporation// 保留所有权利。// MainFrm.cpp : CMainFrame 类的实现//#include "stdafx.h"#include "inkdoc.h"#include "MainFrm.h"#ifdef _DEBUG#define new DEBUG_NEW#endif// CMainFrameIMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) ON_WM_CREATE() ON_COMMAND(ID_WINDOW_MANAGER, &CMainFrame::OnWindowManager) ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook) ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook) ON_COMMAND(ID_VIEW_CAPTION_BAR, &CMainFrame::OnViewCaptionBar) ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTION_BAR, &CMainFrame::OnUpdateViewCaptionBar) ON_COMMAND(ID_TOOLS_OPTIONS, &CMainFrame::OnOptions) ON_COMMAND(ID_BUTTON2, &CMainFrame::OnButton2) ON_COMMAND(ID_BUTTON31, &CMainFrame::OnButton31) ON_COMMAND(ID_BUTTON4, &CMainFrame::OnButton4) ON_COMMAND(ID_BUTTON5, &CMainFrame::OnButton5) ON_COMMAND(ID_BUTTON6, &CMainFrame::OnButton6) ON_COMMAND(ID_BUTTON7, &CMainFrame::OnButton7) ON_COMMAND(ID_BUTTON8, &CMainFrame::OnButton8) ON_COMMAND(ID_BUTTON9, &CMainFrame::OnButton9)END_MESSAGE_MAP()// CMainFrame 构造/析构CMainFrame::CMainFrame(){ // TODO: 在此添加成员初始化代码 theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_WINDOWS_7);}CMainFrame::~CMainFrame(){}int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct){ if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)  return -1; BOOL bNameValid; // 基于持久值设置视觉管理器和样式 OnApplicationLook(theApp.m_nAppLook); CMDITabInfo mdiTabParams; mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; // 其他可用样式... mdiTabParams.m_bActiveTabCloseButton = TRUE;      // 设置为 FALSE 会将关闭按钮放置在选项卡区域的右侧 mdiTabParams.m_bTabIcons = FALSE;    // 设置为 TRUE 将在 MDI 选项卡上启用文档图标 mdiTabParams.m_bAutoColor = TRUE;    // 设置为 FALSE 将禁用 MDI 选项卡的自动着色 mdiTabParams.m_bDocumentMenu = TRUE; // 在选项卡区域的右边缘启用文档菜单 EnableMDITabbedGroups(TRUE, mdiTabParams); m_wndRibbonBar.Create(this); m_wndRibbonBar.LoadFromResource(IDR_RIBBON); if (!m_wndStatusBar.Create(this)) {  TRACE0("未能创建状态栏/n");  return -1;      // 未能创建 } CString strTitlePane1; CString strTitlePane2; bNameValid = strTitlePane1.LoadString(IDS_STATUS_PANE1); ASSERT(bNameValid); bNameValid = strTitlePane2.LoadString(IDS_STATUS_PANE2); ASSERT(bNameValid); m_wndStatusBar.AddElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE1, strTitlePane1, TRUE), strTitlePane1); m_wndStatusBar.AddExtendedElement(new CMFCRibbonStatusBarPane(ID_STATUSBAR_PANE2, strTitlePane2, TRUE), strTitlePane2); // 启用 Visual Studio 2005 样式停靠窗口行为 CDockingManager::SetDockingMode(DT_SMART); // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 EnableAutoHidePanes(CBRS_ALIGN_ANY); // 导航窗格将创建在左侧,因此将暂时禁用左侧的停靠: EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT); // 创建并设置“Outlook”导航栏: if (!CreateOutlookBar(m_wndNavigationBar, ID_VIEW_NAVIGATION, m_wndTree, m_wndCalendar, 250)) {  TRACE0("未能创建导航窗格/n");  return -1;      // 未能创建 } // 创建标题栏: if (!CreateCaptionBar()) {  TRACE0("未能创建标题栏/n");  return -1;      // 未能创建 } // 已创建 Outlook 栏,应允许在左侧停靠。 EnableDocking(CBRS_ALIGN_LEFT); EnableAutoHidePanes(CBRS_ALIGN_RIGHT); // 启用增强的窗口管理对话框 EnableWindowsDialog(ID_WINDOW_MANAGER, ID_WINDOW_MANAGER, TRUE); // 将文档名和应用程序名称在窗口标题栏上的顺序进行交换。这 // 将改进任务栏的可用性,因为显示的文档名带有缩略图。 ModifyStyle(0, FWS_PREFIXTITLE); return 0;}BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs){ if( !CMDIFrameWndEx::PreCreateWindow(cs) )  return FALSE; // TODO: 在此处通过修改 //  CREATESTRUCT cs 来修改窗口类或样式 cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE   | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE | WS_SYSMENU; return TRUE;}BOOL CMainFrame::CreateOutlookBar(CMFCOutlookBar& bar, UINT uiID, CMFCShellTreeCtrl& tree, CCalendarBar& calendar, int nInitialWidth){ bar.SetMode2003(); BOOL bNameValid; CString strTemp; bNameValid = strTemp.LoadString(IDS_SHORTCUTS); ASSERT(bNameValid); if (!bar.Create(strTemp, this, CRect(0, 0, nInitialWidth, 32000), uiID, WS_CHILD | WS_VISIBLE | CBRS_LEFT)) {  return FALSE; // 未能创建 } CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*)bar.GetUnderlyingWindow(); if (pOutlookBar == NULL) {  ASSERT(FALSE);  return FALSE; } pOutlookBar->EnableInPlaceEdit(TRUE); static UINT uiPageID = 1; // 可浮动,可自动隐藏,可调整大小,但不能关闭 DWORD dwStyle = AFX_CBRS_FLOAT | AFX_CBRS_AUTOHIDE | AFX_CBRS_RESIZE; CRect rectDummy(0, 0, 0, 0); const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; tree.Create(dwTreeStyle, rectDummy, &bar, 1200); bNameValid = strTemp.LoadString(IDS_FOLDERS); ASSERT(bNameValid); pOutlookBar->AddControl(&tree, strTemp, 2, TRUE, dwStyle); calendar.Create(rectDummy, &bar, 1201); bNameValid = strTemp.LoadString(IDS_CALENDAR); ASSERT(bNameValid); pOutlookBar->AddControl(&calendar, strTemp, 3, TRUE, dwStyle); bar.SetPaneStyle(bar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); pOutlookBar->SetImageList(theApp.m_bHiColorIcons ? IDB_PAGES_HC : IDB_PAGES, 24); pOutlookBar->SetToolbarImageList(theApp.m_bHiColorIcons ? IDB_PAGES_SMALL_HC : IDB_PAGES_SMALL, 16); pOutlookBar->RecalcLayout(); BOOL bAnimation = theApp.GetInt(_T("OutlookAnimation"), TRUE); CMFCOutlookBarTabCtrl::EnableAnimation(bAnimation); bar.SetButtonsFont(&afxGlobalData.fontBold); return TRUE;}BOOL CMainFrame::CreateCaptionBar(){ if (!m_wndCaptionBar.Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, this, ID_VIEW_CAPTION_BAR, -1, TRUE)) {  TRACE0("未能创建标题栏/n");  return FALSE; } BOOL bNameValid; CString strTemp, strTemp2; bNameValid = strTemp.LoadString(IDS_CAPTION_BUTTON); ASSERT(bNameValid); m_wndCaptionBar.SetButton(strTemp, ID_TOOLS_OPTIONS, CMFCCaptionBar::ALIGN_LEFT, FALSE); bNameValid = strTemp.LoadString(IDS_CAPTION_BUTTON_TIP); ASSERT(bNameValid); m_wndCaptionBar.SetButtonToolTip(strTemp); bNameValid = strTemp.LoadString(IDS_CAPTION_TEXT); ASSERT(bNameValid); m_wndCaptionBar.SetText(strTemp, CMFCCaptionBar::ALIGN_LEFT); m_wndCaptionBar.SetBitmap(IDB_INFO, RGB(255, 255, 255), FALSE, CMFCCaptionBar::ALIGN_LEFT); bNameValid = strTemp.LoadString(IDS_CAPTION_IMAGE_TIP); ASSERT(bNameValid); bNameValid = strTemp2.LoadString(IDS_CAPTION_IMAGE_TEXT); ASSERT(bNameValid); m_wndCaptionBar.SetImageToolTip(strTemp, strTemp2); return TRUE;}// CMainFrame 诊断#ifdef _DEBUGvoid CMainFrame::AssertValid() const{ CMDIFrameWndEx::AssertValid();}void CMainFrame::Dump(CDumpContext& dc) const{ CMDIFrameWndEx::Dump(dc);}#endif //_DEBUG// CMainFrame 消息处理程序void CMainFrame::OnWindowManager(){ ShowWindowsDialog();}void CMainFrame::OnApplicationLook(UINT id){ CWaitCursor wait; theApp.m_nAppLook = id; switch (theApp.m_nAppLook) { case ID_VIEW_APPLOOK_WIN_2000:  CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager));  m_wndRibbonBar.SetWindows7Look(FALSE);  break; case ID_VIEW_APPLOOK_OFF_XP:  CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP));  m_wndRibbonBar.SetWindows7Look(FALSE);  break; case ID_VIEW_APPLOOK_WIN_XP:  CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE;  CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));  m_wndRibbonBar.SetWindows7Look(FALSE);  break; case ID_VIEW_APPLOOK_OFF_2003:  CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003));  CDockingManager::SetDockingMode(DT_SMART);  m_wndRibbonBar.SetWindows7Look(FALSE);  break; case ID_VIEW_APPLOOK_VS_2005:  CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005));  CDockingManager::SetDockingMode(DT_SMART);  m_wndRibbonBar.SetWindows7Look(FALSE);  break; case ID_VIEW_APPLOOK_VS_2008:  CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008));  CDockingManager::SetDockingMode(DT_SMART);  m_wndRibbonBar.SetWindows7Look(FALSE);  break; case ID_VIEW_APPLOOK_WINDOWS_7:  CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7));  CDockingManager::SetDockingMode(DT_SMART);  m_wndRibbonBar.SetWindows7Look(TRUE);  break; default:  switch (theApp.m_nAppLook)  {  case ID_VIEW_APPLOOK_OFF_2007_BLUE:   CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue);   break;  case ID_VIEW_APPLOOK_OFF_2007_BLACK:   CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);   break;  case ID_VIEW_APPLOOK_OFF_2007_SILVER:   CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver);   break;  case ID_VIEW_APPLOOK_OFF_2007_AQUA:   CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua);   break;  }  CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));  CDockingManager::SetDockingMode(DT_SMART);  m_wndRibbonBar.SetWindows7Look(FALSE); } RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE); theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook);}void CMainFrame::OnUpdateApplicationLook(CCmdUI* pCmdUI){ pCmdUI->SetRadio(theApp.m_nAppLook == pCmdUI->m_nID);}void CMainFrame::OnViewCaptionBar(){ m_wndCaptionBar.ShowWindow(m_wndCaptionBar.IsVisible() ? SW_HIDE : SW_SHOW); RecalcLayout(FALSE);}void CMainFrame::OnUpdateViewCaptionBar(CCmdUI* pCmdUI){ pCmdUI->SetCheck(m_wndCaptionBar.IsVisible());}void CMainFrame::OnOptions(){ CMFCRibbonCustomizeDialog *pOptionsDlg = new CMFCRibbonCustomizeDialog(this, &m_wndRibbonBar); ASSERT(pOptionsDlg != NULL); pOptionsDlg->DoModal(); delete pOptionsDlg;}

 

 

 

如果需要工程源码,请本人****博客留言留下email!

 

本文作者专著《Visual C++2010开发权威指南》即将推出,敬请关注,Visual C++2010最近技术,Windows7开发最新技术!

 

 

           

给我老师的人工智能教程打call!http://blog.****.net/jiangjunshow

SDI实现多视图并切换视图