Custom connect dialog does not save Server/username
Custom connect dialog does not save Server/username
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
I noticed that the SaveServerListToRegistry() call is protected in DBAccess.hpp. Is this what TMyConnectDialog uses? How do I access it?
Thanks
Piet
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.
You can look at the example of using custom connection dialog in the ConnectDialog demo of MyDACDemo.
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.
To solve the problem add the ConnectDialog published property to the TConnectDlg class, like this:
To connect to MySQL server use the following code instead of your code in the bConnectClick method:
Code: Select all
__published:
__property TMyConnectDialog* ConnectDialog = {read=FConnectDialog, write=SetConnectDialog};Code: Select all
RegisterClass(__classid(TConnectDlg));
DMod->MyConnection->ConnectDialog->DialogClass = "TConnectDlg";
DMod->MyConnection->Connect();