Solved

OnInitDialog( ) function VC++

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now