selectDirectory怎样才能使目录浏览窗口居中? if SelectDirectory('Select a Directory', '', NewDir) then editPutDir.Text := NewDir;但窗口不能居中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //在疯一疯装,看看~~uses ShlObj, ActiveX;function SelectDirCB(Wnd: HWND; uMsg: UINT; lParam, lpData: LPARAM): Integer stdcall;begin if (uMsg = BFFM_INITIALIZED) and (lpData <> 0) then SendMessage(Wnd, BFFM_SETSELECTION, Integer(True), lpdata); result := 0;end;function SelectDirectory(const Caption: string; const Root: WideString; var Directory: string; Owner: THandle): Boolean;var WindowList: Pointer; BrowseInfo: TBrowseInfo; Buffer: PChar; RootItemIDList, ItemIDList: PItemIDList; ShellMalloc: IMalloc; IDesktopFolder: IShellFolder; Eaten, Flags: LongWord;begin Result := False; if not DirectoryExists(Directory) then Directory := ''; FillChar(BrowseInfo, SizeOf(BrowseInfo), 0); if (ShGetMalloc(ShellMalloc) = S_OK) and (ShellMalloc <> nil) then begin Buffer := ShellMalloc.Alloc(MAX_PATH); try RootItemIDList := nil; if Root <> '' then begin SHGetDesktopFolder(IDesktopFolder); IDesktopFolder.ParseDisplayName(Application.Handle, nil, POleStr(Root), Eaten, RootItemIDList, Flags); end; with BrowseInfo do begin hwndOwner := Owner; //Application.Handle; pidlRoot := RootItemIDList; pszDisplayName := Buffer; lpszTitle := PChar(Caption); ulFlags := BIF_RETURNONLYFSDIRS; if Directory <> '' then begin lpfn := SelectDirCB; lParam := Integer(PChar(Directory)); end; end; WindowList := DisableTaskWindows(0); try ItemIDList := ShBrowseForFolder(BrowseInfo); finally EnableTaskWindows(WindowList); end; Result := ItemIDList <> nil; if Result then begin ShGetPathFromIDList(ItemIDList, Buffer); ShellMalloc.Free(ItemIDList); Directory := Buffer; end; finally ShellMalloc.Free(Buffer); end; end;end;procedure TForm1.Button1Click(Sender: TObject);var NewDir: string;begin NewDir := Edit1.Text; if SelectDirectory('Select a Directory', '', NewDir, Handle) then Edit1.Text := NewDir;end; 问个问题? 他怎么就不能自动添加那? 大家帮忙看看 一个关于文本写入的问题!! 跪求高手帮忙,修改机读卡接口程序 初学dll,有问题向各位请教 一个初学者的简单问题 delphi如何编写modem 关于地图的问题 本来不是这个坛论的问题,但我急于解决,请高手帮一下? 哪里有Delphi控件的详细说明啊!就是Delhpi的一般控件比如TButton 着急 装了IE6和OFFICE XP后还用得着装MDAC(Microsoft Data Access Components) Ver2.7吗? 怪啊怪啊,ListView的问题
begin
if (uMsg = BFFM_INITIALIZED) and (lpData <> 0) then
SendMessage(Wnd, BFFM_SETSELECTION, Integer(True), lpdata);
result := 0;
end;function SelectDirectory(const Caption: string; const Root: WideString;
var Directory: string; Owner: THandle): Boolean;
var
WindowList: Pointer;
BrowseInfo: TBrowseInfo;
Buffer: PChar;
RootItemIDList, ItemIDList: PItemIDList;
ShellMalloc: IMalloc;
IDesktopFolder: IShellFolder;
Eaten, Flags: LongWord;
begin
Result := False;
if not DirectoryExists(Directory) then
Directory := '';
FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
if (ShGetMalloc(ShellMalloc) = S_OK) and (ShellMalloc <> nil) then
begin
Buffer := ShellMalloc.Alloc(MAX_PATH);
try
RootItemIDList := nil;
if Root <> '' then
begin
SHGetDesktopFolder(IDesktopFolder);
IDesktopFolder.ParseDisplayName(Application.Handle, nil,
POleStr(Root), Eaten, RootItemIDList, Flags);
end;
with BrowseInfo do
begin
hwndOwner := Owner; //Application.Handle;
pidlRoot := RootItemIDList;
pszDisplayName := Buffer;
lpszTitle := PChar(Caption);
ulFlags := BIF_RETURNONLYFSDIRS;
if Directory <> '' then
begin
lpfn := SelectDirCB;
lParam := Integer(PChar(Directory));
end;
end;
WindowList := DisableTaskWindows(0);
try
ItemIDList := ShBrowseForFolder(BrowseInfo);
finally
EnableTaskWindows(WindowList);
end;
Result := ItemIDList <> nil;
if Result then
begin
ShGetPathFromIDList(ItemIDList, Buffer);
ShellMalloc.Free(ItemIDList);
Directory := Buffer;
end;
finally
ShellMalloc.Free(Buffer);
end;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
NewDir: string;
begin
NewDir := Edit1.Text;
if SelectDirectory('Select a Directory', '', NewDir, Handle) then
Edit1.Text := NewDir;
end;