Solved

Moving objects programmatically within the .INIT() event

Posted on 2012-03-15
2
502 Views
Last Modified: 2012-06-21
I'm trying to keep my FORMs tidy by hiding unused objects and moving others up to fill these spaces.

The particular FORM that I'm having trouble with has a pageframe. Within that there's a series of pages. Within those there's a series of objects, mostly containers.

Within the .INIT event for container A, we decide whether it's needed. If it isn't, then it gets hidden with a
    .VISIBLE = .F.

Let's suppose that container B is just below this. It is needed, so the .VISIBLE property is set as .T.

Then what I'm trying to do is within the .INIT event. The code looks like

FOR EACH loObject1 IN THIS.Objects
      IF .NOT. loObject1.Visible
            FOR EACH loObject2 IN THIS.Objects
                  IF ( loObject2.Top >= loObject1.Top + loObject1.Height )
                        loObject2.Top = loObject2.Top - loObject1.Height
                        ENDIF
                  NEXT
            ENDIF
      NEXT

That all seems to work - tracing it through with DEBUG certainly re-positions container B higher up the window.

But after it's gone through that process, and after it has come out of the page's INIT event, then the object position springs back to its original value.

Any suggestions?
0
Comment
Question by:IainMacb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 42

Accepted Solution

by:
pcelba earned 400 total points
ID: 37728153
Do you use non-zero Anchor property for Containers? If yes then you have to set it to zero before "shuffling".
0
 
LVL 1

Author Comment

by:IainMacb
ID: 37728747
Brilliant. Key section of code changed to

FOR EACH loObject1 IN THIS.Objects
      IF .NOT. loObject1.Visible
            FOR EACH loObject2 IN THIS.Objects
                  IF ( loObject2.Top >= loObject1.Top + loObject1.Height )
                        llAnchor         = loObject2.Anchor
                        loObject2.Anchor = 0
                        loObject2.Top    = loObject2.Top - loObject1.Height
                        loObject2.Anchor = llAnchor
                        ENDIF
                  NEXT
            ENDIF
      NEXT

Now works perfectly. Many many thanks.
0

Featured Post

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question