请有什么好方法给多窗体程序的客户区加图片,并把图片设为平铺?望高手指点!!!
解决方案 »
- 请问:TCheckListBox的OnDataObject、OnData、OnDataFind事件怎么用,各个事件的含义?什么时候被触发。
- 诚徵delphi开发工程师(深圳罗湖)
- 想学Dephi,大家给介绍几本好书吧!
- 编辑过后dbedit 不能写入?
- 如何获得网页上元素的焦点??
- 怎么能让MP3文件按指定的速度播放?
- 请问,ttreeview怎么用,如有时间能详细说以下吗?谢谢。
- infopower 3000的问题
- 请问如何使listview中的columns中的Caption所显示的字居中?
- 鼠标移动到菜单自动显示菜单怎么弄。。。。菜单给我弄到ToolBar里了
- 如何的MDI的父窗体中插入图片????????
- 报“SQL语句结束位置缺少分号(;)"的错误,为什么!在线急等
/在主窗体中添加Image1控件//申明private FClientInstance : TFarProc;
FPrevClientProc : TFarProc;
procedure ClientWndProc(var Message: Tmessage);//------------------------------procedure TMainFrm.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;
for Row := 0 to ClientHeight div Image1.Picture.Height do
for Col := 0 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,
0,
0,
SRCCOPY);
Result := 1; end;
else Result := CallWindowProc(FPrevClientProc,
ClientHandle,
Msg,
wParam,
lParam);
end;
end; //FormOnCreate procedure TMainFrm.FormCreate(Sender: Tobject); begin FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientProc := Pointer(GetWindowLong(ClientHandle,GWL_WNDPROC));
SetWindowLong(ClientHandle,GWL_WNDPROC, LongInt(FClientInstance)); end;
AJpeg:TJpegImage;
...
Canvas.Draw(0,0,AJpeg);
for Row := 0 to ClientHeight div Image1.Picture.Height do
for Col := 0 to ClientWidth div Image1.Picture.Width do就出现了除0错误
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FClientInstance,
FPrevClientProc: TFarProc;
procedure ClientWndProc(var Message: TMessage); public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}{ TForm1 }procedure TForm1.ClientWndProc(var Message: TMessage);var
MyDC: hDC;
Ro, Co: Word;
begin
with Message do
case Msg of
WM_ERASEBKGND:
begin
MyDC := TWMEraseBkGnd(Message).DC;
for Ro := 0 to ClientHeight div Image1.Picture.Height do
for Co := 0 to ClientWIDTH div Image1.Picture.Width do
BitBlt(MyDC, Co * Image1.Picture.Width, Ro * Image1.Picture.Height,
Image1.Picture.Width, Image1.Picture.Height,
Image1.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
Result := 1;
end;
else
Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wParam, lParam);
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
FClientInstance := MakeObjectInstance(ClientWndProc);
FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
end;end.