Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File open dialog problem.

15 views
Skip to first unread message

gaby

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
Hi all

I have implemented the file open dialog as it is described in
installsite.org,
and i have 2 problems.

1) Filter- i can't get the dialog to show only the files i am interested in
(db files).
the filter does appear inside the lile where it should be, but All files
are shown
in the specified directory.

2) I get an error massage when i use the dialog every seconed time, but
only
if i have chosen a file. that means- open the dialog,choose a file, open
the dialog again- you get the error massage (nErr = -1 the massage said that
the function can't open the file) . but if you open the dialog, choose a
file and then cancel- you don't get the error. should i handle the dialog
window for a smooth exit
or is done by windows itself ?

what am i doing wrong ?

bdw- what is the meaning of the bDerefLinks in the function ?
here is the code :
FileBrowseDlg( szCertFile, 512,
szFilter,
"Select something",
"c:\\",
bMultiSel,
listFiles,
bDerefLinks );

function FileBrowseDlg( szFile, nszFileSize, szFilter, szDialogTitle,
szInitialDir, bMultiSel, listFiles, bDerefLinks )
OPENFILENAME ofn;
STRING szMsg, szFileTitle[260];
STRING szCustomFilter[260], szTemp[260];
LONG Result, n, nFlags, nErr;
begin

UseDLL(WINSYSDIR ^ "comdlg32.dll");

nFlags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
OFN_NOCHANGEDIR | OFN_EXPLORER;
if bMultiSel then
nFlags = nFlags | OFN_ALLOWMULTISELECT;
endif;
if bDerefLinks = FALSE then
nFlags = nFlags | OFN_NODEREFERENCELINKS;
endif;

Result = GetWindowHandle(HWND_INSTALL);

// Notice how the address of an explicitly sized string
// is used when assigning to a member who was declared
// as a LONG string pointer (lpstr). For example, &szFilter.
ofn.lStructSize = 76;
ofn.hwndOwner = nResult;
ofn.lpstrFilter = &szFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = &szFile;
ofn.nMaxFile = nszFileSize;
ofn.lpstrFileTitle = &szFileTitle;
ofn.nMaxFileTitle = 260;
ofn.lpstrTitle = &szDialogTitle;
ofn.Flags = nFlags;
ofn.lpstrDefExt = &szTemp;
ofn.lpstrInitialDir = &szInitialDir;
ofn.hInstance = 0;
ofn.lpstrCustomFilter = &szCustomFilter;
ofn.nMaxCustFilter = 260;
ofn.lpfnHook = 0;

nResult = GetOpenFileNameA(&ofn);
if Result = 1 then
// IMPORTANT: InstallShield does not allow you to access
// string contents directly through a structure member
// declared as LONG pointer (lpstr), so you must use the
// STRING whose address was stored there instead.
if bMultiSel then
StrGetTokens(listFiles, szFile, "");
else
szFile = szFile;
endif;
else
nErr = CommDlgExtendedError();
switch (nErr)
case CDERR_DIALOGFAILURE: szMsg = CDERR_DIALOGFAILURE_MSG;
case CDERR_FINDRESFAILURE: szMsg = CDERR_FINDRESFAILURE_MSG;
case CDERR_INITIALIZATION: szMsg = CDERR_INITIALIZATION_MSG;
case CDERR_LOADRESFAILURE: szMsg = CDERR_LOADRESFAILURE_MSG;
case CDERR_LOADSTRFAILURE: szMsg = CDERR_LOADSTRFAILURE_MSG;
case CDERR_LOCKRESFAILURE: szMsg = CDERR_LOCKRESFAILURE_MSG;
case CDERR_MEMALLOCFAILURE: szMsg = CDERR_MEMALLOCFAILURE_MSG;
case CDERR_MEMLOCKFAILURE: szMsg = CDERR_MEMLOCKFAILURE_MSG;
case CDERR_NOHINSTANCE: szMsg = CDERR_NOHINSTANCE_MSG;
case CDERR_NOHOOK: szMsg = CDERR_NOHOOK_MSG;
case CDERR_NOTEMPLATE: szMsg = CDERR_NOTEMPLATE_MSG;
case CDERR_REGISTERMSGFAIL: szMsg = CDERR_REGISTERMSGFAIL_MSG;
case CDERR_STRUCTSIZE: szMsg = CDERR_STRUCTSIZE_MSG;
case FNERR_BUFFERTOOSMALL: szMsg = FNERR_BUFFERTOOSMALL_MSG;
case FNERR_INVALIDFILENAME: szMsg = FNERR_INVALIDFILENAME_MSG;
case FNERR_SUBCLASSFAILURE: szMsg = FNERR_SUBCLASSFAILURE_MSG;
endswitch;
if nErr != 0 then
// User did not close or cancel dialog box.
MessageBox("FileBrowseDlg() error:\n\n" + szMsg, SEVERE);
endif;
return -1;
endif;

UnUseDLL(WINSYSDIR ^ "comdlg32.dll");

return 0;
end;

0 new messages