- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a problem for GetOpenFileName/GetSaveFileName dialog box.
It works fine on Windows 2000/Windows XP but not on Windows VISTA/Windows 7.
So, I would like to change that interfaces to IFileDialog/IFileOpenDialog/IFileSaveDialog using WIN32 API.
The problem is that I have no idea about it.
There are some examples for MS VC++, VBA, but NOT Visual FORTRAN (WIN32 API).
Is there any one who knew about that one?
Thanks in advance.
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following works just fine on all versions of Windows, including Vista and Win7:
[bash]LOGICAL FUNCTION CmnDlgOpenFile (hwndParent, filter, filename) USE charfunc, ONLY: NullTerminateString IMPLICIT NONE INTEGER(HANDLE), INTENT(IN) :: hwndParent CHARACTER(LEN=*), INTENT(IN) :: filter CHARACTER(LEN=*), INTENT(INOUT) :: filename TYPE(T_OPENFILENAME) :: ofn CALL NullTerminateString(filename) ! ofn structure component list increased ! to emulate IVF sample code GETOPENFILENAME.F90; ! omission of the extra components caused an ! access violation with the v11.0.074 compiler ofn%lStructSize = SIZEOF(ofn) ofn%hwndOwner = hwndParent ofn%hInstance = ghInstance ofn%lpstrFile = LOC(filename) ofn%nMaxFile = LEN(filename) ofn%lpstrFilter = LOC(filter) ofn%nFilterIndex = 1 ofn%Flags = IOR(OFN_HIDEREADONLY, & IOR(OFN_PATHMUSTEXIST, & OFN_FILEMUSTEXIST) ) ofn%lpstrCustomFilter = NULL ofn%nMaxCustFilter = 0 ofn%nMaxFileTitle = 0 ofn%lpstrInitialDir = NULL ! Use Windows default directory ofn%lpstrTitle = loc(""C) ofn%lpstrDefExt = loc(""C) ofn%lpfnHook = NULL ofn%lpTemplateName = NULL CmnDlgOpenFile = GetOpenFileName(ofn) END FUNCTION CmnDlgOpenFile [/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you be so kind to tell us where we can find more about the (new?) library charfunc and the included functions, for example TeminateNullString? I could not find the functions via Help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Charfunc is a private library of string manipulation functions, similar to one posted here recently.
NullTerminateString() does exactly what the name says, ie adds a null byte beyond the last non-null character in the string, so that the string will be properly formatted for use by Win32 API functions.
NullTerminateString() does exactly what the name says, ie adds a null byte beyond the last non-null character in the string, so that the string will be properly formatted for use by Win32 API functions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could replace the call to NullTerminateString with:
filename = TRIM(filename) // CHAR(0)
Of course, this (and the routine) require that Filename be a variable (and not a constant) and that it be long enough to contain the trailing NUL.
I'd be more comfortable with declaring a local variable that gets the nul-terminated string rather than modifying the argument.
filename = TRIM(filename) // CHAR(0)
Of course, this (and the routine) require that Filename be a variable (and not a constant) and that it be long enough to contain the trailing NUL.
I'd be more comfortable with declaring a local variable that gets the nul-terminated string rather than modifying the argument.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for reply.
I just disabled visual themes &desktop composition only, which is in the compatibility options.
OOPS, it works fine...!
Is there anyone, who can explain more about this case...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have been througth the other threads on this matter with stack problems and the inability for some users to be able to open and save files with GetOpenFileName/GetSaveFileName. It has not given answers to my similar problem with these functions on W7. I would like to try the recommended newer API functions IFileDialog/IFileOpenDialog/IFileSaveDialog but I lack a Intel Fortran sample. Please help ... thanks!
Best,
Morten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
GetOpenFileName and GetSaveFileName work fine on Windows 7 as long as you call them correctly. The "newer API functions" you refer to are not callable APIs but rather COM methods. While you could get at these through the Fortran Module Wizard, it is probably not worth the trouble.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page