[A5] al_create_native_file_dialog() Windows source?
Neil Roy

Could someone point me to where the Windows source code for the al_create_native_file_dialog() function is? I want to dig through it and see if I can improve it, at least for my own needs anyhow.

(preferably without any sarcasm)

Matthew Leverton

Look in the add-ons native dialog folder.

Or, if you have git installed:

git grep al_create_native_file_dialog

Edgar Reynaldo

addons/native_dialog/dialog.c line 43

although you are probably more interested in _al_show_native_file_dialog which is in
addons/native_dialog/win_dialog.c line 135

Neil Roy

Thanks. I may be in over my head here. Trying to figure out how I can get this thing to accept a default filename when opening a save dialog. :/

Edgar Reynaldo
A5 git said:

191 if (flags & OFN_OVERWRITEPROMPT) { 192 ret = GetSaveFileName(&ofn); 193 } 194 else { 195 ret = GetOpenFileName(&ofn); 196 }

GetOpenFileName is called on a OPENFILENAME structure. It looks like the lpstrFile field needs to be initialized for it to accept a default selected file.

What allegro does currently :

172 if (fd->fc_initial_path) { 173 ofn.lpstrInitialDir = 174 al_path_cstr(fd->fc_initial_path, ALLEGRO_NATIVE_PATH_SEP); 175 }


Thanks for trying to help out! It will be easiest if you clone Allego's git repository, so you can make a patch easily with git diff or git format-patch. The Allegro Git repository is explained here:


Edgar Reynaldo

lpstrFile is a LPTSTR type, which is dependent on whether UNICODE is defined before including windows.h. UNICODE is not currently defined in any files included in win_dialog.c. That makes LPTSTR a typedef for unsigned char*[1]. So it should be okay to use a char* str in its place, I think...

So, we can set lpstrFile to the filename held in fc_initial_path I believe. I will test this later tonight.

Still working on this. Been busy with orientation for school.

Thread #614568. Printed from Allegro.cc