toolbars什么意思_Toolbars工具栏

1、工具栏

工具栏的BUTTON分为Pushbutton和 Check Box Button两种。Pushbutton是像“新建”、“打开”那种,而Check Box Button是按下去不弹起的那种,例如迅雷中的“下载完毕关键”按钮。

虽然有很多按钮,但工具栏只有一个BMP资源。用记事本打开.rc文件,可以看到以下定义:

/

//

// Bitmap

//

IDR_MAINFRAME           BITMAP  MOVEABLE PURE   "res\\Toolbar.bmp"

/

//

// Toolbar

//

IDR_MAINFRAME TOOLBAR DISCARDABLE  16, 15

BEGIN

BUTTON      ID_FILE_NEW

BUTTON      ID_FILE_OPEN

BUTTON      ID_FILE_SAVE

SEPARATOR

BUTTON      ID_EDIT_CUT

BUTTON      ID_EDIT_COPY

BUTTON      ID_EDIT_PASTE

SEPARATOR

BUTTON      ID_FILE_PRINT

SEPARATOR

BUTTON      ID_APP_ABOUT

BUTTON      ID_BUTTON32779

BUTTON      ID_BUTTON32780

BUTTON      ID_BUTTON32781

BUTTON      ID_BUTTON32782

END

从中可以看出,一个按钮对应一个菜单ID。如果BMP上的按钮数量超过上面BUTTON的个数,那么多余的按钮将不被显示。如果某个BUTTON没有对应一个菜单ID,那最好对应一个快捷键。

Toolbar Update Command UI Message Handlers

函数CmdUI::Enable(false)控制可按不可按。false--不可按;true---可按。

函数CmdUI::SetCheck(0)控制按下或弹起。0--弹起;1--按下。

Locating the Main Frame Window

If you want your view class to work in both SDI and MDI applications, you must find the main frame window through the application object. The AfxGetApp global function returns a pointer to the application object. You can use that pointer to get the CWinApp data member m_pMainWnd. In an MDI application, AppWizard generates code that sets m_pMainWnd, but in an SDI application, the framework sets m_pMainWnd during the view creation process. Once m_pMainWnd is set, you can use it in a view class to get the frame's toolbar with statements such as this:

CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;CToolBar* pToolBar = &pFrame->m_wndToolBar;You'll need to cast m_pMainWnd from CFrameWnd* to CMainFrame*

because m_wndToolBar is a member of that derived class. You'll

also have to make m_wndToolBar public or make your class a friend

of CMainFrame.

You can use similar logic to locate menu objects, status bar objects,

and dialog objects.

In an SDI application, the value of m_pMainWnd is not set when the

view's OnCreate message handler is called. If you need to access the

main frame window in your OnCreate function, you must use the

GetParentFrame function.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值