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;
相关文档:
一、Dll建立
(一)DLL项目的建立
library mydll;
uses
base in 'base.pas';
exports
Triple name 'Tr';
{$R *.res}
begin
end.
(二)函数单元
unit base;
interface
uses windows;
function Triple(N:integer):integer;stdcall;
  ......
想没想过在DELPHI中显示GIF动画?Delphi的用户是非常幸运的,因为有免费控件可以使用。最著名的控件是Anders Melander编写的TGifImage,并提供完整的源程序。它原来的主页是www.melander.dk/delphi/gifimage/,不过有很长时间没有更新了。如果要在新版本的Delphi中使用,可以从http://finn.mobilixnet.dk/delphi/下载Finn T ......
delphi指针简单入门:
看一个指针用法的例子:
1 var
2 X, Y: Integer; // X and Y 整数类型
3 ......
1.因为KeyPreview默认是 False;我们这里需要响应键盘事件的话,需要将其修改为True;
所以KeyPreview:=True; 这对一些快捷键会有用。
在窗体属性上修改KeyPreview := True;
2.在窗体的FormKeyDown函数里写:
if KeyPreview then
Form将先响应键盘事件(在TEdit等控件之前)
else
除非Fo ......
附件资料
*类的内存信息(代码)
示例:获取类信息
说明:比对通过类地址以及通过类方法获取信息的效果。
代码:
type
TMyObject = class(TObject)
private
FData: Integer;
protected
......