Solved

OnInitDialog( ) function VC++

Posted on 2001-08-15
3
848 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 75 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

790 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