Solved

Opening a long form at the top

Posted on 2002-07-02
8
130 Views
Last Modified: 2010-04-04
Hi

I have a data entry form which is longer than one screen.  When the form opens, it opens at the bottom instead of the top.  

I have tried Contact_Name.SetFocus which now opens the form near the top, but there are some lines of text in TLabels above the first control, and also a couple of buttons which are not able to be seen.

How do I get the form to open right at the top?

Regards
John
0
Comment
Question by:jdthedj
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 44

Expert Comment

by:CrazyOne
ID: 7125559
I am not sure I understand what you are asking but try this MyForm.Top := 0;


The Crazy One
0
 
LVL 3

Author Comment

by:jdthedj
ID: 7125567
Hi Crazy One

I don't need the form to be at position 0,0 on the screen - I need the form to open with the topmost controls showing at the top of the form.  At the moment the controls in the middle of the form are at the top when the form opens, so that the controls above that are not seen and the user must scroll up to see them.

John
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 7125789
Hmmm well I guess what you would need to do is write a routine to calculate the difference between what component you want to have shown at the top of the screen and the distance in pixels between it an the top of the form. Of course if the component is parented to something other then the form then you would have to work in with the calculation the parent of the component.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7125807
Try setting the ActiveControl of your form :)
0
 
LVL 3

Author Comment

by:jdthedj
ID: 7126354
Hi DragonSlayer - Sorry! that does not work
0
 
LVL 7

Accepted Solution

by:
Cynna earned 50 total points
ID: 7126545
jdthedj,

Let's say this happens with Form1. Try this:

var
MoveToTop: Boolean; // Global var

procedure TForm2.FormShow(Sender: TObject);
begin
  MoveToTop:=TRUE;
end;

procedure TForm2.FormPaint(Sender: TObject);
begin
  // This actually moves contens of the form on the top:
  if MoveToTop then VertScrollBar.Position:=0;
  MoveToTop:=FALSE;
end;
0
 
LVL 3

Author Comment

by:jdthedj
ID: 7127970
Thanks Cynna - it works perfectly!

John
0
 
LVL 7

Expert Comment

by:Cynna
ID: 7128123
You're welcome.

Cy.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 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