I am new to windows programming. I have created a simple GUI using MFC AppWizard (exe). While working I need to put data in Edit box via SetDlgItemText(hDlg,nIDDlgItem,lpString).
First parameter is handle of Window. I am not able to get the same. Please help me go ahead.
You should give us more time to respond. Someone isn't always on the forum.
Anyway if you're using MFC, you probably wouldn't use SetDlgItemText, you'd probably use CWnd::SetWindowText.
It's been a while since I've used MFC, but iirc you need to tie your edit box to a CEdit control. In VS, you can do this with the Class Wizard (or at least you could back in the day -- like I said it's been a while for me).
Then when you have an CEdit object you can just do this:
1 2
// CEdit m_myeditctrl; // ClassWizard makes this for you in your header file
m_myeditctrl.SetWindowText(_T("Whatever you want in your edit box"));
Did classwizard make the CEdit control for you? Or did you just type it into your header?
Classwizard does a few other "magical" things to bind the CEdit to the actual control. If you did it yourself you probably missed a step and that's causing the assertion error.