I'm trying to create an edit box inside my Win-32 application, but am having a bit of trouble. It will only show up under the circumstances that my mouse is moving, clicking and dragging at the same time, and it wil be flickering in and out of visibility
I create my initial window like this:
m_hWnd = CreateWindow(m_wWindowName.c_str(), m_wWindowName.c_str(),
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, 0, 0, m_hInstance, this);
And then I try to create a new Edit box inside the existing window afterwards:
CreateWindowEx(WS_EX_CLIENTEDGE,
TEXT("Edit"), TEXT(""),
WS_CHILD | WS_VISIBLE,
10, 80,
200, 20,
m_hWnd, (HMENU)1, NULL, NULL);
EDIT: I am creating my initial window in its own class, by doing the following
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance,
PSTR cmdLine, int showCmd)
{
CApplication Application;
Application.Initialise(hInstance, MainWndProc, L"GUI Tool");
return Application.Run();
}
The initialise function creates the window, and then directly after (still in the initialise function) I am attempting to create the edit box.
Could someone give some help as to why this is happening?
Thanks
It sounds like you're painting over the top of the control in your
WM_PAINT
handler (or this is being done byDefWindowProc
).The easiest solution is to set the
WS_CLIPCHILDREN
style on the parent window, which will automatically clip out any child windows when painting.