首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

MouseWheel事件,鼠标向后滚图像消失,该怎么处理

2012-04-15 
MouseWheel事件,鼠标向后滚图像消失我使用Form的MouseWheel()事件缩放Image1中的图像,鼠标前滚缩小,后滚放

MouseWheel事件,鼠标向后滚图像消失
我使用Form的MouseWheel()事件缩放Image1中的图像,鼠标前滚缩小,后滚放大。但是前滚没问题,后滚一下图像就消失了,这是什么bug?

C/C++ code
else  {  Graphics::TBitmap *bitmap1 = new Graphics::TBitmap();  Graphics::TBitmap *bitmap2 = new Graphics::TBitmap();  bitmap1 -> Assign(Image1 -> Picture -> Bitmap);  Image1 -> ShowHint = true;  Image1 -> Hint = "鼠标滚轮向前滚动缩小Image1中图像, 鼠标滚轮向后滚动放大Image1中图像";  Image1 -> Proportional = true; //锁定缩放图像时的纵横比  if(WheelDelta > 0)  //滚轮上滚图像缩小    {    bitmap2 -> Width = (int)(0.99 * bitmap1 -> Width);    bitmap2 -> Height = (int)(0.99 * bitmap1 -> Height);    SetStretchBltMode(bitmap2 -> Canvas -> Handle, HALFTONE);    StretchBlt(bitmap2 -> Canvas -> Handle,               0,               0,               bitmap2 -> Width,               bitmap2 -> Height,               bitmap1 -> Canvas -> Handle,               0,               0,               bitmap1 -> Width,               bitmap1 -> Height,               SRCCOPY);    }  else     //放大    {    bitmap2 -> Width = 1.01 * bitmap1 -> Width;    bitmap2 -> Width = 1.01 * bitmap1 -> Height;    SetStretchBltMode(bitmap2 -> Canvas -> Handle, HALFTONE);    StretchBlt(bitmap2 -> Canvas -> Handle,               0,               0,               bitmap2 -> Width,               bitmap2 -> Height,               bitmap1 -> Canvas -> Handle,               0,               0,               bitmap1 -> Width,               bitmap1 -> Height,               SRCCOPY);    }  Image1 -> Picture -> Bitmap = bitmap2;  Image1 -> Refresh();  w = Image1 -> Width;  h = Image1 -> Height;  StatusBar1 -> Panels -> Items[2] -> Text = "图像尺寸:" + h + "x" + w + " pixel";  //状态栏更改缩放后的尺寸  delete bitmap1;  delete bitmap2;  }


[解决办法]
换号发。分别写到MouseWheelDown和MouseWheelUp事件中就不会出现这种现象。

热点排行