Open the file dialog box getopenfilename Win32, PPC, and smartphone

Source: Internet
Author: User

Some days ago, someone asked me how to open the open file dialog box on mobile. in C #, we know that there is an openfiledialog, which is quite convenient, if you want to do the same in the native API of wince, The getopenfilename interface is used here (the same parameter as getsavefilename will not be mentioned ). For specific usage, see the implementation here:

 

openfilename ofn; // Common Dialog Box Structure <br/> tchar szfile [260]; // buffer for file name <br/> zeromemory (szfile, sizeof (szfile )); <br/> // initialize openfilename <br/> zeromemory (& ofn, sizeof (openfilename); <br/> ofn. lstructsize = sizeof (openfilename); <br/> ofn. hwndowner = hwnd; <br/> ofn. hinstance = g_hinst; <br/> ofn. lpstrfile = szfile; <br/> ofn. nmaxfile = sizeof (szfile); <br/> ofn. lpstrfilter = text ("BMP/0 *. BMP/0 "); <br/> ofn. nfilterindex = 1; <br/> ofn. lpstrfiletitle = NULL; <br/> ofn. nmaxfiletitle = 0; <br/> ofn. lpstrinitialdir = NULL; <br/> ofn. flags = ofn_pathmustexist | ofn_filemustexist; <br/> // display the open dialog box. <br/> If (getopenfilename (& ofn) = true) <br/>{< br/>}

HereCodeThe opened folder has been seen in many applications, as shown in the following figure:

 

If you want to test this interface on smartphone, but it does not work, no matter how you set the parameter, the getopenfilename always returns false. Later, we found another available interface getopenfilenameex to work:

 

Tchar szfile [max_path]; <br/> openfilenameex ofnex = {0}; <br/> ofnex. lstructsize = sizeof (ofnex); <br/> ofnex. hwndowner = hwnd; <br/> ofnex. lpstrfile = szfile; <br/> ofnex. nmaxfile = sizeof (szfile)/sizeof (szfile [0]); <br/> ofnex. lpstrfilter = text ("all files (*. *)/0 *. */0 "); <br/> ofnex. lpstrinitialdir = _ T ("// Program Files"); <br/> ofnex. exflags = ofn_exflag_thumbnailview | ofn_exflag_hidedrmprotected; <br/> return getopenfilenameex (& ofnex); <br/>

The effect is similar.

right and put it here. Please remember to forget it later.

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.