Background Color (Dev C++)

I have a basic window with a menu thing (File, Edit, Options...) and I made it so when you press options there is a option to make the background green. I did the code right, and it works, but I do not know what to put in the if statement. If you understand, please help me. Here is the part of the code that I am confused on:


1
2
3
4
5
6
7
8
9
case WM_COMMAND:{

if (LOWORD(wParam)==ID_BUTTON){

//What do I put here?

} 
break;
}   
Can you give us full code?
Well... What do you want that button to do? That's what you put in that if statement. There's no right or wrong answer here, there may be better ways to go about certain things but one can't really say something is wrong (assuming it compiles runs and doesn't do anything crazy).
If you want to change background color of menu itself you need to use owner-drawn menus, not default windows menus, this is the catch. Search the google for example code or MSDN.
Last edited on
if you just want to change only the background of your menu it's not necessary to use owner-draw you can do it using SetMenuInfo() function. According to your question if you want to make your menu green then add this line between those two bracket of 'if' statement:

MENUINFO mi;
mi.cbSize=sizeof(mi);
mi.fMask=2|0x80000000L;
mi.hbrBack=CreateSolidBrush(RGB(0,255,0)); //you can change the color combination here
SetMenuInfo(GetMenu(hwnd),&mi); // i assume hwnd is handle of your window that contains menu
Last edited on
Topic archived. No new replies allowed.