delphi Ñ¡ÔñÎļþ¼Ð
function BrowseCallbackProc(Wnd: HWND; uMsg: UINT; lParam, lpData: LPARAM): Integer; stdcall;
begin
if uMsg = BFFM_INITIALIZED then
begin
SendMessage(Wnd, BFFM_SETSELECTION, 1, lpData);
SetWindowText(Wnd, 'Ñ¡ÔñÒ»¸öÄ¿±ê');
end;
Result := 0;
end;
//hdl: ´°¿Ú¾ä±ú
//Root: ¸ùĿ¼
//InitDir: ³õʼ»¯Â·¾¶
//Hint: ¶Ô»°¿òÌáʾÓï¾ä
function fBrowseFolder(hdl:THandle; const Root: String; const InitDir: string;
Hint: string = 'ÇëÑ¡ÔñÎļþ¼Ð'): string;
var
Info:TBrowseInfo;
Dir:array[0..260] of char;
ItemId, RootItemIDList:PItemIDList;
Eaten, Attribute: Cardinal;
ID: IShellFolder;
begin
FillChar(Info, SizeOf(TBrowseInfo), #0);
with Info do
begin
hwndOwner := hdl;
SHGetDesktopFolder(ID);
ID.ParseDisplayName(hdl, nil, POleStr(WideString(Root)), Eaten, RootItemIDList, Attribute);
pidlRoot := RootItemIDList;
pszDisplayName := nil;
lpszTitle:= PChar(Hint);
ulFlags:=BIF_RETURNONLYFSDIRS + BIF_NEWDIALOGSTYLE; //Èç²»ÐèҪн¨°´Å¥£¬Ò²¿É²»¼ÓBIF_NEWDIALOGSTYLE
lpfn := BrowseCallbackProc;
lParam := Integer(PChar(InitDir));
iImage := 0;
end;
ItemId := SHBrowseForFolder(Info);
if ItemId<>nil then
begin
SHGetPathfromIDList(ItemId,@Dir);
GlobalFreePtr(ItemId);
Result:=string(Dir);
end
else
Result:='';
end;
Ïà¹ØÎĵµ£º
µÚÒ»ÖÖ·½·¨,ʹÓÃSelectDirectory º¯Êý ,ÔÚShellApiÖÐ
procedure TForm2.BtSelectPathClick(Sender: TObject);
var
strCaption,strDirectory:String;
wstrRoot:WideString;
begin
strCaption:='ÕâÊÇä¯ÀÀÎļþ¼ÐµÄ˵Ã÷ÎÄ×Ö£¬¿ÉÒÔ¸ù¾ÝÐèÒª½ ......
¹Ø¿ª·¢Ï°¹ßµÄһЩÏë·¨£¬ÈçöáÔÚºí£¬²»Í²»¿ì¡£¾¿Æä·¢Ìù¶¯»ú£¬µ±È»²»ÅųýÓÐÆÈ¡²ÎÓë·ÖµÄ¿ÉÄÜ£¬µ«ÁíÒ»·½Ã棬ҲϣÍûÄܸøÍ¬ÐУ¨ÄîXing£©ÕßÌṩһЩ½¨Ò飬»òÕ߲ο¼(Ï£Íû²»ÊÇÎóÈË×ÓµÜ)¡£Í¬Ê±£¬Ò²Ï£Íû¸÷λÄܹ»¾ÍÎÒµÄÕâЩªϰ£¬·¢±íÒ»µã¿´·¨£¬¸ø³öÅúÆÀºÍÖ¸ÕýµÄÒâ¼û¡£Ð»Ð»¡£
Ò»£®½¨Á¢¹¤³ÌĿ¼
&nbs ......
Ë÷ÒýÊÇitemindex
itemÊÇÀïÃæµÄÄÚÈÝ
Ë÷ÒýµÄ»°£¬ÊÇ´Ó0¿ªÊ¼
item itemindex
A 1
B 2
C 3
listbox1.items.count¾ÍÊÇÕâ¸öÁбí¿òÀï×ܹ²ÓжàÉÙÏî. ......
▼¡øDelphiÃæÏò¶ÔÏó±à³ÌµÄ20Ìõ¹æÔò(×ªÔØ)
Â¥Ö÷ZyxIp£¨¾øÍûÖÐ...£©2003-09-02 14:28:07 ÔÚ Delphi / VCL×é¼þ¿ª·¢¼°Ó¦Óà ÌáÎÊ
×÷Õß¼ò½é
Marco CantuÊÇÒ»¸öÖªÃûµÄDelphiר¼Ò£¬ËûÔø³ö°æ¹ý¡¶¾«Í¨Delphi¡·ÏµÁдÔÊ飬¡¶Delphi¿ª·¢ÊֲᡷÒÔ¼°µç×ÓÊé¡¶¾«Í¨Pascal¡·(¸Ãµç×ÓÊé¿ÉÔÚÍøÉÏÃâ·Ñ»ñµÃ)¡ ......
1.ÒòΪKeyPreviewĬÈÏÊÇ False;ÎÒÃÇÕâÀïÐèÒªÏìÓ¦¼üÅÌʼþµÄ»°£¬ÐèÒª½«ÆäÐÞ¸ÄΪTrue£»
ËùÒÔKeyPreview:=True; Õâ¶ÔһЩ¿ì½Ý¼ü»áÓÐÓá£
ÔÚ´°ÌåÊôÐÔÉÏÐÞ¸ÄKeyPreview := True;
2.ÔÚ´°ÌåµÄFormKeyDownº¯ÊýÀïд£º
if KeyPreview then
Form½«ÏÈÏìÓ¦¼üÅÌʼþ£¨ÔÚTEditµÈ¿Ø¼þ֮ǰ£©
else
³ý·ÇFo ......