I'm attempting to understand the inner core workings of these methods. Specifically, I'd like to know exactly which method is used to resize child controls, which one is used to resize the parent control itself, ect...
What I've done is create a Toolstrip with AutoSize = true, and then added a label to it. I then override the ToolStrip's OnResize, OnLayout and OnLayoutComplete so I can see when each is fired and in what order. In my test I simply change the text of the label to something smaller and print out the firing of the overriden methods. The order I've found is this.
The original ToolStrip size is 223x25. At each function call I print out the width and height of the toolstrip before calling base.OnMethod and then immediately after I do the same thing. Hence you see OnLayout1 and OnLayout2.
code executed:
label->Text = "ABC";
order of calls:
OnLayout1: 223, 25
OnLayoutCompleted1: 223, 25
OnLayoutCompleted2: 223, 25
OnLayout2: 223, 25
OnResize1: 167, 25
OnLayout1: 167, 25
OnLayoutCompleted1: 167, 25
OnLayoutCompleted2: 167, 25
OnLayout2: 167, 25
OnResize2: 167, 25
So looking at this printout, it seems that OnLayout is first calculating how much the ToolStrip should grow or shrink based on its child contents, and then after base.OnLayout is called, the ToolStrip still has the same size. But right when OnResize is called, the size has been updated. So where does the resizing of the parent control occur? Does OnLayout allow posting of resizing events if a child control extends beyond the boundaries of the ToolStrip? I'm trying to duplicate all of this functionality myself but I can't figure out the order at which things are occurring. | | soconne Thursday, October 09, 2008 2:06 PM | I think you are on the right track to answering your own question.
You just might need to dig a little deeper.
I don't know the answer with testing it out for myself.
In which class are you doing the overrides?
The child control, the parent control, the form, all of the above?
Rudedog =8^D | | Rudedog2 Thursday, October 09, 2008 2:28 PM | I'm overriding the methods in the ToolStrip control by creating my own subclass of it.
class MyToolStrip : ToolStrip
{
// overriden methods
};
I'm not interested in when the child controls' onMethods are called, only the ToolStrips. But yeah, I've tried digging as far as possible, but I can't seem to nail down what's happening. | | soconne Thursday, October 09, 2008 3:46 PM |
| soconne wrote: |
| I'm overriding the methods in the ToolStrip control by creating my own subclass of it.
class MyToolStrip : ToolStrip
{
// overriden methods
};
I'm not interested in when the child controls' onMethods are called, only the ToolStrips. But yeah, I've tried digging as far as possible, but I can't seem to nail down what's happening.
| |
| soconne wrote: |
|
So where does the resizing of the parent control occur?
Does OnLayout allow posting of resizing events if a child control extends beyond the boundaries of the ToolStrip?
I'm trying to duplicate all of this functionality myself but I can't figure out the order at which things are occurring.
| |
You have only scratched the surface. You need to dig a little deeper. You ask when does re-sizing on the parent occur, yet you only override methods in the child control. Then, turn around and say you are not interested when the child occurs. I would describe what you have done as inheritance. You have inherited from ToolStrip, not created a "sub-class".
How will you know when the if parent control is called before or after the child control without monitoring both? I think your original test is ingenious. You need to follow it through to its logical conclusion. You are getting reports back from the ToolStrip, but nothing from the ToolStrip child controls.
Monitor more events from parent and child if you want to know the order in which they occur. Monitoring just one controlor the other tells you nothing about the the other control. I do not think you need to override the OnEvent methods to determine the order in which the events fire. You should get the same results just by monitoring the events associated with the controls.
Rudedog =8^D | | Rudedog2 Thursday, October 09, 2008 4:14 PM |
| Rudedog2 wrote: |
|
You ask when does re-sizing on the parent occur, yet you only override methods in the child control. Then, turn around and say you are not interested when the child occurs.
| |
Which code are you looking at? I'm NOT overriding methods in the child controls, I'm overriding methods in the parent ToolStrip control.
| Rudedog2 wrote: |
You are getting reports back from the ToolStrip, but nothing from the ToolStrip child controls.
| |
Again, I'm not interested specifically in when child controls are resized. As I stated in my initial post, I set the ToolStrip's AutoSize property to true, and I'm interested in when the TOOLSTRIP'S Size property is changed, hence, does it get modified in the ToolStrip's OnLayout, OnLayoutCompleted or OnResize method.
| Rudedog2 wrote: |
Monitoring just one controlor the other tells you nothing about the the other control.
| |
Again, I don't care about the child controls. | | soconne Thursday, October 09, 2008 7:14 PM |
| soconne wrote: |
| Rudedog2 wrote: |
|
You ask when does re-sizing on the parent occur, yet you only override methods in the child control. Then, turn around and say you are not interested when the child occurs.
| |
Which code are you looking at? I'm NOT overriding methods in the child controls, I'm overriding methods in the parent ToolStrip control.
| Rudedog2 wrote: |
You are getting reports back from the ToolStrip, but nothing from the ToolStrip child controls.
| |
Again, I'm not interested specifically in when child controls are resized. As I stated in my initial post, I set the ToolStrip's AutoSize property to true, and I'm interested in when the TOOLSTRIP'S Size property is changed, hence, does it get modified in the ToolStrip's OnLayout, OnLayoutCompleted or OnResize method.
| Rudedog2 wrote: |
Monitoring just one controlor the other tells you nothing about the the other control.
| |
Again, I don't care about the child controls.
| |
1. A ToolStrip is a child control of the form.
2. I no longer have any clue what you are asking. I had thought it was the order in which controls get redrawn.
3. Your "question" is not making any sense to me.
This is what I thought you had asked.
|
So where does the resizing of the parent control occur?
Does OnLayout allow posting of resizing events if a child control extends beyond the boundaries of the ToolStrip?
| |
Resizing occurs on the screen.
But, you are not concerned with child controls.
Happy coding. I tried.
http://www.geekpedia.com/tutorial181_Capturing-screenshots-using-Csharp.html | | Rudedog2 Thursday, October 09, 2008 7:51 PM |
|