Print Page | Close Window

How to get the CXTPToolBar Runtime class

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=6769
Printed Date: 23 November 2024 at 9:18am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to get the CXTPToolBar Runtime class
Posted By: Makarand
Subject: How to get the CXTPToolBar Runtime class
Date Posted: 30 March 2007 at 9:29am
Hi,
 
Please go through the following code. Code is written for the codejock version 4.2, I am trying to integrate it with 10.4.2.
 
The function "IsToolBarCreated" return the Menu bar ID (Menu which is closed by user using close button).
 
----------------------------------------------------------------------------------------------
int CMainFrame::IsToolBarCreated(const char * pszTitle)
{
   char cTitle[MAXSTRLENGTH];
   // Find a toolbar with the same caption as the caption passed in.
   int          nID = 0;
   CControlBar* pBar = NULL;
   BOOL         bNotFound = TRUE;
   CPtrList& list = m_listControlBars;
   POSITION pos = list.GetHeadPosition();
   while( pos != NULL )
   {
      pBar = (CControlBar*) list.GetNext(pos);
      //if(pBar->IsKindOf(RUNTIME_CLASS(SECCustomToolBar)))
      if(pBar->IsKindOf(RUNTIME_CLASS(CXTToolBar)))
      {
         pBar->GetWindowText(cTitle, sizeof(cTitle));
         if( lstrcmp(cTitle, pszTitle) == 0 )
         {
            // We found it.
            nID = pBar->GetDlgCtrlID();
            bNotFound = FALSE;
            break;
         }
      }
   }
   return nID;
}
----------------------------------------------------------------------------------------------
 
Please help me to get the runtime class of CXTPToolBar or Is there another way to display the closed toolbar?
 
Thank You,
Makarand.
 



Replies:
Posted By: Oleg
Date Posted: 02 April 2007 at 2:46am
Hi,
Toolbars never go to m_listControlBars collection. Use CXTPCommandBars::GetCount, CXTPCommandBars::GetAt to itterate them.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 03 April 2007 at 7:40am
Hi Oleg,
 
Thank you for the reply.
 
I am able to iterate the toolbar by using GetAt(). But I am not able to associate my toolbar with command bar.
 
I have created the the object of CXTPToolBar class and using the CreateToolBar(..) and LoadToolBar(IDR_WGDTLBAR), I am creating my toolbar.
 
Now, how can I associate my toolbar with the command bar?
 
If I creates the toolbar using pCommandBars->Add(..), it shows toolbar with complete background panel. By using CreateToolBar(..) It shows me only the toolbar button (no background panel bar).
 
Please help me for the same.
 
Thank You,
Makarand
 


Posted By: Oleg
Date Posted: 03 April 2007 at 7:54am
Hi,
If you use CXTPCommandBars, you have class ->Add and not CreateToolbar.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 03 April 2007 at 8:09am
Hi,
 
I want to create toolbar to the child window, in this case how can I use command bar from main window. By using CreateToolBar(..) I can able to see the toolbar but no backgroud panel bar.


Posted By: Oleg
Date Posted: 03 April 2007 at 8:39am
Hi,
 
For Child frame you need to create own CXTPCommandBars.
 
override your CChildFrame from CXTPFrameWndBase<CMDIChildWnd>
 
and use same
 
 if (!InitCommandBars())
  return -1;
 CXTPCommandBars* pCommandBars = GetCommandBars();
code
 
 
see Samples\DockingPane\MDIPanes


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 04 April 2007 at 2:05am
Hi Oleg,
 
Thank you very much for the reply.
 
I am able to set the Toolbar to child window. In codeJock 4.2 we are used CToolBarCtrl object to handle the toolbar for different reasons like HideButton, IsButtonChecked, GetItemRect etc...
 
---------------------------------------------------------------------------------------------
CToolBarCtrl *CTBC;
CTBC = &(m_wndChildTB.GetToolBarCtrl()); //m_wndChildTB OBJECT OF CXTToolBar
CTBC = &(m_wndCalTB1.GetToolBarCtrl());
CTBC->HideButton(IDMDTLFIRST, TRUE);
---------------------------------------------------------------------------------------------
 
In codejock 10.4.2 can we use CToolBarCtrl? or Is there any another way to handle the Toolbar?


Posted By: Oleg
Date Posted: 04 April 2007 at 5:12am

Hi,

 
Use method of CXTPControl/CXTPControls:
 
pToolBar->GetControl(i)->SetVisible(FALSE);
pToolBar->GetControl(i)->SetEnabled(TRUE);
etc.
 
 
but better use Update handlers.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 06 April 2007 at 2:10am
Hi Oleg,
 
