Solved

Opening a long form at the top

Posted on 2002-07-02
8
128 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
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7125807
Try setting the ActiveControl of your form :)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

17 Experts available now in Live!

Get 1:1 Help Now