Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre>
CMenu m_ShortMenu;

	m_ShortMenu.LoadMenu(IDR_MENU1); //carica il menù per la toolbar e inserimento lingua

	SetMenu(&m_ShortMenu);
	CBrush* NewBrush;
	NewBrush = new CBrush;
	NewBrush->CreateSolidBrush(RGB(211, 211, 211));

	CMenu* pMenu1 = this->GetMenu();

	MENUINFO MenuInfo = { 0 };
	MenuInfo.cbSize = sizeof(MenuInfo);
	MenuInfo.hbrBack = *NewBrush; // Brush you want to draw
	MenuInfo.fMask = MIM_BACKGROUND;
	MenuInfo.dwStyle = MNS_AUTODISMISS;

	MENUINFO MenuInfo1 = { 1 };
	MenuInfo1.cbSize = sizeof(MenuInfo);
	MenuInfo1.hbrBack = *NewBrush; // Brush you want to draw
	MenuInfo1.fMask = MIM_BACKGROUND;
	MenuInfo1.dwStyle = MNS_AUTODISMISS;

	//CMenu* pMenu1 = this->GetMenu();

	if (IsMenu(pMenu1->m_hMenu))
	{
		SetMenuInfo(pMenu1->m_hMenu, &MenuInfo);
	}




I use this code to change color of menu, but when I click on my treeview in dialog color of menu becomes white

What I have tried:

I put this code also in event double click but menu becomes white
Posted
Updated 17-Feb-22 5:10am
Comments
[no name] 17-Feb-22 11:22am    
1
jeron1 17-Feb-22 17:45pm    
Just a guess, looks like you're setting a CBrush object to MenuInfo.hbrBack, the doc says it should be an HBRUSH.
MenuInfo.hbrBack = *NewBrush;

You could try using the HBRUSH operator something like;
MenuInfo.hbrBack = (HBRUSH)*NewBrush;

Not sure if it will help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900