P1,P2为矩形区域的lefttop,bottomright<br>在同一矩形区域,第一下画方框,第二下清除<br>Procedure TForm1.APIDrawFrame(P1,P2:TPoint);<br>var<br> a:LOGBRUSH;<br> TempHandle:Integer;<br> OldHandle,OldHandle1:Integer;<br> K:hdc;<br> BrushHandle:Integer;<br>begin<br> a.lbStyle:=bs_null;<br> TempHandle:=CreatePen(PS_SOLID,1,rgb(255,255,255));<br> k:=GetDc(0);<br> brushhandle:=CreateBrushIndirect(a);<br> OldHandle1:=SelectObject(k,brushhandle);<br> OldHandle:=SelectObject(k,TempHandle);<br> setrop2(k,R2_XORPEN);<br> Rectangle(k,P1.x-1,P1.y-1,P2.x+1,P2.y+1);<br> selectobject(k,oldhandle);<br> selectObject(k,OldHandle1);<br> DeleteObject(temphandle);<br> DeleteObject(brushhandle);<br> ReleaseDc(0,k);<br>end;