Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Moving objects programmatically within the .INIT() event

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

963 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