Originally Posted by
Ken Fitlike
You can but it's not pretty - well this isn't anyway:
Thanks. Guess I've learnt something new today!
I always thought GetDesktopHandle() returned NULL, and so I always used NULL for hWndParent when creating a child window, which of course never worked.
Edit:
@sethjackson
I believe your problem is you have 2 different CWindow objects.
One is a global object defined at the top of main.cpp
Code:
#include <windows.h>
#include "editcontrol.h"
#include "window.h"
#include "main.h"
CEditControl EditControl;
CWindow Window;
Another is a local object defined in CEditControl's Create() method.
Code:
int CEditControl::Create()
{
CWindow Window;
m_hEdit = CreateWindowEx(
WS_EX_CLIENTEDGE,
"EDIT",
NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL |
ES_WANTRETURN,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
Window.g_hMainWindow,
(HMENU)ID_TEXT,
Window.g_hThisInstance,
NULL
);
So you're trying to create the edit control using a local CWindow object that didn't call CWindow::Create.
Another possible issue: Your CWindow and CEditControl contructors don't initialize their data members to meaningful values.