Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

OnInitDialog( ) function VC++

Posted on 2001-08-15
3
Medium Priority
?
904 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:mitchguy
  • 2
3 Comments
 

Expert Comment

by:Dave_Anderson
ID: 6389167
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!
0
 

Author Comment

by:mitchguy
ID: 6389574
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.
0
 

Accepted Solution

by:
Dave_Anderson earned 300 total points
ID: 6389731
On the dialog that contains your listbox, go to Member Variables in ClassWizard and add a member variable for the list box.  When you add it, change the category to Control, and the variable type should be CListBox (or whatever class the control is) and you can name it m_TableList.  This will declare the variable in the dialog class and will eliminate the undeclared error.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question