用MFC来实现为作为主窗口的对话框添加状态栏实在是累。(可参考:StatusBar on Dialogs-为作为主窗口的对话框添加状态栏的一种方法)
还是调用API函数CreateStatusWindow()创建来得快。
实现方法如下:
1。在CSwfPlayerDlg类定义中 加入状态栏变量的声明 :
class CSwfPlayerDlg : public CDialog
{
// Construction
public:
CSwfPlayerDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CSwfPlayerDlg)
enum { IDD = IDD_SWFPLAYER_DIALOG };
CShockwaveFlash m_SwfBox;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSwfPlayerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
HWND m_hStatusWindow; //加入状态栏变量的声明
// Generated message map functions
//{{AFX_MSG(CSwfPlayerDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnbtnOpen();
afx_msg void OnbtnPlay();
afx_msg void OnbtnForward();
afx_msg void OnbtnBack();
afx_msg void OnbtnFastBack();
afx_msg void OnbtnFastForward();
afx_msg void OnbtnStop();
afx_msg void OnbtnStopPlay();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
2。在对话框的OnInitDialog()中调用API函数创建状态栏
BOOL CSwfPlayerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
//调用API函数创建状态栏
m_hStatusWindow = CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_BORDER, //风格
NULL, //显示在状态栏上的信息
GetSafeHwnd(), //父窗口句柄
100); //的资源ID
UINT indicators[] = {240, 330, 420, -1}; //设定间隔
::SendMessage(m_hStatusWindow, SB_SETPARTS, sizeof(indicators) / sizeof(UINT), (LPARAM)indicators);
::SendMessage(m_hStatusWindow, SB_SETTEXT, 0, (LPARAM)TEXT("作者:Purple Endurer"));
::SendMessage(m_hStatusWindow, SB_SETTEXT, 1, (LPARAM)TEXT("当前为第 帧"));
::SendMessage(m_hStatusWindow, SB_SETTEXT, 2, (LPARAM)TEXT("共有 帧"));
return TRUE; // return TRUE unless you set the focus to a control
}