Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2002.05.06;
Скачать: [xml.tar.bz2];

Вниз

Диалог   Найти похожие ветки 

 
stormick   (2002-02-27 21:51) [0]

Ребята подскажите. Как можно вызвать стандартный диалог windows "Открыть файл...". Знаю, что находиться эта функция в comdlg32.dll, а вот как описана незнаю, а shlobj.pas у меня нет.
Лучше юудет мылом.
mailto:stormick@mail.ru


 
Stan4Ever   (2002-02-27 22:52) [1]

Рочему просто не сделаеш это с OpenDialog1, "Dialogs"?


 
Dimaond Cat   (2002-02-28 00:44) [2]

Shellexecute(0,"open","с:\",nil,nil,SW_SHOWDEFAULT);
и не забудь в uses вставить "Shellapi"


 
Evgeny   (2002-02-28 06:17) [3]

я делал это примерно так, это я в свое время нашел на сайте у Акжана:


type
{Browse for folders}
TBrowseFolderKind = (bfAll, bfDrives, bfComputers);

function BrowseFolder(Wnd: HWND;
ATitle : string;
var APath : String;
AKind : TBrowseFolderKind;
Show : Boolean) : Boolean;
var
bi : TBROWSEINFO;
pidlBrowse : PITEMIDLIST; // PIDL selected by user
Temp : array[0..MAX_PATH] of Char;
begin
MainWnd := Wnd;
if APath <> "" then
InitialDir := APath;

// Fill in the BROWSEINFO structure.
bi.hwndOwner := Wnd;
case AKind of
bfDrives : SHGetSpecialFolderLocation(0, CSIDL_DRIVES, bi.pidlRoot);
bfComputers : SHGetSpecialFolderLocation(0, CSIDL_NETWORK, bi.pidlRoot);
end;
case AKind of
bfAll,
bfDrives : bi.ulFlags := BIF_RETURNONLYFSDIRS or BIF_RETURNFSANCESTORS;
bfComputers : bi.ulFlags := BIF_DONTGOBELOWDOMAIN or BIF_BROWSEFORCOMPUTER;
end;
bi.pszDisplayName := NIL;
bi.lpszTitle := PChar(ATitle);
if Show then
bi.ulFlags := bi.ulFlags or BIF_STATUSTEXT;
bi.lpfn := BrowseCallbackProc;

// Browse for a folder and return its PIDL.
pidlBrowse := SHBrowseForFolder(bi);
Result := False;
if (pidlBrowse <> NIL) then
begin
SHGetPathFromIDList(pidlBrowse, Temp);

// Free the PIDL returned by SHBrowseForFolder.
CoTaskMemFree(pidlBrowse);
aPath := StrPas(@Temp[0]);
Result := aPath <> "";
end;
end;


 
Raptor   (2002-02-28 12:54) [4]

2 Dimaond Cat
Shellexecute(0,"open","с:\",nil,nil,SW_SHOWDEFAULT);
и не забудь в uses вставить "Shellapi"


Ну и что это даст. Просто откроется окно проводника с содержимым диска С. А как оттуда прикажешь имя файла выцепить?

2 Evgeny
Это вызовет диалог выбора папки, а никак не диалог выбора файла.

2 stormick
Используй GetOpenFileName(). Эта функция находится в ComDlg32.dll.

<****************************************************************************>
GetOpenFileName
The GetOpenFileName function creates an Open common dialog box that lets the user specify the drive, directory, and the name of a file or set of files to open.

BOOL GetOpenFileName(
LPOPENFILENAME lpofn // address of structure with initialization
// data
);

Parameters
lpofn
Pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetOpenFileName returns, this structure contains information about the user"s file selection.
Return Values
If the user specifies a filename and clicks the OK button, the return value is nonzero. The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains the full path and filename specified by the user.

If the user cancels or closes the Open dialog box or an error occurs, the return value is zero. To get extended error information, call the CommDlgExtendedError function, which can return one of the following values:

CDERR_FINDRESFAILURE CDERR_NOHINSTANCE
CDERR_INITIALIZATION CDERR_NOHOOK
CDERR_LOCKRESFAILURE CDERR_NOTEMPLATE
CDERR_LOADRESFAILURE CDERR_STRUCTSIZE
CDERR_LOADSTRFAILURE FNERR_BUFFERTOOSMALL
CDERR_MEMALLOCFAILURE FNERR_INVALIDFILENAME
CDERR_MEMLOCKFAILURE FNERR_SUBCLASSFAILURE


Remarks
Beginning with Windows 95 and Windows NT version 4.0, the default Open dialog box provides user-interface features that are similar to the Windows Explorer. You can provide an OFNHookProc hook procedure for an Explorer-style Open dialog box. To enable the hook procedure, set the OFN_EXPLORER and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and specify the address of the hook procedure in the lpfnHook member.

Windows 95 and Windows NT continue to support the old-style Open dialog box for applications that want to maintain a user-interface consistent with the Windows 3.1 or Windows NT 3.51 user-interface. To display the old-style Open dialog box, enable an OFNHookProcOldStyle hook procedure and ensure that the OFN_EXPLORER flag is not set.

To display a dialog box that allows the user to select a directory instead of a file, call theSHBrowseForFolder function.

Windows CE: Not all members of the OPENFILENAME structure are defined in Windows CE. For information about the defined members, see the reference topic for the OPENFILENAME structure.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in commdlg.h.
Import Library: Use comdlg32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
<****************************************************************************>


 
Evgeny   (2002-02-28 13:03) [5]

Виноват - погорячился. Невнимательно прочитал вопрос.


 
Dimaond Cat   (2002-02-28 22:09) [6]

видимо я тоже не внимательно прочитал вопрос звиняй.
блин как-то я это делал, вспомню напишу


 
VuDZ   (2002-03-01 01:56) [7]

А что вспоминать-то? Raptor правильно всё сказал...



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2002.05.06;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.008 c
1-17614
VJar
2002-04-22 23:29
2002.05.06
Отключение события


4-17742
Пастор
2002-03-02 22:33
2002.05.06
API Controls Library


6-17662
ATLANTIDO
2002-02-19 20:01
2002.05.06
ПОДАВИТЬ ОШИБКУ


3-17512
yozhik
2002-04-11 21:39
2002.05.06
Создание перекрестного запроса


1-17544
VJar
2002-04-23 00:02
2002.05.06
О закрытии приложения





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский