Change the default open mode of MDI in MFC (id_file_open)

Source: Internet
Author: User

In the cxxxapp: onfileopen () method of the app class, do not call cwinapp: onfileopen. Instead, call your own file selection box to obtain the file path and then call cwinapp: opendocumentfile to open the file.

As follows:



Void cmyprjeditdemoapp: onfileopen ()

{

// Todo: add your command handler code here

// The following is the self-added file opening dialog box
Cfiledialog DLG (true );

Int structsize = 0;

DWORD dwversion, dwwindowsmajorversion, dwwindowsminorversion;

Dwversion = getversion ();

Dwwindowsmajorversion = (DWORD) (lobyte (loword (dwversion )));

Dwwindowsminorversion = (DWORD) (hibyte (loword (dwversion )));

If (dwversion <0x80000000)

Structsize = 88;

Else

Structsize = 76;



//

Gisenv * Env = _ getenv ();



DLG. m_ofn.lpstrinitialdir = env-> cur;

DLG. m_ofn.lstructsize = structsize;

DLG. m_ofn.lpstrfilter = "project file (*. MPJ) \ 0 *. MPJ \ 0 all files (*. *) \ 0 *. * \ 0 \ 0 ";

If (idok = DLG. domodal ())

{

Cstring Path = DLG. getpathname ();

// Call cwinapp: opendocumentfile () to pass the path

Cwinapp: opendocumentfile (path. getbuffer (path. getlength ()));

}

 

}

Post: http://wwboss.blog.sohu.com/88957540.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.