나누기 내가 그 여러 개의 창을추가 코드는 코드
그대로이 코드가 구현bool UISystem::HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
UIWindow* target = NULL;
for(vector<UIWindow*>::iterator it = windowList.begin(); it < windowList.end(); it++)
{
if((*it)->windowHandle == hwnd)
{
target = *it;
break;
}
}
if(target == NULL)
{ return false; }
switch(msg)
{
case WM_DESTROY:
return true;
case WM_PAINT:
return true;
default:
return false;
}
}
LRESULT WINAPI UISystem::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
/*if(UISYSTEM->HandleMessage(hwnd, msg, wParam, lParam))
{
}*/
return DefWindowProc(hwnd, msg, wParam, lParam);
}
이있을 것이다 만드는 오전 내 사용자 인터페이스 시스템의 일부인이 코드를 가지고, UISystem :: WndProc의 주석 블록을 포함하여 윈도우가 올바르게 표시되지만 UISystem :: WndProc에서이 블록의 주석 처리를 제거하면 잘못된 핸들이 CreateWindow에서 반환됩니다.이 도움말은 나를 혼란스럽게 만들기 때문에 도움이 될 것입니다. UISystem :: WndProc에서 다른 코드를 수행하기 전에 DefWindowProc을 호출하지만 모든 attemps가 실패했습니다.
이 UIWindow에 대한 생성자입니다 :
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
에서 :
UIWindow::UIWindow(int x, int y, int width, int height, string & text)
이이 루트 문제가 있지만 해결해야 한 가지 제거하는 경우
UIWindow::UIWindow(int x, int y, int width, int height, string & text)
{
int frameWidth = GetSystemMetrics(SM_CXSIZEFRAME);
int frameHeight = GetSystemMetrics(SM_CYSIZEFRAME);
int menuHeight = GetSystemMetrics(SM_CYMENU);
int windowXPos = (GetSystemMetrics(SM_CXSCREEN) - width)/2;
int windowYPos = (GetSystemMetrics(SM_CYSCREEN) - height)/2;
int windowWidth = width + frameWidth * 2;
int windowHeight = height + frameHeight * 2 + menuHeight;
bounds.X = x;
bounds.Y = y;
bounds.Width = width;
bounds.Height = height;
title = text;
MSG msg;
WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_VREDRAW|CS_HREDRAW|CS_OWNDC,
&UISystem::WndProc, 0, 0, hInstance, NULL, NULL, (HBRUSH)(COLOR_WINDOW + 1),
NULL, "AurousWindow", NULL};
RegisterClassEx(&wc);
windowHandle = CreateWindow("AurousWindow", title.c_str(), WS_OVERLAPPEDWINDOW, windowXPos, windowYPos, windowWidth, windowHeight, NULL, NULL, hInstance, NULL);
SetWindowRgn(windowHandle, CreateRectRgn(0, 0, width, height), TRUE);
ShowWindow(windowHandle, nShow);
UpdateWindow(windowHandle);
//RECT rec = {0, 0, width, height};
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
참고로 모든 창에 대한 전역 목록을 유지 관리하는 대신 GWL_USERDATA를 사용하여 SetWindowLong을 호출하여 창에 사용자 데이터를 저장할 수 있습니다. http://msdn.microsoft.com/en-us/library/windows/ desktop/ms633591 (v = vs.85) .aspx – avakar