Solved

Anchor Property

Posted on 2010-09-22
3
774 Views
Last Modified: 2012-05-10
I have been working for last 2 weeks to get it done but to no avail. What the hell is wrong with the Anchor Property???

I have seen someone suggesting Anchor to be 15 (resize widith and height with form) but this is not mentioned in VFP help????

The Anchor=15 works fine but this is not what I'm looking for..

for example:

I draw a form as below:


PUBLIC MyItem1
      MyItem1=NEWOBJECT("MyForm")
      MyItem1.Show
      READ EVENTS
 
DEFINE CLASS MyForm AS form
      Top = 0
      Left = 0
      Height = 500
      AlwaysOnTop = .f.
      Width = 600
      borderstyle = 3
      controbox=.f.
      MinButton=.t.
      MaxButton=.t.
      autocenter = .t.
      Name = "MyForm"
      Forecolor = RGB(192,192,192)
      backcolor = RGB(192,192,192)      
      showwindow = 2
      TitleBar=0
      windowState = 0

      ADD Object TopShape1 AS Container WITH Top = 1, Left = -1, Width = 1280, Height = 710, Curvature = 0, specialeffect=0, Visible=.t., Anchor=15

      ADD Object BottomCont AS Container WITH Top = 400, Left = -1, Width = 600, Height = 50, Curvature = 0, specialeffect=1, Visible=.t., Anchor=64

enddefine


Questions:
======

OK...what happens when I resize the form ( I click on Max button) and then form is resized but the control's width (BottonCont) is set to something else....???

Thanks!
SP
0
Comment
Question by:Nirmal Sharma
  • 2
3 Comments
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33737149
Have you tried doubleclicking the anchor property from the property window? You get a visual interface for setting the anchor with absolute vs relative anchoring vs no anchoring to all four directions.

When I run your example the width of the ButtomCont is not changes, as that is not anchored in regard to right/left position at all. So it stays left=0, but width does not change. You might want to anchor relative towards the bottom and absolute toward the left and right border, then you need Anchor = 2+8+64=74

Especially not anchoring to the right means width never changes. You also might want to change height, eg anchor relative towards the top border (16), so you might try 90.

Take the visual anchor property editor and play around with it to see what settings mean what.

Other useful anchor settings are: Buttons in the lower right corner anchored to right bottom absolute to not change position and size: 4+8=12

Bye, Olaf.
0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 33737193
Also keep in mind anchor settings are always to the next parent container, so you anchor controls which you put into a container in respect to the container, not the form. This enables you to "cascade" anchors. Perhaps you already realized and therefore are working with containers, both with visible and non visible borders as some kind of analogon to a DIV container of HTML pages.

Bye, Olaf.
0
 
LVL 35

Author Comment

by:Nirmal Sharma
ID: 33737590
Thank You so much for your help, Olaf!

It was really helpful.

SP
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Word opens in background when called from an application 22 309
set order of a table by two fields vfp 4 1,614
VFP application slow and freezes 14 440
Remove duplicates values. 14 62
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…
If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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