Procedure Drawborder (handle: thandle; ADC: HDC ); VaR R: trect; canvas: TCanvas; P: tpoint; Begin Canvas: = TCanvas. Create; canvas. Handle: = ADC; P: = Point ( 0 , 0 ); Windows. clienttoscreen (handle, P); windows. getwindowrect (handle, R); p. x: = P. x- R. Left; p. Y: = P. Y- R. Top; windows. getclientrect (handle, R ); /// Exclude areas that do not need to be drawn /// Advantages: 1 Will not draw out the boundaries /// 2 When the area is large, such as the background, there will be no large area color block issues when dragging and zooming /// Excludecliprect (canvas. Handle, p. x, P. Y, R. Right -R. Left + p. x, R. Bottom-R. Top + P. Y); windows. getwindowrect (handle, R); offsetrect (r, -R. Left ,- R. Top ); /// Draw background /// Paintbackground (canvas, R ); /// Clear the cut area selectcliprgn (canvas. handle, 0 ); Canvas. Handle: = 0 ; Canvas. Free; End ;
Eliminate unnecessary painting areas and reduce the number of Painting