Drawing & Animation II[6]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 sonicdater 的 blog

a device context created with the createcompatibledc must be deleted by calling the deletedc api function and the bitmap handle returned from loadimage much be deleted with the deleteobject api. so let's create a reusable function for this called deletegenerateddc. this function takes two arguments, a dc to be deleted and the bitmap handle for the corresponding dc. 

 

private function deletegenerateddc(hbitmap as long, memdc as long) as long

deletegenerateddc = deletedc(memdc)
deleteobject hbitmap

end function


run the sample project. press the load bitmap button. the bitmaps are now loaded and ready for use. we use the usual bltbit function to blit them from the memory context and into the device context of the form. press the draw the sprite button, and observe how the sprite is blitted transparently onto the form.

one word of advice when using this scheme to create a memory device context: be observant of the scope of the variables which you store the device contexts in. if the variable goes out of scope, and you have not deleted it with the deletedc function, you抣l start losing resources. so always delete the created device contexts to be on the safe side.

本文关键:Drawing & Animation
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top