|
-
December 2nd, 2003, 01:33 PM
#1
Problem with status pane
I'm trying to use the status pane to display some text.
Here's the code I have in mainfrm.h:
Code:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "HotView.h"
#include "HotViewView.h"
#include "Dlgbar.h"
#include "MainFrm.h"
#include "mapi.h"
#include "cmapi.h"
#include "family.h"
#include <SypODLAll.h>
#include <afxdtctl.h>
#include <sypodlall.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifndef WS_EX_LAYERED
#define WS_EX_LAYERED 0x00080000
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_CLOSE()
ON_WM_ACTIVATE()
ON_WM_KILLFOCUS()
//}}AFX_MSG_MAP
ON_NOTIFY(DTN_CLOSEUP, IDC_DATETIMEPICKER1, OnCloseupDatetimepicker1)
ON_BN_CLICKED(IDC_BUTTONSEND, OnButtonsend)
ON_COMMAND(IDR_UPDATESTATUSBAR, OnRemoteUpdateStatusBarCommand)
ON_UPDATE_COMMAND_UI(ID_INDICATOR_TEXT, OnUpdateText)
ON_MENUXP_MESSAGES()
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_INDICATOR_TEXT,
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndDlgBar.Create(this, IDR_MAINFRAME, CBRS_ALIGN_TOP, IDR_MAINFRAME))
{
TRACE0("Failed to create dialogbar\n");
return -1; // fail to create
}
if (!m_wndReBar.Create(this) ||
!m_wndReBar.AddBar(&m_wndToolBar) ||
!m_wndReBar.AddBar(&m_wndDlgBar))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndStatusBar.SetPaneStyle(0,SBPS_STRETCH);
m_wndStatusBar.SetWindowText("Test");
// TODO: Remove this if you don't want tool tips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
m_wndStatusBar.SetWindowText("test");
m_wndStatusBar.UpdateWindow();
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style &= ~FWS_ADDTOTITLE; // remove document title stuff
return CMDIFrameWnd::PreCreateWindow(cs);
}
void CMainFrame::OnUpdateFrameMenu (HMENU hMenuAlt)
{
CMDIFrameWnd::OnUpdateFrameMenu (hMenuAlt);
CMenuXP::UpdateMenuBar (this);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
void CMainFrame::OnRemoteUpdateStatusBarCommand(const CString strMsg)
{
m_wndStatusBar.SetWindowText(strMsg);
m_wndStatusBar.UpdateWindow();
}
void CMainFrame::OnUpdateText(CCmdUI *pCmdUI)
{
pCmdUI->Enable();
}
ID_INDICATOR_TEXT is defined in the string table, and has a default text string of "TXT".
As the main window loads, I see "TXT" displayed in the left pane, but it disappears and I can't write anything to it!
Also, should the left-most pane have an index of 0?
-
December 2nd, 2003, 02:02 PM
#2
You can't set a status bar's text with SetWinodwText. You need to use SetPaneText...
bytz
--This signature left intentionally blank--
-
December 2nd, 2003, 02:35 PM
#3
mmm, according to msdn you can
it will set the text for pane #0.
But I tried the other method as well, no difference.....
-
December 3rd, 2003, 10:20 AM
#4
Try changing the ID ID_INDICATOR_TEXT to a different ID, i.e. Add a string to the string table like ID_IND_FOO and give it a string that is as large as the largest string you'll put on the status bar; use this id in the indicators array and in your code elsewhere.
ID_INDICATOR_TEXT and the other ID's are predefined and are used by the framework in updating the status bar (the framework checks the state of the current doc - "Is it text?", and the states of the numlock and other keys and updates those statusbar enties as needed.)
bytz
--This signature left intentionally blank--
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|