奇怪的错误?(50分)

  • 主题发起人 主题发起人 ff_ff
  • 开始时间 开始时间
F

ff_ff

Unregistered / Unconfirmed
GUEST, unregistred user!
var<br> &nbsp;MyMessage : TMsg; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//消息结构<br> &nbsp;WinClass &nbsp;: TWndClass; &nbsp;<br>....<br> With WinClass do<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Style &nbsp; := 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{类风格}<br> &nbsp; &nbsp; &nbsp;lpfnWndProc := @WndProc; &nbsp; {窗口过程}<br> &nbsp; &nbsp; &nbsp;cbClsExtra &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{额外类信息}<br>错误提示<br>[Error] taskbar.dpr(46): Undeclared identifier: 'lpfnWndProc'<br>[Error] taskbar.dpr(47): Undeclared identifier: 'cbClsExtra'<br>[Error] taskbar.dpr(48): Undeclared identifier: 'cbWndExtra'
 
Undeclared identifier?<br><br>什么东东没有use进去,或者根本就没做声明?
 
uses 进去了<br>uses<br>Windows,shellapi;<br>为什么Style没事呢
 
With WinClass do<br>begin<br> &nbsp;Style := 0;<br> &nbsp;lpfnWndProc := @WndProc;<br> &nbsp;cbClsExtra := 0;<br>end;
 
用begin...end将属于with ... do管辖的范围括起来。
 
楼上的兄弟,
 
我括起来了<br> &nbsp; &nbsp;With WinClass do<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Style &nbsp; := 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{类风格}<br> &nbsp; &nbsp; &nbsp;lpfnWndProc := @WndProc; &nbsp; {窗口过程}<br> &nbsp; &nbsp; &nbsp;cbClsExtra &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{额外类信息}<br> &nbsp; &nbsp; &nbsp;cbWndExtra &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{额外窗口信息}<br> &nbsp; &nbsp; &nbsp;hIcon &nbsp; &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{图标}<br> &nbsp; &nbsp; &nbsp;hCursor := 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{光标}<br> &nbsp; &nbsp; &nbsp;hbrBackground := 0; &nbsp; &nbsp; &nbsp; &nbsp;{颜色}<br> &nbsp; &nbsp; &nbsp;lpszMenuName &nbsp;:= nil; &nbsp; &nbsp; &nbsp;{菜单}<br> &nbsp; &nbsp; &nbsp;lpszClassName := ClassName;{类名称}<br> &nbsp; &nbsp; &nbsp;hInstance:=GetModuleHandle(nil);{实例句柄}<br> &nbsp; &nbsp;end;
 
.dpr文件(工程文件)里use进去的东西不多啊,你额外use了点东西进去了吗?<br>它可不象在.pas文件里use进去的东西那么丰富
 
With WinClass do begin<br>...<br>end;<br><br>楼主 你还是没加begin阿
 
program taskbar;(来自于刘麻子的代码)<br><br>{$R taskbar.res}<br><br>uses<br>Windows,shellapi;<br><br>const<br> &nbsp;ClassName &nbsp; &nbsp; &nbsp; = 'LiuMaZi'; //窗体类名<br> &nbsp;WindowsName &nbsp; &nbsp; = 'LoveLiuMazi';//窗体标题<br> &nbsp;WM_COMMAND &nbsp; &nbsp; &nbsp;= $0111; &nbsp;//单击菜单项消息<br> &nbsp;WM_LBUTTONDOWN &nbsp;= $0201; &nbsp;//鼠标左键单击消息<br> &nbsp;WM_TIMER &nbsp; &nbsp; &nbsp; &nbsp;= $0113; &nbsp;//计时器函数<br> &nbsp;WM_KEYFIRST &nbsp; &nbsp; = $0100; &nbsp;//第一个键盘消息<br> &nbsp;WM_KEYLAST &nbsp; &nbsp; &nbsp;= $0108; &nbsp;//最后一个键盘消息<br> &nbsp;WM_MOUSEFIRST &nbsp; = $0200; &nbsp;//第一个鼠标消息<br> &nbsp;WM_MOUSELAST &nbsp; &nbsp;= $020A; &nbsp;//最后一个鼠标消息<br> &nbsp;WM_MyTray &nbsp; &nbsp; &nbsp; = $0800; &nbsp;//自定义消息,用于响应托盘操作<br><br> &nbsp;var<br> &nbsp;MyMessage : TMsg; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//消息结构<br> &nbsp;WinClass &nbsp;: TWndClass; &nbsp; &nbsp; &nbsp; //窗体类结构<br> &nbsp;WinHandle : hWnd; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//窗体句柄<br> &nbsp;PopupMenu : hMenu; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //菜单句柄<br> &nbsp;MousePos &nbsp;: TPoint; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//鼠标位置<br> &nbsp;IconData &nbsp;: TNotifyIconData; //托盘结构<br> &nbsp;Count &nbsp; &nbsp; : integer; &nbsp; &nbsp; &nbsp; &nbsp; //累计经过的时间<br> &nbsp;state &nbsp; &nbsp; : Boolean=True; &nbsp; &nbsp; &nbsp; &nbsp; //当前状态,True为在线,False为离开<br> &nbsp;NextHook &nbsp;: LongWord;<br><br>function WndProc(WinH : hWnd; WinMsg,WParam,LParam : Longint): Integer; StdCall;<br>begin<br>result:=0;<br><br>end;<br><br><br>begin<br><br> &nbsp;if findwindow(Pchar(ClassName),Pchar(WindowsName))&lt;&gt;0 then<br> &nbsp; &nbsp;MessageBox(0,'程序已运行.....^_^ &nbsp;','',MB_OK)<br> &nbsp;else<br> &nbsp;begin<br> &nbsp; &nbsp;With WinClass do<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Style &nbsp; := 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{类风格}<br> &nbsp; &nbsp; &nbsp;lpfnWndProc := @WndProc; &nbsp; {窗口过程}<br> &nbsp; &nbsp; &nbsp;cbClsExtra &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{额外类信息}<br> &nbsp; &nbsp; &nbsp;cbWndExtra &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{额外窗口信息}<br> &nbsp; &nbsp; &nbsp;hIcon &nbsp; &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{图标}<br> &nbsp; &nbsp; &nbsp;hCursor := 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{光标}<br> &nbsp; &nbsp; &nbsp;hbrBackground := 0; &nbsp; &nbsp; &nbsp; &nbsp;{颜色}<br> &nbsp; &nbsp; &nbsp;lpszMenuName &nbsp;:= nil; &nbsp; &nbsp; &nbsp;{菜单}<br> &nbsp; &nbsp; &nbsp;lpszClassName := ClassName;{类名称}<br> &nbsp; &nbsp; &nbsp;hInstance:=GetModuleHandle(nil);{实例句柄}<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;RegisterClass(WinClass);<br> &nbsp;end;<br><br>end.<br>请哪位富翁给我调试一下.<br>谢谢.
 
晕....我这没问题,可惜没有taskbar.res<br><br><br>begin<br><br> &nbsp;if findwindow(Pchar(ClassName),Pchar(WindowsName))&lt;&gt;0 then<br> &nbsp; &nbsp;MessageBox(0,'程序已运行.....^_^ &nbsp;','',MB_OK)<br> &nbsp;else<br> &nbsp;begin<br> &nbsp; &nbsp;With WinClass do<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;Style &nbsp; := 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{类风格}<br> &nbsp; &nbsp; &nbsp;lpfnWndProc := @WndProc; &nbsp; {窗口过程}<br> &nbsp; &nbsp; &nbsp;cbClsExtra &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{额外类信息}<br> &nbsp; &nbsp; &nbsp;cbWndExtra &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{额外窗口信息}<br> &nbsp; &nbsp; &nbsp;hIcon &nbsp; &nbsp;:= 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{图标}<br> &nbsp; &nbsp; &nbsp;hCursor := 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{光标}<br> &nbsp; &nbsp; &nbsp;hbrBackground := 0; &nbsp; &nbsp; &nbsp; &nbsp;{颜色}<br> &nbsp; &nbsp; &nbsp;lpszMenuName &nbsp;:= nil; &nbsp; &nbsp; &nbsp;{菜单}<br> &nbsp; &nbsp; &nbsp;lpszClassName := ClassName;{类名称}<br> &nbsp; &nbsp; &nbsp;hInstance:=GetModuleHandle(nil);{实例句柄}<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;RegisterClass(WinClass);<br> &nbsp;end;<br><br>end.
 
那不是少个begin???...................
 
汗,太菜了.呵呵
 
多人接受答案了。
 
后退
顶部