天天看點

經典執行個體---帶底圖的MDI視窗

一、建立主菜單m_main。

二、建立主視窗w_main,并将其屬性Window  Type設定為mdihelp!,将MenuName屬性設定為m_main。

三、建立圖檔視窗w_pic,并在該視窗中放置picture控件,起名為p_1;設定w_pic的屬性,把Window  Type的屬性設定為popup!,選擇visible,其它屬性全部取消。

四、編寫w_pic代碼:

    ⑴、定義執行個體變量(instance variables)

           boolean     isfullscreen

           integer      oldwidth,oldheight

    ⑵、編寫open()事件:

          isfullscreen=true

          oldwidth=p_1.width

          oldheight=p_1.height

    ⑶、編寫resize()事件

         if     isfullscreen   then

               p_1.x=0

               p_1.y=0

               p_1.resize(newwidth,newheight)

         else

               p_1.resize(oldwidth,odlheight)

               integer    ax,ay

               ax=(newwidth-oldwidth)/2

               if    ax<0    then   ax=0

               ay=(newheight-oldheight)/2

               if   ay<0     then   ay=0

               p_1.x=ax

               p_1.y=ay

          end   if 

    ⑷、定義function:   init(string   as_picture,boolean  as_isfullscreen)  return (none)

          參數:

                  access:public            return   type:none                   function name:init  

                  pass  by:value            argument  type:string            argument  name:as_picture

                  pass  by:value            argument  type:boolean        argument  name:as_isfullscreen

         代碼:

                 p_1.originalsize=ture

                 p_1.picturename=as_picture

                 oldheight=p_1.height

                 oldwidth=p_1.width

                 p_1.originalsize=false

                 this.resize(this.width,this.height)

五、編寫w_main代碼:

    ⑴、定義執行個體變量(instance variables)

            w_pic   mdipicture

            string    mdipicturename

            boolean    mdiisfullscreen

    ⑵、定義function:   setpicture()

            參數:

                       access:public              return  type:(none)                    function   name:setpicture

                       pass  by:value             argument  type:string               argument   name:as_picture

                       pass  by:value             argument  type:boolean           argument   name:as_isfullscreent

            代碼:

                       mdipicturename=as_picture

                       mdiisfullscreen=as_isfullscreen

                       if    isvalid(mdipicture)    then

                             mdipicture.init(mdipicturename,mdiisfullscreen)

                             mdipicture.resize(this.width,this.height)

                       end  if

    ⑶、編寫resize()事件:

            if    isvalid(mdipicture) = false    then

                  opensheet(mdipicture,this)

                  mdipicture.init(mdipicturename,mdiisfullscreen)

                  mdipicture.x=0

                  mdipicture.y=0

              end  if

              mdipicture.resize(newwidth,newheight)

六、編寫application的open()事件

        open(w_main)

        w_main.setpicture("back.bmp",true)

圖1:最小化視窗

經典執行個體---帶底圖的MDI視窗

圖2:最大化視窗

經典執行個體---帶底圖的MDI視窗

繼續閱讀