Creating OPENFILENAME struct for GetOpen/SaveFileName

Hi there.

I/we are wanting to use the Windows API GetOpenFilename/GetSaveFileName functions. I have been trying to construct a GROUP (or CLASS) based on the OPENFILENAME struct but can’t seem to get it right.

My call to GetOpenFileName(OPENFILENAME) seems to work OK in that I don’t get a GPF, but it doesn’t open a window (returns 0) and the Windows extended error is 1 (CDERR_STRUCTSIZE), the lStructSize member … is invalid.

Now. Many, many years ago, Mark Goldberg alluded to a solution in this post: but no code was posted.

Mark, I managed to track you down (provided you are the same Mark Goldberg). Do you have a solution you can share with me?

Days of searching for Clarion example code has confused me more than ever.

Some indicate the prototype should be:
others show it as:

Anybody else able to assist?

Many, many thanks.


Hi Andrew,
You may have a very good reason that you want to use GetOpenFilename API. But, why not use clarion’s FILEDIALOGA function instead?

Just curious

G’day Mathew.

FileDialog is fine if you want to Open a file. A user selects a name etc and the full filename is returned, drive:\path\filename.ext

On the other hand, if you want to save a file and the user changes the name, regardless of the file extension selected for the filter/droplist, if the user does not include an extension, it is not added to the filename.

The link included in my OP outlines the issue. Mark Goldberg encountered the same and developed a function to call the Windows API GetSaveFileName which contains considerably more information about the whole file save process (including the selected extension).

I am having a little trouble getting my head around replicating the struct (including pointers) etc in Clarion. Most other API or external DLL calls I have no trouble with.


< edit > Mathew, just noticed you said FILEDIALOGA. As below, still using C5, no FILEIDALOGA < /edit >

A new attribute was added a number of years ago to the Clarion FileDialog ( I believe in one of the C6 updates).
File:AddExtension. This adds the extension to the file name in the save dialog if none was included.
Take a look and see if that helps.


Thanks Rick.

I’m sure it would but for various reasons, still using C5Pro, so still stuck with same issue.

Hi Andrew,

I’ll see if I can dig up the code in question.

Hi Andrew,

How is the structure prototyped?
If LONG is used then you pass address of the structure


Hi Mark and Leonid (and others),
While looking for something else marginally related, I came across this site: , and part of the way down is a WinAPI toolkit. Lo and behold, there was an example of GetOpen/SaveFileName, albeit as a template and for an older version, but it pointed out a couple of things I was doing wrong (eg getting the SIZE of the wrong object).
Many thanks to that developer, but I am now well on my way to resolving my issue.
Thanks everyone for your help.

Mark, I would be curious to see your code if available.



Please read the Readme.MD in the gist where I discuss some short comings of the posted code.

1 Like

Wow! Thanks very much for that.

My implementation is somewhat ‘thinner’ than yours, but it does what I require for now.

Do you mind if I borrow some of your ideas (and code) so as to improve my own?

I will have to invest some time to understanding WINAPI a bit more.


Please do improve it.
I’d love to see the result.
I suppose I should’ve added a LGPLv3 ( to it.

I apologize for a bit of a sidetrack, but after repeatedly reading the docs just yesterday, I still miss the difference between FILEDIALOG and FILEDIALOGA. Might anyone have some insight?

Thank you,

FILEDIALOGA in the help is title as (extended file dialog)

This has an extra parameter (index) as shown below:
FILEDIALOGA( [title] ,file [,extensions] [,flag] [,index] )

index = A signed integer variable used to select a different default extension by specifying the index number.

Example Code:


FILEDIALOGA(‘Choose File to View’ ,FileName, ‘Text|.TXT|Source|.CLW’, FILE:LongName, Fxt)

If Fxt is 1, it would default the file extension to “Text” when the file dialog is opened. If set to 2, it would default the file extension to “Source”.



Thank you. Definitely one of those things where it now seems so obvious. I kept looking at the docs regarding “extensions” and did not even notice the index parameter difference.