[RESOLVED] Resizing objects bring to front other objects in SSTab
Hi.
I've got a SStab object with 3 tabs. Each tab has one MSHFlexGrid.
These object are in a MDIForm Child.
When I resize the child form, i'll do this code:
Code:
'Consultas is a form
'every object started with Grid is a MSHFlexgrid
Public Sub FormConsultas()
On Error GoTo Erro
Consultas.SSTab1.Height = Consultas.Height
Consultas.SSTab1.Width = Consultas.Width
If Consultas.Width < 11925 Then Consultas.Width = 11925
If Consultas.Height < 8055 Then Consultas.Height = 8055
Consultas.GridFactESDDExp.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
Consultas.GridAcordoHorasFech.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
Consultas.GridAvisosCobrancas.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
Erro:
Select Case Err.Number
Case 0
Case 384
Case Else
MsgBox Err.Number & " - " & Err.Description & " - " & Err.Source
End Select
End Sub
What happens is: after resizing the form, sometimes, the grid of the 2nd tab persist visible when tab 1 is selected.
What can explain this behavior, and how can I avoid this?
Thanks
Re: Resizing objects bring to front other objects in SSTab
If the grid of the 2nd tab is Consultas.GridAcordoHorasFech, you can
Consultas.GridAcordoHorasFech.Visible = False
Re: Resizing objects bring to front other objects in SSTab
Ok, that could be one possible way to resolve my problem.Thanks!
But can you tell me why that behavior happens?
Re: Resizing objects bring to front other objects in SSTab
Quote:
But can you tell me why that behavior happens?
To understand why this happens you need to understand how the SSTab works.
The SSTab really only has one container. It simply moves controls on and off the container by changing their Left property. It does this by adding and subtracting 75000 to the left property of each control on the container as you switch tabs.
For example, a control whose Left property is 360 when it is on the current Tab becomes -74640 (360 - 75000) when you switch tabs. Switch back and it adds the 75000 back to the Left property. When you change the Left property in code, you are in effect moving the control onto the current Tab.
Note this only affects controls whose container is the SSTab. The Left property of controls in a Frame which is on the SSTab are not manipulated, only the Frame's Left property is changed.
To resolve this problem here are some options. I would recommend # 3.
1) Don't change the Left property.
2) Only change the Left property of controls that are on the current Tab
If for some reason you need to change the Left property of all controls on every tab simply set the current Tab before doing so.
Code:
Consultas.Tab = 0
Consultas.GridFactESDDExp.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
Consultas.Tab = 1
Consultas.GridAcordoHorasFech.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
Consultas.Tab = 2
Consultas.GridAvisosCobrancas.Move 90, 600, Consultas.Width - 420, Consultas.Height - 2000
3) Put a Frame on every Tab and place the controls for the Tab on the Frame. The SSTab only has to worry about the Frame controls and when you change the Left property of controls via code it is relative to the Frame not the SSTab.
Re: Resizing objects bring to front other objects in SSTab
Ok. That's enough for me, thank you. :thumb:
I'll try your suggestions.