Is it possible to embed a standard dialogue in a custom form? For example, if I wanted to filter text input through a user-specified regular expression, can I set up a form containing a file-open dialog plus an edit box for the regex, or do I have to implement it from scratch?
Mailing lists / lazarus / 2012-04
Embedding a standard dialogue
9 messages · 5 people · –
- MMark Morgan Lloyd 5
- AAntonio Fortuny 1
- JJuha Manninen 1
- LLudo Brands 1
- UUnknown author 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
On Tue, Apr 17, 2012 at 12:17 PM, Mark Morgan Lloyd <
Show quoted text 7 lines
No, you must create your own dialog from scratch.
Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120417/ab48b8ae/attachment-0001.html>
Is it possible to embed a standard dialogue in a custom form? For example, if I wanted to…
Apologies for my lousy threading here, a message got chopped by our firewall.
Show quoted text 9 lines
OK, If I can lead on from this. The cause of bug 21792 that I raised yesterday is, I'm told, that I'd set the main form visible but minimised. The reason I'd done this is that before the form was displayed I wanted the user to provide database login credentials, I couldn't rely on a standard dialogue for that since I also needed to have him select what kind of database- PostgreSQL or Firefox- as well as the server and possibly port.
What is the correct thing to do in this sort of situation? I've seen a description of a hack for Delphi which relied on creating the main form manually, should something like that be attempted for Lazarus?
Or should I simply redo the app so that the login is the main form?
Le 18/04/2012 09:42, Mark Morgan Lloyd a ?crit :
Show quoted text 20 lines
For such cases I build a DataModule whith auto creation. In the DataModule OnCreate event code I create and display a modal little window asking for credentials. Depending on user's answers I cancel the program. Make sure the login form is NOT auto crated. If credentials are OK, processing continues as usual and the main form is created and displayed.
The only thing to take care of is to make sure that the creation of the DataModule is done BEFORE the main form in the project code (.dpr or .lpr) Because the DataModule is never displayed, that's it.
Antonio.
Show quoted text 7 lines
Apologies for my lousy threading here, a message got chopped by our firewall. OK, If I…
Sorry, on cell, so formatting limited here too.
Sample login form for mssql and sybase, i.e. 2 dbs at bug 21619... committed as sample program in trunk. I think the sample form could easily extended to support more dbs... Actually want to do that some day and get it into lazarus...
Ludo brands came up with the original code at the forum... Sorry, cannot find link here.
Regards,
Reinier
On 18-04-12 09:42 Mark Morgan Lloyd wrote:
Apologies for my lousy threading here, a message got chopped by our firewall.
Show quoted text 9 lines
OK, If I can lead on from this. The cause of bug 21792 that I raised yesterday is, I'm told, that I'd set the main form visible but minimised. The reason I'd done this is that before the form was displayed I wanted the user to provide database login credentials, I couldn't rely on a standard dialogue for that since I also needed to have him select what kind of database- PostgreSQL or Firefox- as well as the server and possibly port.
What is the correct thing to do in this sort of situation? I've seen a description of a hack for Delphi which relied on creating the main form manually, should something like that be attempted for Lazarus?
Or should I simply redo the app so that the login is the main form?
Le 18/04/2012 09:42, Mark Morgan Lloyd a ?crit : For such cases I build a DataModule…
Antonio Fortuny wrote 37 lines
Thanks, will follow up.
Sorry, on cell, so formatting limited here too. Sample login form for mssql and sybase,…
Show quoted text 37 lines
Thanks, I'll investigate. I notice that the form I set up allowed the server type, name/address, port, SSL usage, user name and password to be set up.
Apologies for my lousy threading here, a message got chopped by our firewall. OK, If I…
Show quoted text 18 lines
In the OnCreate handler for the main form, you can create your login form and do a showmodal of that form. In Oncreate the main form isn't visible yet. In case the user can't provide correct credentials, call application.terminate: under gtk2 the main form will never show, windows shows the main form in a very short flash which can be avoided by setting windowstate:=wsminimized; just before application.terminate.
procedure TFormMain.FormCreate(Sender: TObject);
begin
FormLogin:=TFormLogin.create(self);
while true do
case FormLogin.showmodal of
mrAbort:
begin
windowstate:=wsminimized;
application.terminate;
break;
end;
mrOK:
break;
end;
FormLogin.destroy;
end;This will loop on the login form until the user aborts (mrAbort) or the correct login credentials are provided (mrOK). You can do the credential check in the login form or in the mrOK case if you like.
Ludo
Ludo Brands wrote 45 lines
Thanks Ludo, "clear as a bell" :-)
I'm already tinkering in various apps with getting things to happen at various times relative to the validity of the main form object, it just hadn't occurred to me that I could forcibly create a premature login form.
