Link to home
Start Free TrialLog in
Avatar of mitchguy
mitchguy

asked on

OnInitDialog( ) function VC++

This is my first time using VC++:
I'm trying to follow a database tutorial from a book and it isn't clear or it leaves out how to accomplish this simple task of adding names of database tables to a list box.

I want to add the following code:

m_TableList.AddString(" my database ");

("where m_TableList is the variable name associated with my list box")

to the OnInitDialog() function

My problem is i don't know where this function is, I
thought is would have been automatically generated from the addition of the list box, but i cant seem to find it.

So if someone can tell me where the OnInitDialog() function is or where to and how to create it if that's what's necessary, my problem will be solved.
Thanks
Avatar of Dave_Anderson
Dave_Anderson

The OnInitDialog() function that is provided with the AppWizard is in the application's dialog class file.  So if your app is called "MyApp" try looking in the "MyAppDlg.cpp" source code file.  If you need to create it, bring up the ClassWizard and select the MyAppDlg class in the class name drop down list.  (located at the top of the dialog)  On the left hand side of the dialog, select the CMyAppDlg object ID, and on the right hand side, select the WM_INITDIALOG Message ID, and click Add Function.  This will add the OnInitDialog() function and you can edit the code from there.  Hope this helps!
Avatar of mitchguy

ASKER

I was able to add the class following your instructions
although the variable m_TableList which is mapped to the
list box is not recognized and caused an undeclared compile error. I added the function to a class called
CAboutDig() which was generated for me when i created the APP. The code for this is in a file named DBExplore.cpp, but the previously recognized usage of the variable m_TableList is in another file DBExploreView.cpp
A header DBExploreView.h is included in DBExplore.cpp
yet it still gives a compile error. I don't know if i'm making my situation any clearer or not. My objective is just to add a string name to a list box.
ASKER CERTIFIED SOLUTION
Avatar of Dave_Anderson
Dave_Anderson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial