Visual Basic中實現帶預覽的對話框

發表于:2007-05-25來源:作者:點擊數: 標簽:預覽對話框visual實現basic
用戶在圖片框中選擇圖片時,希望預先對圖片的輪廓及大小有初步了解,但是 VB 的通用對話框沒有預覽的功能,為此需要定制一個自定義對話框。我們可以通過image控件加入窗體中來實現其功能。 程序示例: 程序功能說明: 在窗體的file1中選擇一個圖片文件,點選
 用戶在圖片框中選擇圖片時,希望預先對圖片的輪廓及大小有初步了解,但是VB的通用對話框沒有預覽的功能,為此需要定制一個自定義對話框。我們可以通過image控件加入窗體中來實現其功能。

   程序示例:

   程序功能說明:

   在窗體的file1中選擇一個圖片文件,點選“預覽”復選框,image控件就顯示相應的圖片,label1就顯示該圖片的大小。

   新建一個工程,加入以下控件:

   控件 名稱 屬性
   form form1 borderstyle=3
   (vbsizedouble)
   caption=“圖片預覽對話框"
   drivelistbox drive1
   dirlistbox dir1
   filelistbox file1 pattern=“*.bmp;
   *.jpg;*.gif"
   image image1 stretch=true
   checkbox chk value=“預覽"
   commandbutton cmd1 caption=“確定"
   cmd2 caption=“退出"
   label lab1 caption=“"

   源代碼:

clearcase/" target="_blank" >cccccc" width="90%" align="center" bgcolor="#e7e9e9" border="1">
'declare
Public filename$
dim sfilename$
Private sub drive1_change()
 dir1.path=drive1.drive
End sub
Private sub dir1_change()
 file1.path=dir1.path
End sub
Private sub cmd1_click()
 filename=sfilename
End sub
Private sub cmd2_click()
 End
End sub
Private sub file1_click()
 dim ssize as long
 if fille1.listcount>0 then
  if right(file1.path,1)<>“\" then
   sfilename=file1.path&“\"&file1.filename
  else
   sfilename=file1.path&file1.filename
  End if
 if chk.checked then
  image1.picture=loadpicture(“")
  image1.picture=loadpicture(sfilename)
  ssize=filelen(sfilename)
  ssize=ssize/1000
  lab1.caption=str(ssize)&“k"
 else
  lab1.caption=“"
  image1.picture=loadpicture(“")
 end if
 end if
End sub

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97