DrawGrabHandle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kate Luu

    #1

    DrawGrabHandle

    I did create a custom control, which inherit from picturebox control.
    OnClick method, I have put this line of code:

    Graphics gfx = this.createGrap hics();

    ControlPaint.Dr awGrabHandle(gf x , this.ClientRect angle, true,true );

    this.Invalidate ();

    but nothing happen.



    Does any body know what's the problem? Thanks you so much in advance, and
    I'm very appreciated for your help.





  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: DrawGrabHandle

    Kate,

    If you want to apply any custom painting to a control, you should
    override the OnPaint method, or you should add an event handler to your
    control to handle the Paint event.

    In your paint event, you should custom paint the control to display
    itself as you wish. What you paint, however, would be determined by state
    that is held elsewhere in your control. So, in your case, when you click
    the button, you set a flag indicating that the rectangle will be painted.
    Then, you call invalidate, which will cause a repaint of your control, and
    the rectangle to be painted.

    The reason for all of this is that the painting of a control is handled
    in a loop, just like any other action in the UI. The message pump is called
    over and over. The paint event gets called a number of times, and you have
    to be ready to paint at any time (due to a number of other things that could
    be going on).

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "Kate Luu" <cql90@yahoo.co m> wrote in message
    news:eUsIF3NaDH A.2932@tk2msftn gp13.phx.gbl...[color=blue]
    > I did create a custom control, which inherit from picturebox control.
    > OnClick method, I have put this line of code:
    >
    > Graphics gfx = this.createGrap hics();
    >
    > ControlPaint.Dr awGrabHandle(gf x , this.ClientRect angle, true,true );
    >
    > this.Invalidate ();
    >
    > but nothing happen.
    >
    >
    >
    > Does any body know what's the problem? Thanks you so much in advance, and
    > I'm very appreciated for your help.
    >
    >
    >
    >
    >[/color]


    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: DrawGrabHandle

      Kate,
      Drawing code generally should not be in the OnClick method, it really should
      be in the OnPaint method. As the OnPaint will be called when you Invalidate
      the control, or the system invalidates it. For example, you had another
      window in the fore ground, then came back to this window.

      The argument to OnPaint method has a Graphics property that gives you a
      Graphics object you can use.

      If you call CreateGraphics, be certain to call graphics.Dispos e when you are
      done with it. The graphics passed to the OnPaint is disposed of for you.

      This is you "real" problem.[color=blue]
      > this.Invalidate ();[/color]

      You draw on the control, then you invalidate the displayed area making the
      OnPaint method to be called. If you want to see what was drawn during the
      OnClick event do not invalidate the Window.

      Hope this helps
      Jay

      "Kate Luu" <cql90@yahoo.co m> wrote in message
      news:eUsIF3NaDH A.2932@tk2msftn gp13.phx.gbl...[color=blue]
      > I did create a custom control, which inherit from picturebox control.
      > OnClick method, I have put this line of code:
      >
      > Graphics gfx = this.createGrap hics();
      >
      > ControlPaint.Dr awGrabHandle(gf x , this.ClientRect angle, true,true );
      >
      > this.Invalidate ();
      >
      > but nothing happen.
      >
      >
      >
      > Does any body know what's the problem? Thanks you so much in advance, and
      > I'm very appreciated for your help.
      >
      >
      >
      >
      >[/color]


      Comment

      • Kate Luu

        #4
        Re: DrawGrabHandle

        Thanks you so much for your all help, Nicholas and Jay. I'm deeply
        appreciated. So, you guy should be PRO because the instruction from two of
        you are the same. I did follow the instruction but I cannot make it work,
        because nothing happen. I didn't see any sizing drag around the control. Do
        I missed something...

        Here how I do it:

        private void UserControl1_Mo useDown(object sender,
        System.Windows. Forms.MouseEven tArgs e)

        {

        bMouse_Down = true;

        this.Invalidate ();

        }



        private void UserControl1_Pa int(object sender,
        System.Windows. Forms.PaintEven tArgs e)

        {

        if( bMouse_Down == true )

        {

        //ControlPaint.Dr awSizeGrip( e.Graphics, Color.Red,
        this.ClientRect angle);

        ControlPaint.Dr awGrabHandle( e.Graphics,
        this.ClientRect angle, true,true );

        this.Invalidate ();

        }

        }




        "Kate Luu" <cql90@yahoo.co m> wrote in message
        news:eUsIF3NaDH A.2932@tk2msftn gp13.phx.gbl...[color=blue]
        > I did create a custom control, which inherit from picturebox control.
        > OnClick method, I have put this line of code:
        >
        > Graphics gfx = this.createGrap hics();
        >
        > ControlPaint.Dr awGrabHandle(gf x , this.ClientRect angle, true,true );
        >
        > this.Invalidate ();
        >
        > but nothing happen.
        >
        >
        >
        > Does any body know what's the problem? Thanks you so much in advance, and
        > I'm very appreciated for your help.
        >
        >
        >
        >
        >[/color]


        Comment

        • Kate Luu

          #5
          Re: DrawGrabHandle

          Thanks you so much Jay. I did try it without any "invalidate " but I still
          not work. I might be missed something but I don't know what do I miss. Once
          again, thanks you a lots for your help. Have a nice weekend :)

          Kate

          "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
          news:eCB4xNPaDH A.2960@tk2msftn gp13.phx.gbl...[color=blue]
          > Kate,
          > Don't include this.Invalidate in your Paint event, it will only cause the
          > paint event to be raised again.
          >[color=green]
          > > private void UserControl1_Pa int(object sender,
          > > System.Windows. Forms.PaintEven tArgs e)
          > > {
          > > if( bMouse_Down == true )
          > > {
          > > //ControlPaint.Dr awSizeGrip( e.Graphics, Color.Red,
          > > this.ClientRect angle);
          > > ControlPaint.Dr awGrabHandle( e.Graphics,
          > > this.ClientRect angle, true,true );
          > > }
          > > }[/color]
          >
          > Hope this helps
          > Jay
          >
          > "Kate Luu" <cql90@yahoo.co m> wrote in message
          > news:uzx45oOaDH A.1916@TK2MSFTN GP12.phx.gbl...[color=green]
          > > Thanks you so much for your all help, Nicholas and Jay. I'm deeply
          > > appreciated. So, you guy should be PRO because the instruction from two[/color][/color]
          of[color=blue][color=green]
          > > you are the same. I did follow the instruction but I cannot make it[/color][/color]
          work,[color=blue][color=green]
          > > because nothing happen. I didn't see any sizing drag around the control.[/color]
          > Do[color=green]
          > > I missed something...
          > >
          > > Here how I do it:
          > >
          > > private void UserControl1_Mo useDown(object sender,
          > > System.Windows. Forms.MouseEven tArgs e)
          > >
          > > {
          > >
          > > bMouse_Down = true;
          > >
          > > this.Invalidate ();
          > >
          > > }
          > >
          > >
          > >
          > > private void UserControl1_Pa int(object sender,
          > > System.Windows. Forms.PaintEven tArgs e)
          > >
          > > {
          > >
          > > if( bMouse_Down == true )
          > >
          > > {
          > >
          > > //ControlPaint.Dr awSizeGrip( e.Graphics, Color.Red,
          > > this.ClientRect angle);
          > >
          > > ControlPaint.Dr awGrabHandle( e.Graphics,
          > > this.ClientRect angle, true,true );
          > >
          > > this.Invalidate ();
          > >
          > > }
          > >
          > > }
          > >
          > >
          > >
          > >
          > > "Kate Luu" <cql90@yahoo.co m> wrote in message
          > > news:eUsIF3NaDH A.2932@tk2msftn gp13.phx.gbl...[color=darkred]
          > > > I did create a custom control, which inherit from picturebox control.
          > > > OnClick method, I have put this line of code:
          > > >
          > > > Graphics gfx = this.createGrap hics();
          > > >
          > > > ControlPaint.Dr awGrabHandle(gf x , this.ClientRect angle, true,true );
          > > >
          > > > this.Invalidate ();
          > > >
          > > > but nothing happen.
          > > >
          > > >
          > > >
          > > > Does any body know what's the problem? Thanks you so much in advance,[/color][/color]
          > and[color=green][color=darkred]
          > > > I'm very appreciated for your help.
          > > >
          > > >
          > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • kate-luu

            #6
            Re: DrawGrabHandle

            Yes, I did. I was removed the mouse down flag at OnMouseUp event. But seem
            like unluck to get it work. Might be this is Microsoft bug, who's know,
            right. Thanks you so much to follow my problem, Jay. I'm deeply appreciated
            of your help. I owed you...

            Kate

            "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
            news:OLflibPaDH A.2020@TK2MSFTN GP10.phx.gbl...[color=blue]
            > Kate,[color=green]
            > > Thanks you so much Jay. I did try it without any "invalidate " but I[/color][/color]
            still[color=blue][color=green]
            > > not work. I might be missed something but I don't know what do I miss.[/color]
            > Are you remembering to clear the bMouse_Down any place?
            >
            > If I create a new user control and only add the following events: (via the
            > properties window so the events are tied in to where they belong).
            >
            > bool bMouse_Down = false;
            >
            > private void UserControl1_Pa int(object sender,
            > System.Windows. Forms.PaintEven tArgs e)
            > {
            > if (bMouse_Down == true )
            > {
            > ControlPaint.Dr awGrabHandle( e.Graphics,
            > this.ClientRect angle, true,true );
            > }
            > }
            >
            > private void UserControl1_Mo useDown(object sender,
            > System.Windows. Forms.MouseEven tArgs e)
            > {
            > bMouse_Down = true;
            > this.Invalidate ();
            > }
            >
            > private void UserControl1_Mo useUp(object sender,
            > System.Windows. Forms.MouseEven tArgs e)
            > {
            > bMouse_Down = false;
            > this.Invalidate ();
            > }
            >
            > It leaves the control gray or it draws the grab handle (white), based on
            > pressing & releasing the mouse button.
            >
            > Hope this helps
            > Jay
            >
            >
            > "Kate Luu" <cql90@yahoo.co m> wrote in message
            > news:eg6qgRPaDH A.2620@TK2MSFTN GP09.phx.gbl...[color=green]
            > > Thanks you so much Jay. I did try it without any "invalidate " but I[/color][/color]
            still[color=blue][color=green]
            > > not work. I might be missed something but I don't know what do I miss.[/color]
            > Once[color=green]
            > > again, thanks you a lots for your help. Have a nice weekend :)
            > >
            > > Kate
            > >
            > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
            > message[color=green]
            > > news:eCB4xNPaDH A.2960@tk2msftn gp13.phx.gbl...[color=darkred]
            > > > Kate,
            > > > Don't include this.Invalidate in your Paint event, it will only cause[/color][/color]
            > the[color=green][color=darkred]
            > > > paint event to be raised again.
            > > >
            > > > > private void UserControl1_Pa int(object sender,
            > > > > System.Windows. Forms.PaintEven tArgs e)
            > > > > {
            > > > > if( bMouse_Down == true )
            > > > > {
            > > > > //ControlPaint.Dr awSizeGrip( e.Graphics, Color.Red,
            > > > > this.ClientRect angle);
            > > > > ControlPaint.Dr awGrabHandle( e.Graphics,
            > > > > this.ClientRect angle, true,true );
            > > > > }
            > > > > }
            > > >
            > > > Hope this helps
            > > > Jay
            > > >
            > > > "Kate Luu" <cql90@yahoo.co m> wrote in message
            > > > news:uzx45oOaDH A.1916@TK2MSFTN GP12.phx.gbl...
            > > > > Thanks you so much for your all help, Nicholas and Jay. I'm deeply
            > > > > appreciated. So, you guy should be PRO because the instruction from[/color][/color]
            > two[color=green]
            > > of[color=darkred]
            > > > > you are the same. I did follow the instruction but I cannot make it[/color]
            > > work,[color=darkred]
            > > > > because nothing happen. I didn't see any sizing drag around the[/color][/color]
            > control.[color=green][color=darkred]
            > > > Do
            > > > > I missed something...
            > > > >
            > > > > Here how I do it:
            > > > >
            > > > > private void UserControl1_Mo useDown(object sender,
            > > > > System.Windows. Forms.MouseEven tArgs e)
            > > > >
            > > > > {
            > > > >
            > > > > bMouse_Down = true;
            > > > >
            > > > > this.Invalidate ();
            > > > >
            > > > > }
            > > > >
            > > > >
            > > > >
            > > > > private void UserControl1_Pa int(object sender,
            > > > > System.Windows. Forms.PaintEven tArgs e)
            > > > >
            > > > > {
            > > > >
            > > > > if( bMouse_Down == true )
            > > > >
            > > > > {
            > > > >
            > > > > //ControlPaint.Dr awSizeGrip( e.Graphics, Color.Red,
            > > > > this.ClientRect angle);
            > > > >
            > > > > ControlPaint.Dr awGrabHandle( e.Graphics,
            > > > > this.ClientRect angle, true,true );
            > > > >
            > > > > this.Invalidate ();
            > > > >
            > > > > }
            > > > >
            > > > > }
            > > > >
            > > > >
            > > > >
            > > > >
            > > > > "Kate Luu" <cql90@yahoo.co m> wrote in message
            > > > > news:eUsIF3NaDH A.2932@tk2msftn gp13.phx.gbl...
            > > > > > I did create a custom control, which inherit from picturebox[/color][/color]
            > control.[color=green][color=darkred]
            > > > > > OnClick method, I have put this line of code:
            > > > > >
            > > > > > Graphics gfx = this.createGrap hics();
            > > > > >
            > > > > > ControlPaint.Dr awGrabHandle(gf x , this.ClientRect angle,[/color][/color][/color]
            true,true );[color=blue][color=green][color=darkred]
            > > > > >
            > > > > > this.Invalidate ();
            > > > > >
            > > > > > but nothing happen.
            > > > > >
            > > > > >
            > > > > >
            > > > > > Does any body know what's the problem? Thanks you so much in[/color][/color]
            > advance,[color=green][color=darkred]
            > > > and
            > > > > > I'm very appreciated for your help.
            > > > > >
            > > > > >
            > > > > >
            > > > > >
            > > > > >
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Jay B. Harlow [MVP - Outlook]

              #7
              Re: DrawGrabHandle

              Kate,
              Are you still having problems? Can you post the entire source for the
              control that is having a problem?

              I don't really see anything close to a Microsoft Bug here.

              Hope this helps
              Jay

              "kate-luu" <cql60@yahoo.co m> wrote in message
              news:OSNf2NZaDH A.2136@TK2MSFTN GP10.phx.gbl...[color=blue]
              > Yes, I did. I was removed the mouse down flag at OnMouseUp event. But seem
              > like unluck to get it work. Might be this is Microsoft bug, who's know,
              > right. Thanks you so much to follow my problem, Jay. I'm deeply[/color]
              appreciated[color=blue]
              > of your help. I owed you...
              >
              > Kate
              >
              > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
              message[color=blue]
              > news:OLflibPaDH A.2020@TK2MSFTN GP10.phx.gbl...[color=green]
              > > Kate,[color=darkred]
              > > > Thanks you so much Jay. I did try it without any "invalidate " but I[/color][/color]
              > still[color=green][color=darkred]
              > > > not work. I might be missed something but I don't know what do I miss.[/color]
              > > Are you remembering to clear the bMouse_Down any place?
              > >
              > > If I create a new user control and only add the following events: (via[/color][/color]
              the[color=blue][color=green]
              > > properties window so the events are tied in to where they belong).
              > >
              > > bool bMouse_Down = false;
              > >
              > > private void UserControl1_Pa int(object sender,
              > > System.Windows. Forms.PaintEven tArgs e)
              > > {
              > > if (bMouse_Down == true )
              > > {
              > > ControlPaint.Dr awGrabHandle( e.Graphics,
              > > this.ClientRect angle, true,true );
              > > }
              > > }
              > >
              > > private void UserControl1_Mo useDown(object sender,
              > > System.Windows. Forms.MouseEven tArgs e)
              > > {
              > > bMouse_Down = true;
              > > this.Invalidate ();
              > > }
              > >
              > > private void UserControl1_Mo useUp(object sender,
              > > System.Windows. Forms.MouseEven tArgs e)
              > > {
              > > bMouse_Down = false;
              > > this.Invalidate ();
              > > }
              > >
              > > It leaves the control gray or it draws the grab handle (white), based on
              > > pressing & releasing the mouse button.
              > >
              > > Hope this helps
              > > Jay
              > >
              > >
              > > "Kate Luu" <cql90@yahoo.co m> wrote in message
              > > news:eg6qgRPaDH A.2620@TK2MSFTN GP09.phx.gbl...[color=darkred]
              > > > Thanks you so much Jay. I did try it without any "invalidate " but I[/color][/color]
              > still[color=green][color=darkred]
              > > > not work. I might be missed something but I don't know what do I miss.[/color]
              > > Once[color=darkred]
              > > > again, thanks you a lots for your help. Have a nice weekend :)
              > > >
              > > > Kate
              > > >
              > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
              > > message[color=darkred]
              > > > news:eCB4xNPaDH A.2960@tk2msftn gp13.phx.gbl...
              > > > > Kate,
              > > > > Don't include this.Invalidate in your Paint event, it will only[/color][/color][/color]
              cause[color=blue][color=green]
              > > the[color=darkred]
              > > > > paint event to be raised again.
              > > > >
              > > > > > private void UserControl1_Pa int(object sender,
              > > > > > System.Windows. Forms.PaintEven tArgs e)
              > > > > > {
              > > > > > if( bMouse_Down == true )
              > > > > > {
              > > > > > //ControlPaint.Dr awSizeGrip( e.Graphics,[/color][/color][/color]
              Color.Red,[color=blue][color=green][color=darkred]
              > > > > > this.ClientRect angle);
              > > > > > ControlPaint.Dr awGrabHandle( e.Graphics,
              > > > > > this.ClientRect angle, true,true );
              > > > > > }
              > > > > > }
              > > > >
              > > > > Hope this helps
              > > > > Jay
              > > > >
              > > > > "Kate Luu" <cql90@yahoo.co m> wrote in message
              > > > > news:uzx45oOaDH A.1916@TK2MSFTN GP12.phx.gbl...
              > > > > > Thanks you so much for your all help, Nicholas and Jay. I'm deeply
              > > > > > appreciated. So, you guy should be PRO because the instruction[/color][/color][/color]
              from[color=blue][color=green]
              > > two[color=darkred]
              > > > of
              > > > > > you are the same. I did follow the instruction but I cannot make[/color][/color][/color]
              it[color=blue][color=green][color=darkred]
              > > > work,
              > > > > > because nothing happen. I didn't see any sizing drag around the[/color]
              > > control.[color=darkred]
              > > > > Do
              > > > > > I missed something...
              > > > > >
              > > > > > Here how I do it:
              > > > > >
              > > > > > private void UserControl1_Mo useDown(object sender,
              > > > > > System.Windows. Forms.MouseEven tArgs e)
              > > > > >
              > > > > > {
              > > > > >
              > > > > > bMouse_Down = true;
              > > > > >
              > > > > > this.Invalidate ();
              > > > > >
              > > > > > }
              > > > > >
              > > > > >
              > > > > >
              > > > > > private void UserControl1_Pa int(object sender,
              > > > > > System.Windows. Forms.PaintEven tArgs e)
              > > > > >
              > > > > > {
              > > > > >
              > > > > > if( bMouse_Down == true )
              > > > > >
              > > > > > {
              > > > > >
              > > > > > //ControlPaint.Dr awSizeGrip( e.Graphics,[/color][/color][/color]
              Color.Red,[color=blue][color=green][color=darkred]
              > > > > > this.ClientRect angle);
              > > > > >
              > > > > > ControlPaint.Dr awGrabHandle( e.Graphics,
              > > > > > this.ClientRect angle, true,true );
              > > > > >
              > > > > > this.Invalidate ();
              > > > > >
              > > > > > }
              > > > > >
              > > > > > }
              > > > > >
              > > > > >
              > > > > >
              > > > > >
              > > > > > "Kate Luu" <cql90@yahoo.co m> wrote in message
              > > > > > news:eUsIF3NaDH A.2932@tk2msftn gp13.phx.gbl...
              > > > > > > I did create a custom control, which inherit from picturebox[/color]
              > > control.[color=darkred]
              > > > > > > OnClick method, I have put this line of code:
              > > > > > >
              > > > > > > Graphics gfx = this.createGrap hics();
              > > > > > >
              > > > > > > ControlPaint.Dr awGrabHandle(gf x , this.ClientRect angle,[/color][/color]
              > true,true );[color=green][color=darkred]
              > > > > > >
              > > > > > > this.Invalidate ();
              > > > > > >
              > > > > > > but nothing happen.
              > > > > > >
              > > > > > >
              > > > > > >
              > > > > > > Does any body know what's the problem? Thanks you so much in[/color]
              > > advance,[color=darkred]
              > > > > and
              > > > > > > I'm very appreciated for your help.
              > > > > > >
              > > > > > >
              > > > > > >
              > > > > > >
              > > > > > >
              > > > > >
              > > > > >
              > > > >
              > > > >
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • kate-luu

                #8
                Re: DrawGrabHandle

                Thanks you so much, Jay.

                Here is the entire source code:

                *************** *************** *************** *

                using System;

                using System.Collecti ons;

                using System.Componen tModel;

                using System.Drawing;

                using System.Data;

                using System.Windows. Forms;

                namespace PictureBox_Exte nsion

                {

                /// <summary>

                /// Summary description for UserControl1.

                /// </summary>

                public class UserControl1 : System.Windows. Forms.PictureBo x

                {

                /// <summary>

                /// Required designer variable.

                /// </summary>

                private bool bMouse_Down = false;

                private System.Componen tModel.Containe r components = null;

                public UserControl1()

                {

                // This call is required by the Windows.Forms Form Designer.

                InitializeCompo nent();

                // TODO: Add any initialization after the InitForm call

                }

                /// <summary>

                /// Clean up any resources being used.

                /// </summary>

                protected override void Dispose( bool disposing )

                {

                if( disposing )

                {

                if( components != null )

                components.Disp ose();

                }

                base.Dispose( disposing );

                }

                #region Component Designer generated code

                /// <summary>

                /// Required method for Designer support - do not modify

                /// the contents of this method with the code editor.

                /// </summary>

                private void InitializeCompo nent()

                {

                //

                // UserControl1

                //

                this.Name = "UserContro l1";

                this.Size = new System.Drawing. Size(340, 310);

                this.MouseUp += new
                System.Windows. Forms.MouseEven tHandler(this.U serControl1_Mou seUp);

                this.Paint += new
                System.Windows. Forms.PaintEven tHandler(this.U serControl1_Pai nt);

                this.MouseDown += new
                System.Windows. Forms.MouseEven tHandler(this.U serControl1_Mou seDown);

                }

                #endregion

                private void UserControl1_Mo useDown(object sender,
                System.Windows. Forms.MouseEven tArgs e)

                {

                bMouse_Down = true;

                this.Invalidate ();

                }

                private void UserControl1_Mo useUp(object sender,
                System.Windows. Forms.MouseEven tArgs e)

                {

                if( bMouse_Down )

                {

                bMouse_Down = false;

                this.Invalidate ();

                }

                }

                private void UserControl1_Pa int(object sender,
                System.Windows. Forms.PaintEven tArgs e)

                {

                if( bMouse_Down )

                {

                ControlPaint.Dr awGrabHandle( e.Graphics, this.ClientRect angle, true, true );

                }

                }

                }

                }


                *************** *************** *************** *

                "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
                news:u28R9gZaDH A.1640@TK2MSFTN GP10.phx.gbl...[color=blue]
                > Kate,
                > Are you still having problems? Can you post the entire source for the
                > control that is having a problem?
                >
                > I don't really see anything close to a Microsoft Bug here.
                >
                > Hope this helps
                > Jay
                >
                > "kate-luu" <cql60@yahoo.co m> wrote in message
                > news:OSNf2NZaDH A.2136@TK2MSFTN GP10.phx.gbl...[color=green]
                > > Yes, I did. I was removed the mouse down flag at OnMouseUp event. But[/color][/color]
                seem[color=blue][color=green]
                > > like unluck to get it work. Might be this is Microsoft bug, who's know,
                > > right. Thanks you so much to follow my problem, Jay. I'm deeply[/color]
                > appreciated[color=green]
                > > of your help. I owed you...
                > >
                > > Kate
                > >
                > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
                > message[color=green]
                > > news:OLflibPaDH A.2020@TK2MSFTN GP10.phx.gbl...[color=darkred]
                > > > Kate,
                > > > > Thanks you so much Jay. I did try it without any "invalidate " but I[/color]
                > > still[color=darkred]
                > > > > not work. I might be missed something but I don't know what do I[/color][/color][/color]
                miss.[color=blue][color=green][color=darkred]
                > > > Are you remembering to clear the bMouse_Down any place?
                > > >
                > > > If I create a new user control and only add the following events: (via[/color][/color]
                > the[color=green][color=darkred]
                > > > properties window so the events are tied in to where they belong).
                > > >
                > > > bool bMouse_Down = false;
                > > >
                > > > private void UserControl1_Pa int(object sender,
                > > > System.Windows. Forms.PaintEven tArgs e)
                > > > {
                > > > if (bMouse_Down == true )
                > > > {
                > > > ControlPaint.Dr awGrabHandle( e.Graphics,
                > > > this.ClientRect angle, true,true );
                > > > }
                > > > }
                > > >
                > > > private void UserControl1_Mo useDown(object sender,
                > > > System.Windows. Forms.MouseEven tArgs e)
                > > > {
                > > > bMouse_Down = true;
                > > > this.Invalidate ();
                > > > }
                > > >
                > > > private void UserControl1_Mo useUp(object sender,
                > > > System.Windows. Forms.MouseEven tArgs e)
                > > > {
                > > > bMouse_Down = false;
                > > > this.Invalidate ();
                > > > }
                > > >
                > > > It leaves the control gray or it draws the grab handle (white), based[/color][/color][/color]
                on[color=blue][color=green][color=darkred]
                > > > pressing & releasing the mouse button.
                > > >
                > > > Hope this helps
                > > > Jay
                > > >
                > > >
                > > > "Kate Luu" <cql90@yahoo.co m> wrote in message
                > > > news:eg6qgRPaDH A.2620@TK2MSFTN GP09.phx.gbl...
                > > > > Thanks you so much Jay. I did try it without any "invalidate " but I[/color]
                > > still[color=darkred]
                > > > > not work. I might be missed something but I don't know what do I[/color][/color][/color]
                miss.[color=blue][color=green][color=darkred]
                > > > Once
                > > > > again, thanks you a lots for your help. Have a nice weekend :)
                > > > >
                > > > > Kate
                > > > >
                > > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in
                > > > message
                > > > > news:eCB4xNPaDH A.2960@tk2msftn gp13.phx.gbl...
                > > > > > Kate,
                > > > > > Don't include this.Invalidate in your Paint event, it will only[/color][/color]
                > cause[color=green][color=darkred]
                > > > the
                > > > > > paint event to be raised again.
                > > > > >
                > > > > > > private void UserControl1_Pa int(object sender,
                > > > > > > System.Windows. Forms.PaintEven tArgs e)
                > > > > > > {
                > > > > > > if( bMouse_Down == true )
                > > > > > > {
                > > > > > > //ControlPaint.Dr awSizeGrip( e.Graphics,[/color][/color]
                > Color.Red,[color=green][color=darkred]
                > > > > > > this.ClientRect angle);
                > > > > > > ControlPaint.Dr awGrabHandle( e.Graphics,
                > > > > > > this.ClientRect angle, true,true );
                > > > > > > }
                > > > > > > }
                > > > > >
                > > > > > Hope this helps
                > > > > > Jay
                > > > > >
                > > > > > "Kate Luu" <cql90@yahoo.co m> wrote in message
                > > > > > news:uzx45oOaDH A.1916@TK2MSFTN GP12.phx.gbl...
                > > > > > > Thanks you so much for your all help, Nicholas and Jay. I'm[/color][/color][/color]
                deeply[color=blue][color=green][color=darkred]
                > > > > > > appreciated. So, you guy should be PRO because the instruction[/color][/color]
                > from[color=green][color=darkred]
                > > > two
                > > > > of
                > > > > > > you are the same. I did follow the instruction but I cannot make[/color][/color]
                > it[color=green][color=darkred]
                > > > > work,
                > > > > > > because nothing happen. I didn't see any sizing drag around the
                > > > control.
                > > > > > Do
                > > > > > > I missed something...
                > > > > > >
                > > > > > > Here how I do it:
                > > > > > >
                > > > > > > private void UserControl1_Mo useDown(object sender,
                > > > > > > System.Windows. Forms.MouseEven tArgs e)
                > > > > > >
                > > > > > > {
                > > > > > >
                > > > > > > bMouse_Down = true;
                > > > > > >
                > > > > > > this.Invalidate ();
                > > > > > >
                > > > > > > }
                > > > > > >
                > > > > > >
                > > > > > >
                > > > > > > private void UserControl1_Pa int(object sender,
                > > > > > > System.Windows. Forms.PaintEven tArgs e)
                > > > > > >
                > > > > > > {
                > > > > > >
                > > > > > > if( bMouse_Down == true )
                > > > > > >
                > > > > > > {
                > > > > > >
                > > > > > > //ControlPaint.Dr awSizeGrip( e.Graphics,[/color][/color]
                > Color.Red,[color=green][color=darkred]
                > > > > > > this.ClientRect angle);
                > > > > > >
                > > > > > > ControlPaint.Dr awGrabHandle( e.Graphics,
                > > > > > > this.ClientRect angle, true,true );
                > > > > > >
                > > > > > > this.Invalidate ();
                > > > > > >
                > > > > > > }
                > > > > > >
                > > > > > > }
                > > > > > >
                > > > > > >
                > > > > > >
                > > > > > >
                > > > > > > "Kate Luu" <cql90@yahoo.co m> wrote in message
                > > > > > > news:eUsIF3NaDH A.2932@tk2msftn gp13.phx.gbl...
                > > > > > > > I did create a custom control, which inherit from picturebox
                > > > control.
                > > > > > > > OnClick method, I have put this line of code:
                > > > > > > >
                > > > > > > > Graphics gfx = this.createGrap hics();
                > > > > > > >
                > > > > > > > ControlPaint.Dr awGrabHandle(gf x , this.ClientRect angle,[/color]
                > > true,true );[color=darkred]
                > > > > > > >
                > > > > > > > this.Invalidate ();
                > > > > > > >
                > > > > > > > but nothing happen.
                > > > > > > >
                > > > > > > >
                > > > > > > >
                > > > > > > > Does any body know what's the problem? Thanks you so much in
                > > > advance,
                > > > > > and
                > > > > > > > I'm very appreciated for your help.
                > > > > > > >
                > > > > > > >
                > > > > > > >
                > > > > > > >
                > > > > > > >
                > > > > > >
                > > > > > >
                > > > > >
                > > > > >
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Jay B. Harlow [MVP - Outlook]

                  #9
                  Re: DrawGrabHandle

                  Kate,
                  If I put your control on a form, then run the form. When I press down on the
                  mouse the control changes color, when I release the mouse the control
                  returns to the original color.

                  Remember in the UserControl designer no code will run for this control, only
                  for base controls, in the forms designer (on a form you put your control)
                  the mouse is used by the designer, your code cannot run.

                  Hope this helps
                  Jay

                  "kate-luu" <cql60@yahoo.co m> wrote in message
                  news:O8MCK5laDH A.216@TK2MSFTNG P09.phx.gbl...[color=blue]
                  > Thanks you so much, Jay.
                  >
                  > Here is the entire source code:
                  >[/color]
                  <<snip>>


                  Comment

                  • Kate Luu

                    #10
                    Re: DrawGrabHandle

                    Good Morning Jay,

                    It means that I'm no luck at all. But I'm still think that we must be able
                    to change the apparent of the control any ways we want at design time and
                    runtime, and it should be. Any ways, thanks you so much Jay, I'm really
                    appreciated for your help. Have a nice day...

                    "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
                    news:uyltfKoaDH A.1748@TK2MSFTN GP12.phx.gbl...[color=blue]
                    > Kate,
                    > If I put your control on a form, then run the form. When I press down on[/color]
                    the[color=blue]
                    > mouse the control changes color, when I release the mouse the control
                    > returns to the original color.
                    >
                    > Remember in the UserControl designer no code will run for this control,[/color]
                    only[color=blue]
                    > for base controls, in the forms designer (on a form you put your control)
                    > the mouse is used by the designer, your code cannot run.
                    >
                    > Hope this helps
                    > Jay
                    >
                    > "kate-luu" <cql60@yahoo.co m> wrote in message
                    > news:O8MCK5laDH A.216@TK2MSFTNG P09.phx.gbl...[color=green]
                    > > Thanks you so much, Jay.
                    > >
                    > > Here is the entire source code:
                    > >[/color]
                    > <<snip>>
                    >
                    >[/color]


                    Comment

                    • Jay B. Harlow [MVP - Outlook]

                      #11
                      Re: DrawGrabHandle

                      Kate,
                      How is the designer going to know that you are clicking for the sake of the
                      designer or the control? The designer assumes you are designing, so it gets
                      all the mouse clicks. If you are really asking for in place editing, I'm not
                      sure how to do that, you will need to ask 'down the hall' in the
                      microsoft.publi c.dotnet.framew ork.windowsform s.designtime newsgroup.

                      If you add a public property (needs to be a property) to your user control
                      that changes your bMouse_Down variable. You will be able to set the property
                      in the Properties window of the designer. You control will then change
                      appearance.

                      Something like:
                      [Description("th e mouse is down")]
                      [Category("Appea rance")]
                      public bool Mouse_Down
                      {
                      get
                      {
                      return bMouse_Down;
                      }
                      set
                      {
                      bMouse_Down = value;
                      this.Invalidate ();
                      }
                      }

                      Add the above code to your UserControl1, compile your project, then add the
                      control to a form. changing the above property in the properties window will
                      change the appearance of the control.

                      Hope this helps
                      Jay

                      "Kate Luu" <cql90@yahoo.co m> wrote in message
                      news:%23xtRTpya DHA.2672@tk2msf tngp13.phx.gbl. ..[color=blue]
                      > Good Morning Jay,
                      >
                      > It means that I'm no luck at all. But I'm still think that we must be able
                      > to change the apparent of the control any ways we want at design time and
                      > runtime, and it should be. Any ways, thanks you so much Jay, I'm really
                      > appreciated for your help. Have a nice day...
                      >
                      > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
                      message[color=blue]
                      > news:uyltfKoaDH A.1748@TK2MSFTN GP12.phx.gbl...[color=green]
                      > > Kate,
                      > > If I put your control on a form, then run the form. When I press down on[/color]
                      > the[color=green]
                      > > mouse the control changes color, when I release the mouse the control
                      > > returns to the original color.
                      > >
                      > > Remember in the UserControl designer no code will run for this control,[/color]
                      > only[color=green]
                      > > for base controls, in the forms designer (on a form you put your[/color][/color]
                      control)[color=blue][color=green]
                      > > the mouse is used by the designer, your code cannot run.
                      > >
                      > > Hope this helps
                      > > Jay
                      > >
                      > > "kate-luu" <cql60@yahoo.co m> wrote in message
                      > > news:O8MCK5laDH A.216@TK2MSFTNG P09.phx.gbl...[color=darkred]
                      > > > Thanks you so much, Jay.
                      > > >
                      > > > Here is the entire source code:
                      > > >[/color]
                      > > <<snip>>
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • Kate Luu

                        #12
                        Re: DrawGrabHandle

                        Thanks you so much Jay, you're so wonderful and kindness person, help me
                        with all your best, I don't know how to address my appreciated, Jay. All the
                        thing you did show me are just for design time support only. But, the
                        feature I want at runtime. So, like you said, I think I have to post my
                        question at "microsoft.publ ic.dotnet.frame work", might be some expert there
                        like you can give me an answer. Have a nice day...JAY

                        Kate

                        "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
                        news:uzOkZ7yaDH A.2588@TK2MSFTN GP09.phx.gbl...[color=blue]
                        > Kate,
                        > How is the designer going to know that you are clicking for the sake of[/color]
                        the[color=blue]
                        > designer or the control? The designer assumes you are designing, so it[/color]
                        gets[color=blue]
                        > all the mouse clicks. If you are really asking for in place editing, I'm[/color]
                        not[color=blue]
                        > sure how to do that, you will need to ask 'down the hall' in the
                        > microsoft.publi c.dotnet.framew ork.windowsform s.designtime newsgroup.
                        >
                        > If you add a public property (needs to be a property) to your user control
                        > that changes your bMouse_Down variable. You will be able to set the[/color]
                        property[color=blue]
                        > in the Properties window of the designer. You control will then change
                        > appearance.
                        >
                        > Something like:
                        > [Description("th e mouse is down")]
                        > [Category("Appea rance")]
                        > public bool Mouse_Down
                        > {
                        > get
                        > {
                        > return bMouse_Down;
                        > }
                        > set
                        > {
                        > bMouse_Down = value;
                        > this.Invalidate ();
                        > }
                        > }
                        >
                        > Add the above code to your UserControl1, compile your project, then add[/color]
                        the[color=blue]
                        > control to a form. changing the above property in the properties window[/color]
                        will[color=blue]
                        > change the appearance of the control.
                        >
                        > Hope this helps
                        > Jay
                        >
                        > "Kate Luu" <cql90@yahoo.co m> wrote in message
                        > news:%23xtRTpya DHA.2672@tk2msf tngp13.phx.gbl. ..[color=green]
                        > > Good Morning Jay,
                        > >
                        > > It means that I'm no luck at all. But I'm still think that we must be[/color][/color]
                        able[color=blue][color=green]
                        > > to change the apparent of the control any ways we want at design time an[/color][/color]
                        d[color=blue][color=green]
                        > > runtime, and it should be. Any ways, thanks you so much Jay, I'm really
                        > > appreciated for your help. Have a nice day...
                        > >
                        > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
                        > message[color=green]
                        > > news:uyltfKoaDH A.1748@TK2MSFTN GP12.phx.gbl...[color=darkred]
                        > > > Kate,
                        > > > If I put your control on a form, then run the form. When I press down[/color][/color][/color]
                        on[color=blue][color=green]
                        > > the[color=darkred]
                        > > > mouse the control changes color, when I release the mouse the control
                        > > > returns to the original color.
                        > > >
                        > > > Remember in the UserControl designer no code will run for this[/color][/color][/color]
                        control,[color=blue][color=green]
                        > > only[color=darkred]
                        > > > for base controls, in the forms designer (on a form you put your[/color][/color]
                        > control)[color=green][color=darkred]
                        > > > the mouse is used by the designer, your code cannot run.
                        > > >
                        > > > Hope this helps
                        > > > Jay
                        > > >
                        > > > "kate-luu" <cql60@yahoo.co m> wrote in message
                        > > > news:O8MCK5laDH A.216@TK2MSFTNG P09.phx.gbl...
                        > > > > Thanks you so much, Jay.
                        > > > >
                        > > > > Here is the entire source code:
                        > > > >
                        > > > <<snip>>
                        > > >
                        > > >[/color]
                        > >
                        > >[/color]
                        >
                        >[/color]


                        Comment

                        • Jay B. Harlow [MVP - Outlook]

                          #13
                          Re: DrawGrabHandle

                          Kate,
                          The sample you gave me works at runtime! (for me)

                          Hope this helps
                          Jay

                          "Kate Luu" <cql90@yahoo.co m> wrote in message
                          news:eeRIIB$aDH A.2136@TK2MSFTN GP10.phx.gbl...[color=blue]
                          > Thanks you so much Jay, you're so wonderful and kindness person, help me
                          > with all your best, I don't know how to address my appreciated, Jay. All[/color]
                          the[color=blue]
                          > thing you did show me are just for design time support only. But, the
                          > feature I want at runtime. So, like you said, I think I have to post my
                          > question at "microsoft.publ ic.dotnet.frame work", might be some expert[/color]
                          there[color=blue]
                          > like you can give me an answer. Have a nice day...JAY
                          >
                          > Kate
                          >
                          > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
                          message[color=blue]
                          > news:uzOkZ7yaDH A.2588@TK2MSFTN GP09.phx.gbl...[color=green]
                          > > Kate,
                          > > How is the designer going to know that you are clicking for the sake of[/color]
                          > the[color=green]
                          > > designer or the control? The designer assumes you are designing, so it[/color]
                          > gets[color=green]
                          > > all the mouse clicks. If you are really asking for in place editing, I'm[/color]
                          > not[color=green]
                          > > sure how to do that, you will need to ask 'down the hall' in the
                          > > microsoft.publi c.dotnet.framew ork.windowsform s.designtime newsgroup.
                          > >
                          > > If you add a public property (needs to be a property) to your user[/color][/color]
                          control[color=blue][color=green]
                          > > that changes your bMouse_Down variable. You will be able to set the[/color]
                          > property[color=green]
                          > > in the Properties window of the designer. You control will then change
                          > > appearance.
                          > >
                          > > Something like:
                          > > [Description("th e mouse is down")]
                          > > [Category("Appea rance")]
                          > > public bool Mouse_Down
                          > > {
                          > > get
                          > > {
                          > > return bMouse_Down;
                          > > }
                          > > set
                          > > {
                          > > bMouse_Down = value;
                          > > this.Invalidate ();
                          > > }
                          > > }
                          > >
                          > > Add the above code to your UserControl1, compile your project, then add[/color]
                          > the[color=green]
                          > > control to a form. changing the above property in the properties window[/color]
                          > will[color=green]
                          > > change the appearance of the control.
                          > >
                          > > Hope this helps
                          > > Jay
                          > >
                          > > "Kate Luu" <cql90@yahoo.co m> wrote in message
                          > > news:%23xtRTpya DHA.2672@tk2msf tngp13.phx.gbl. ..[color=darkred]
                          > > > Good Morning Jay,
                          > > >
                          > > > It means that I'm no luck at all. But I'm still think that we must be[/color][/color]
                          > able[color=green][color=darkred]
                          > > > to change the apparent of the control any ways we want at design time[/color][/color][/color]
                          an[color=blue]
                          > d[color=green][color=darkred]
                          > > > runtime, and it should be. Any ways, thanks you so much Jay, I'm[/color][/color][/color]
                          really[color=blue][color=green][color=darkred]
                          > > > appreciated for your help. Have a nice day...
                          > > >
                          > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
                          > > message[color=darkred]
                          > > > news:uyltfKoaDH A.1748@TK2MSFTN GP12.phx.gbl...
                          > > > > Kate,
                          > > > > If I put your control on a form, then run the form. When I press[/color][/color][/color]
                          down[color=blue]
                          > on[color=green][color=darkred]
                          > > > the
                          > > > > mouse the control changes color, when I release the mouse the[/color][/color][/color]
                          control[color=blue][color=green][color=darkred]
                          > > > > returns to the original color.
                          > > > >
                          > > > > Remember in the UserControl designer no code will run for this[/color][/color]
                          > control,[color=green][color=darkred]
                          > > > only
                          > > > > for base controls, in the forms designer (on a form you put your[/color]
                          > > control)[color=darkred]
                          > > > > the mouse is used by the designer, your code cannot run.
                          > > > >
                          > > > > Hope this helps
                          > > > > Jay
                          > > > >
                          > > > > "kate-luu" <cql60@yahoo.co m> wrote in message
                          > > > > news:O8MCK5laDH A.216@TK2MSFTNG P09.phx.gbl...
                          > > > > > Thanks you so much, Jay.
                          > > > > >
                          > > > > > Here is the entire source code:
                          > > > > >
                          > > > > <<snip>>
                          > > > >
                          > > > >
                          > > >
                          > > >[/color]
                          > >
                          > >[/color]
                          >
                          >[/color]


                          Comment

                          • Jay B. Harlow [MVP - Outlook]

                            #14
                            Re: DrawGrabHandle

                            Kate,
                            O.K. lets go back to the beginning!

                            Do you want the control to change colors or do you want functional sizing
                            handles in the corners?

                            If you want "drag sizing stuff", you need to manually draw the "drag sizing
                            stuff". The DrawGrabHandle will draw a single handle. You were drawing that
                            single handle in the entire client area of your control.

                            Normally there are 8 handles you need to draw, plus a border. You need to
                            call DrawGrabHandle 8 times once for each corner & once for each mid-point
                            on the side.

                            I use ControlPaint.Dr awSelectionFram e to draw the border, draw the border
                            before you draw the handles.

                            Then you need to handle the Mouse move, mouse down, mouse up events. To get
                            the sizing functional

                            In my project I have code to draw the sizing handles working, I have yet to
                            finish the code for getting the mouse to work.

                            A couple projects that may have the code you need includes:
                            ICSharpCode has 22 repositories available. Follow their code on GitHub.



                            Both have code available.

                            Hope this helps
                            Jay


                            "Kate Luu" <cql90@yahoo.co m> wrote in message
                            news:%23n$i9YLb DHA.1940@TK2MSF TNGP10.phx.gbl. ..[color=blue]
                            > Good Morning Jay,
                            >
                            > No way Jay. If it worked for you, it should work for me too. While it[/color]
                            works[color=blue]
                            > for you and not for me than. The control just change the color, it never
                            > show the drag sizing stuff. You should be kidding me. Have a nice day...
                            >
                            > Kate
                            >[/color]
                            <<snip>>


                            Comment

                            Working...