창을 만드는 콘솔 응용 프로그램이 있습니다.C++ Win32 창 응답 없음
창문에 물건을 잘 표시 할 수 있습니다. 그러나 창은 사용자가 응답하지 않거나 제어 할 수 없습니다.
창 위로 마우스를 가져 가면 모래 시계 커서가 나타나고 창을 이동할 수 없습니다.
이 문제의 원인은 무엇입니까?
편집 :
WNDCLASSEX wndClass; // Window class
ZeroMemory(&wndClass, sizeof(wndClass)); // Clear the window class structure
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC;
wndClass.lpfnWndProc = DefWindowProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = nullptr;
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndClass.lpszMenuName = NULL;//MAKEINTRESOURCE(IDR_MAINMENU);
wndClass.lpszClassName = _classname.c_str();
wndClass.hIconSm = 0;
if (RegisterClassEx(&wndClass) == 0)// Attemp to register the window class
throw std::exception("WINDOW ERROR: Failed to register the window class!");
DWORD dwStyle = 0; // Window styles
DWORD dwExStyle = 0; // Extended window styles
dwStyle = WS_OVERLAPPEDWINDOW | // Creates an overlapping window
WS_CLIPCHILDREN | // Doesn"t draw within child windows
WS_CLIPSIBLINGS; // Doesn"t draw within sibling windows
//adjust window size
RECT rMain;
rMain.left = 0;
rMain.right = width;
rMain.top = 0;
rMain.bottom = height;
AdjustWindowRect(&rMain, dwStyle, 0);
// Attempt to create the actual window
_hwnd = CreateWindowEx(dwExStyle,
className,
windowTitle,
dwStyle,
0, 0,
rMain.right - rMain.left,
rMain.bottom - rMain.top,
nullptr,
0,
nullptr,
0);
ShowWindow(_hwnd, SW_SHOW);
SetForegroundWindow(_hwnd);
SetFocus(_hwnd);
이 문제를 나타내는 코드 스 니펫이있는 경우 매우 유용합니다. –
WindowProc에서 WM_MOUSE * 메시지를 처리합니까? – munissor
DefWindowProc을 사용하는 것은 아무것도 처리하지 않습니다. – ronag