Jump to content

Ribbon


trancexx
 Share

Recommended Posts

Win7 x64 SP1

There are no additional dependencies. Only three files from the zip file (being in the same folder) are needed for the example to work. I can't try now but really, it should work. Did you try 32 bit AutoIt or only x64 version?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

For me it works properly on my Win7 x64 notebook running it in both versions (x64 and x86).

AutoIt version: 3.3.8.1 and AutoIt Object version: 1.2.7.0

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Link to comment
Share on other sites

Seems like a great project, but ribbon will not appear on XPro SP3. Not surprising. ;)

EDIT: Tried it on my home system (Win7 HP x64), works great! Very nice.

Edited by cyberbit

_ArrayConcatenate2D · Aero Flip 3D · EPOCH (destroy timestamps) · File Properties Modifier · _GetFileType · UpdateEngine<new> · In-line Case (_ICase) <new>

[hr]

50% of the time, it works all the time. -PezoFaSho

Link to comment
Share on other sites

  • 2 weeks later...

Looking at a C++ example (example is to set the global color) and based on what I saw in your other example functions I tried to get the global color of the ribbon but I can get this work.

CComPtr<IPropertyStore> spPropertyStore;

// _spFramework is a pointer to the IUIFramework interface that is assigned 
// when the Ribbon is initialized.
if (SUCCEEDED(_spFramework->QueryInterface(&spPropertyStore)))
{
  PROPVARIANT propvarBackground;
  PROPVARIANT propvarHighlight;
  PROPVARIANT propvarText;
 
  // UI_HSBCOLOR is a type defined in UIRibbon.h that is composed of 
  // three component values: hue, saturation and brightness, respectively.
  UI_HSBCOLOR BackgroundColor = UI_HSB(0x14, 0x38, 0x54);
  UI_HSBCOLOR HighlightColor = UI_HSB(0x00, 0x36, 0x87);
  UI_HSBCOLOR TextColor = UI_HSB(0x2B, 0xD6, 0x00);

  InitPropVariantFromUInt32(BackgroundColor, &propvarBackground);
  InitPropVariantFromUInt32(HighlightColor, &propvarHighlight);
  InitPropVariantFromUInt32(TextColor, &propvarText);
 
  spPropertyStore->SetValue(UI_PKEY_GlobalBackgroundColor, propvarBackground);
  spPropertyStore->SetValue(UI_PKEY_GlobalTextColor, propvarText);
 
  spPropertyStore->Commit();
}
Func _GetGlobalColor()
    Local $tIID_IPropertyStore = _AutoItObject_CLSIDFromString($sIID_IPropertyStore)
    Local $aCall = $oRibbFramework.QueryInterface(Number(DllStructGetPtr($tIID_IPropertyStore)), 0)
    Local $pPropertyStore = $aCall[2]
    Local $oPropertyStore = _AutoItObject_WrapperCreate($pPropertyStore, $dtagIPropertyStore)
    Local $tGUIDByte = _AutoItObject_DllStructCreate("byte Data[16]", _AutoItObject_CLSIDFromString("{00002000-7363-696e-8441798acf5aebb7}"))
    Local $tUI_PKEY_GlobalBackgroundColor = _AutoItObject_DllStructCreate("byte GUID[16]; dword PID;")
    $tUI_PKEY_GlobalBackgroundColor.GUID = $tGUIDByte.Data
    $tUI_PKEY_GlobalBackgroundColor.PID = 19 ; type = VT_UI4
    $aCall = $oPropertyStore.GetValue($tUI_PKEY_GlobalBackgroundColor(), 0)
    If IsArray($aCall) And $aCall[2] <> 0 Then Return $aCall[2]
EndFunc

I'm confused about PROPVARIANT and UI_HSBCOLOR.

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

@trancexx

I see you suggest everyone to use the built-in object functions.

However I can see in the helpfile for the ObjCreateInterface an experimental warning.

Is it up to date? I mean you finished the function so it can be safely used?

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Function can be safely used. It's not finished in parts which are not directly related to the functionallity but rather on validating input. Other things I wanted to add are really for additional user convenience and other parts of AutoIt needed updating before that. I can't say what Jon wants. Sometimes he makes completely wrong decisions, but it's highly unlikely he'll remove this function. That would be plain stupid.

Use built-in function.

@Andreik, yes the whole thing.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Andreik UI_PKEY_GlobalBackgroundColor is defined as "{000007D0-7363-696e-8441-798acf5aebb7} 19" in string form. First part of the string is guid and other is dword pid. You can use PSPropertyKeyFromString to convert to struct form. Or you can do it manually with _WinAPI_GUIDFromString() and append dword value of pid.

I'm not sure where you got the definition you have in your code.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Thanks for tips, PSPropertyKeyFromString works nice but I get a COM error when I use GetValue method from IPropertyStore.

COM Error, ScriptLine(307) : Number 0x80004003 - Invalid pointer

I suppose it's because I send 0 as PROPVARIANT (second parameter)??

When the words fail... music speaks.

Link to comment
Share on other sites

Well when you ditch AutoItObject you will have this function for that:

