Set Left and Width simultaneously? 
Author Message
 Set Left and Width simultaneously?

I'm creating a control that allows itself to be resized by
stretching out any corner.  When the upper-left corner is
stretched, it does the following:

        This.Left = This.Left + (X - m_AnchorX)
        This.Width = This.Width - (X - m_AnchorX)

And it similarly updates the top and height.  The problem
is that the window is being painted between these two
lines of code, producing a funky flicker effect.  Is there
any way to set both at once?

Is there a way to turn off painting for a moment?  Without
making the control invisible and then visible again (since
that also flickers).

~BenDilts( void );



Sat, 26 Nov 2005 23:48:18 GMT  
 Set Left and Width simultaneously?


Quote:
> And it similarly updates the top and height.  The problem
> is that the window is being painted between these two
> lines of code, producing a funky flicker effect.  Is there
> any way to set both at once?

Move


Sun, 27 Nov 2005 00:06:32 GMT  
 Set Left and Width simultaneously?


Quote:
> I'm creating a control that allows itself to be resized by
> stretching out any corner.  When the upper-left corner is
> stretched, it does the following:

>         This.Left = This.Left + (X - m_AnchorX)
>         This.Width = This.Width - (X - m_AnchorX)

> And it similarly updates the top and height.  The problem
> is that the window is being painted between these two
> lines of code, producing a funky flicker effect.  Is there
> any way to set both at once?

Use the Move method rather than set the individual properties (Height, Left,
Top, and Width) .  As a rule of thumb, it's almost always better to use the
Move method than it is to set these 4 properties.  Namely because the Move
method "sets" all 4 of these properties at once so you won't have the
problem you're encountering.

Quote:
> Is there a way to turn off painting for a moment?  Without
> making the control invisible and then visible again (since
> that also flickers).

You can call the LockWindowUpdate API function to prevent painting of any
window, but in this case, you shouldn't need to do that if you use the Move
method.

Mike



Tue, 29 Nov 2005 08:26:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Property Left and Width in a status bar could not be set

2. Setting datagrid column width sets width of toplevel!!

3. Setting form width/height = image width/height

4. Set Grid width to sum of Column Widths

5. Setting Usercontrol (ocx) width at runtime wider than Width property of usercontrol

6. Left or Right Marging greater than the width of the paper error

7. How do you force VB to update .left, .width etc after WM_NCLBUTTONDOWN

8. 2101 error when trying to set Left property on text box

9. Setting Left Join

10. Q: Set Top and Left of ListViewItem???

11. Setting Left Margin

12. controls on frame disappear when setting left

 

 
Powered by phpBB® Forum Software