Z
zx
Unregistered / Unconfirmed
GUEST, unregistred user!
透明窗口的wm_Panit消息响应怎么处理不好!
一个SDK程序:
program Project1;
uses
Windows,
Messages;
const
AppName='Window1';
function WindowProc(Window:HWnd;
AMessage,WParam,LParam:Longint)
:Longint;stdcall;export;
var
PRgn: hRgn;
lpPaint aintStruct;
DC1,DC2 :HDC ;
begin
WindowProc:=0;
case AMessage of
wm_Destroy: begin
PostQuitMessage(0);
Exit;
end;
wm_Paint : begin
//这儿应该怎么写才好呢? 移动窗口是保持背景透明!
//每次只有最小化,最大化以后才刷新。
{ DC1:=begin
Paint(window,lpPaint);
PRgn:=CreateRoundRectRgn(10,10,100,100,10,10);
InvalidateRgn(window,PRgn,false);
UpdateWindow(window);
EndPaint(window,lpPaint);}
end;
end;
windowProc:=DefWindowProc(Window,AMessage,WParam,LParam);
end;
function WinRegister:Boolean;
var
WndClass:TWndClass;
begin
WndClass.style:=0;
WndClass.lpfnWndProc:=@WindowProc;
WndClass.cbClsExtra:=0;
WndClass.cbWndExtra:=0;
WndClass.hInstance:=Hinstance;
WndClass.hIcon:=LoadIcon(0,idi_winlogo);
WndClass.hCursor:=LoadCursor(0,idc_arrow);
WndClass.hbrBackground:=0;//HBrush(Color_Window);这样透明...
WndClass.lpszMenuName:=nil;
WndClass.lpszClassName:=AppName;
Result:= ( RegisterClass(WndClass)<>0 );
end;
function WinCreate:HWnd;
var
hWindow: HWnd;
begin
hWindow:= CreateWindow(AppName, 'object pascal window', ws_OverlappedWindow,
cw_UseDefault,cw_UseDefault,cw_UseDefault,cw_UseDefault,
0,0,HInstance,nil);
if hWindow<>0 then
begin
ShowWindow(hWindow,CmdShow);
UpdateWindow(hWindow);
end;
Result:= hWindow;
end;
var
AMessage: TMsg;
hWindow: HWnd;
begin
if not WinRegister then
begin
MessageBox(0,'Registerfailed',nil,mb_OK);
Exit;
end;
hWindow:=WinCreate;
if hWindow=0 then
begin
MessageBox(0,'window create failed',nil,mb_OK);
Exit;
end;
while GetMessage(AMessage,0,0,0)do
begin
TranslateMessage(AMessage);
DispatchMessage(AMessage);
end;
Halt(Amessage.WParam);
end.
一个SDK程序:
program Project1;
uses
Windows,
Messages;
const
AppName='Window1';
function WindowProc(Window:HWnd;
AMessage,WParam,LParam:Longint)
:Longint;stdcall;export;
var
PRgn: hRgn;
lpPaint aintStruct;
DC1,DC2 :HDC ;
begin
WindowProc:=0;
case AMessage of
wm_Destroy: begin
PostQuitMessage(0);
Exit;
end;
wm_Paint : begin
//这儿应该怎么写才好呢? 移动窗口是保持背景透明!
//每次只有最小化,最大化以后才刷新。
{ DC1:=begin
Paint(window,lpPaint);
PRgn:=CreateRoundRectRgn(10,10,100,100,10,10);
InvalidateRgn(window,PRgn,false);
UpdateWindow(window);
EndPaint(window,lpPaint);}
end;
end;
windowProc:=DefWindowProc(Window,AMessage,WParam,LParam);
end;
function WinRegister:Boolean;
var
WndClass:TWndClass;
begin
WndClass.style:=0;
WndClass.lpfnWndProc:=@WindowProc;
WndClass.cbClsExtra:=0;
WndClass.cbWndExtra:=0;
WndClass.hInstance:=Hinstance;
WndClass.hIcon:=LoadIcon(0,idi_winlogo);
WndClass.hCursor:=LoadCursor(0,idc_arrow);
WndClass.hbrBackground:=0;//HBrush(Color_Window);这样透明...
WndClass.lpszMenuName:=nil;
WndClass.lpszClassName:=AppName;
Result:= ( RegisterClass(WndClass)<>0 );
end;
function WinCreate:HWnd;
var
hWindow: HWnd;
begin
hWindow:= CreateWindow(AppName, 'object pascal window', ws_OverlappedWindow,
cw_UseDefault,cw_UseDefault,cw_UseDefault,cw_UseDefault,
0,0,HInstance,nil);
if hWindow<>0 then
begin
ShowWindow(hWindow,CmdShow);
UpdateWindow(hWindow);
end;
Result:= hWindow;
end;
var
AMessage: TMsg;
hWindow: HWnd;
begin
if not WinRegister then
begin
MessageBox(0,'Registerfailed',nil,mb_OK);
Exit;
end;
hWindow:=WinCreate;
if hWindow=0 then
begin
MessageBox(0,'window create failed',nil,mb_OK);
Exit;
end;
while GetMessage(AMessage,0,0,0)do
begin
TranslateMessage(AMessage);
DispatchMessage(AMessage);
end;
Halt(Amessage.WParam);
end.