Custom resources - MFC

Add or remove tool buttons and menus; Add dialog boxes;

2025-11-20

Written by: xiaobin

Remove “New” from the menu.

tool button

Remove the print and new button from the toolbar;

The effect after dragging

Note:
必须保证图标是一个挨一个的排列。

rc(part)

使用Notepad++, 修改*.rc

/////////////////////////////////////////////////////////////////////////////
//
// Toolbar
//

IDR_MAINFRAME TOOLBAR 16, 15
BEGIN
    BUTTON      ID_FILE_OPEN
    BUTTON      ID_FILE_SAVE
    BUTTON      ID_EDIT_CUT
    BUTTON      ID_EDIT_COPY
    BUTTON      ID_EDIT_PASTE
    SEPARATOR
    BUTTON      ID_APP_ABOUT
END

保存后,Visual Studio 会弹出对话框:

This file has been modified outside of Microsoft Visual Studio. 
Do you want to reload it?

点击”yes”.

再次打开Toolbar下的IDR_MAINFRAME 会弹出对话框:

The bitmap for this toolbar must be adjusted to use this size.
Adjust the bitmap to fit?

点击”OK”.

最后,

File -> Save<ProjectName>.rc, 

保存图片。

dialog

In the dialog:

Add Resource -> 

Port Configuration

Right-click the dialog box, Add MFC Class:

Breaking changes

nullptr

In VC++ (VS2005~VS2010) that does not support the C++11 standard:

CConfigDlg(CWnd* pParent = nullptr);

Ref