Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tip of the day. Scrollable containers, the easy way
Message
From
30/04/2012 15:12:17
Walter Meester
HoogkarspelNetherlands
 
 
To
30/04/2012 12:44:51
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01542846
Message ID:
01542919
Views:
103
>>
>>PUBLIC x
>>x = CREATEOBJECT("Mainform")
>>x.Show()
>>
>>*-
>>
>>DEFINE CLASS MainForm as Form
>>	SContainer = NULL 
>>	width = 700
>>	Height = 400
>>	
>>	ADD OBJECT Pgf AS PageFrame WITH left = 5, Top =210, Width = 690, Height = 180, pagecount = 2, TabStyle = 1, Anchor = 14 
>>
>>	FUNCTION Init
>>		THIS.sContainer = CREATEOBJECT("SContainer")
>>		ACTIVATE WINDOW (THIS.sContainer.Name) IN WINDOW (THIS.Name)
>>		THIS.sContainer.Show()
>>		THIS.Resize()
>>	ENDFUNC
>>
>>	FUNCTION resize
>>		THIS.sContainer.Move(0,0, THIS.Width - SYSMETRIC(5), THIS.Height - 200 - SYSMETRIC(6))
>>	ENDFUNC
>>ENDDEFINE
>>
>>*-
>>
>>DEFINE CLASS Scontainer as Form
>>	Scrollbars = 3
>>	TitleBar= 0
>>	BorderStyle = 0
>>		
>>	ADD OBJECT Explanation as Label WITH Caption = "This is the scrollable container", left = 100, top = 100, autosize = .t.
>>	ADD OBJECT FarObject as commandbutton WITH Left = 1000, top = 1000
>>ENDDEFINE
>>
>
>With this solution,
>because the SContainer isn't a main form's member,
>there are many side effects to fix with other code or bindevent().
>
>Like:
>
>1. if the main form datasession is changed, the Scontainer still on the original datasession.
>2. when the focus go into a SContainer's member, the main form loses the focus
>3. SContainer.parent doesn't exists

Hi Fabio,

1. Personally I don't see the problem. If the scontainer is defined with a default datasession, it will always inherit the datasession of the mainform as it is initiated in the mainforms init. I do not think too many people would change the datasession while the form is running.

2. Yes and No. The mainform does fire the deactivate event, but never loses focus in the way that the titlebar shows inactive. So from a user experience this is not an issue

3. True, perhaps that could be simulated by using a access property on the parent property that will redirect you to the mainform

There however are other concerns that are more serious.

1. if you put this on a pageframe, you'll have to hide and show the s_container depending on which page is active.

2. THISFORM within any member of s_container does not refer to the mainform but to the s_container itself. However I can image this could be resolved by the using the _access event on the THIS of the s_container form. the access code could redirect the reference to the mainform.

OTOH, the alternatives are no picknick either. Designing your own scrollable container with real scrollbars is also one riddled with roadblocks and dealing with VFP bugs (suchs as contained objects bleeding through the outside of the scontainer). I've used the ct32_scontainer in a project and had a lot of trouble there as well to get things working the way they should.

This solution is quite straighforward and the scrollbars and mouse scrolling work just the way they should, No bleed through and very simple to design the contents of the scrollable form in designtime. From a GUI and a user experience, I don't think there is any compromise.

Walter,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform