Archived

This topic is now archived and is closed to further replies.

NRest

DirectX and MFC

Recommended Posts

Hello, I got an annoying problem and I don''t know how to fix it and neither the people arround me, so as one of my last ways to ask help, I ask it here. I have a project, using MFC and an extern engine (static dll). The engine uses DirectX, and to init dx, I have to give a hWnd, so I can render the stuff on the window (of the hwnd). But, the MFC project I have doesn''t have really something called "hWnd", it has lotsa stuff like CWnd, but that won''t help me, using dx. the code looks like: int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // create a view to occupy the client area of the frame if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) { TRACE0("Failed to create view window\n"); return -1; } if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_LEFT | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } and so on, but all this stuff is not using hWnd (like other MFC is using). Any help would be good to get the hWnd of an object (and not a one that returns ERROR EXPRESSION NOT..... Regards, N. Rest.

Share this post


Link to post
Share on other sites
but be sure to use CWnd::GetSafeHandle() after creating the window. i faced that while i am working in a level editor. i had to post the handle after i created the window (Splitter) in OnCreateClient

Share this post


Link to post
Share on other sites