MFC框體新增選單欄工具欄狀態列

2021-06-19 03:39:45 字數 3428 閱讀 7448

cmenu封裝了選單控制代碼和相關選單

api

1.1新增資源

1.2在

cmainframe::oncreate

函式中新增選單;cmenu::attach——將選單控制代碼附加到選單物件中;cmenu::detach——將選單控制代碼從選單物件中分離

1.3 命令相關 on_command

1.4 選單項的狀態  on_update_command_ui    ccmdui類

工具欄相關類c*******ctrl

——父類是

cwnd

,封裝了

******* control

控制項的相關資訊,

api等。

c*******

——父類

ccontrolbar

,封裝了

*******

和cframewnd

之間的關係。

2.1建立工具欄   

c*******

::create/ex

2.2 載入工具欄

2.3工具欄的停靠   c*******::enabledocking設定工具欄允許停靠;

cframewnd::enabledocking

設定視窗允許被停靠;

cframewnd::dockcontrolbar

設定停靠位置。

2.4命令處理

2.5工具欄的顯示與隱藏  

cframewnd

::showcontrolbar

2.6資訊提示  增加風格 

cbrs_tooltips

;設定提示資訊。

狀態列相關類cstatusbarctrl

——父類是

cwnd

,封裝了

statusbars

的相關資訊,

api等。

cstatusbar

——父類

ccontrolbar

,封裝了狀態列和視窗之間的關係。

3.1建立狀態列  

cstatusbar::create/ex

3.2設定狀態列指示器 

cstatusbar::setindicators

3.3設定或獲取狀態列資訊

cstatusbar::setpanetext,cstatusbar::getpanetext

[cpp]view plain

copy

#include "stdafx.h" 

#include "resource.h"

uint

g_nindicators=  

;  class

cmainframe:

public

cframewnd  

;  begin_message_map(cmainframe,cframewnd)  

on_wm_create()  

on_command(id_open,onopen)  

on_command(id_exit,onexit)  

on_update_command_ui(id_open,onupdateuiopen)  

on_command(id_view_standard,onviewstandard)  

on_update_command_ui(id_view_standard,onupdateuistandard)  

on_wm_timer()  

on_wm_mousemove()  

end_message_map()  

intcmainframe::oncreate(lpcreatestruct lpcreatestruct)  

void

cmainframe::onopen()  

void

cmainframe::onexit()  

void

cmainframe::onupdateuiopen(ccmdui* pcmdui)  

void

cmainframe::onviewstandard()  

else

}  void

cmainframe::onupdateuistandard(ccmdui* pcmdui)  

void

cmainframe::ontimer(

uint

nidevent)  

void

cmainframe::onmousemove(

uint

nflags, cpoint point)  

class

mfcmenu:

public

;  bool

mfcmenu::initinstance()    

選單欄的一些資源

[cpp]view plain

copy

/ // bitmap 

idr_mainframe           bitmap                  "res\\*******1.bmp"

/ // ******* 

idr_mainframe ******* 16, 15  

begin  

button      id_open  

button      id_exit  

separator  

button      id_edit_copy  

button      id_edit_paste  

separator  

end  

/ // menu 

idr_mainframe menu  

begin  

popup "檔案(&f)"

begin  

menuitem "開啟(&o)"

,                      id_open  

menuitem "退出(&x)"

,                      id_exit  

end  

popup "檢視(&v)"

begin  

popup "工具欄(&t)"

begin  

menuitem "標準(&s)"

,                      id_view_standard  

end  

end  

end  

/stringtable  

begin  

ids_time                "                             "

end  

執行結果:

多文件 新增選單欄 工具欄 刪除ribbon

vs vs2010 工程型別 mfc 多文件 office office2007 1 去掉ribbon 在cmainframe oncreate中刪除 m wndribbonbar.create this delete by psq m wndribbonbar.loadfromresource i...

MFC選單欄及工具欄實現

mfc選單欄實現 在資源檢視中,右鍵工程名.rc 新增資源,選擇menu。對menu設定id,並對menu選單進行設定 即新增選單欄的名字 在c dlg.h中,新增cmenu m menu 在c dlg.c的初始化中,新增m menu.loadmenu idr menu1 idr menu1 set...

(12)選單欄 工具欄和狀態列

openaction new qaction qicon images doc open tr open.this openaction setshortcuts qkeysequence open openaction setstatustip tr open an existing file c...