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.