GetSaveFileNameW is a Windows API. It creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save. I had a ActiveX plugin which was using this function to get the name of the file user is saving. It was working fine in IE8 in Windows XP but it started failing in IE9 on Windows 7. It did not create a dialog box and returned error!
CommDlgExtendedError : When inquired through CommDlgExtendedError about the reason for failure of GetSaveFileNameW, it said error code : 0xFFFF
Explanation for error code 0xFFFF(CDERR_DIALOGFAILURE) - The dialog box could not be created. The common dialog box function's call to the DialogBox function failed. For example, this error occurs if the common dialog box call specifies an invalid window handle.
Debugging : Internet literature provided little help. Then, I checked whether this function - GetSaveFileNameW - worked fine for a standalone application. It did and then tried with the same set of parameters in ActiveX plugin. But it did not work for ActiveX plugin
Reason for failure : Later I found that IE9 was not fully supporting the ATL version I was using. GetSaveFileNameW was failing because of the flag OFN_EXPLORER. How?
Solution : OPENFILENAMEW structure is filled before passing as a parameter to GetSaveFileNameW. Here, we set the flag OFN_EXPLORER in the Flags attribute of OPENFILENAMEW structure. If the OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box. If the OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box. I was setting the flag - OFN_EXPLORER. I now reset the OPENFILENAMEW and it works!!!
No comments:
Post a Comment