Image1.LoadFromFile(ExtractFilePath(Application.ExeName)+'\图片名');
解决方案 »
- 弱弱的问下有没有delphi重构的例子或者资料
- 软件使用后提示连接失败!
- 又出错了,怎么做转换啊![DCC Error] download.dpr(19): E2003 Undeclared identifier: 'HKEY_LOCAL_MACHINE'
- 大家帮我看看,触发器问题,怎么在触发器中查寻返回数据?
- 奇怪错误
- 我该选择delphi吗?不是在比较语言!!!
- 多线程 程序退出报错 :system error:code:5 拒绝访问 -附代码
- 如何用Sql 来更新记录集 啊?各位请帮忙!
- 太郁闷了。。。有关mts的调试
- 请报表高手门指教:有关报表的问题?(急急急)
- 怎样让应用程序收到某个消息以后把自己提到最前面来?
- 请教如何控制WORD文档中表格各个列(columns)的宽度(急!)
我的也是这样写的。我改变了图片后,再重新执行这个句子时。原来的图片还在。不知如何重画一次。
var
CR: TRect;
begin
GetWindowRect(ClientHandle, CR);
StretchBlt(FDrawDC, 0, 0, CR.Right, CR.Bottom,
imgMain.Picture.Bitmap.Canvas.Handle, 0, 0,
imgMain.Picture.Width, imgMain.Picture.Height, SRCCOPY);
end;procedure TMainFrm.DrawCentered;//局中
var
CR: TRect;
begin
GetWindowRect(ClientHandle, CR);
with imgMain do
BitBlt(FDrawDC, ((CR.Right - CR.Left) - Picture.Width) div 2,
((CR.Bottom - CR.Top) - Picture.Height) div 2,
Picture.Graphic.Width, Picture.Graphic.Height,
Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
end;procedure TMainFrm.DrawTiled;//平铺
var
Row, Col: Integer;
CR, IR: TRect;
NumRows, NumCols: INteger;begin
GetWindowRect(ClientHandle, CR);
IR := imgMain.ClientRect;
NumRows := CR.Bottom div IR.Bottom;
NumCols := CR.Right div IR.Right;
with imgMain do
for Row :=0 to NumRows+1 do
for Col :=0 to NumCols+1 do
BitBlt(FDrawDC, Col*Picture.Width, Row*Picture.Height,
Picture.Width, Picture.Height,
Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
end;procedure TMainFrm.ClientWndProc(var Message: TMessage);
begin
case Message.Msg of
WM_EraseBKGnd:
begin
CallWindowProc(FoldClientProc, ClientHandle, Message.Msg,
Message.WParam, Message.LParam);
FDrawDC := TWMEraseBKGnd(Message).DC;
DrawStretched; //拉伸
//DrawCentered; //居中
//DrawTiled; //平铺
Message.Result := 1;
end;
WM_VSCROLL, WM_HSCROLL:
begin
Message.Result := CallWindowProc(FOldClientProc, CLientHandle,
Message.Msg, Message.WParam, Message.LParam);
InvalidateRect(ClientHandle, nil, True);
end;
else
Message.Result := CallWindowProc(FOldClientProc, CLientHandle,
Message.Msg, Message.WParam, Message.LParam);
end;
end;procedure TMainFrm.FormCreate(Sender: TObject);
begin
FNewClientProc := MakeObjectInstance(ClientWndProc);
FOldClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
SetWindowLong(ClientHandle,GWL_WNDPROC,LongInt(FNewClientProc));
end;重新装入新图片时,运行FormCreate中的代码
loadfromfile()
refrish;