Click here to Skip to main content
15,914,070 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created an SDI application with ODBC support & I want to add to it a login dialog with User & Password.
I am wondering if I use that login dialog as a CDialog derived class, and then call the DoModal() function or should I use the CRecordView derived class, and then create another CFrameWnd and attach to it the CRecordView and show it. and from where calling that login dialog before the main frame is first shown.
Help me please, I am confused :confused:
Posted

Since you want the get the credentials to authenticate from the application you should use a CDialog derived class.
A view is normally used if you want it to be a form which the user uses at any time to enter any details.
 
Share this answer
 
As superman said CDialog::DoModal seems good here.You could show it on InitInstance itself. so if authentication fails you can just stop there. :)
 
Share this answer
 
Comments
Mr. Tomay 31-Dec-10 4:49am    
Thanks for the suggestion. I tried to call the CDialog::DoModal() function from CWinApp::InitInstance() first (before the main frame is created & shown), my application crashes. & when I call it as last function from CWinApp::InitInstance(), my application starts normaly, but the main frame window will also be shown :confused:
jk chan 31-Dec-10 7:05am    
This what you need to do

CApp::InitInstance()
{
//...some codes
CLoginDlg dlg;
if( dlg.DoModal() != OK )
{
// login failed , you don't need to show your frame window.
return FALSE;
}

// as usual CSingleDocTemplate and creation of CFrameWnd and all...

return TRUE;
}
Mr. Tomay 31-Dec-10 17:00pm    
Thanks for the code. It's working now ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900