How to create CWnd from QWidget?
file.h have: class CTaskbarNotifier : public CWnd
///////
CTaskbarNotifier m_wndTaskbarNotifier;
\\\\\\\
file.cpp
///////
Code:
{
// create the layout
createLayout();
// create the animations
createAnimations();
m_wndTaskbarNotifier.Create(/*what_this?*/);
}
\\\\\\\
Include TaskbarNotifier.cpp
///////
Code:
int CTaskbarNotifier::Create(CWnd *pWndParent)
{
m_pWndParent=pWndParent;
CString strWndClass=AfxRegisterWndClass(0,AfxGetApp()->LoadStandardCursor(IDC_ARROW),GetSysColorBrush(COLOR_WINDOW),NULL);
return CreateEx(0,strWndClass,NULL,WS_POPUP,0,0,0,0,pWndParent->m_hWnd,NULL);
}
\\\\\\\
Thanks!!!
Re: How to create CWnd from QWidget?
You are mixing Qt and MFC. Are you sure???
Try using QWidget::winId to extract Windows Native Handle of the Widget
Re: How to create CWnd from QWidget?
Thank you very much!
But you can give me an example of it?
Re: How to create CWnd from QWidget?
Sorry but I don't know MFC.
Re: How to create CWnd from QWidget?
You can do CWnd *wnd = CWnd::FromHandle(QtWnd->winId) but note that this only creates a temporary CWnd object and so should not be stored for later use.
Re: How to create CWnd from QWidget?
This ok:
Code:
void Myclass::CreateTaskbarNotifier()
{
CTaskbarNotifier pTaskbarItem;
afxCurrentInstanceHandle = qWinAppInst();
CWnd *pWnd;
pWnd = AfxGetApp()->GetMainWnd();
pTaskbarItem.Create(pWnd);
}
int CTaskbarNotifier::Create(CWnd *pWndParent)
{
m_pWndParent = pWndParent;
CString strWndClass = AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW), GetSysColorBrush(COLOR_WINDOW), NULL);
return CreateEx(WS_EX_TOOLWINDOW, strWndClass, NULL, WS_POPUP, 0, 0, 0, 0, pWndParent->m_hWnd, NULL);
}