Professional UI Solutions
Site Map   /  Register
 
 

Forum

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 put a toolbar into the CExtControlBar? Collapse All
Subject Author Date
Chau Andy Apr 13, 2004 - 3:43 AM

Hello, I’m a newbie of using the Prof-UIS, it’s a wonderful tools that saving my  to beautify the GUI.


But I have a problem that I can’t create a toolbar inside the CExtControlBar, I saw the example of the GLView, it seems that I can only put the toolbar on the CWnd base control, are there anyway that I can put the toolbar inside CExtControlBar?


Thx a lot.

Technical Support Apr 14, 2004 - 12:48 AM

Dear Chau,

The parent of any toolbar should be a CWnd-derived window. The control bar itself is a window; therefore it may contain any child items: any HWND-based windows such as toolbars, views, frames or any CWnd-derived controls.

You can create a toolbar as a child window of the CExtControlBar class, but the best way is to create a separate child window as it is done in the ProfStudio and GLViews samples.

Please take a look at the CProfStudioSolutionExplorer class in the ProfStudio sample. It is a CExtResizableDialog-derived child window. This dialog is inserted into a control bar and contains one toolbar (m_wndToolBar) which is always at the top of the dialog. The m_wndToolBar object is created in CProfStudioSolutionExplorer::OnInitDialog().
In the methods of the CProfStudioSolutionExplorer class you can also find the following line:

RepositionBars( 0, 0xFFFF, IDC_TREE_SE );

This line performs reposition of all the dialog child windows to dialog borders (In our case we have only one toolbar at the dialog top). IDC_TREE_SE is an identifier of the tree control that occupies the rest of the dialog.

So what you have to do is:

1) Create a child dialog inside your control bar
2) Create and initialize a toolbar in this dialog
3) Call CWnd::RepositionBars() twice: In CYourDlg::OnInitDialog() and in CYourDlg::OnSize()

Do not hesitate to contact us if you still have difficulties so that we can help you to code control bars that contain toolbars.

Chau Andy Apr 15, 2004 - 2:16 AM

Hello,thx for reply,but now,I have encounter a new problem.


///////////////////////////////////////////////


MainFrm.h


 CExtControlBar  m_wndSequenceListBar;
 CSequenceList  m_wndSequenceListChild;         // the class derived from CExtResizableDialog


///////////////////////////////////////////////


MainFrm.cpp


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)


{


...


 if( !m_wndSequenceListBar.Create( _T("Sequence List"), this, ID_VIEW_BAR_SL ) )
 {
  TRACE0("Failed to create ID_VIEW_BAR_SL\n");
  return -1;      // fail to create
 }
 if (!m_wndSequenceListChild.Create( CSequenceList::IDD,&m_wndSequenceListBar ) )
 {
  TRACE0("Failed to create SL\n");
  return -1;      // fail to create
 }


...


}


when the program run to


m_wndSequenceListChild.Create( CSequenceList::IDD,&m_wndSequenceListBar )


it seems it can’t create the dialog, and the program is fail to load.


is that I miss some important procedure?thx.

Technical Support Apr 15, 2004 - 8:30 AM

Dear Chau,

Your code is correct. There seems to be a problem in your CSequenceList class.
We think the problem is incorrect usage of MFC DDX mechanism when creating the toolbar.
In the previous message we wrote "2) Create and initialize a toolbar in this dialog".
Let’s view this point in detail. To add the toolbar into the dialog correctly please follow the next steps:

1. Open your dialog template in the resource editor;

2. Add a custom control to your dialog and specify the string "ProfUIS-ControlBar" as its window class, the valid control identifier (for instance IDC_MY_TOOLBAR), the value 0x50002034 as its window style, and the zero value as its extended style;

3. Add the CExtToolControlBar m_wndToolBar member variable to your dialog class header;

4. You should assign the toolbar resource to your m_wndToolBar variable: add the
DDX_Control(pDX, IDC_MY_TOOLBAR, m_wndToolBar) line
to the DoDataExchange() method body;

5. Now your toolbar is created but it is empty. You can load the toolbar from resources via the LoadToolbar method:
m_wndToolBar.LoadToolBar( IDR_TOOLBAR ).

If it does not solve the problem, send us your CSequenceList’s class source code (.H and .CPP) files or your test project and we will help you.