L
lchyy
Unregistered / Unconfirmed
GUEST, unregistred user!
以下例子<br>uses ShlObj, ActiveX;<br><br>var<br> FPath:string;<br><br>function BrowseCallBackProc(hwnd: HWND;uMsg: UINT;lParam: Cardinal;lpData: Cardinal): integer; stdcall;<br>begin<br> if uMsg=BFFM_INITIALIZED then<br> result :=SendMessage(Hwnd,BFFM_SETSELECTION,Ord(TRUE),Longint(PChar(FPath)))<br> else<br> result :=1<br>end;<br><br>function BrowseDir(const OwnerHandle:HWND;const Caption: string; const Root:WideString):string ;<br>var<br> BI: BROWSEINFO;<br> IDLt: pointer;<br>begin<br> fillchar(BI,sizeof(BROWSEINFO),0);<br> BI.hWndOwner := OwnerHandle;<br> BI.iImage := 0;<br> BI.lParam := 1;<br> BI.lpfn := nil;<br> BI.lpszTitle := PAnsiChar(Caption);<br> BI.ulFlags := BIF_RETURNONLYFSDIRS;<br> FPath:=Root;<br> BI.lpfn :=@BrowseCallBackProc;<br> BI.lParam :=BFFM_INITIALIZED;<br> IDLt := SHBrowseForFolder(BI);<br> if Assigned(IDLt) then<br> begin<br> setlength(Result,MAX_PATH);<br> SHGetPathFromIDList(IDLt, pchar(Result));<br> end;<br>end;<br><br>procedure TFormTest.BitBtn2Click(Sender: TObject);<br>begin<br> BrowseDir(Handle,'aaa','c:/');<br>end;<br><br>=========================================================<br>为什么点击项目“我的电脑”时“确定”的按钮是灰色的