Thanks,
 
I have used following code to set the property of the toolbar button's
 
----------------------------------------------------------------------------------------------
CXTPControlButton *btToolBar;
     btToolBar = (CXTPControlButton*)m_wndChildTB->GetControls()->FindControl(xtpControlButton, IDMDTLFIRST, TRUE, FALSE);
     btToolBar->SetVisible(FALSE);
----------------------------------------------------------------------------------------------
 
Please go through the following code. Code is used to set the control on the toolbar.
 
----------------------------------------------------------------------------------------------
nRtn = m_wndCalTB.SetButtons(NULL, sizeof(calbuttons1)/sizeof(UINT));
// Set up the combo box.
      m_wndCalTB.SetButtonInfo(0, IDCAL_COMBO,  
                               TBBS_SEPARATOR, CALCOMBOBOXWIDTH);
// Design guide advises a 12 pixel separator between combos and buttons
      m_wndCalTB.SetButtonInfo(1, ID_SEPARATOR,
                               TBBS_SEPARATOR, CALCOMBOBOXSEP);
// Set up the legend check button.
      m_wndCalTB.SetButtonInfo(2, IDMPVLEGEND, TBBS_CHECKBOX, 0);
      m_wndCalTB.SetButtonInfo(3, ID_SEPARATOR, TBBS_SEPARATOR, 8);
----------------------------------------------------------------------------------------------
 
Help me to set the control's(combo box, check box) on the toolbar.
 
Thank You,
Makarand


Posted By: Makarand
Date Posted: 09 April 2007 at 2:35am
Hi Oleg,
 
How can I get the Toolbar Window Rect (CRect) ?
 
Waiting for the reply....
 
Thank You,
Makarand
 


Posted By: Oleg
Date Posted: 09 April 2007 at 6:07am
HI,
 
as any other window:
pToolBar->GetWindowRect(&rc);


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 09 April 2007 at 7:37am
Hi Oleg,
 
Please go through the following code. Code is used to set the control on the toolbar on codejock 4.2.
 
----------------------------------------------------------------------------------------------
nRtn = m_wndCalTB.SetButtons(NULL, sizeof(calbuttons1)/sizeof(UINT));
// Set up the combo box.
      m_wndCalTB.SetButtonInfo(0, IDCAL_COMBO,  
                               TBBS_SEPARATOR, CALCOMBOBOXWIDTH);
// Design guide advises a 12 pixel separator between combos and buttons
      m_wndCalTB.SetButtonInfo(1, ID_SEPARATOR,
                               TBBS_SEPARATOR, CALCOMBOBOXSEP);
// Set up the legend check button.
      m_wndCalTB.SetButtonInfo(2, IDMPVLEGEND, TBBS_CHECKBOX, 0);
      m_wndCalTB.SetButtonInfo(3, ID_SEPARATOR, TBBS_SEPARATOR, 8);
----------------------------------------------------------------------------------------------
 
Help me to set the control's(combo box, check box) on the toolbar.
Also
How can I get the toolbar button count (button or separator )with the help of CXTPToolBar?
 
Thank You,
Makarand


Posted By: Oleg
Date Posted: 10 April 2007 at 12:08am

Hello,

Please look through  our samples first and check method of CXTPControls in SymbolReference.chm. Samples have a lot of toolbars with comboboxes, checkboxes, split buttons etc.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 10 April 2007 at 8:59am
Hi,
 
In codejock 10.4.2 toolbar implementetion how can I add the CXTButton?


Posted By: Oleg
Date Posted: 10 April 2007 at 2:51pm
Hi,
to add simple button control (not CXTButton) call
 
pToolbar->GetControls()->Add(xtpControlButtin, ID);


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 12 April 2007 at 1:55am

Hi Oleg,

What is the replacement function for the CheckButton(ID, FALSE); and CTBC->IsButtonChecked(ID); ?


Posted By: Oleg
Date Posted: 12 April 2007 at 9:10am
Hi,
Please check CXTPControl and CXTPControls methods in SymboReference.chm and our samples. There are _a lot_ of demonstations how to check/uncheck buttons.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 16 April 2007 at 5:47am

Hi Oleg,

I don't want to allow use to move toolbar window,
How do I set the fix style to the toolbar?
 


Posted By: Oleg
Date Posted: 16 April 2007 at 1:21pm
Hi,
 
Call EnableDocking(0);


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 17 April 2007 at 5:56am
Hi Oleg,
 
