纯C中的丝带背景颜色 [英] Ribbon background color in pure C

查看:74
本文介绍了纯C中的丝带背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我30年来一直在编写原生c程序,但现在我的老板已经完成了使用功能区菜单改进现有程序的任务,而无需编写c ++新增的所有程序或c#。

我从2010年来自Stephen Wiria的程序Win32 C应用程序中的Windows功能区框架获得了完美的指导(非常感谢这个伟大的程序!)并且所有程序都非常好用一个例外:

我无法使用UI_PKEY_GlobalBackgroundColor设置功能区的全局背景颜色。

我绝对不熟悉C ++和我所有的尝试将一个示例c ++代码转换为纯c来设置功能区的背景颜色失败。

有人给我一个简短的解决方案吗?

非常感谢你。

Detlef



我的尝试:



Hi,
I'm writing native c programs since 30 years, but now I have the task by my boss to improve the existing programs with a ribbon menu without writing all programs new in c++ or c#.
I was guided perfect by the program "Windows Ribbon Framework in Win32 C Application" from Stephen Wiria from the year 2010 (thanks a lot for this great program!) and all lools very good with one exception:
I'm not able to set the global background color of the ribbon using "UI_PKEY_GlobalBackgroundColor".
I'm abolute not familar with C++ and all my attemps to translate an example c++ code to pure c to set the backgrouind color of a ribbon failed.
Has somebody a short solution for me?
Thank you so much.
Detlef

What I have tried:

HRESULT STDMETHODCALLTYPE OnCreateUICommand(IUIApplication *This, UINT32 commandId, UI_COMMANDTYPE typeID, IUICommandHandler **commandHandler)
{
	HRESULT hr;
	VOID *ppvObj = NULL;
	PROPVARIANT pv;
	
	
	/* allocate pApplication */
	
	// Command-Handler für das Abfragen der Command-Ids
	pCommandHandler = (IUICommandHandler *)GlobalAlloc(GMEM_FIXED, sizeof(IUICommandHandler));
	(IUICommandHandlerVtbl *)pCommandHandler->lpVtbl = &myCommand_Vtbl;
	hr = pCommandHandler->lpVtbl->QueryInterface(pCommandHandler, &IID_IUICommandHandler, (void**)commandHandler);
	


	// Property-Handler
	pPropertyStore = (IPropertyStore *)GlobalAlloc(GMEM_FIXED, sizeof(IPropertyStore));
	
	(IPropertyStoreVtbl*)pPropertyStore->lpVtbl = &myPropertyStore_Vtbl;

	pPropertyStore->lpVtbl->QueryInterface(pPropertyStore, &IID_IUIPropertyHandler, &ppvObj);

		

	UI_HSBCOLOR BackgroundColor = UI_HSB(0xFF, 0xFF, 0x00);
	

	PropVariantInit (&pv);

	pv.vt = VT_UI4;
	pv.lVal = BackgroundColor;
		
	hr = pPropertyStore->lpVtbl->SetValue(pPropertyStore, &UI_PKEY_GlobalBackgroundColor, &pv);
	hr = pPropertyStore->lpVtbl->Commit(pPropertyStore);
	
	
	return hr;

}

推荐答案

如果这会有所帮助,那就不要了:



https://docs.microsoft.com/de-de/windows/desktop/windowsribbon/windowsribbon-templates
Not shure if this will help:

https://docs.microsoft.com/de-de/windows/desktop/windowsribbon/windowsribbon-templates


IPropertyStoreCache *ppvObj_propertystore = NULL;
PROPVARIANT    pvBackgroundColor;

UI_HSBCOLOR BackgroundColor = UI_HSB(0xFF, 0xFF, 0x54);
HRESULT hr;

hr = CoCreateInstance(&CLSID_InMemoryPropertyStore, NULL, CLSCTX_INPROC_SERVER, &IID_IPropertyStoreCache, (void**)&ppvObj_propertystore);

hr = ppvObj_propertystore->lpVtbl->Release(ppvObj_propertystore);

hr = ppvObj_propertystore->lpVtbl->QueryInterface(ppvObj_propertystore, &IID_IPropertyStoreCache, &ppvObj_propertystore);


	
PropVariantInit (&pvBackgroundColor);
hr = InitPropVariantFromUInt32(BackgroundColor, &pvBackgroundColor);

PropVariantInit(&pvBackgroundColorIn);
hr = InitPropVariantFromUInt32(BackgroundColor, &pvBackgroundColorIn);

hr = ppvObj_propertystore->lpVtbl->GetValue(ppvObj_propertystore, &UI_PKEY_GlobalBackgroundColor, &pvBackgroundColorIn);

PropVariantToUInt32(&pvBackgroundColorIn, &uErgebnis);


hr = ppvObj_propertystore->lpVtbl->SetValue(ppvObj_propertystore,  
        &UI_PKEY_GlobalBackgroundColor, &pvBackgroundColor);
hr = ppvObj_propertystore->lpVtbl->Commit(ppvObj_propertystore);


这篇关于纯C中的丝带背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