尝试了一下,但是运行后没有窗口显示,请高手赐教
program API;uses
Windows,Messages;{$R *.res}function WindowMSGProc(hwnd:LongWord;msg:tagMSG;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
begin
case msg.message of
WM_CLOSE:
DestroyWindow(hwnd);
WM_DESTROY:
PostQuitMessage(0);
else
WindowMSGProc:=DefWindowProc(hwnd,msg.message,wParam,lParam);
exit;
end;
WindowMSGProc:=0;
end;var
wndcl:tagWNDCLASSA;
hwnd:LongWord;
msg:tagMSG;
begin
wndcl.style:=CS_HREDRAW or CS_VREDRAW;
wndcl.cbClsExtra:=0;
wndcl.cbWndExtra:=0;
wndcl.hInstance:=hInstance;
wndcl.hbrBackground:=HBRUSH(GetStockObject(WHITE_BRUSH));
wndcl.lpszMenuName:=nil;
wndcl.lpszClassName:='S';
wndcl.lpfnWndProc:=@WindowMSGProc; RegisterClass(wndcl);
hwnd:=CreateWindow(PChar('S'),PChar('ssss'),WS_OVERLAPPEDWINDOW,0,0,100,100,0,HMENU(nil),hInstance,nil);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
while GetMessage(msg,0,0,0) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end.
program API;uses
Windows,Messages;{$R *.res}function WindowMSGProc(hwnd:LongWord;msg:tagMSG;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
begin
case msg.message of
WM_CLOSE:
DestroyWindow(hwnd);
WM_DESTROY:
PostQuitMessage(0);
else
WindowMSGProc:=DefWindowProc(hwnd,msg.message,wParam,lParam);
exit;
end;
WindowMSGProc:=0;
end;var
wndcl:tagWNDCLASSA;
hwnd:LongWord;
msg:tagMSG;
begin
wndcl.style:=CS_HREDRAW or CS_VREDRAW;
wndcl.cbClsExtra:=0;
wndcl.cbWndExtra:=0;
wndcl.hInstance:=hInstance;
wndcl.hbrBackground:=HBRUSH(GetStockObject(WHITE_BRUSH));
wndcl.lpszMenuName:=nil;
wndcl.lpszClassName:='S';
wndcl.lpfnWndProc:=@WindowMSGProc; RegisterClass(wndcl);
hwnd:=CreateWindow(PChar('S'),PChar('ssss'),WS_OVERLAPPEDWINDOW,0,0,100,100,0,HMENU(nil),hInstance,nil);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
while GetMessage(msg,0,0,0) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end.
解决方案 »
- 帮忙看一下,有关线程定义时的问题。
- 高手们,又没有人会做一个中国铁路的地理信息系统,其中包括火车最短路径查询功能,急!!!!
- 字段和索引的真正含义?(解释好的给100分)全给了!
- ??一个关于票据打印的问题??
- 诚邀版主,希望大家支持!
- 相求一个教师排课程序
- 选中控件,按ctrl+c,ctrl+v,怎样复制出相同的控件出来,就象是在设计的时候一样。up有分,谢谢
- 寻找学习Delphi的好资源,电子书或者其他的好资料???
- Delphi6安装Raize4的问题????在线等啊!
- 想做个dbgrid 的 树状结构显示 没有思路 求大佬给点思路
- 初学Delphi﹐求Delphi控件组件用法等﹐谢谢了﹗
- 把一图片改为画笔,用来画线!!!!!! (有代码)请大家帮忙看看应该怎么改好。
Windows,
Messages,
SysUtils;const
AppName = 'ObjectPascalHello';
function WindowProc(Window: HWnd; AMessage: UINT; WParam : WPARAM;
LParam: LPARAM): LRESULT; stdcall; export;
var
dc : hdc;
ps : TPaintStruct;
r : TRect;
begin
WindowProc := 0;
case AMessage of
WM_PAINT :
begin
dc := BeginPaint(Window,ps);
GetClientRect(Window,r);
DrawText(dc,'使用Object Pascal撰写的Native Windows程序',-1,r,DT_SINGLELINE or DT_CENTER or DT_VCENTER);
EndPaint(Window,ps);
Exit;
end;
WM_MOUSEMOVE :
begin
dc := BeginPaint(Window,ps);
GetClientRect(Window,r);
DrawText(dc,'移动了Mouse',-1,r,
DT_SINGLELINE or DT_CENTER or DT_VCENTER);
EndPaint(Window,ps);
Exit;
end;
WM_LBUTTONDOWN :
begin
dc := BeginPaint(Window,ps);
GetClientRect(Window,r);
DrawText(dc,'点击了Mouse',-1,r,
DT_SINGLELINE or DT_CENTER or DT_VCENTER);
EndPaint(Window,ps);
Exit;
end;
wm_Destroy:
begin
PostQuitMessage(0);
Exit;
end;
end;
WindowProc := DefWindowProc(Window, AMessage, WParam, LParam);
end;
{ Register the Window Class }
function WinRegister: Boolean;
var
WindowClass: WndClass;
begin
WindowClass.Style := cs_hRedraw or cs_vRedraw;
WindowClass.lpfnWndProc := TFNWndProc(@WindowProc);
WindowClass.cbClsExtra := 0;
WindowClass.cbWndExtra := 0;
WindowClass.hInstance := system.MainInstance;
WindowClass.hIcon := LoadIcon(0, idi_Application);
WindowClass.hCursor := LoadCursor(0, idc_Arrow);
WindowClass.hbrBackground := GetStockObject(WHITE_BRUSH);
WindowClass.lpszMenuName := nil;
WindowClass.lpszClassName := AppName;
Result := RegisterClass(WindowClass) <> 0;
end;
{ Create the Window Class }
function WinCreate: HWnd;
var
hWindow: HWnd;
begin
hWindow := CreateWindow(AppName, 'Hello world Object Pascal program',ws_OverlappedWindow, cw_UseDefault, cw_UseDefault, cw_UseDefault, cw_UseDefault, 0, 0, system.MainInstance, nil);
if hWindow <> 0 then begin
ShowWindow(hWindow, CmdShow);
ShowWindow(hWindow, SW_SHOW);
UpdateWindow(hWindow);
end;
Result := hWindow;
end;var
AMessage: TMsg;
hWindow: HWnd;
begin
if not WinRegister then begin
MessageBox(0, 'Register failed', nil, mb_Ok);
Exit;
end;
hWindow := WinCreate;
if longint(hWindow) = 0 then begin
MessageBox(0, 'WinCreate failed', nil, mb_Ok);
Exit;
end;
while GetMessage(AMessage, 0, 0, 0) do begin
TranslateMessage(AMessage);
DispatchMessage(AMessage);
end;
Halt(AMessage.wParam);
end.李维的代码,学习下先