为何不能释放资源?看看这段代码
请指点
var
ps: PAINTSTRUCT;
DC, drawDC1, drawDC2: HDC;
drawBMP1, drawBMP2, oldBMP1, oldBMP2: HBitmap;
iWidth, iHeight, ibmpWidth, ibmpHeight, I, J, K, W: integer;
begin
FInterDrawing := True;
try
BeginPaint(Self.Handle, Ps);
try DC := Ps.hdc;
iWidth := ClientWidth;
iHeight := ClientHeight;
drawDC1 := CreateCompatibleDC(DC);
drawBMP1 := CreateCompatibleBitmap(DC, iWidth, iHeight);
oldBMP1 := SelectObject(drawDC1, drawBMP1); SendMessage(Handle, WM_PAINT, drawDC1, 0); drawDC2 := CreateCompatibleDC(DC);
drawBMP2 := CreateCompatibleBitmap(DC, iWidth, iHeight);
oldBMP2 := SelectObject(drawDC2, drawBMP2); iBmpWidth := Background.Width;
iBmpHeight := Background.Height;
K := ClientWidth div iBmpWidth;
W := ClientHeight div iBmpHeight;
for I := 0 to K do
for J := 0 to W do
BitBlt(drawDC2, I * iBmpWidth, J * iBmpHeight, iBmpWidth, iBmpHeight, Background.Canvas.Handle, 0, 0, SRCCOPY); TransparentBlt(drawDC2, 0, 0, iWidth, iHeight, drawDC1, 0, 0, iWidth, iHeight, ColorToRGB(clWindow));
BitBlt(DC, 0, 0, iWidth, iHeight, drawDC2, 0, 0, SRCCOPY); SelectObject(drawDC1, oldBMP1);
DeleteObject(drawBMP1); SelectObject(drawDC2, oldBMP2); DeleteObject(drawBMP2); finally
ReleaseDC(self.Handle,DC);
DeleteDC(drawDC1);
DeleteDC(drawDC2); EndPaint(Handle, Ps);
end; finally
FInterDrawing := False;
end;
请指点
var
ps: PAINTSTRUCT;
DC, drawDC1, drawDC2: HDC;
drawBMP1, drawBMP2, oldBMP1, oldBMP2: HBitmap;
iWidth, iHeight, ibmpWidth, ibmpHeight, I, J, K, W: integer;
begin
FInterDrawing := True;
try
BeginPaint(Self.Handle, Ps);
try DC := Ps.hdc;
iWidth := ClientWidth;
iHeight := ClientHeight;
drawDC1 := CreateCompatibleDC(DC);
drawBMP1 := CreateCompatibleBitmap(DC, iWidth, iHeight);
oldBMP1 := SelectObject(drawDC1, drawBMP1); SendMessage(Handle, WM_PAINT, drawDC1, 0); drawDC2 := CreateCompatibleDC(DC);
drawBMP2 := CreateCompatibleBitmap(DC, iWidth, iHeight);
oldBMP2 := SelectObject(drawDC2, drawBMP2); iBmpWidth := Background.Width;
iBmpHeight := Background.Height;
K := ClientWidth div iBmpWidth;
W := ClientHeight div iBmpHeight;
for I := 0 to K do
for J := 0 to W do
BitBlt(drawDC2, I * iBmpWidth, J * iBmpHeight, iBmpWidth, iBmpHeight, Background.Canvas.Handle, 0, 0, SRCCOPY); TransparentBlt(drawDC2, 0, 0, iWidth, iHeight, drawDC1, 0, 0, iWidth, iHeight, ColorToRGB(clWindow));
BitBlt(DC, 0, 0, iWidth, iHeight, drawDC2, 0, 0, SRCCOPY); SelectObject(drawDC1, oldBMP1);
DeleteObject(drawBMP1); SelectObject(drawDC2, oldBMP2); DeleteObject(drawBMP2); finally
ReleaseDC(self.Handle,DC);
DeleteDC(drawDC1);
DeleteDC(drawDC2); EndPaint(Handle, Ps);
end; finally
FInterDrawing := False;
end;
解决方案 »
- var Locateparams:Tlocateparams; 声明这一句需在程序手动use 什么单元??
- ★★fastreport中怎样得到一行的合计值★★
- ★书上的一个例子,有源代码,不能运行,请看看错在哪?谢谢!
- Operator not applicable to this operand type
- 如何對一類的對象屬性賦值
- 如何正确得到.scr文件名的有趣问题
- 请大家说说什么情况下需要创建触发器和存储过程。
- 我还是一个菜鸟,有两个简单的问题,劳烦各位兄弟给看一下,谢谢了
- 难道是Delphi的Bug?(WebBrowser的问题)
- Who can tell me how to?
- 如何控制TListView中的内容的变化!!!
- 多个控件显示的问题
//ReleaseDC(self.Handle,DC);这句有问题,去掉
DeleteDC(drawDC1);
DeleteDC(drawDC2);