   Direct2D, background becomes black when redraw
  Hello,I'm trying to create some sort of simple game. I've never used Direct X before so maybe there are some stupid things.Anyways, the problem is that, whenever I minimalize or make it smaller/bigger instead of the yellow background I gave it, it becomes black and it stays, well I think you need my code for it. Start of the program, win32 things#include "Main.h"#include "Dmain.h"int WINAPI WinMain(HINSTANCE /* hInstance */,HINSTANCE /* hPrevInstance */,LPSTR /* lpCmdLine */,int /* nCmdShow */){HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);if (SUCCEEDED(CoInitialize(NULL))){DemoApp app;if (SUCCEEDED(app.Initialize())){app.RunMessageLoop();}CoUninitialize();}return 0;}DemoApp::DemoApp(){m_hwnd = 0;}DemoApp::~DemoApp(){}HRESULT DemoApp::Initialize(){HRESULT hr = S_OK;DirectStart clDirectX;hr = clDirectX.InitializeDirectX();if(hr == S_FALSE )return hr;WNDCLASSEX wcex = { sizeof(wcex) };wcex.style= CS_HREDRAW | CS_VREDRAW;wcex.lpfnWndProc   = WndProc;wcex.hIconSm   = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));wcex.cbWndExtra= sizeof(LONG_PTR);wcex.hInstance = HINST_THISCOMPONENT;wcex.hCursor   = LoadCursor(NULL, IDC_ARROW);wcex.lpszClassName = L"D2DDemoApp";RegisterClassEx(&wcex);m_hwnd = CreateWindow(L"D2DDemoApp",L"NazStory",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,300,300,NULL,NULL,HINST_THISCOMPONENT,this);hr = m_hwnd ? S_OK : S_FALSE;if (SUCCEEDED(hr)){ShowWindow(m_hwnd, SW_SHOWNORMAL);UpdateWindow(m_hwnd);}hr = clDirectX.StartDirectX(m_hwnd);return hr;}void DemoApp::RunMessageLoop(){MSG msg;while (GetMessage(&msg, NULL, 0, 0)){TranslateMessage(&msg);DispatchMessage(&msg);}}LRESULT CALLBACK DemoApp::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){switch (message){case WM_PAINT:{break;}case WM_DESTROY:{PostQuitMessage(0);break;}default:DefWindowProc(hwnd, message, wParam, lParam);}return true;}Direct X class I wrote#include "DMain.h"DirectStart::DirectStart() : pFactory(NULL),pRT(NULL),pBlackBrush(NULL){}DirectStart::~DirectStart(){}/* Start from DirectX 2D */HRESULT DirectStart::InitializeDirectX(){HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,&pFactory);return hr;}HRESULT DirectStart::StartDirectX(HWND hwnd){if(!hwnd)return false;RECT rc;GetClientRect(hwnd, &rc);HRESULT hr = pFactory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(),D2D1::HwndRenderTargetProperties(hwnd,D2D1::SizeU(rc.right - rc.left,rc.bottom - rc.top)),&pRT);if(SUCCEEDED(hr)){hr = pRT->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Yellow),&pBlackBrush); }/*to make sure if it works or not, testing this */pRT->BeginDraw();pRT->SetTransform(D2D1::Matrix3x2F::Identity());pRT->Clear(D2D1::ColorF(D2D1::ColorF::Yellow));pRT->EndDraw();return hr;}Off course commens on my code are always welcome, I've read some SDK documentation and coded most myself, except some unintrested things.Thanks for reading,   
  i dont see a "normal" DirectX Graphics Device there, i use the IDirect3D9 and IDirect3DDevice9 Interface and then  D3DXSPRITE Interface to do 2D.but your Code, i Dont Know maybe someone with experiance with that can help  ;  I don't see the includes you make, but because you are using D2D1CreateFactory I assume that u are working with Direct2D / DirectDraw.DirectDraw is deprecated, so I suggest you learn Direct3D.If you use Direct3D9 then you  must use IDirect3D9 and IDirect3DDevice9 like ryan20fun already said.   ;  It looks like you're only rendering once, put your render code under WM_PAINT.  Whenever you need to redraw (e.g WM_MOUSEMOVE ) call InvalidateRect(hwnd, 0, 0);You'll also need to add code to resize the render target when the window size changes.   