vfp圖像框(image)

字號:

一.圖像框:用于顯示圖片文件,以加強程序的界面效果.在圖像框中使用的圖片文件的格式通常為.BMP格式或.JPG格式.
     二.圖像框的常用屬性:如下表
    屬性 作用
    top 距父對象上方的距離
    left 距父對象左方的距離
    height 對象的高度
    width 對象的寬度
    enabled 設(shè)置對象是否可用
    visible 設(shè)置對象是否可見
    picture 指定對象中顯示的圖片
     三.例:設(shè)計一個程序,要求按順序顯示圖片,并可放大,縮小圖片,暫?;蜻B續(xù)顯示圖片.運行界面如圖51
    1.新建表單,添加一個圖像框image1,一個選項按鈕組optiongroup1,一個計時器控件timer1(運行時不可見,可放置于表單的任意位置),三個命令按鈕command1,command2及command3
    2.設(shè)置對象屬性:
    ★ 將三個命令按鈕command1~command3的caption屬性依次設(shè)為"縮小按鈕","放大按鈕"及"結(jié)束按鈕";
    ★將單選按鈕組optiongroup1中的兩個單選按鈕option1和option2的caption依次設(shè)為"連續(xù)顯示"和"暫停顯示"(設(shè)置方法見第五章第九節(jié))
    ★計時器控件timer1的屬性:enabled屬性設(shè)為.T.,interval屬性設(shè)為300(300毫秒即3秒,每3秒顯示一幅圖片,此處如改為100則為每隔1秒顯示一幅圖片)
    3.編寫代碼:
    ★表單的load事件:
    public xh &&定義全局變量,用于存放圖片文件的主名
    xh=1 &&賦初值
    ★單選按鈕"連續(xù)顯示"的click事件代碼(向單選按鈕組中某個單選按鈕添加代碼的方法見第五章第九節(jié)):
    thisform.optiongroup1.option2.value=.f.
    this.value=.t.
    xh=1
    thisform.timer1.enabled=.t.
    ★單選按鈕"暫停顯示"的click事件代碼(向單選按鈕組中某個單選按鈕添加代碼的方法見第五章第九節(jié)):
    thisform.optiongroup1.option2.value=.f.
    this.value=.t.
    thisform.timer1.enabled=.f.
    ★計時器控件timer1的timer1事件:
    xh=xh+1
    if xh>3
    xh=1
    endif
    xh0=alltrim(str(xh))
    xp=xh0+".jpg"
    thisform.image1.picture="&xp"
    ★"縮小按鈕"的click事件010:
    thisform.image1.height=thisform.image1.height/1.2
    thisform.image1.width=thisform.image1.width/1.2
    ★"放大按鈕"的click事件:
    thisform.image1.height=1.2*thisform.image1.height
    thisform.image1.width=1.2*thisform.image1.width
    ★"結(jié)束按鈕"的click事件:
    thisform.timer1.enabled=.f.
    thisform.release
    4.說明:制作此例時,須自己找三個.jpg格式的文件(可從網(wǎng)上下載),將它們分別重命名為1.jpg,2.jpg,和3.jpg,然后將它們復(fù)制到默認目錄中.