Custom connect dialog does not save Server/username

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pterblan
Posts: 6
Joined: Thu 22 Jul 2010 15:19

Custom connect dialog does not save Server/username

Post by pterblan » Mon 20 Sep 2010 09:40

I've implemented my own themed connect dialog in Builder 2010. It works fine but does not store the previous successful server or user names. It does list the servers stored by TMyConnectDialog (if I switch to TMyConnectDialog and then back to my custom one).

I noticed that the SaveServerListToRegistry() call is protected in DBAccess.hpp. Is this what TMyConnectDialog uses? How do I access it?

Thanks
Piet

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 22 Sep 2010 09:39

You can use your own connection form, but you should use it with TCustomConnectDialog or its descendant. In this case you can use the functionality of TCustomConnectDialog. To save connection options set the TCustomConnectDialog.StoreLogInfo property to True.
You can look at the example of using custom connection dialog in the ConnectDialog demo of MyDACDemo.

pterblan
Posts: 6
Joined: Thu 22 Jul 2010 15:19

Post by pterblan » Thu 30 Sep 2010 11:48

I followed the example and use my own dialog with TCustomConnectDialog. I also set the StoreLogInfo property to true, but that only worked when I used TMyConnectDialog directly. The problem appears to be that my connection dialog would read info previously stored by TMyConnectDialog, but not add any new info. Everything else works well.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 04 Oct 2010 13:50

Please try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.

pterblan
Posts: 6
Joined: Thu 22 Jul 2010 15:19

Post by pterblan » Wed 20 Oct 2010 11:55

Any luck with my sample app?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 26 Oct 2010 11:39

To solve the problem add the ConnectDialog published property to the TConnectDlg class, like this:

Code: Select all

__published:
  __property TMyConnectDialog* ConnectDialog = {read=FConnectDialog, write=SetConnectDialog};
To connect to MySQL server use the following code instead of your code in the bConnectClick method:

Code: Select all

  RegisterClass(__classid(TConnectDlg));
  DMod->MyConnection->ConnectDialog->DialogClass = "TConnectDlg";
  DMod->MyConnection->Connect();

pterblan
Posts: 6
Joined: Thu 22 Jul 2010 15:19

Post by pterblan » Tue 26 Oct 2010 12:47

Great! Everything now works exactly as I wanted it to.
Thanks again for excellent support.

Post Reply