I have two windows, parent window where I'm rendering by D3D11 and second child window what I want to move over parent window.
here is code how I'm creating windows:
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = 0;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)0;
wcex.lpszMenuName = 0;
wcex.lpszClassName = L"Parent";
wcex.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&wcex)){
return E_FAIL;
}
if(!(hWnd = CreateWindowEx(WS_EX_COMPOSITED,L"Parent",L"WINDOW",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN |
WS_VISIBLE,
CW_USEDEFAULT,CW_USEDEFAULT,
WIDTH,HEIGHT,
NULL,NULL,
hInstance,NULL))){
return E_FAIL;
}
and child window
wcex2.cbSize = sizeof(WNDCLASSEX);
wcex2.style = 0;
wcex2.lpfnWndProc = WndProc2;
wcex2.cbClsExtra = 0;
wcex2.cbWndExtra = 0;
wcex2.hInstance = hInstance;
wcex2.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wcex2.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex2.hbrBackground = (HBRUSH)0;
wcex2.lpszMenuName = 0;
wcex2.lpszClassName = L"Child";
wcex2.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&wcex2)){
return E_FAIL;
}
if(!(chilWnd = CreateWindowEx(0, wcex2.lpszClassName, NULL,
WS_CHILD|WS_CLIPSIBLINGS,
0,0,
200, 100,
hWnd,NULL,
hInstance,0)))
{
return FALSE;
}
this is child window's WndProc
case WM_LBUTTONDOWN:
dragWindow = true;
SetCapture(hWnd);
break;
case WM_LBUTTONUP:
ReleaseCapture();
dragWindow = false;
break;
case WM_MOUSEMOVE:
if (dragWindow == true)
{
RECT mainWindowRect;
POINT pos;
int windowWidth, windowHeight;
pos.x = (int)(short) LOWORD(lp);
pos.y = (int)(short) HIWORD(lp);
GetWindowRect(hWnd,&mainWindowRect);
windowHeight = mainWindowRect.bottom - mainWindowRect.top;
windowWidth = mainWindowRect.right - mainWindowRect.left;
ClientToScreen(hWnd, &pos);
HDWP hdwp = BeginDeferWindowPos(1);
DeferWindowPos(hdwp,
hWnd,
HWND_TOP,
pos.x,
pos.y,
windowWidth,
windowHeight,
SWP_NOZORDER);
EndDeferWindowPos(hdwp);
LockWindowUpdate(hWnd);
RedrawWindow(hWnd, 0, 0, RDW_UPDATENOW);
LockWindowUpdate(NULL);
....
case WM_PAINT:
hdc = BeginPaint(hWnd, &Ps);
FillRect( hdc, &r, (HBRUSH)GetStockObject(GRAY_BRUSH));
EndPaint(hWnd, &Ps);
without LockWindowUpdate() function I have child window traces when I'm moving it. so final result is that child window is black while I'm moving it . What can I do more? I tried GDI double buffering i.e draw in offscreen buffer on WM_MOUSEMOVE event and paint on window on WM_PAINT event but same result.
case WM_NCHITTEST: return HTCAPTION;
this will move the window around (removeWM_MOUSEMOVE/LBUTTONUP/DOWN
) Also try changingWS_EX_COMPOSITED
to zero – Barmak Shemiranicase WM_NCHITTEST: return HTCAPTION;
and removedWM_MOUSEMOVE/LBUTTONUP/DOWN
but I have traces of child window when I'm moving it , like old positions. – Alatriste