工程含有1个MDI主窗口和2个子窗口。唯一需要注意的是,每个窗体都有ClientHandle,但只有当自己是MDI主窗体的情况下才有值,否则等于0。

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, jpeg, Menus; type
TForm1 = class(TForm)
Image1: TImage;
MainMenu1: TMainMenu;
N1: TMenuItem;
dd1: TMenuItem;
procedure FormShow(Sender: TObject);
private
FClientInstance : TFarProc;
FPrevClientProc : TFarProc;
Procedure ClientWndProc(Var Message: TMessage); // 自定义的窗口过程
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.DFM}
procedure TForm1.ClientWndProc(var Message: TMessage);
var
Dc : hDC;
Row : Integer;
Col : Integer;
begin
with Message do
case Msg of
WM_ERASEBKGND
:// 当要重会背景时
begin
Dc :=
TWMEraseBkGnd(Message).DC; // 消息自带DC
// 铺图象
// 计算并会制行和高总共要画的数量。
for Row := to ClientHeight div Image1.Picture.Height do
for Col := to ClientWidth div Image1.Picture.Width do
BitBlt
(Dc,Col * Image1.Picture.Width, Row * Image1.Picture.Height
,Image1.Picture.Width, Image1.Picture.Height
,Image1.Picture.Bitmap.Canvas.Handle, , , SRCCOPY);
Result := ; // 到此结束,并不继续传递
end;
else // 传递其他消息
Result := CallWindowProc(FPrevClientProc,ClientHandle,Msg,wParam,lParam);
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);//将自定义过程的地址入口存入PClientInstance中
FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));//记录消息位置
SetWindowLong(ClientHandle,GWL_WNDPROC,LongInt(FClientInstance));//重新载入窗口的消息并继续处理。
end; end.

另外还有: Delphi非应用程序主窗口创建MDI (把原来的主窗体都给换掉了并且关闭掉了,牛!)
http://blog.csdn.net/suiyunonghen/article/details/4209306

另一个通过修改窗口函数达到目的的例子(禁止用键盘左右箭头,去切换PageControl页签):

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls; type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure EditWndProc(var Message: TMessage);
public
{ Public declarations }
end; var
Form1: TForm1;
EditHandle: THandle;
EditPointer:Pointer; implementation {$R *.dfm} procedure TForm1.EditWndProc(var Message: TMessage);
begin
case Message.Msg of
WM_KEYDOWN : //如果是按键消息
begin
if Message.WParam in [,] then //如果是左右箭头
Exit;
end;
end;
Message.Result:=CallWindowProc(EditPointer, EditHandle, Message.Msg, Message.WParam, Message.LParam);
end; procedure TForm1.FormCreate(Sender: TObject);
Var P:Pointer;
begin
EditHandle:=PageControl1.Handle;
if EditHandle<> then
begin
EditPointer := Pointer(GetWindowLong(EditHandle, GWL_WNDPROC));
P := Classes.MakeObjectInstance(EditWndProc);
SetWindowLong(EditHandle, GWL_WNDPROC, Longint(P));
end;
end;

 我的理解:不能通过覆盖TPageControl的WndProc来达到目的,否则WndProc这个函数写在哪里呢(因为我没有重新定义一个类)?只能通过替换TPageControl的WndProc来达到目的。

最新文章

  1. Wannafly Union Goodbye 2016
  2. Struts2拦截器的使用 (详解)
  3. DHTMLX-第一弹
  4. 03_Java面向对象特征: 封装性
  5. jquery cdn加速点
  6. gulp使用外部配置文件
  7. Access
  8. http请求方式和状态管理
  9. Objective-C学习篇05—Foundation框架简介
  10. MFC自创建类了解
  11. SNMP_802.1
  12. 关于Windows Boot Manager、Bootmgfw.efi、Bootx64.efi、bcdboot.exe 的详解
  13. Eclipse安装JD-Eclipse反编译插件成功看源码
  14. CentOS 6.*通过yum安装 MySQL-5.5
  15. Java中的4个并发工具类 CountDownLatch CyclicBarrier Semaphore Exchanger
  16. 脚本监控web服务器,工作不正常发邮件提醒
  17. T-SQL ORDER BY子句 排序方式
  18. linux的基本操作(mysql 的基本操作)
  19. proxy config (firefox config)
  20. AJPFX:外汇的点差和点值

热门文章

  1. 【共享单车】—— React后台管理系统开发手记:权限设置和菜单调整(未完)
  2. PHP empty()函数说明---用了N遍了就是记不住
  3. ECSHOP去版权(删除ECSHOP所有标识)
  4. running android lint has encountered a
  5. JAVA经常使用集合框架使用方法具体解释基础篇二之Colletion子接口List
  6. PHP SPL库
  7. Laravel请求/Cookies/文件上传
  8. DB2 锁问题分析与解释
  9. maven nexus myeclipse 学习
  10. select * from A.B.C.D sqlserver 中 select * from .Literary_PuDong.dbo.Users