Code for NETCF MainMenu Extension to Support Background Color Property

I was looking for a solution to change the background color in a Main Framework CompactMenu control, and the only answer I found was that you need to create a custom control. Does anyone have some sample code for this?

+4
source share
3 answers

There is no way to do this.
Your right is that you will probably need to create your own control.

This was what I planned to do anyway, so that the application would go to Windows CE and Windows Mobile.
The problem with adding menus when an application should work with them is that the menu goes to the top of the screen in Windows CE and covers any controls that might be there. It would be less hassle in the long run, just make a new control.

0
source

I did something vague where I wanted to process a WM_EXITMENULOOP message that was not available as an event in .NETCF.

The solution was to “subclass” the main menu, the old MFC trick, in which you replaced the WndProc function with your own, process any Windows messages (WM_EXITMENULOOP in my case), and call the WndProc base class for everything else.

Alex Yakhnin's blog post has some code examples on how to subclass a control: An example of subclassing a window in .NETCF

In your case, you will actually subclass the form that MainMenu is on, and I think WM_DRAWITEM will be the Windows message that you want to process yourself. I have not tried changing the background color myself, so I'm not completely sure that this will work, but the subclass should have started.

+2
source

I tried to do something similar some time ago and found that you need to write your own menu; supremely from scratch. I gave up because the project I was working on could not afford the costs. I also found that OpenNETCF has a pretty awesome menu control. I don't know if this is included in their free software, but it can be interesting to learn.

0
source

Source: https://habr.com/ru/post/1277421/


All Articles