电脑技术学习

基于Windows 7中的 Ribbon开发技术应用

dn001

  nVIEwChanged允许从 IUIFramework和查询其状态请求一个接口。如果typeId == UI_VIEWTYPE_RIBBON和verb== UI_VIEWVERB_CREATE或UI_VIEWVERB_SIZE 例如,这会告诉你,ribbon创建或改变大小,这样你就可以查询IUnknown指针的IUIRibbon并获得其预期的高度。

  为了避免上述所有的问题,把这些接口包装到类库。一个RIBBON类,并且你使用如下:

RIBBON(HWND hh = 0);~RIBBON();bool Initialize();

  Ribbon初始化成功返回Ture

bool LoadMarkup(HINSTANCE hInst,LPCWSTR resourceName);

  Ribbon初始化成功返回Turebool LoadMarkup(HINSTANCE hInst,LPCWSTR resourceName);

  从资源里加载ribbon,如果现有的ribbon被加载,则释放它。void DestroyMarkup();销毁加载的ribbon。int& DesiredHeight();

  返回理想高度ribbonvoid SetHeight(int);允许设置ribbon高度

  调用类库向父窗口发送一个预定义的MESSAGE_RIBBON (const int MESSAGE_RIBBON = RegisterWindowMessage(L"{E733E4DA-904C-486b-B5FB-6201773D69DE}");),与 WPARAM设置为RIBBON *类,和LPARAM设置为RIBBON_MESSAGE结构:

struct RIBBON_MESSAGE{ IUIFramework * u_f; 
      // Pointer to the IUIFramework of the ribbon UINT32 cmd; 
            // Command ID  UINT32 reason; 
                 // Reason code (When View is changed) UI_COMMANDTYPE type; 
           // Type of the command UI_VIEWTYPE vtype; 
             // Verb Type of the view change (When View is changed) UI_VIEWVERB vverb 
;             // Verb of the view change (When View is changed) UI_EXECUTIONVERB verb; 
         // Verb of the command const PROPERTYKEY* key; 
        // Contains the new value const PROPVARIANT* cv; 
         // Contains the current value IUISimplePropertySet* pset; 
    // Contains an interface which you can set/query values void* view; 
                    // Contains an IUnknown* of the view interface 
                                // (when view is changed) which you 
                                // can use to query for an IUIRibbon. bool update; 
                  // true if view is changed. };

标签: