我做了个VCL控件具体代码如下,可注册后当时能在“Standard”中看见,但重新打开一个Project后就看不见了,但在“Configure Palette”的“Standard“能看见。这是为什么,该怎么解决?
nit QPathButton;interfaceuses
Windows, Messages, SysUtils, Classes, QControls, QStdCtrls, ShlObj;type
TPathButton = class(TButton)
private
function SelectDirectoryEX(Handle: HWND;
const Caption: string; const Root: WideString; out Directory: string): Boolean;
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create(Owner: TComponent); override;
function FileSavePath(Handle:HWND):String;
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Standard', [TPathButton]);
end;constructor TPathButton.Create(Owner: TComponent);
begin
inherited Create (Owner);
width := 65;
Height := 22;end;function TPathButton.SelectDirectoryEX(Handle: HWND;
const Caption: string; const Root: WideString; out Directory: string): Boolean;
var
lpbi: _browseinfo;
buf: array[0..MAX_PATH] of Char;
ID: IShellFolder;
eaten, att: Cardinal;
rt: pItemIDList;
initDir: PWideChar;
begin
lpbi.HWNDOwner := Handle;
lpbi.lpfn := nil;
lpbi.lpszTitle := pchar(caption);
lpbi.ulFlags := BIF_RETURNONLYFSDIRS + 16;
SHGetDesktopFolder(ID);
initdir := pwchar(Root);
id.ParseDisplayName(0, nil, initDir, eaten, rt, att);
lpbi.pidlRoot := rt;
GetMem(lpbi.pszDisplayName, MAX_PATH);
try
Result := SHGetPathFromIDList(SHBrowseForFolder(lpbi), buf);
except
FreeMem(lpbi.pszDisplayName);
end;
if Result then Directory := buf;
end;function TPathButton.FileSavePath(Handle:HWND):String;
var
S: string;
begin
SelectDirectoryEX(Handle, 'Browse', 'Desktop', S);
if S<>'' then
Result:=S
else
Result:='';
end;end.
nit QPathButton;interfaceuses
Windows, Messages, SysUtils, Classes, QControls, QStdCtrls, ShlObj;type
TPathButton = class(TButton)
private
function SelectDirectoryEX(Handle: HWND;
const Caption: string; const Root: WideString; out Directory: string): Boolean;
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create(Owner: TComponent); override;
function FileSavePath(Handle:HWND):String;
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Standard', [TPathButton]);
end;constructor TPathButton.Create(Owner: TComponent);
begin
inherited Create (Owner);
width := 65;
Height := 22;end;function TPathButton.SelectDirectoryEX(Handle: HWND;
const Caption: string; const Root: WideString; out Directory: string): Boolean;
var
lpbi: _browseinfo;
buf: array[0..MAX_PATH] of Char;
ID: IShellFolder;
eaten, att: Cardinal;
rt: pItemIDList;
initDir: PWideChar;
begin
lpbi.HWNDOwner := Handle;
lpbi.lpfn := nil;
lpbi.lpszTitle := pchar(caption);
lpbi.ulFlags := BIF_RETURNONLYFSDIRS + 16;
SHGetDesktopFolder(ID);
initdir := pwchar(Root);
id.ParseDisplayName(0, nil, initDir, eaten, rt, att);
lpbi.pidlRoot := rt;
GetMem(lpbi.pszDisplayName, MAX_PATH);
try
Result := SHGetPathFromIDList(SHBrowseForFolder(lpbi), buf);
except
FreeMem(lpbi.pszDisplayName);
end;
if Result then Directory := buf;
end;function TPathButton.FileSavePath(Handle:HWND):String;
var
S: string;
begin
SelectDirectoryEX(Handle, 'Browse', 'Desktop', S);
if S<>'' then
Result:=S
else
Result:='';
end;end.
解决方案 »
- 这样是怎样的写的?急
- 如何使用SendMessage发送按键组合,例如:Ctrl+A
- 执行一个外部的exe文件,如何使其再次成为当前激活窗体?
- 请问在Delphi7里面怎么找不到TClientSocket和TServerSocket两个组件?
- InstallShield里卸载项应怎么加入?
- 问一个关于select查询的问题!
- 执行线程时引发“因为应用程序正在发送一个输入同步呼叫,所以无法执行传出的呼叫”的错误提示!!
- self 是 對象 還是 指向對象的指針?
- 我好自卑,这么简单的题目都没答出来!
- 寻求工业控制的控件,就是各种仪表,guage....
- 强力散分!也许,我要告别一段DELPHI的日子,决定做网络去!E文差看不懂帮助!
- 请问谁有或知道哪里有D6开发人员指南的配套光盘代码下载????
2.是否已经选择
3.有可能和TBUTTON冲突
不然怎么会..我一般都是放在自已的PALETTE的..
Windows, Messages, SysUtils, Classes, QControls, QStdCtrls, ShlObj;把QControls, QStdCtrls, 前面的Q去掉。换成Controls, StdCtrls,即可。