After your application creates the hook function and the dialog box template, it should set the members of the structure for the common dialog box being customized and call the appropriate function to display the custom dialog box.
The following example calls the GetOpenFileName function and creates a backup file if the user selected the custom Backup File check box in the custom Open dialog box:
/* Open the file and create a backup. */
if (GetOpenFileName(&ofn)) {
hf = _lopen(ofn.lpstrFile, OF_READWRITE);
/* Create the backup file. */
if (ofn.lCustData) {
/* Process files with extension. */
if (ofn.nFileExtension){
for (i=0; i<(int)ofn.nFileExtension; i++)
szChar[i] = *ofn.lpstrFile++;
}/*endif */
/* Process files without extension. */
else {
i=0;
while (*ofn.lpstrFile!='\0')
szChar[i++] = *ofn.lpstrFile++;
szChar[i]='.';
}/*end else*/
pszNewPAFN = lstrcat(szChar, "BAK");
/* Create the backup file. */
hfBackup = _lcreat(pszNewPAFN, 0);
/* Copy contents of original file to the backup file. */
while ((cBufLngth=_lread(hf, cBuf1, 256)) == 256)
_lwrite(hfBackup, cBuf1, cBufLngth);
_lwrite(hfBackup, cBuf1, cBufLngth);
_lclose(hfBackup);
} /*endif GetOpenFileName*/
/* File operations begin here. */
} /* endif (GetOpenFileName) */
The following is the custom Open dialog box. The new Backup File check box appears in the lower-right corner.