各位大侠,小弟手头有一段代码,可不明其理,故请大家伸出援助之手,帮小第一把。不知能不能给小弟加加注释,说说函数用法?不胜感激!
代码如下:
应用于mdi程序中,这段代码是主窗口中的。
unit fm_main;
...
...
private
FClientInstance,fPrevClientProc: TFarProc;
PROCEDURE ClientWndProc(VAR Message: TMessage);
...
implementation
procedure Tmainfm.clientwndproc(var message: tmessage);
VAR
MyDC : hDC;
cr:TRect;
begin
with Message do
begin
case Msg of
WM_ERASEBKGND:
begin
MyDC := TWMEraseBkGnd(Message).DC;
getwindowrect(clienthandle,cr);
stretchblt(mydc,0,0,cr.right,cr.bottom-45,
Image1.Picture.Bitmap.Canvas.Handle,
0,0,Image1.Picture.Width,Image1.Picture.Height,
SRCCOPY);
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc,
ClientHandle,
Msg,
wParam,
lParam);
end;
end;
end;procedure Tmainfm.FormCreate(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientProc := Pointer(GetWindowLong(ClientHandle,
GWL_WNDPROC));
SetWindowLong(ClientHandle,
GWL_WNDPROC,
LongInt(FClientInstance));
end;
代码如下:
应用于mdi程序中,这段代码是主窗口中的。
unit fm_main;
...
...
private
FClientInstance,fPrevClientProc: TFarProc;
PROCEDURE ClientWndProc(VAR Message: TMessage);
...
implementation
procedure Tmainfm.clientwndproc(var message: tmessage);
VAR
MyDC : hDC;
cr:TRect;
begin
with Message do
begin
case Msg of
WM_ERASEBKGND:
begin
MyDC := TWMEraseBkGnd(Message).DC;
getwindowrect(clienthandle,cr);
stretchblt(mydc,0,0,cr.right,cr.bottom-45,
Image1.Picture.Bitmap.Canvas.Handle,
0,0,Image1.Picture.Width,Image1.Picture.Height,
SRCCOPY);
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc,
ClientHandle,
Msg,
wParam,
lParam);
end;
end;
end;procedure Tmainfm.FormCreate(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientProc := Pointer(GetWindowLong(ClientHandle,
GWL_WNDPROC));
SetWindowLong(ClientHandle,
GWL_WNDPROC,
LongInt(FClientInstance));
end;
代码如下:
应用于mdi程序中,这段代码是主窗口中的。
首先这个程序是在MDI主窗口画背景的
unit fm_main;
...
...
private
FClientInstance,fPrevClientProc: TFarProc;
PROCEDURE ClientWndProc(VAR Message: TMessage);
...
implementation
procedure Tmainfm.clientwndproc(var message: tmessage);//这是被替换的MDI客户区的窗口函数
VAR
MyDC : hDC;
cr:TRect;
begin
with Message do
begin
case Msg of
WM_ERASEBKGND://如果是删除背景消息则
begin
MyDC := TWMEraseBkGnd(Message).DC;
getwindowrect(clienthandle,cr);
stretchblt(mydc,0,0,cr.right,cr.bottom-45,
Image1.Picture.Bitmap.Canvas.Handle,
0,0,Image1.Picture.Width,Image1.Picture.Height,
SRCCOPY);//画背景图部分到清楚部分刷新
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc, //否则调用原来的窗口处理函数
ClientHandle,
Msg,
wParam,
lParam);
end;
end;
end;procedure Tmainfm.FormCreate(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);//把一个对象过程转换成窗口函数
FPrevClientProc := Pointer(GetWindowLong(ClientHandle,//保存旧窗口函数
GWL_WNDPROC));
SetWindowLong(ClientHandle,
GWL_WNDPROC,
LongInt(FClientInstance));//替换窗口函数
end;
还有50分,有兴趣的去
http://expert.csdn.net/Expert/topic/1812/1812240.xml?temp=.9647638