简体   繁体   中英

MFC trigger ID_FILE_OPEN command

I have a standard SDI app in MFC and I would like to trigger the standard File->Open for opening a document from a user button.

How can I do this?

You'll need to design your button handler code to create an instance of the CFileDialog class. Make sure to set the appropriate flags when you construct the object. Then call its DoModal method. If you need more control, you can derive your own class from CFileDialog. You should be able to search and find plenty of examples.

如果只想调用预定义的File-> Open操作,请发布以下消息:

AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_OPEN, 0);

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