Solved

OnInitDialog( ) function VC++

Posted on 2001-08-15
3
853 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
How to convert MFC::CString to UTF8 wchar_t* 10 381
mapAB Challlenge 35 173
Message not shown 5 84
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.

756 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