Thank You very much.
Now I am able to set the toolbar.
 
I have one grid view child window which is not derive from CXTPFrameWndBase<CMDIChildWnd>. I want to add the toolbar to this window.
Codejock 4.2 tolbar implementation is as follow
----------------------------------------------------------------------------------------------
m_GridToolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED,
                        IDR_GRIDTOOLBAR);
----------------------------------------------------------------------------------------------
I tried following replacement code
----------------------------------------------------------------------------------------------
if (!InitCommandBars())
        return -1;
 pCommandBars = GetCommandBars();
 
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }
 // Create ToolBar
    m_GridToolbar = (CCmcStyleBar *) pCommandBars->Add(_T("Toolbar"), xtpBarTop);
 if ( m_wndChildTB->LoadToolBar(IDR_GRIDTOOLBAR))
 {
        TRACE0("Failed to create toolbar\n");
  return -1;      // fail to create
 }
----------------------------------------------------------------------------------------------
 
But this child window class not derive from CXTPFrameWndBase<CMDIChildWnd>.
How can I set the toolbar to this child window?
 
Thank You,
Makarand.
 
 


Posted By: Makarand
Date Posted: 19 April 2007 at 2:13am
Hi Oleg,
 
I have one grid view child window which is not derive from CXTPFrameWndBase<CMDIChildWnd>. I want to add the toolbar to this window.
 
How can I set the toolbar to this child window?
 
Thank You,
Makarand.


Posted By: Makarand
Date Posted: 24 April 2007 at 1:37am
Hi Oleg,
 
 
I have one grid view child window which is not derive from CXTPFrameWndBase<CMDIChildWnd>. I want to add the toolbar to this window.
Codejock 4.2 tolbar implementation is as follow
----------------------------------------------------------------------------------------------
m_GridToolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED,
                        IDR_GRIDTOOLBAR);
----------------------------------------------------------------------------------------------
I tried following replacement code
----------------------------------------------------------------------------------------------
if (!InitCommandBars())
        return -1;
 pCommandBars = GetCommandBars();
 
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }
 // Create ToolBar
    m_GridToolbar = (CCmcStyleBar *) pCommandBars->Add(_T("Toolbar"), xtpBarTop);
 if ( m_wndChildTB->LoadToolBar(IDR_GRIDTOOLBAR))
 {
        TRACE0("Failed to create toolbar\n");
  return -1;      // fail to create
 }
----------------------------------------------------------------------------------------------
 
But this child window class not derive from CXTPFrameWndBase<CMDIChildWnd>.
How can I set the toolbar to this child window?
 
Thank You,
Makarand.


Posted By: Oleg
Date Posted: 24 April 2007 at 7:18am
Hi,
 
Check \Samples\UserInterface\GUI_VisualStudio  sample.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 03 May 2007 at 1:15am
Hi Oleg,
 
I want to add the separator on toolbar. I have used following code to set the separator.
------------------------------------------------------------------------------------------
m_wndCalTB.GetControls()->Add(xtpControlButton, ID_SEPARATOR);
------------------------------------------------------------------------------------------
Above code shows me the normal toolbar button.
How do I add the separator on toolbar?
 
Thank You,
Makarand.


Posted By: Makarand
Date Posted: 02 August 2007 at 2:16am
Hi Oleq,

How do I set the CXTFlatComboBox on Toolbar in CodeJock10.4.2 ?


Posted By: Oleg
Date Posted: 02 August 2007 at 6:13am
Hello,
use CXTPControlComboBox instead.
 
toolbar.GetControls()->Add(new CXTPControlComboBox (), ...);


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 02 August 2007 at 7:46am
Hi Oleq,

I have created Toolbar on client window by using CreateToolBar(..) method. I put some control and button on the toolbar

-->
//Control (Combo)
m_wndToolBar.GetControls()->Add(xtpControlComboBox, IDCAL_COMBO)
//Toolbar button
m_wndCalTB.GetControls()->Add(xtpControlButton, IDMPVLEGEND);
<--

By using LoadToolBar(..)  we can set the toolbar with icons, but in CreateToolBar(..) How we can set the icon on the button?

Please help me for the same.

Thanks in advance.
Waiting for the reply....






Posted By: Makarand
Date Posted: 02 August 2007 at 9:23am
Hi Oleq,

As per your suggestion I had made the change in my code.

I replace the CXTFlatComboBox to CXTPControlComboBox and I am able to display the combo control on the toolbar.

Out previous implementation is deferent as we have a structure with having member variable "HWND  hComboBox;" which need to intialise with combo control "m_hWnd".

