Solved

Moving objects programmatically within the .INIT() event

Posted on 2012-03-15
2
475 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
2 Comments
 
LVL 41

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now