Solved

MFC,C++: CEdit inexplicably has a HWND of X00000000

Posted on 2007-11-30
3
628 Views
Last Modified: 2013-12-14
I've created an MFC CDialog, in the usual way. The following ENSURE is causing the application to trigger a breakpoint:

void CWnd::SetWindowText(LPCTSTR lpszString)
{
      ENSURE(this);
      ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
.....
}

Looking through the call stack, I can see that my CEDit, from which I have called SetWindowTextA(), has a HWND of 0x00000000:

Description = {CEdit hWnd=0x00000000}

This is clearly bogus, but I have no idea why it should be so.

If I don't call any dialog items member functions, the dialog displays without trouble.

I've never had any trouble doing this in the recent past.

MY DoDataExchange is perfect - It was generated by the form editor.

The correct dialog IDD is specified in my enum.

What has gone wrong?

Regards,
Sternocera
0
Comment
Question by:sternocera
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 20380637
You haven't linked the edit control to the edit (in the resource).

Check you have the necessary line in the DoDataExchange.
Check you are NOT calling the SetText before the CDialog::OnInitDialog is called
0
 

Author Comment

by:sternocera
ID: 20380645
Andy,

I forgot to call the base class implementation. Embarresingly enough, this is the second time you've answered the same question in a short period.

I'm quite sick at the moment, so I guess I'm not at my peek.

Anyway, Thanks.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 20380680
Thanks, and get well soon.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

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

23 Experts available now in Live!

Get 1:1 Help Now