| |

VerySource

 Forgot password?
 Register
Search
View: 1847|Reply: 10

How to remove the automatically generated menu?

[Copy link]

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-15 23:30:01
| Show all posts |Read mode
I built a single-document program, but I don't want toolbars and menus. How do I remove the default menu generated by the wizard?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-18 18:00:01
| Show all posts
Should be deleted from the resource
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-19 08:30:01
| Show all posts
Use dialog
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-20 11:45:01
| Show all posts
I need to use a single document frame, to have frame windows, views, documents, these things, so I can not use Dialog
Reply

Use magic Report

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 Japan

Post time: 2020-4-20 13:45:01
| Show all posts
SetMenu (NULL)
Reply

Use magic Report

0

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-4-20 14:00:01
| Show all posts
toolbar is unnecessary when you build a project.
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-21 00:15:01
| Show all posts
SetMenu (NULL) is possible, but the menu generated by the wizard is completely useless
Can you delete the useless menu in the project from the resource?
I made a mistake after deleting it.
Reply

Use magic Report

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-4-21 19:00:03
| Show all posts
Overload the CFrameWnd :: Create virtual function, and handle it by yourself. The following is the source code of MFC. I have not changed it. I believe you will handle it yourself.
BOOL CFrameWnd :: Create (LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
const RECT&rect,
CWnd * pParentWnd,
LPCTSTR lpszMenuName,
DWORD dwExStyle,
CCreateContext * pContext)
{
HMENU hMenu = NULL;
if (lpszMenuName! = NULL)
{
// load in a menu that will get destroyed when window gets destroyed
HINSTANCE hInst = AfxFindResourceHandle (lpszMenuName, RT_MENU);
if ((hMenu = :: LoadMenu (hInst, lpszMenuName)) == NULL)
{
TRACE (traceAppMsg, 0, "Warning: failed to load menu for CFrameWnd.\n");
PostNcDestroy (); // perhaps delete the C ++ object
return FALSE;
}
}

m_strTitle = lpszWindowName; // save title for later

if (! CreateEx (dwExStyle, lpszClassName, lpszWindowName, dwStyle,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
pParentWnd-> GetSafeHwnd (), hMenu, (LPVOID) pContext))
{
TRACE (traceAppMsg, 0, "Warning: failed to create CFrameWnd.\n");
if (hMenu! = NULL)
DestroyMenu (hMenu);
return FALSE;
}

return TRUE;
}
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-21 20:45:01
| Show all posts
After studying it myself, you can change it in PreCreateWindow of CMainFrame
cs.hMenu = NULL;
You can not display the menu, but after deleting the useless menu, the running program will pop up
The "Failed to create empty document" dialog box, and then the program is directly launched, how to solve this problem?
Reply

Use magic Report

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-4-22 16:15:01
| Show all posts
Is your program executed to PostNcDestroy (); // Maybe delete the C ++ line to exit, it is recommended that you rewrite the Create function
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list