Changing the color of MainMenu

I would likt to change the color of MainMenu control in a MDI form using Windows API,so I derived a FMainMenu class from MainMenu and added one method named SetMenuBkColor.Here is my code

public class FMainMenu : System.Windows.Forms.MainMenu
private static extern long SetBkColor(int hdc,long color);
private static extern int GetDC(int hwnd);

public void SetMenuBkColor(long ColorRef)
int hdc=GetDC((int)(this.CreateMenuHandle()));
catch(System.Exception e)
MessageBox.Show(e.Message); }
And I call this method later in my form load event like this:
to make the menu color white.But it doesn't work properly and the color doesn't change.I know there is a problem with calling API,maybe casting isn't correct or something else.

Any one can tell me what happens with this code and what's wrong with it?

Thanks alot
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!