Print Page | Close Window

CXTPStatusBar

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=11441
Printed Date: 05 June 2024 at 10:56pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPStatusBar
Posted By: Surbhi
Subject: CXTPStatusBar
Date Posted: 15 July 2008 at 12:44am
Hi,
I want to create a button on status Bar, and add functionality to it in a Dialog Application.
Please can you guide me proper steps for it.
Thanking in anticipation,
Regards,
Surbhi Mehta



Replies:
Posted By: Oleg
Date Posted: 15 July 2008 at 9:23am
Hi,
 
Just add simple pane and call pPane->SetButton(TRUE);


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


Posted By: Surbhi
Date Posted: 15 July 2008 at 11:20pm
Dear Sir,
Thanks a lot for the input. But even trying out your solution is causing the Dialog  Application to crash. I have created a a function CreateStatusBar() and calling it in OnInitDialog(). Sir Could you please provide me with more inputs if possible. I will be very grateful to you.
Thanking you in anticipation,

Best Regards,
Surbhi Mehta
Software Developer.


Posted By: Oleg
Date Posted: 16 July 2008 at 1:09am
Hi,
Attach what you have with crush. I will show how to fix it.


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


Posted By: Surbhi
Date Posted: 16 July 2008 at 1:54am
Dear Sir,
Thanks for the input. Here is the code
//Declaration
        CXTPStatusBar m_wndStatusBar;
        CXTPStatusBarPane* pPane;

//Implementation
BOOL CDialogSampleDlg::CreateStatusBar()
{
    if (!m_wndStatusBar.Create(this))
    {
        TRACE0("Failed to create status bar\n");
        return FALSE;      // fail to create
    }

    pPane = m_wndStatusBar.AddIndicator(0);
    pPane->SetWidth(100);
    pPane->SetStyle(SBPS_STRETCH | SBPS_NOBORDERS);
    pPane->SetBeginGroup(TRUE);
     
    pPane = m_wndStatusBar.AddIndicator(IDC_BTN_FIRST_STATUS,1);
    pPane->SetText(_T("First"));
    pPane->SetButton(TRUE);
    pPane->SetPadding(50, 0, 50, 0);
    pPane->SetWidth(pPane->GetBestFit());

    return TRUE;
}

//Calling
BOOL CDialogSampleDlg::OnInitDialog()
{
    CDialog::OnInitDialog();


    if (!CreateStatusBar())
        return -1;

    if (!InitCommandBars())
        return -1;
   
    CXTPCommandBars* pCommandBars = GetCommandBars();
    m_wndStatusBar.SetCommandBars(pCommandBars);

return TRUE;
}

Sir  on the  click of  button  it  crashes  ,  Even though I had handled
its  event 

ON_COMMAND(IDC_BTN_FIRST_STATUS, OnBtnFirst)

In OnBtnFirst I had implemented A MessageBox only.
Sir could  you  please guide me about change of Class or anything.
Thanking you in anticipation,
Best Regards,
Surbhi Mehta
Software Developer


Posted By: Oleg
Date Posted: 16 July 2008 at 5:50am

Hi,

 
Not sure why you have CXTPStatusBarPane* pPane in class declaration but think it can be reason.
 
declare it in method:
 
 CXTPStatusBarPane* pPane= m_wndStatusBar.AddIndicator(0);



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


Posted By: Surbhi
Date Posted: 16 July 2008 at 7:10am
Dear Sir,
Thanks alot for the input.I implemented your suggestion. But still the crash is persistent. Sir could you  please  send  me  a  Dialog Based  Sample which has a status bar with a button and its event is handled. I am sure it would be of great help to me.
Thanking you in anticipation,
Surbhi  Mehta
Software Developer.
uploads/20080716_081933_mydialog.zip - uploads/20080716_081933_mydialog.zip


Posted By: Oleg
Date Posted: 16 July 2008 at 1:23pm
Hello,
 
Now you're right :( Buttons in statusbar assumes statusbar located in Frame.
 
Please add small derived class
 

class CMyStatusBar : public CXTPStatusBar

{

void OnPaneClick(CXTPStatusBarPane* pPane)

{

GetParent()->SendMessage(WM_COMMAND, pPane->GetID());

}

};

 

and replace

CXTPStatusBar m_wndStatusBar;

to

CMyStatusBar m_wndStatusBar;

it will be fixed in next release


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


Posted By: Surbhi
Date Posted: 18 July 2008 at 2:01am
Dear Sir,
Thanks a lot for the input. My problem is solved I am very grateful to you.
Best Regards,
Surbhi Mehta



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