Func _GetGlobalColor()
    Local $oPropertyStore = ObjCreateInterface($oRibbFramework(), $sIID_IPropertyStore, $tagIPropertyStore)
    If @error Then Return SetError(1, 0, 0)
    $oPropertyStore.AddRef()
    Local $tPKEY = PSPropertyKeyFromString($sUI_PKEY_GlobalBackgroundColor)
    Local $iColor
    If $oPropertyStore.GetValue($tPKEY, $iColor) Then Return SetError(2, 0, 0)
    Return $iColor
EndFunc

...and IPropertyStore definition will be:

;===============================================================================
#interface "IPropertyStore"
Global Const $sIID_IPropertyStore = "{886d8eeb-8cf2-4446-8d02-cdba1dbdcf99}"
Global Const $tagIPropertyStore = _
        "GetCount hresult(dword*);" & _
        "GetAt hresult(dword;ptr*);" & _
        "GetValue hresult(struct*;variant*);" & _
        "SetValue hresult(struct*;variant*);" & _
        "Commit hresult();"
;===============================================================================

...and it will work just fine.

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Func _GetGlobalColor()
    Local $sUI_PKEY_GlobalBackgroundColor = "{000007D0-7363-696e-8441-798acf5aebb7} 19"
    Local $oPropertyStore = ObjCreateInterface($sCLSID_UIRibbonFramework, $sIID_IPropertyStore, $dtagIPropertyStore)
    If @error Then Return SetError(1, 0, 0)
    $oPropertyStore.AddRef()
    
    $tPROPERTYKEY = DllStructCreate("BYTE GUID[16]; DWORD PID")
    DllCall("propsys.dll","ulong","PSPropertyKeyFromString","wstr",$sUI_PKEY_GlobalBackgroundColor,"ptr",DllStructGetPtr($tPROPERTYKEY))

    ConsoleWrite(DllStructGetData($tPROPERTYKEY,"GUID") & @CRLF)
    ConsoleWrite(DllStructGetData($tPROPERTYKEY,"PID") & @CRLF)

    Local $iColor
    If $oPropertyStore.GetValue(DllStructGetPtr($tPROPERTYKEY), $iColor) Then Return SetError(2, 0, 0)
    Return $iColor
EndFunc

The structure is filled with correct informations as I can see in console but when the method GetValue is called I get the same error.

When the words fail... music speaks.

Link to comment
Share on other sites

Yes, it works great. Thank you!

PS: did you notice the fail closing the application from menu?

No I haven't. Now that you mention it makes sense to fail, right? It's the same thing as

delete this;

... in C++.

After releasing objects they shouldn't be accessed in any way. My bad. I'll fix that before updating the OP with the new code.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • 1 month later...

I try to get the height of ribbon when it is created and I have as example a code from MSDN but don't work very well.

STDMETHODIMP CApplication::OnViewChanged(
    UINT viewId,
    UI_VIEWTYPE typeId,
    IUnknown* pView,
    UI_VIEWVERB verb,
    INT uReasonCode)
{
    HRESULT hr = E_NOTIMPL;
    
    // Checks to see if the view that was changed was a Ribbon view.
    if (UI_VIEWTYPE_RIBBON == typeId)
    {
        switch (verb)
        {            
            // The view was newly created.
            case UI_VIEWVERB_CREATE:
                _cwprintf(L"IUIApplication::OnViewChanged called with verb=CREATE\r\n");

                if (NULL == g_pRibbon) /* g_pRibbon is a global pointer to the IUIRibbon object */
                {
                    // Retrieve and store the IUIRibbon
                    hr = pView->QueryInterface(&g_pRibbon);
                }
                break;

            // The view was resized.  
            // In the case of the Ribbon view, the application should call 
            // GetHeight() to determine the height of the Ribbon.
            case UI_VIEWVERB_SIZE:
                _cwprintf(L"IUIApplication::OnViewChanged called with verb=SIZE\r\n");
                // Call to the framework to determine the height of the Ribbon.
                if (NULL != g_pRibbon)
                {
                    UINT uRibbonHeight;
                    hr = g_pRibbon->GetHeight(&uRibbonHeight);
                }
                if (!SUCCEEDED(hr))
                {
                    //_cwprintf(L"IUIRibbon::GetHeight() failed with hr=0x%X\r\n", hr);
                }
                break;
                
            // The view was destroyed.
            case UI_VIEWVERB_DESTROY:
                //_cwprintf(L"IUIApplication::OnViewChanged called with verb=DESTROY\r\n");
                g_pRibbon = NULL;
                hr = S_OK;
                break;
        }
    }
    return hr;
}

And what I tried:

Func _MyUIApp_OnViewChanged($pSelf, $iViewId, $iTypeId, $pView, $iVerb, $iReason)
    #forceref $pSelf, $iViewId, $iTypeId, $pView, $iVerb, $iReason
    Switch $iVerb
        Case 0  ;UI_VIEWVERB_CREATE
            ConsoleWrite("UI_VIEWVERB_CREATE" & @CRLF)
            $oUnknown = ObjCreateInterface($pView,$sIID_IUnknown)
            $oUnknown.QueryInterface($g_pRibbon)
        Case 2  ;UI_VIEWVERB_SIZE
            ConsoleWrite("UI_VIEWVERB_SIZE" & @CRLF)
            Local $uRibbonHeight
            $g_pRibbon.GetHeight($uRibbonHeight)
    EndSwitch
    Return 0 ; S_OK
EndFunc   ;==>_MyUIApp_OnViewChanged

What I'm doing wrong?

When the words fail... music speaks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...