|
|
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Зделал функцию, структуру. Зову функцию из окна, выпрыгивает виндовский диалог, если сохранять файлы в пассуемой a_s_file_dir, всё в порядке, если начинаю двигатса по директориям и создавать новые фолдэры, фолдэры создаютса... только аппликация рушитса. Гляньте плиз, может кто чего (что не так увидит) Спасибо. Function long GetSaveFileNameA(REF OPENFILENAME SaveFileName) library "comdlg32.dll" $PBExportHeader$f_get_file_save_name.srf global type f_get_file_save_name from function_object end type forward prototypes global function long f_get_file_save_name (window a_w_caller, string a_s_def_file_name, string a_s_file_type, string a_s_file_dir, string a_s_popup_title, ref string ar_s_full_name, ref string ar_s_short_name) end prototypes global function long f_get_file_save_name (window a_w_caller, string a_s_def_file_name, string a_s_file_type, string a_s_file_dir, string a_s_popup_title, ref string ar_s_full_name, ref string ar_s_short_name);/* a_s_file_type example: 'Text Files(*.txt), *.TXT,All Files (*.*)", "*.*",' */ /* a_s_file_dir example: 'c:\NewFolder' */ blob{1000} bl_filter openfilename st_open ULong OFN_EXPLORER, OFN_HIDEREADONLY, OFN_OVERWRITEPROMPT, l_result char c_filter[1000] long l_idx, l_str_size int i_rc string s[] i_rc = 0 OFN_EXPLORER = (16^4) * 8 /* 0x00080000 */ OFN_HIDEREADONLY = 4 /* 0x00000004 */ OFN_OVERWRITEPROMPT = 1 /* 0x00000002 */ st_open.lstructsize = 76 st_open.hInstance = 0 st_open.lpstrcustomfilter = 0 st_open.nmaxcustomfilter = 0 st_open.nfilterindex = 0 st_open.nmaxfile = 500 st_open.lpstrfile = Space(500) st_open.lpstrfiletitle = Space(500) st_open.nmaxfiletitle = 500 st_open.nfileoffset = 0 st_open.nfileextension = 0 st_open.lpstrdefext = 0 st_open.lcustdata = 0 st_open.lpfnhook = 0 st_open.lptemplatename = 0 st_open.flags = OFN_EXPLORER + OFN_HIDEREADONLY + OFN_OVERWRITEPROMPT bl_filter = Blob(a_s_file_type) c_filter = a_s_file_type FOR l_idx = 1 TO len(a_s_file_type) IF string(c_filter[l_Idx]) = ',' THEN l_result = BlobEdit(bl_filter, l_idx, Char(0)) END IF NEXT st_open.hwndowner = Handle(a_w_caller) st_open.lpstrfile = a_s_def_file_name st_open.lpstrfilter = bl_filter st_open.lpstrinitialdir = a_s_file_dir st_open.lpstrtitle = a_s_popup_title i_rc = GetSaveFileNameA(st_open) ar_s_full_name = st_open.lpstrfile ar_s_short_name = st_open.lpstrfiletitle RETURN i_rc end function $PBExportHeader$openfilename.srs global type openfilename from structure long lstructsize long hwndowner long hinstance blob lpstrfilter long lpstrcustomfilter long nmaxcustomfilter long nfilterindex string lpstrfile long nmaxfile string lpstrfiletitle long nmaxfiletitle string lpstrinitialdir string lpstrtitle long flags integer nfileoffset integer nfileextension long lpstrdefext long lcustdata long lpfnhook long lptemplatename end type Туды её в качель... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 02.05.2005, 21:49 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Поскольку версия РВ не указано, ещё более уверенно спрошу, а зачем всё это? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 00:18 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
version 9.0.2 Build 7610. народ просит виндовский диалог, говорят эстетичней и удобнее чем билдэровский GetFileSaveName() Туды её в качель... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 00:52 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Ну для начала, и та и другая картинка - виндовский диалог, а НЕ билдэровский . Поиск в этом форуме рулит. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 02:32 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
RTFMThe dialog boxes presented by GetFileOpenName and GetFileSaveName are system dialog boxes. They provide standard system behavior, including control over the current directory. When users change the drive, directory, or folder in the dialog box, they change the current directory or folder. The newly selected directory or folder becomes the default for file operations until they exit the application, unless the optional initdir argument is passed. The aFlag argument is used to pass one or more options that determine the appearance of the dialog box. For each option, the value of the flag is 2^(index -1), where index is an integer associated with each option as shown in the following table.You can pass multiple options by passing an aggregate flag, calculated by adding the values of the individual flags. If you do not pass an aFlag, the Explorer-style open file dialog box is used. If you do pass a flag, the old-style dialog box is used by default. Some options do not apply when the Explorer-style dialog box is used. For those that do apply, add the option value for using the Explorer-style dialog box (2) to the value of the option if you want to display an Explorer-style dialog box. For example, passing the flag 32768 (2^15) to the GetFileSaveName function opens the old-style dialog box with the Read Only check box selected by default. Passing the flag 32770 opens the Explorer-style dialog box with the Read Only check box selected by default. Index Constant name Description 1 OFN_CREATEPROMPT If the specified file does not exist, prompt for permission to create the file. If the user chooses to create the file, the dialog box closes; otherwise the dialog box remains open. 2 OFN_EXPLORER Use an Explorer-style dialog box. 3 OFN_EXTENSIONDIFFERENT The file extension entered differed from the extensions specified in extension. 4 OFN_FILEMUSTEXIST Only the names of existing files can be entered. 5 OFN_HIDEREADONLY Hide the Read Only check box. 6 OFN_LONGNAMES Use long file names. Ignored for Explorer-style dialog boxes. 7 OFN_NOCHANGEDIR Restore the current directory to its original value if the user changed the directory while searching for files. This option has no effect for GetOpenFileName on Windows NT, 2000, and XP. 8 OFN_NODEREFERENCELINKS Return the path and file name of the selected shortcut (.lnk file); otherwise the path and file name pointed to by the shortcut are returned. 9 OFN_NOLONGNAMES Use short file names (8.3 format). Ignored for Explorer-style dialog boxes. 10 OFN_NONETWORKBUTTON Hide the Network button. Ignored for Explorer-style dialog boxes. 11 OFN_NOREADONLYRETURN The file returned is not read only and is not in a write-protected directory. 12 OFN_NOTESTFILECREATE Do not create the file before the dialog box is closed. This option should be specified if the application saves the file on a netwrok share where files can be created but not modified. No check is made for write protection, a full disk, an open drive door, or network protection. A file cannot be reopened once it is closed. 13 OFN_NOVALIDATE Invalid characters are allowed in file names. 14 OFN_OVERWRITEPROMPT Used in Save As dialog boxes. Generates a message box if the selected file already exists. 15 OFN_PATHMUSTEXIST Only valid paths and file names can be entered. 16 OFN_READONLY Select the Read Only check box when the Save dialog box is created. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 10:52 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Для начала и для конца: спасибо Филипп за квалифицированный ответ "по делу". Обожаю когда вместо ответа по делу цепляютса к словам или пытаютса доказать что "так делать нельзя". Зять тёще: - Мама, хотите рыбки? - Да. - Так встаньте и возьмите. - У меня ноги не ходят. - Ну так сидите и не звездите. ФилиппНу для начала, и та и другая картинка - виндовский диалог, а НЕ билдэровский . Поиск в этом форуме рулит. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 16:15 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Геннадич, я как бы прочитал но не нашёл (пока), почему у меня то аппликация рушитса? Геннадич RTFMThe dialog boxes presented by GetFileOpenName and GetFileSaveName are system dialog boxes. They provide standard system behavior, including control over the current directory. When users change the drive, directory, or folder in the dialog box, they change the current directory or folder. The newly selected directory or folder becomes the default for file operations until they exit the application, unless the optional initdir argument is passed. The aFlag argument is used to pass one or more options that determine the appearance of the dialog box. For each option, the value of the flag is 2^(index -1), where index is an integer associated with each option as shown in the following table.You can pass multiple options by passing an aggregate flag, calculated by adding the values of the individual flags. If you do not pass an aFlag, the Explorer-style open file dialog box is used. If you do pass a flag, the old-style dialog box is used by default. Some options do not apply when the Explorer-style dialog box is used. For those that do apply, add the option value for using the Explorer-style dialog box (2) to the value of the option if you want to display an Explorer-style dialog box. For example, passing the flag 32768 (2^15) to the GetFileSaveName function opens the old-style dialog box with the Read Only check box selected by default. Passing the flag 32770 opens the Explorer-style dialog box with the Read Only check box selected by default. Index Constant name Description 1 OFN_CREATEPROMPT If the specified file does not exist, prompt for permission to create the file. If the user chooses to create the file, the dialog box closes; otherwise the dialog box remains open. 2 OFN_EXPLORER Use an Explorer-style dialog box. 3 OFN_EXTENSIONDIFFERENT The file extension entered differed from the extensions specified in extension. 4 OFN_FILEMUSTEXIST Only the names of existing files can be entered. 5 OFN_HIDEREADONLY Hide the Read Only check box. 6 OFN_LONGNAMES Use long file names. Ignored for Explorer-style dialog boxes. 7 OFN_NOCHANGEDIR Restore the current directory to its original value if the user changed the directory while searching for files. This option has no effect for GetOpenFileName on Windows NT, 2000, and XP. 8 OFN_NODEREFERENCELINKS Return the path and file name of the selected shortcut (.lnk file); otherwise the path and file name pointed to by the shortcut are returned. 9 OFN_NOLONGNAMES Use short file names (8.3 format). Ignored for Explorer-style dialog boxes. 10 OFN_NONETWORKBUTTON Hide the Network button. Ignored for Explorer-style dialog boxes. 11 OFN_NOREADONLYRETURN The file returned is not read only and is not in a write-protected directory. 12 OFN_NOTESTFILECREATE Do not create the file before the dialog box is closed. This option should be specified if the application saves the file on a netwrok share where files can be created but not modified. No check is made for write protection, a full disk, an open drive door, or network protection. A file cannot be reopened once it is closed. 13 OFN_NOVALIDATE Invalid characters are allowed in file names. 14 OFN_OVERWRITEPROMPT Used in Save As dialog boxes. Generates a message box if the selected file already exists. 15 OFN_PATHMUSTEXIST Only valid paths and file names can be entered. 16 OFN_READONLY Select the Read Only check box when the Save dialog box is created. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 16:20 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
voronkГеннадич, я как бы прочитал но не нашёл (пока), почему у меня то аппликация рушитса? ну так почитай Help ... PowerBuilder 9 Help: GetFileSaveName PowerScript function For usage notes on the filter , initdir , and aFlag arguments, see the GetFileOpenName function. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 17:09 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
О,о,о,о,о,.... Дробь атаке, война окончена всем спасибо. Извините те кому заморочил голову, дело в том, что в прошлый четверг я/мы переехали с 7 билдэра на 9. А кашу я заварил в 7. Геннадичу спасибо, я глянул в хэлп 9му на GetFileSaveName/GetFileSaveOpen, добавлена initdir (optional) и aFlag (optional). Только я ещё не разобрался, что нужно пасс к aFlag что бы он открыл нужный мне диалог, пока получаетса или "old style" или тот что открываетса бай дефолт и без aFlag. Туды её в качель... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 17:12 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Спасибо Саша, только что посмотрел, есть контакт. alexis glinski voronkГеннадич, я как бы прочитал но не нашёл (пока), почему у меня то аппликация рушитса? ну так почитай Help ... PowerBuilder 9 Help: GetFileSaveName PowerScript function For usage notes on the filter , initdir , and aFlag arguments, see the GetFileOpenName function. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 17:14 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
2 voronok: первое -- всё равно этот "расширенный" диалог выбора файла не будет работать на win9x/me и на winnt4.0 второе -- откуда такой рамер структуры: Код: plaintext автортолько аппликация рушитса. Подозреваю, что дело в неправильном размере структуры st_open. Я когда пытался открыть файло (а именно, пытался пересобрать MFC на хялявном компиляторе borland'а) тоже споткнулся на диалоге открытия файла (кот. похож на GetSaveFileName()). Смотри: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. Повторюсь: откуда такой размер структуры -- 76? в 2000-ке он, вроде бы 80 с чем-то.. Кстати, перед употреблением, неплохо бы заполнить структуру нулями на всякий случай.. В догонку: почему у тябе константная строка ( LPCTSTR lpstrFilter; ) в PB объявлена как blob? Так должно быть? может про оборачивание winapi-функций посмотреть здесь ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 17:33 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Сергей... Код я нашёл на гуглях, "магический" размер структуры 76... , первоначально хотел динамически посчитать, а потом подписать, оказалось, любое другое значение, 75 или 77, не открывает диалог вообще. Клиентура вся на w2k и ХР. Блоб должен быт, потому как в перспективе я могу давать функции не только: "Text Files(*.txt), *.TXT, All Files (*.*), *.*", но и "PIF files, *.PIF, Batch files, *.BAT", или ещё чего. Посредством: bl_filter = Blob(a_s_file_type) c_filter = a_s_file_type FOR l_idx = 1 TO len(a_s_file_type) IF string(c_filter[l_Idx]) = ',' THEN l_result = BlobEdit(bl_filter, l_idx, Char(0)) END IF NEXT получаетса симпатичное "dddw". С PFC не работаем, powertool. Попробую заполнить структуру нулями, потому как "стероидная" версия GetFileSaveName() 9 билдэра, даже при наличие aFlag (optional), всё равно не открывает нужный диалог. Туды её в качель... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 18:15 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
мысль номер два: как-то возились мы с функцией GetCurrentDirectoryA Код: plaintext Выход: перед вызовом функции заполнять передаваемую строку, например, пробелами (штук эдак 255). В какой момет у тебя происходит сваливание? попробую всё-таки для начала строку передать ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 19:01 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
мысль два с половиной! Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 19:07 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
savosin_sergeyтретье -- очень плохо полагаться на константы (тот же размер структуры), так как выйдет какая-нибудь другая версия windows'а -- и всё свалится.. Если выйдет какая-либо другая версия Windows, которая не понимает константы 76, то придется перекомпилировать все приложения, которые использовали данную функцию. Дополнительные поля то в структуре могут появляться, но обратная совместимость всегда поддерживается. Размер же структуры для приложения зависит от ее описания в коде - т.е. вещь статическая и никак от версии Windows не зависящая. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 19:09 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
voronk- Ну так сидите и не звездите. Звездун, поиск в этом форуме рулит!!! как вызвать модное окно выбора файлов? (а-ля офис ХР?) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 19:35 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
savosin_sergeyхитрость такая: передавать не строку, а элемент массива строк! почему -- не знаю, не я делал. но работает (ещё) 1. Должно работать и без массивов, просто обязано. 2. Почему нужно заполнять чем-нибудь - я думаю понятно. 3. В PowerBuilder'е есть такая функция space(...) 4. В WinApi есть такая константа Код: plaintext Код: plaintext ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 03.05.2005, 21:45 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Филлип, не серчай ежели обидел, в запарке был немного. Ребята, большое всем спасибо. Проблема решена (сейчас действительно отбой). Всё работает безотказно. Я чегось намудрил когда подписывал структуру (массив по русски?) Вообшем поменял немного последовательность чего, куда, когда и скока, и вот: bl_filter = Blob(a_s_file_type) c_filter = a_s_file_type FOR l_idx = 1 TO len(s_string) IF string(c_filter[l_Idx]) = ',' THEN l_result = BlobEdit(bl_filter, l_idx, Char(0)) END IF NEXT setnull(s_null) st_open.lstructsize = 76 st_open.hwndowner = Handle(This) st_open.hInstance = 0 st_open.lpstrfilter = bl_filter st_open.lpstrcustomfilter = 0 st_open.nmaxcustomfilter = 0 st_open.nfilterindex = 1 st_open.lpstrfile = a_s_def_file_name + space(500) st_open.nmaxfile = len(st_open.lpstrfile) + 1 st_open.lpstrfiletitle = s_null st_open.nmaxfiletitle = 0 st_open.lpstrinitialdir = a_s_file_dir st_open.lpstrtitle = a_s_popup_title st_open.flags = OFN_EXPLORER st_open.nfileoffset = 0 st_open.nfileextension = 0 st_open.lpstrdefext = 0 st_open.lcustdata = 0 st_open.lpfnhook = 0 st_open.lptemplatename = 0 i_rc = GetSaveFileNameA(st_open) Спасибо всем ещё раз. Туды её в качель... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.05.2005, 00:24 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Я одно не могу понять: зачем использовать API, когда есть в билдере родная функция GetSaveFileName, хелп по которой я привёл выше? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.05.2005, 09:26 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
voronkst_open.nmaxfile = len(st_open.lpstrfile) + 1 вот в этом всё и дело. пока я тоже не указал длину nmaxfile на 1 больше, чем число powerBuilder-ровская длина строки lpstrfile , то вылетало.. 2 Геннадич: по приколу! изучение передачи структур в функции winapi ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.05.2005, 11:36 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Когда-то очень давно я скачивал объект под названием nvo_commdlg. В нем все эти функции из comdlg32 (GetOpenFileNameA, GetSaveFileNameA, PrintDlgA, ChooseFontA) присутствуют. К сожалению, ссылка не сохранилась. Кое-что на эту тему еще можно посмотреть в группе PowerObject на yahoo: http://groups.yahoo.com/group/PowerObject/ ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.05.2005, 13:27 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
Геннадич..., дык не открывает она нужный диалог, верхний (см. картинку), или по крайней мере у меня не получаетса. Открывает или нижний на той же картинке или вот этот: ГеннадичЯ одно не могу понять: зачем использовать API, когда есть в билдере родная функция GetSaveFileName, хелп по которой я привёл выше? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.05.2005, 16:04 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
savosin_sergey voronkst_open.nmaxfile = len(st_open.lpstrfile) + 1 вот в этом всё и дело. пока я тоже не указал длину nmaxfile на 1 больше, чем число powerBuilder-ровская длина строки lpstrfile , то вылетало.. 2 Геннадич: по приколу! изучение передачи структур в функции winapi Все логично - доп. 1 байт требуется для #0 - в API строки в основном #0-terminated. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.05.2005, 16:42 |
|
||
|
GetSaveFileNameA... У кого есть опыт?
|
|||
|---|---|---|---|
|
#18+
засада :( ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.05.2005, 17:41 |
|
||
|
|

start [/forum/topic.php?fid=15&fpage=86&tid=1338375]: |
0ms |
get settings: |
7ms |
get forum list: |
20ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
35ms |
get topic data: |
10ms |
get forum data: |
2ms |
get page messages: |
62ms |
get tp. blocked users: |
2ms |
| others: | 258ms |
| total: | 402ms |

| 0 / 0 |