CXTPControlComboBox class is not derive from mfc class (CWnd), so we can't get the m_hWnd from the CXTPControlComboBox?

Which is the way where we can get the m_hWnd as we can't change our structure?


Posted By: Makarand
Date Posted: 08 August 2007 at 5:31am
Hi Oleq,

Please help to solve above problem.
I tried both method to put combo on toolbar, CXTFlatComboBox and CXTPControlComboBox.

In CXTPControlComboBox : Not able to get the m_hWnd.
In CXTFlatComboBox : Using m_combobox.Create(..) method, I can able to create combo but combo box getting placed on toolbar which already contains buttons.

Thanks in advance.
Waiting for the reply....



Posted By: Oleg
Date Posted: 08 August 2007 at 9:02am
See CXTPControlComboBox methods in SymbolReference.
 
You need pCombo->GetEditCtrl()->GetSafeHwnd();


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 08 August 2007 at 9:57am
Hi Oleq,

Thanks for the reply.
My combo box is not editable, I am not getting GetEditCtrl()->GetSafeHwnd();
In this case what is the way to get m_hWnd

Waiting for the reply....



Posted By: Oleg
Date Posted: 09 August 2007 at 1:45am
Hello,
 
not editable combobox doesn't have any handle. It draws directly to commanbar.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 10 August 2007 at 6:45am
Hi Oleg,

I have design the toolbar with com box control using GetControls()->Add(..) method.

How can I create the separator as there is not separator XTPControlType.
How do I get the rect position of toolbar and specific control or toolbar button?
How can I add the CXTButton on toolbar?

Please help me....
Waiting for the reply....


Posted By: Oleg
Date Posted: 10 August 2007 at 8:56am
Hello,
 
1,2. See CXTPControl members in SymbolReference.
3. see Samples\CommandBars\CommandBarControls  sample.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 14 August 2007 at 7:24am
Hi Oleg,

How can I get the Crect value of the Toolbar button.
My current implementation is as follow
-->
//Creating Toolbar
VERIFY(m_wndCalTB.CreateToolBar(WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED, this));
//Setting Button
if(!m_wndCalTB.SetButtons(calbuttons1,sizeof(calbuttons1)/sizeof(UINT))){
          TRACE0("Failed to SetButtons\n");
          nRtn = 0 ;      }
//Setting control on the toolbar
CXTPControl *ctrl;
CXTPControlComboBox *btComboBox;     
ctrl = (CXTPControlButton*)m_wndCalTB.GetControls()->FindControl(xtpControlButton, IDCAL_COMBO, TRUE, FALSE);
m_wndCalTB.GetControls()->SetControlType(ctrl, xtpControlComboBox);
btComboBox = (CXTPControlComboBox*)m_wndCalTB.GetControls()->FindControl(xtpControlComboBox, IDCAL_COMBO, TRUE, FALSE);   
btComboBox->SetWidth(nComboBoxWidth+30);

//Problem to get the rect of the toolbar button.
Crect rect;
rect = wndCalTB.GetControl(2)->GetRect();
//rect gives the all value  = 0

Please help me to get the rect position of the control/button.
Thanks in advance.



Posted By: Oleg
Date Posted: 14 August 2007 at 10:22am
Hello,
 
Yes wndCalTB.GetControl(2)->GetRect(); have return rect. Think toolbar is not moved to right position when you call it. Call RepositionBars to be sure it has right position.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 16 August 2007 at 3:24am
Hi Oleg,

I tryed function RepositionBars to get the Rect of the tollbar control.
My code smiler like the example from CodeJock
SAMPLES\DockingPane\MDIPanes\
Implemented same code for toolbar design which is in file
ChildFrm.cpp
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

In OnCreate(..) function I add my code to get the rect value of ID ID_TOOLS_PROPERTIES

CRect rect;
rect = pControl->GetRect();

Not able to retrieve the rect value.... :(

My child window is derive from CXTPFrameWndBase<CMDIChildWnd>

Please Help me ....
Waiting for the reply....




Posted By: Oleg
Date Posted: 17 August 2007 at 8:52am
Hello,
 
Send CChildFrm.cpp/h to mailto:support@codejock.com - support@codejock.com .


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Makarand
Date Posted: 22 August 2007 at 8:14am
Hi Oleg,

What are the replacement function for GetButtonInfo(..) and SetButtonInfo(..) for toolbar buttons?


Posted By: Oleg
Date Posted: 22 August 2007 at 8:27am

Hello,

What  code you need replace?


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net