CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

图片大小问题,急急!

楼主xiangshi(湘诗)2004-01-04 16:31:53 在 VB / 基础类 提问

我用的是vb-mdi-form   ,在picture里放一幅图片,我要怎么样才能使小图片能随窗体的大小而改变。求救,谢谢! 问题点数:100、回复次数:9Top

1 楼liuyanghe111(yang)回复于 2004-01-04 16:43:46 得分 10

可以先计算缩放比例,然后用stretchblt函数缩放图片Top

2 楼rainstormmaster(暴风雨 v2.0)回复于 2004-01-04 16:46:31 得分 10

处理窗体的resize事件Top

3 楼xiangshi(湘诗)回复于 2004-01-05 14:31:50 得分 0

有没有代码,给一段,谢谢!Top

4 楼3661512(.Net)回复于 2004-01-05 14:36:13 得分 30

try   it  
   
  Option   Explicit  
   
  Private   Sub   Form_Load()  
  Picture1.AutoSize   =   True  
  End   Sub  
   
  Private   Sub   Form_Resize()  
  Picture1.Move   Form1.Left,   Form1.Top,   Form1.Width,   Form1.Height  
  End   Sub  
   
  Top

5 楼sunnychild(sunnychild)回复于 2004-01-05 15:05:57 得分 20

pic.PaintPicture   pic.Picture,   0,   0,   Me.Width,   Me.HeightTop

6 楼lk_cool(Loken _ 超级无敌小地主)回复于 2004-01-05 18:41:54 得分 30

借用别人给我的代码:  
  Option   Explicit  
   
  Private   Declare   Function   StretchBlt   Lib   "gdi32"   (ByVal   hDC   As   Long,   ByVal   x   As   Long,   ByVal   y   As   Long,   ByVal   nWidth   As   Long,   ByVal   nHeight   As   Long,   ByVal   hSrcDC   As   Long,   ByVal   xSrc   As   Long,   ByVal   ySrc   As   Long,   ByVal   nSrcWidth   As   Long,   ByVal   nSrcHeight   As   Long,   ByVal   dwRop   As   Long)   As   Long  
  Private   Declare   Function   BitBlt   Lib   "gdi32"   (ByVal   hDestDC   As   Long,   ByVal   x   As   Long,   ByVal   y   As   Long,   ByVal   nWidth   As   Long,   ByVal   nHeight   As   Long,   ByVal   hSrcDC   As   Long,   ByVal   xSrc   As   Long,   ByVal   ySrc   As   Long,   ByVal   dwRop   As   Long)   As   Long  
   
  Dim   intPicturePos   As   Integer  
   
  Private   Sub   PaintPicInCenter()  
          With   picTmp  
                  .Cls  
                  Set   .Picture   =   Nothing  
                  .Height   =   Me.ScaleHeight   /   Screen.TwipsPerPixelY  
                  .Width   =   Me.ScaleWidth   /   Screen.TwipsPerPixelX  
                  BitBlt   .hDC,   (.ScaleWidth   -   picBack.ScaleWidth)   /   2,   (.ScaleHeight   -   picBack.ScaleHeight)   /   2,   picBack.ScaleWidth,   picBack.ScaleHeight,   picBack.hDC,   0,   0,   vbSrcCopy  
                  .Refresh  
                  Set   .Picture   =   .Image  
                  Set   Me.Picture   =   Nothing  
                  Set   Me.Picture   =   .Picture  
                  Me.Visible   =   False  
                  Me.Visible   =   True  
          End   With  
  End   Sub  
   
  Private   Sub   PaintPicFullSize()  
          With   picTmp  
                  .Cls  
                  Set   .Picture   =   Nothing  
                  .Height   =   Me.ScaleHeight   /   Screen.TwipsPerPixelY  
                  .Width   =   Me.ScaleWidth   /   Screen.TwipsPerPixelX  
                   
                  StretchBlt   .hDC,   0,   0,   .ScaleWidth,   .ScaleHeight,   picBack.hDC,   0,   0,   picBack.ScaleWidth,   picBack.ScaleHeight,   vbSrcCopy  
                  .Refresh  
                  Set   .Picture   =   .Image  
                  Set   Me.Picture   =   Nothing  
                  Set   Me.Picture   =   .Picture  
                  Me.Visible   =   False  
                  Me.Visible   =   True  
          End   With  
  End   Sub  
   
  Private   Sub   MDIForm_Load()  
          Form1.Width   =   4000  
          Form1.Height   =   3000  
          Form1.Show  
  End   Sub  
   
  Public   Property   Let   PicturePos(ByVal   intPos   As   Integer)  
          If   intPicturePos   <>   intPos   Then  
                  intPicturePos   =   intPos  
                  Call   MDIForm_Resize  
          End   If  
  End   Property  
   
  Public   Property   Get   PicturePos()   As   Integer  
          PicturePos   =   intPicturePos  
  End   Property  
   
  Private   Sub   MDIForm_Resize()  
          If   Me.WindowState   =   1   Then   Exit   Sub  
          If   intPicturePos   =   0   Then  
                  Call   PaintPicInCenter  
          Else  
                  Call   PaintPicFullSize  
          End   If  
  End   Sub  
   
   
  再设置MDIForm1.PicturePos   =   0  
              MDIForm1.PicturePos   =   1  
   
  我试过,搞定  
   
  Top

