Solved

Show a PasswordDlg

Posted on 1997-05-24
3
392 Views
Last Modified: 2012-06-27
I want a PasswordDlg appears immediately after form1 created.
Where I should put the statement, PasswordDlg.ShowModal?
I don't want to put it in a button Onclick event, I want that is automatically done.
I don't want to put it in the Onpaint event of form1, since whenever the form repainted PasswordDog would appear again.
0
Comment
Question by:zhuhail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
sleach earned 40 total points
ID: 1336574
If you want the Pass Dialog shown before the form is displayed, place it in the OnCreate event of the form.

If you want the Pass Dialog shown after the form is displayed, but before the user can do anything, place it in the OnActivate method, and set a global flag so that it is only displayed the first time the event occurs.

0
 

Author Comment

by:zhuhail
ID: 1336575
Thank you.

I have tried to put PasswordDlg.ShowMadal in OnActive event of Form1. That worked fine. However, when put that in OnCreate event of Form1, I got an error message:
'Access violation at address 0041DC8F. Read of address FFFFFFFF'
What is the message means?
0
 
LVL 1

Expert Comment

by:sleach
ID: 1336576
PasswordDlg must be a delphi form.  I used a MessageBox to test.  The problem is that PasswordDlg is not the first form created.  Your main form is.  Therefore your trying to ShowModal a form that has not yet been created.

The solution is to create the PasswordDlg form at runtime.
REMOVE PasswordDlg from the projects AutoCreate list with the project manager.  Then Create the form at runtime.  An example of how to do this is below.

procedure TForm1.FormCreate(Sender: TObject);
var
PasswordDlg:  TPasswordDlg;
begin
PasswordDlg := TPasswordDlg.create(self);
PasswordDlg.ShowModal;
end;

0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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