经典实例---带底图的MDI窗口

作者在 2011-06-11 09:55:01 发布以下内容

一、创建主菜单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:最小化窗口

图片

图2:最大化窗口

 图片

pb-example | 阅读 1086 次
文章评论,共0条
游客请输入验证码
浏览21766次