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 Tech Support » Question CExtContorlBar Collapse All
Subject Author Date
tera t Jul 17, 2008 - 2:56 AM

Hello.


I make CExtContorlBar dynamically.

Is there any problem?




void CTabMultiDlg::OnButton16()

{

 static int iStCnt = -1;

 iStCnt++;


    CMainFrame * pCMainFrame;

    pCMainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;


 CMuControlBar *pDynBar;

    pDynBar = &pCMainFrame->m_wndDynBar[iStCnt];


 UINT uID;

 uID = 5051 + iStCnt;


    if( ! pDynBar->Create(

            _T("Optional control bar caption"),

            pCMainFrame ,

            uID ,

            WS_CHILD

            |WS_VISIBLE

            |CBRS_TOP

            |CBRS_GRIPPER

            |CBRS_FLYBY

            |CBRS_SIZE_DYNAMIC

            |CBRS_HIDE_INPLACE

            )

        )

    {

        return ;

    }


 pDynBar->EnableDocking( CBRS_ALIGN_ANY );

    pDynBar->ShowFloat(

  CPoint( 100 + iStCnt*3 , 100),

  CSize ( 100            , 100)

 );


}




BOOL CMainFrame::DestroyWindow()

{

 //---------------------------

 int iRec = 0;

 while(1){

  if ( m_wndDynBar[iRec].m_hWnd != NULL ){

   //m_wndDynBar[iRec].HideBar();

   m_wndDynBar[iRec].DestroyWindow( );

  }

  iRec++;

  if ( iRec > 90 ){

   break;

  }

 }


 CWinApp * pApp = ::AfxGetApp();


 

Technical Support Jul 17, 2008 - 1:34 PM

This code will not work. Both MFC and Prof-UIS control bars require special destroying actions because internal data of MFC frame windows contains references to control bars created inside frame window. Please find the source code of the KillBar() function by searching the KillBar text in this forum. This function performs correct de-allocation of control bar.

There is one more problem may appear: the state loading algorithms of both MFC and Prof-UIS control bars require exact matching between control bars created inside frame window and control bar state data.

But there are two very good approaches implemented in Prof-UIS for projects which require dynamically allocated control bars:

1) In case of toolbars: you can use customizable toolbars and menu controlled by the CExtCustomizeSite class and demonstrated in DRAWCLI and StyleEditor sample applications. The customize site implements subsystem which allows to allocate, de-allocate, load and save dynamic toolbars and commands both in toolbars and menus. The very extended version of customize site is implemented in the ProfAuto library and demonstrated in ActiveScripts and SimpleScripts sample applications. The ProfAuto library implements set of wrapper COM objects which also allow to work with dynamically allocated toolbars and commands. These COM object can be used for providing automation based languages (VB Script, Java Script, VB, VBA, VB .NET, C#) with ability to access toolbars, menus and commands implemented in your Prof-UIS/ProfAuto based project. This feature is supported in Word, Excel and many other modern applications.

2) In case of resizeable control bars: you can use dynamic resizable control bars (CExtDynamicControlBar) controlled by dynamic bar site (CExtDynamicBarSite) instead of simple resizable control bars (CExtControlBar). Dynamic resizable control bars have several additional features: full support for dynamic count of control bars, support for document and persistently floating modes, Window Options menu in control bar’s caption. They demonstrated in the SDI_DynamicBars and MDI_DynamicBars sample applications.

tera t Jul 18, 2008 - 3:19 AM

Hello.


Thank you very much.