Is there a done resizing event ?

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

    Is there a done resizing event ?

    I'm writing a new control derived from UserControl.
    I need to get an event when the control is done resizing.

    I tried the Resize, SizeChanged, Move and the Layout events and I also tried
    to override them. But they all invoked when the control is in the middle of
    the resizing process.

    I'm not using breakpoints, I'm using trace to see which one is invoked and
    when.

    Is there an event that simply tells me when the resizing is done ?


    ---------
    Thanks
    Sharon
  • Abubakar

    #2
    Re: Is there a done resizing event ?

    Hi,
    In case the window is being resized with a mouse, you can treat a mouseup
    event to be end of resizing.
    I hope that helps u.

    -Ab.
    Blogger ist ein Veröffentlichungs-Tool von Google, mit dem du ganz einfach deine Gedanken der Welt mitteilen kannst. Mit Blogger kannst du problemlos Texte, Fotos und Videos in deinem persönlichen Blog oder deinem Team-Blog veröffentlichen.


    "Sharon" <SharonG@newsgr oups.nospam> wrote in message
    news:E33AE9FC-2543-4B13-86E3-A0D1202D714D@mi crosoft.com...[color=blue]
    > I'm writing a new control derived from UserControl.
    > I need to get an event when the control is done resizing.
    >
    > I tried the Resize, SizeChanged, Move and the Layout events and I also[/color]
    tried[color=blue]
    > to override them. But they all invoked when the control is in the middle[/color]
    of[color=blue]
    > the resizing process.
    >
    > I'm not using breakpoints, I'm using trace to see which one is invoked and
    > when.
    >
    > Is there an event that simply tells me when the resizing is done ?
    >
    >
    > ---------
    > Thanks
    > Sharon[/color]


    Comment

    • Sharon

      #3
      Re: Is there a done resizing event ?

      It looks like a good idea, but it's may be good for Forms, but I need it for
      the control that I'm writing.
      I'll explain:
      The control that I'm writing can no be resized separately, it's being
      resized by resizing its parent Form.
      (The Form is setting my control Dock = None, Anchor = Top,Left,Right) .
      So when the user done resizing the Form, the MouseUp is in the Form context
      and of the control.
      I tried to set Parent.MouseUp (where Parent is the Form) event, but it is
      not being fired.

      So I'll be very happy to hear any more Ideas.


      ----------
      Thanks
      Sharon
      --
      Thanks
      Sharon


      "Abubakar" wrote:
      [color=blue]
      > Hi,
      > In case the window is being resized with a mouse, you can treat a mouseup
      > event to be end of resizing.
      > I hope that helps u.
      >
      > -Ab.
      > http://joehacker.blogspot.com
      >
      > "Sharon" <SharonG@newsgr oups.nospam> wrote in message
      > news:E33AE9FC-2543-4B13-86E3-A0D1202D714D@mi crosoft.com...[color=green]
      > > I'm writing a new control derived from UserControl.
      > > I need to get an event when the control is done resizing.
      > >
      > > I tried the Resize, SizeChanged, Move and the Layout events and I also[/color]
      > tried[color=green]
      > > to override them. But they all invoked when the control is in the middle[/color]
      > of[color=green]
      > > the resizing process.
      > >
      > > I'm not using breakpoints, I'm using trace to see which one is invoked and
      > > when.
      > >
      > > Is there an event that simply tells me when the resizing is done ?
      > >
      > >
      > > ---------
      > > Thanks
      > > Sharon[/color]
      >
      >
      >[/color]

      Comment

      • Abubakar

        #4
        Re: Is there a done resizing event ?

        The following code works in visual studio 2k5:

        private void UserControl1_Lo ad(object sender, EventArgs e)
        {
        ((Form)this.Par ent).ResizeEnd += new EventHandler(Us erControl1_Resi zeEnd);
        }
        void UserControl1_Re sizeEnd(object sender, EventArgs e)
        {
        MessageBox.Show ("Resize end");
        }

        I hope that helps.

        -Ab.
        Blogger ist ein Veröffentlichungs-Tool von Google, mit dem du ganz einfach deine Gedanken der Welt mitteilen kannst. Mit Blogger kannst du problemlos Texte, Fotos und Videos in deinem persönlichen Blog oder deinem Team-Blog veröffentlichen.


        "Sharon" <SharonG@newsgr oups.nospam> wrote in message
        news:A8A37E62-7DAB-4D95-AC9F-B2AEB8A2D7A4@mi crosoft.com...[color=blue]
        > It looks like a good idea, but it's may be good for Forms, but I need it[/color]
        for[color=blue]
        > the control that I'm writing.
        > I'll explain:
        > The control that I'm writing can no be resized separately, it's being
        > resized by resizing its parent Form.
        > (The Form is setting my control Dock = None, Anchor = Top,Left,Right) .
        > So when the user done resizing the Form, the MouseUp is in the Form[/color]
        context[color=blue]
        > and of the control.
        > I tried to set Parent.MouseUp (where Parent is the Form) event, but it is
        > not being fired.
        >
        > So I'll be very happy to hear any more Ideas.
        >
        >
        > ----------
        > Thanks
        > Sharon
        > --
        > Thanks
        > Sharon
        >
        >
        > "Abubakar" wrote:
        >[color=green]
        > > Hi,
        > > In case the window is being resized with a mouse, you can treat a[/color][/color]
        mouseup[color=blue][color=green]
        > > event to be end of resizing.
        > > I hope that helps u.
        > >
        > > -Ab.
        > > http://joehacker.blogspot.com
        > >
        > > "Sharon" <SharonG@newsgr oups.nospam> wrote in message
        > > news:E33AE9FC-2543-4B13-86E3-A0D1202D714D@mi crosoft.com...[color=darkred]
        > > > I'm writing a new control derived from UserControl.
        > > > I need to get an event when the control is done resizing.
        > > >
        > > > I tried the Resize, SizeChanged, Move and the Layout events and I also[/color]
        > > tried[color=darkred]
        > > > to override them. But they all invoked when the control is in the[/color][/color][/color]
        middle[color=blue][color=green]
        > > of[color=darkred]
        > > > the resizing process.
        > > >
        > > > I'm not using breakpoints, I'm using trace to see which one is invoked[/color][/color][/color]
        and[color=blue][color=green][color=darkred]
        > > > when.
        > > >
        > > > Is there an event that simply tells me when the resizing is done ?
        > > >
        > > >
        > > > ---------
        > > > Thanks
        > > > Sharon[/color]
        > >
        > >
        > >[/color][/color]


        Comment

        • Sharon

          #5
          Re: Is there a done resizing event ?

          That is very good, But I'm using the VS 2003 that does not have the
          ResizedEnd event.

          ----
          Thanks
          Sharon

          Comment

          • Jeffrey Tan[MSFT]

            #6
            Re: Is there a done resizing event ?

            Hi Sharon,

            Thanks for your feedback.

            First, you should determine if ResizeEnd event meets your need. This event
            is raised when the user finishes resizing a form, typically by dragging one
            of the borders or the sizing grip located on the lower-right corner of the
            form, and then releasing it. It is also generated after the user moves a
            form, typically by clicking and dragging on the caption bar.

            So for the second scenario, I do not think it meet your need. However, I
            think we can distinguish these 2 conditions with comparing the new control
            size with the original control size.(This requires to store the original
            control size in a private filed/property)

            Ok, I assume that you need this event in .Net1.1. Let's do some
            customization to achieve this:
            Form.ResizeEnd event leverages win32 WM_EXITSIZEMOVE message, so in
            .Net1.1, we can override Form's WndProc and create a public ResizeEnd
            event, trigger this event in WM_EXITSIZEMOVE message, like below:

            public event EventHandler ResizeEnd;
            private int WM_EXITSIZEMOVE =0x232;
            protected override void WndProc(ref Message m)
            {
            if(m.Msg==WM_EX ITSIZEMOVE)
            {
            if(ResizeEnd!=n ull)
            {
            this.ResizeEnd( this, new EventArgs());
            }
            }
            base.WndProc (ref m);
            }

            In usercontrol, we can just listen to this event:
            //I write code to disable this code from running in designmode.
            private void UserControl1_Lo ad(object sender, System.EventArg s e)
            {
            if(!this.Design Mode)
            {
            ((Form1)this.Pa rent).ResizeEnd += new
            EventHandler(Us erControl1_Resi zeEnd);
            }
            else
            {
            MessageBox.Show ("design time");
            }
            }

            private void UserControl1_Re sizeEnd(object sender, EventArgs e)
            {
            MessageBox.Show ("Resize end");
            }

            Hope this helps

            Best regards,
            Jeffrey Tan
            Microsoft Online Partner Support
            Get Secure! - www.microsoft.com/security
            This posting is provided "as is" with no warranties and confers no rights.

            Comment

            • Sharon

              #7
              Re: Is there a done resizing event ?

              Thanks Jeffrey,
              But I'm only writing the control that will be used in Forms that I have no
              control over them.

              As I understand your suggestion; the event is fired by the Form.
              So you see, it's very good for the Form developer, but not for the control
              developer.

              I found some discussion that suggest to use the Application.Idl e event.
              So on the regular OnResize I'm only marking a flag that indicate that a
              resizing operation is in progress, and the event handler that is register for
              the Application.Idl e event is doing the resizing (as if ResizeEnd is fired)
              when the flag is marked.
              It seems to be working, but I'm not so sure it will work at any scenario.

              What do you think?


              ----------
              Thanks
              Sharon

              Comment

              • Jeffrey Tan[MSFT]

                #8
                Re: Is there a done resizing event ?

                Hi SharonG,

                First, I think I have showed you the code how to register the form's
                ResizeEnd event in UserControl, yes? So we should can do this in the
                control development, not just the Form level. Do you have any concern on
                this way?

                Second, I am not sure what is your definition of resizing end. Based on my
                experience, the Resize event should occurs at the end of the resizing
                operation, yes? Please feel free to tell me concern about this.

                Third, the Application.Idl e should can get this done. Because this event
                occurs when the application finishes processing and is about to enter the
                idle state. So the Resizing operation should have been finished.

                Thanks

                Best regards,
                Jeffrey Tan
                Microsoft Online Partner Support
                Get Secure! - www.microsoft.com/security
                This posting is provided "as is" with no warranties and confers no rights.

                Comment

                • Bruce Wood

                  #9
                  Re: Is there a done resizing event ?

                  Jeffrey,

                  Wouldn't it be better to subscribe to the parent form's Resize_End
                  event in a ParentChanged event handler, rather than in a Load event
                  handler?

                  Comment

                  • Sharon

                    #10
                    Re: Is there a done resizing event ?

                    Yes, the code you showed me is perfect. But I prefer a solution that won't
                    involve the user of the control.

                    My definition of 'resizing end' is the mouse up when the user is done
                    pooling the Form corner.
                    So I think that our detentions are the same.

                    I'm glad to hear that the Application.Idl e event usage is a good solution.
                    As you can see it does not need any involvement by the user of my control.



                    -----------
                    Thanks a lot
                    Sharon

                    Comment

                    • Sharon

                      #11
                      Re: Is there a done resizing event ?

                      Yes, it would be better to register to the ResizeEnd event of the parent
                      Form. But this event is only exist in VS 2005 and not in VS2003.
                      The Solution that Jeffrey has suggested is for VS2003.

                      Comment

                      • Jeffrey Tan[MSFT]

                        #12
                        Re: Is there a done resizing event ?

                        Oh, yes, it;'s better can use the control without requiring doing extra
                        work in Form class. So the solution you found should be better.

                        If you have any further concern, please feel free to post. Thanks

                        Best regards,
                        Jeffrey Tan
                        Microsoft Online Partner Support
                        Get Secure! - www.microsoft.com/security
                        This posting is provided "as is" with no warranties and confers no rights.

                        Comment

                        Working...