Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » How to use CExtMenuControlBar in ActiveX? Collapse All
Subject Author Date
Chun Pong Lau May 5, 2011 - 12:19 PM

Dear support team,

We cannot create menubar in an ActiveX Control.


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct){

    if( CExtNCW < CFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )         return -1;

   if( !m_wndMenuBar.Create(             _T("Menu Bar"),             this,             IDR_MAINFRAME             )         )     {     TRACE0("Failed to create menubar\n");     return -1;   // failed to create     }

return 0;


 The menubar is not visible no matter how hard we try. Can you please help?

Best regards,

Chun Pong

PROF-UIS users

Chun Pong Lau May 11, 2011 - 4:53 PM

Dear support team,

Thank you so much for your response.

The solution works! But can I associate an icon with each menu item the menubar in an easy way, providing that I do not have a toolbar?


Chun Pong

Technical Support May 13, 2011 - 2:08 AM

The CExtMenuControlBar class is derived from the CExtToolControlBar class. Both contain buttons and can display icons inside buttons. The menu bar just implements additional features specific for menu line. The menu bar’s buttons are created dynamically when menu tree is loaded by menu bar. I.e. buttons inside menu bar use dynamically allocated command identifiers and CExtCmdItem command description objects inside Prof-UIS command manager. There are two ways to display icons inside menu bar’s buttons:

1) The CExtMenuControlBar-based solution. Override the CExtMenuControlBar::_UpdateMenuBar() internal virtual method. Your method should be similar to original, but it should instantiate your CExtBarButton-based button objects for all the menu bar buttons which should display icons. Your button class should implement the CExtBarButton::GetIconPtr() virtual method and return icon object.

2) The CExtToolControlBar-based solution. It’s much easier. You should just initialize toolbar with command buttons with icons from toolbar resource. Then you can attach text and icons to each toolbar button. You can override the CExtToolControlBar::_GetFullRowMode() virtual method and make toolbar occupying entire row of bars like menu bar does.

Chun Pong Lau May 13, 2011 - 7:33 PM

Dear support team,

Can you please advise more in the two approaches? Would there be any similar example in your samples? Or can you please give a minimal example for guidance?

You help is much appreciated.


Chun Pong

Technical Support May 14, 2011 - 1:06 PM

First of all, we need to discuss some important details related to your ActiveX control. Desktop windows often have a menu. It can be a classic menu line. It can be a modern menu bar. Such menus are activated using the Alt key. This requires controlling the thread’s message loop. In a classic MFC application, a message loop is controlled by one global instance of CWinApp derived class. In the case of your ActiveX control, the message loop is controlled by Internet Explorer and it uses this for activating its own menu bar. The menu bar inside your ActiveX control will not be activated on pressing Alt. This means you can implement your menu bar using a toolbar control. Just create a toolbar control and attach menus to its buttons.

Technical Support May 6, 2011 - 11:31 AM

First of all, ActiveX is an MFC regular DLL. So, you should initializes Prof-UIS for regular DLL in your project:

Second, you should register your command manager’s profile for the parent window of your menu bar window. We can discuss this if you provide some additional details or a test project.The solution depends on which window is parent.

Third, MFC regular DLLs and ActiveXes do not handle idle time processing. This means MFC command updating mechanism will not work. To fix this, you should run a 100...200 millisecond timer in some window and invoke application’s OnIdle() virtual method in it.

Chun Pong Lau May 7, 2011 - 12:51 PM

Dear support team,

I have followed your instructions but the menubar is still not showing. The project is below:

To reproduce the problem, simply:

  1. regsvr32 ocxtest.ocx

  2. Open an Internet Explorer and open index.html

I would like to make it under CExtPaintManagerOffice2007_R2_Obsidian but even if I comment the line in CMainFrame::CMainFrame(). It still does not work.

Please advise as the menubar is important for our project. Thanks a lot.


Chun Pong

P.S. Please see below for the two screenshot captured under Internet Explorer 6.0


Figure 1: Normal


Figure 2: With CExtPaintManagerOffice2007_R2_Obsidian


Technical Support May 11, 2011 - 7:25 AM

Here is the fixed version of your test project:

You can use tools like WinDiff or WinMerge to see what we had to fix in its source code.