一个小问题,PLEASE!!!(50分)

  • 主题发起人 主题发起人 tymy
  • 开始时间 开始时间
T

tymy

Unregistered / Unconfirmed
GUEST, unregistred user!
我是一个DELPHI的初学者,我在电脑报上看到一个小程序,是用来控制WINDOWS任务栏的隐藏和显示的。但在编译时遇到了问题,请帮我解决。现附源程序如下:
unit startbar;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,stdctrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
ret:hwnd;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
setwindowpos(ret,0,0,0,0,0,swp_hidewindow);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
setwindowpos(ret,0,0,0,0,0,swp_showwindow);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ret:=findwindow('Shell_trayhwnd',");
end;

end.
 
>> ret:=findwindow('Shell_trayhwnd',");
procedure TForm1.FormCreate(Sender: TObject);
var
wndClass : array[0..50] of Char;
begin
StrPCopy(@wndClass[0], 'Shell_TrayWnd');
ret := FindWindow(@wndClass[0], nil);
end;
 
ret:=findwindow('Shell_trayhwnd',");
将这一句该为:
ret:=findwindow('Shell_trayhwnd',nil);

 
参数是PChar, 如果为空, 要用 nil, 一定不能用 '',
具体什么错呢?
 
另外将:
swp_hidewindow,swp_showwindow --->>sw_hidewindow,sw_showwindow.
 
这句错: ret:=findwindow('Shell_traywnd',");
将这一句该为:
ret:=findwindow('Shell_traywnd',nil
 
编译错是因为他
ret:=findwindow('Shell_trayhwnd',");//这里不能为",该为
ret:=findwindow('Shell_trayhwnd','');
ret:=findwindow('Shell_trayhwnd',nil);都可!
运行错是'Shell_trayhwnd'大小写不对,该为'Shell_TrayWnd'
 
多人接受答案了。
 
后退
顶部