When resizing controls at run-time, you may observe that controls are positioned incorrectly on the form as you switch between tabs, or they may disappear altogether.
Typically, this occurs when controls are resized at run-time, in the tab control's Resized event for example.
SftTabs/OCX uses a simple and foolproof mechanism to keep track of control positions as tab pages are hidden. When a tab page is not the current page, the controls on that page are hidden by moving them outside of the form. Rather than saving each control's position (the Left, Top, Width, Height properties), the controls are simply repositioned using the following formula:
(Hidden)Left = -1000-Left-Width
(Hidden)Top = -1000-Top-Height
To recover the original position when the tab page becomes active again, the following is used:
Left = -1000 - (Hidden)Left - Width
Top = -1000 - (Hidden)Top - Height
This scheme is quite simple and SftTabs does not have to save or maintain any control positions or other information. Each control maintains its own information which is reflected in its present position. Any Left/Top properties <= -1000 indicate that a control is hidden and the original position can be extracted using the above formula. Left/Top properties > -1000 are left as-is.
This scheme does have the side effect that changes to a control's width and height or position (while it is hidden) will cause the control to be positioned incorrectly when it becomes visible.
There are two possible methods to avoid incorrect positioning:
Only resize visible controls while the tab page is the current page (indicated by a control's Left/Top properties > -1000)
Resize a hidden control, but at the same time adjust its Left/Top properties, so the above formulas will position it correctly. Basically this means any addition to the Height or Width property has to be offset by subtracting the same amount from the Top or Left property. (A hidden control is a control with Left/Top properties <= -1000).
|