0
点赞
收藏
分享

微信扫一扫

用VC 6.0写flash播放器——2、为作为主窗口的对话框添加状态栏


purpleendurer

2005.11.15 第2

在成功实现对“打开文件”对话框的调用后,现在我们要为作为主窗口的对话框添加状态栏,并把状态栏分为三部分,第一部分显示当前播放的flash文件的文件说明符(盘符:/path/filename.swf),第二部分显示当前显示的是第几帧,第二部分显示当前播放的flash文件的总帧数。

用MFC来实现为作为主窗口的对话框添加状态栏实在是累。(可参考:​​StatusBar on Dialogs-为作为主窗口的对话框添加状态栏的一种方法​​)

还是调用API函数CreateStatusWindow()创建来得快。

实现方法如下:

1。在CSwfPlayerDlg类定义中 加入状态栏变量的声明

class CSwfPlayerDlg : public CDialog
{
.....protected:
HICON m_hIcon;
HWND m_hStatusWindow; //加入状态栏变量的声明
.....
};

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
}

举报

相关推荐

0 条评论