0

I'm new to programming and I am experimenting with Windows Forms Applications on Visual Studio C++ 2012. I added a comboBox to the form and want to initialize with values determined at runtime. I did some research and found that I need to define the OnInitDialog() function. Where do I implement this (and how)? Visual Studio has created two source files: Form1.h and .cpp.

Thank you.

  • That's a different framework. Use the constructor of your Form derived class to initialize it, after the InitializeComponent() call. – Hans Passant Aug 10 '14 at 09:08

2 Answers2

1

OnInitDialog() is for MFC dialogs, not Windows Forms -- you can initialize your controls either in each control's constructor or in the form's Load event (OnLoad overridable method) -- some more info in this SO answer.

Community
  • 1
  • 1
Edward Clements
  • 5,040
  • 2
  • 21
  • 27
0

OnInitDialog need to be part of a class which is derived from CDialog or CDialogEx.

If you used Visual Studio project creation wizard and selected MFC type application and then as Dialog based, you will have OnInitDialog function created by the wizard automatically.

Haja Maideen
  • 450
  • 2
  • 4