Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Moving objects programmatically within the .INIT() event

Posted on 2012-03-15
2
Medium Priority
?
509 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 43

Accepted Solution

by:
pcelba earned 1600 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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…
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 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