Click to See Complete Forum and Search --> : dialog and other probs


April 3rd, 1999, 10:50 AM
I am currently writing a calendar application and am having some problems. If anyone can answer (some of) these queries I would be most grateful.

Firstly I want to use Calendar Control 8.0 in one of my applications but don't know the name of the class, and therefore can't create an instance of it. The file name is Mscal.ocx. It is an SDI program. The thing is this calendar was written in VB and so the help examples are in Visual Basic. Can I use this in my VC++ program ok and can I call the functions etc. The first time I used the Calendar the class was put into my workspace (so I could look at all the code, member functions etc.) but I can't get it to do that anymore and don't know why. If I could get it to reappear ni the workspace it would solve many of my problems.

I also have a dialog box which prompts the user to enter their user name before the program is loaded. Should I put this call in the initinstance function (in CXApp) or in OnCreate (in CMainFrame). I would guess InitInstance but I am not sure.

I have a dialog box where the user enters a password then has to enter it again to confirm. I firstly want to give the edit box focus so the user can start typing immediately, but at the moment the OK button has focus. I would also like the user to be able to press enter after entring the first password and have the focus go to the confirmation edit box but at the moment its as if OK was pressed and the dialog box closes. I have a check to see if the passwords match, which works, but I would like the password dialog box to stay open if the passwords are not the same, but at the moment it just closes. Can I keep that dialog box open or do I have to call the DoModal function to re-open it after it has closed.

Sorry for such a large query and I hope someone can help.

Mark

Daniel Levine
April 3rd, 1999, 12:28 PM
Hi,

Concerning the calendar control, you can use it in your app, and you need to make it appear in your workspace so you can use it. (Sorry, but I'm not sure how to do that. Try doing whatever it was you did before.)

Concerning where to call the Logon dialog, it makes more sense to put the call in InitInstance(), because that will give you greater control over program flow. You can, however, make it work if you put the call in OnCreate for CMainFrame.

Concerning the password dialog, if you want the first edit box to have focus, put it first in the tab order (to set the tab order, goto Layout->Tab Order, or press CTRL+D). To have the user press enter after entering the first password and have focus set to the next edit box requires a bit of trickery. First, make sure the OK button is the default button. Second, Override the OnOK() member function, and call UpdateData(). Then, check to see if the second edit box's variable (m_strPwdConfirm, or whatever) is empty by calling m_strPwdConfirm.IsEmpty(). If it is empty, call SetFocus() for the second edit box, and return from the function without calling CDialog::OnOK(). If the second password is not empty, than compare the two passwords. If they are not equal, then tell the user (MessageBox works well), and return without calling the base class version of OnOK(). Otherwise, just continue on, and allow it to close.

I hope this helps.

Daniel.

Masaaki
April 3rd, 1999, 05:31 PM
Hi.

1) When you want to add ActiveX control like Canledar control, Project->Add to project->Componet(?)
and choose the ActiveX control which you want to add. VC asks you to the class name which you want to use.
After this, control toolbar has the ActiveX control which you did.
However, after this, you may face more diffcult problem?

2) When I made a password dialog, I use loop to generate the dialog. However, the provious post mehod seems to be better.
In my case, the program tries to read user name and password from txt file and compare the data. Also, the databasse will
be available. I want to manupulate the password and user id later programmtically because if we write the data in the code,
we can't change it later.

Hope for help.
-Masaaki Onishi-

April 4th, 1999, 08:40 AM
Thank you for your responses. That is exactly what I was looking for.

Mark