Calls to Barfinf return the type and extension of the graphic file types supported by the Barcodef calls (above).
int WINAPI Barfinf(int I,(LPSTR)szwords,(LPSTR)szext)
Where
I =index of call (starting at 0)
szwords = pointer to NULL terminated string containing the name of the file type [e.g. Windows metafile (*.wmf)]
szext = pointer to NULL terminated string containing the wildcard form of the file name (e.g. *.wmf).
Barfinf calls may be enumerated to determine all the graphics file types supported for use in an OpenFile dialog as shown:
{
char szFileName[128];
char buf[64];
OPENFILENAME ofn;
char szFile[256],szFileTitle[256];
LPSTR szFilt[15];
char szbuf[256];
int i,j;
char szwords[36],szext[12];
i=0;
lstrcpy(buf,"dBarcode - Save Metafile");
szFilt[i]=(LPSTR)szbuf;
szFile[i]='\0';
j=0;
while (Barfinf(j,(LPSTR)szwords,(LPSTR)szext)>-1) {
lstrcpy(szFilt[i],(LPSTR)szwords);
szFilt[i+1]=szFilt[i]+lstrlen(szFilt[i])+1;
i++;
lstrcpy(szFilt[i],(LPSTR)szext);
szFilt[i+1]=szFilt[i]+lstrlen(szFilt[i])+1;
i++;
j++;
}
lstrcpy(szFilt[i],"");
szFilt[i+1]=szFilt[i]+1;
lstrcpy(szFilt[i+1],"");
ofn.lStructSize=sizeof(OPENFILENAME);
ofn.hwndOwner=NULL;
ofn.lpstrFilter=szFilt[0];
…….. etc
ofn.lpstrDefExt=NULL;
if (GetSaveFileName(&ofn)) {
lstrcpy ((LPSTR)szFileName, (LPSTR)szFile);
if (strchr(szFile,'.')==0) {
i=2*(int)ofn.nFilterIndex-1;
if (i<=0)
i=1;
lstrcpy(buf,szFilt[i]);
lstrcat(szFileName,(LPSTR)strchr(buf,'.'));
}
SaveFile(szFileName);
}
}
More: