Application.handle是应用程序的句柄,Application.MainForm.Handle是窗体的句柄,当然不同了。
解决方案 »
- 提示:ambiguous overloaded call to StrLIComp,如何修改?
- 如何让SYSTEM权限的进程创建一个当前登录用户的权限的进程?
- 这道题真有这么难吗?300分求答!! richedit1中的图片传到richedit2里为什么是二进制流啊咋不是图片呢?
- 如何调用Dll中用地址传递的参数?
- 怎样判断所查询的记录是否存在?
- 如何控制IE??
- 利用那个函数可以通过汉字找拼音?
- 请问如何在程序中模拟button的按键操作 ?
- 拖放编程问题
- 请问DELPHI有没有一个椭圆型或是别的形状的登陆提示窗体!!
- Intrabob在delphi6中不能用??
- 常见98桌面右下角显示一些自己定义的文字,如何做的?
2.看RegisterClass的声明
function RegisterClass(const lpWndClass: TWndClass): ATOM; stdcall;
这种参数传的其实就是lpWndClass的地址
并且不允许改变
也就相当于CONST WNDCLASS *lpWndClass;
传变量就行了,而你传@WndClass
相当于
function RegisterClass(lpWndClass: ^TWndClass): ATOM; stdcall;
与windows中的RegisterClass的参数类型不符
3.应该好使吧
回家试试
procedure TApplication.CreateHandle;
var
TempClass: TWndClass;
SysMenu: HMenu;
begin
....FHandle就是Application.Handle
FHandle := CreateWindow(WindowClass.lpszClassName, PChar(FTitle),
WS_POPUP or WS_CAPTION or WS_CLIPSIBLINGS or WS_SYSMENU
or WS_MINIMIZEBOX,
GetSystemMetrics(SM_CXSCREEN) div 2,
GetSystemMetrics(SM_CYSCREEN) div 2,
0, 0, 0, 0, HInstance, nil); //呵呵,都为0,你看不到了吧!!!
。。
end;
Delphi帮助对Application的说明为:
///////////////////////////////////
Provides access to the window handle of the main form (window) of the application.
property Handle: HWND;
/////////////////////////////
我想它所说的Window就是上面的那个窗体!
这样吧,不用with, 什么原因我不知道
wc.style := 0;
wc.lpfnwndproc := @wndproc;
wc.cbclsextra := 0;
wc.cbwndextra := 0;
wc.hicon := 0;
wc.hcursor := 0;
wc.hbrbackground :=COLOR_BACKGROUND;//di2001.jpg;
wc.lpszmenuname := nil;
wc.lpszclassname := 'mytrayiconclass';
wc.hinstance := {system.}Hinstance;
另外同意lixiaolei,Application.Handle是一隐藏窗口的句柄
用 SetWindowPos(Application.Handle, 0, 20, 20, 200, 200, SWP_SHOWWINDOW);
可以看到
这么说Application另有一个隐藏的窗体,可能是用来设置消息循环的的吧?而且它与应用程序的主窗体不是同一个,是不是这样呢?应用程序的消息循环不是那个我们第一个创建的窗体Form1,或者那个在project|option里设置的主窗体,而是这个隐藏的窗体,你说对吗?
也非常感谢xzgyb(老达摩),我这就去试试。对了,我用getlasterror看到出错信息号是1407,就是“找不到窗口类”,怎么回事?
你说,看RegisterClass的声明
function RegisterClass(const lpWndClass: TWndClass): ATOM; stdcall;
这种参数传的其实就是lpWndClass的地址。
可参数说明里没有var关键字啊,书上也没看到过啊,你在哪里看到的呢?另外,我在delphi的IDE里调用API函数时,写完函数名再写一个左括弧,IDE会自动提示函数参数信息,这本来挺好的,可是如果我用一个结构(记录)类型的变量作参数的话,IDE就只是显示函数的参数信息,而不会在我的记录型变量的“.”符号右边把记录的域列表显示出来(类类型的变量也是如此),除非我在屏幕别的地方点击一下鼠标,使函数参数信息消失,这时才会显示那个列表,可函数的参数信息又没了,这可怎么办?可以再显示出来吗?VC++里是可以再显示的,不知delphi也可以吗?
看一下帮助,const与var类似,只是const参数不允许改
A constant (const) parameter is like a local constant or read-only variable. Constant parameters are similar to value parameters, except that you can抰 assign a value to a constant parameter within the body of a procedure or function, nor can you pass one as a var parameter to another routine. (But when you pass an object reference as a constant parameter, you can still modify the object抯 properties.)
Using const allows the compiler to optimize code for structured- and string-type parameters. It also provides a safeguard against unintentionally passing a parameter by reference to another routine.Here, for example, is the header for the CompareStr function in the SysUtils unit:function CompareStr(const S1, S2: string): Integer;Because S1 and S2 are not modified in the body of CompareStr, they can be declared as constant parameters.Ctrl+Shift+空格可以在显示出来
一起学习吧
呵呵
我的E_MAIL [email protected],以后请多多指教。
lixiaolei(快乐)
对,但是省去前缀也行。