7 楼chewinggum(口香糖·个人二五计划第一年)回复于 2004-01-05 19:57:09 得分 0

用不着这么麻烦吧,在picture里面放一个image,用image显示图片  
   
          Image1.Top   =   0  
          Image1.Left   =   0  
          Image1.Width   =   Picture1.Width  
          Image1.Height   =   Picture1.Height  
          Image1.Stretch   =   True  
   
  Top

8 楼chewinggum(口香糖·个人二五计划第一年)回复于 2004-01-05 19:59:49 得分 0

不好意思,没有贴完整,是下面这段代码  
  Private   Sub   Form_Resize()  
          Picture1.Top   =   0  
          Picture1.Left   =   0  
          Picture1.Width   =   Me.Width  
          Picture1.Height   =   Me.Height  
  End   Sub  
   
  Private   Sub   Picture1_Resize()  
          Image1.Top   =   0  
          Image1.Left   =   0  
          Image1.Width   =   Picture1.Width  
          Image1.Height   =   Picture1.Height  
          Image1.Stretch   =   True  
  End   SubTop

9 楼lk_cool(Loken _ 超级无敌小地主)回复于 2004-01-07 11:34:43 得分 0

楼上完全正确:  
  学习了  
  补充:  
  (这样运行没有错误)  
  Private   Sub   MDIForm_Resize()  
   
          Picture1.Top   =   0  
  '         Picture1.Left   =   0  
  '         Picture1.Width   =   Me.Width  
          Picture1.Height   =   Me.Height  
  End   Sub  
   
  Private   Sub   Picture1_Resize()  
          Image1.Top   =   0  
          Image1.Left   =   0  
          Image1.Width   =   Picture1.Width  
          Image1.Height   =   Picture1.Height  
          Image1.Stretch   =   True  
  End   Sub  
  Top

相关问题

  • 我在MSSQLSERVER中存了一个大图片 , 用PHP取出图片时只有4K大小 , 其余部分不见了 , 请问这什么原因 , 急 , 急 , 急。
  • vb+crystal report4.6+win2000+MSSql 自定义纸张大小的问题?急急急急急急急急急急急急急急急
  • 图片大小
  • ----------ASP图片问题!(急!急!!急!!!)----------
  • 图片的显示问题 :急急急!!
  • 图片数据迁移,急急急~~~~
  • 各位老大,小弟有问题求救。!!!!!!!急急急急
  • 怎样调整“客户区”的大小???急,急急急!!!!!
  • 关于文本和图片在数据库中共存的问题(急急急急急急急急!!!!!)
  • 急急~~~~~~~~~~~~~~~~图片问题!!!!!!!!!!

关键词

  • me
  • top
  • picture
  • byval
  • picturepos
  • intpicturepos
  • mdiform
  • 图片
  • resize
  • as long

得分解答快速导航

  • 帖主:xiangshi
  • liuyanghe111
  • rainstormmaster
  • 3661512
  • sunnychild
  • lk_cool

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo