您的位置:程序门 -> .net技术 -> c#



无边框窗体拉伸的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


无边框窗体拉伸的问题
发表于:2007-01-31 16:48:21 楼主
我像拉伸一个无边框的窗体,如果在mousemove事件里面改变窗体大小时,窗体上的图片重绘就抖动的很厉害,所以在mouseup里面执行,想产生一个拖动的虚拟边框来提示用户正在拉伸窗体,这个边框如何实现?
发表于:2007-01-31 16:52:251楼 得分:0
既然是拖动的虚拟边框
还是得在   mousemove   里画矩形
把   form   的   doublebuffer   打开改善一下看看
发表于:2007-02-05 16:11:232楼 得分:0
如果大家装了瑞星杀毒软件,看看它的窗体的拉伸,我就想实现那样的效果
发表于:2007-02-08 17:45:203楼 得分:0
ding
发表于:2007-02-08 17:51:094楼 得分:0
这个边框的画法,可以使用如下的方法:
controlpaint.drawreversibleframe

controlpaint.drawreversibleframe   方法
在屏幕上的指定边界内,按指定背景色绘制处于指定状态的可逆框架。
发表于:2007-02-08 17:51:465楼 得分:0
msdn上的示例代码:
//   the   following   three   methods   will   draw   a   rectangle   and   allow  
//   the   user   to   use   the   mouse   to   resize   the   rectangle.     if   the  
//   rectangle   intersects   a   control 's   client   rectangle,   the  
//   control 's   color   will   change.

bool   isdrag   =   false;
rectangle   therectangle   =   new   rectangle
        (new   point(0,   0),   new   size(0,   0));
point   startpoint;

private   void   form1_mousedown(object   sender,  
        system.windows.forms.mouseeventargs   e)
{

        //   set   the   isdrag   variable   to   true   and   get   the   starting   point  
        //   by   using   the   pointtoscreen   method   to   convert   form  
        //   coordinates   to   screen   coordinates.
        if   (e.button==mousebuttons.left)
        {
                isdrag   =   true;
        }

        control   control   =   (control)   sender;

        //   calculate   the   startpoint   by   using   the   pointtoscreen  
        //   method.
        startpoint   =   control.pointtoscreen(new   point(e.x,   e.y));
}

private   void   form1_mousemove(object   sender,  
        system.windows.forms.mouseeventargs   e)
{

        //   if   the   mouse   is   being   dragged,  
        //   undraw   and   redraw   the   rectangle   as   the   mouse   moves.
        if   (isdrag)

                //   hide   the   previous   rectangle   by   calling   the  
                //   drawreversibleframe   method   with   the   same   parameters.
        {
                controlpaint.drawreversibleframe(therectangle,  
                        this.backcolor,   framestyle.dashed);

                //   calculate   the   endpoint   and   dimensions   for   the   new  
                //   rectangle,   again   using   the   pointtoscreen   method.
                point   endpoint   =   this.pointtoscreen(new   point(e.x,   e.y));
                int   width   =   endpoint.x-startpoint.x;
                int   height   =   endpoint.y-startpoint.y;
                therectangle   =   new   rectangle(startpoint.x,  
                        startpoint.y,   width,   height);

                //   draw   the   new   rectangle   by   calling   drawreversibleframe
                //   again.    
                controlpaint.drawreversibleframe(therectangle,  
                        this.backcolor,   framestyle.dashed);
        }
}

private   void   form1_mouseup(object   sender,  
        system.windows.forms.mouseeventargs   e)
{

        //   if   the   mouseup   event   occurs,   the   user   is   not   dragging.
        isdrag   =   false;

        //   draw   the   rectangle   to   be   evaluated.   set   a   dashed   frame   style  
        //   using   the   framestyle   enumeration.
        controlpaint.drawreversibleframe(therectangle,  
                this.backcolor,   framestyle.dashed);

        //   find   out   which   controls   intersect   the   rectangle   and  
        //   change   their   color.   the   method   uses   the   rectangletoscreen    
        //   method   to   convert   the   control 's   client   coordinates  
        //   to   screen   coordinates.
        rectangle   controlrectangle;
        for(int   i   =   0;   i   <   controls.count;   i++)
        {
                controlrectangle   =   controls[i].rectangletoscreen
                        (controls[i].clientrectangle);
                if   (controlrectangle.intersectswith(therectangle))
                {
                        controls[i].backcolor   =   color.burlywood;
                }
        }

        //   reset   the   rectangle.
        therectangle   =   new   rectangle(0,   0,   0,   0);
}

发表于:2007-02-08 20:17:076楼 得分:0
学习
发表于:2007-02-09 08:08:097楼 得分:0
up


快速检索

最新资讯
热门点击