简体   繁体   中英

Creating a popup CMenu without a checkbox

I am creating a CMenu in Visual Studio 2010, MFC. I have a working CMenu that appears when a user right-clicks on a dialog. I can't seem to find a way to create menu selection without a spot for a checkbox. In Visual Studio's designer, my menu looks like this:

复选框

在此处输入图片说明

I wish to remove the area for a checkmark. In my application, my menu looks like this:

在此处输入图片说明

Is there a way to remove this small box, left of "Change Option"?

Update: Not sure this will help, but this is my code to create the CMenu:

CMenu menu;
VERIFY(menu.LoadMenu(IDR_MENU1));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
while (pWndPopupOwner->GetStyle() & WS_CHILD)
            pWndPopupOwner = pWndPopupOwner->GetParent();
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, screenPoint.x, screenPoint.y,
            pWndPopupOwner);

You will have to use an owner-draw menu for this. Popup menus always (by default) have space allocated for checkmark bitmaps. Going owner-draw will allow you to use CMenu::MeasureItem() and CMenu::DrawItem() to customize the size and drawing behavior of the menu object to your needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM