读书人

API函数创建窗体有关问题

发布时间: 2012-03-06 20:47:55 作者: rapoo

API函数创建窗体问题?
var
wnd:HWND;
wc:TWndClass;
begin
wc.style:=CS_HREDRAW or CS_VREDRAW;
wc.lpfnwndproc:=@DefWindowProc;
wc.cbClsExtra:=0;
wc.cbWndExtra:=0;
wc.hInstance:=hInstance;
wc.hIcon:=LoadIcon(0,IDI_QUESTION);
wc.hCursor:=LoadCursor(0,IDC_ARROW);
wc.hbrBackground:=HBRUSH(getStockObject(WHITE_BRUSH));
wc.lpszMenuName:=nil;
wc.lpszClassName:='wc';

RegisterClass(wc);//在这出错了?[Error] Unit1.pas(42): Incompatible types: 'TPersistentClass' and 'tagWNDCLASSA'

wnd:=CreateWindow('newclass','New Form',WS_OVERLAPPEDWINDOW,100,100,300,150,0,0,Hinstance,nil);
SHowWindow(wnd,SW_SHOWNORMAL);
UpdateWindow(wnd);
end;

[解决办法]
RegisterClass(wc);
改成
Windows.RegisterClass(wc);
[解决办法]

Delphi(Pascal) code
var wnd:HWND; wc:TWndClass; begin wc.style:=CS_HREDRAW or CS_VREDRAW; wc.lpfnwndproc:=@DefWindowProc; wc.cbClsExtra:=0; wc.cbWndExtra:=0; wc.hInstance:=hInstance; wc.hIcon:=LoadIcon(0,IDI_QUESTION); wc.hCursor:=LoadCursor(0,IDC_ARROW); wc.hbrBackground:=HBRUSH(getStockObject(WHITE_BRUSH)); wc.lpszMenuName:=nil; wc.lpszClassName:='wc'; Windows.RegisterClass(wc);//在这出错了?[Error] Unit1.pas(42): Incompatible types: 'TPersistentClass' and 'tagWNDCLASSA' //Delphi中的RegisterClass与WIN32API的RegisterClasser不同wnd:=CreateWindow('newclass','New Form',WS_OVERLAPPEDWINDOW,100,100,300,150,0,0,Hinstance,nil); SHowWindow(wnd,SW_SHOWNORMAL); UpdateWindow(wnd); end; 

读书人网 >.NET

热点推荐