PDA

View Full Version : How to create CWnd from QWidget?



vudvpro
15th April 2011, 10:56
file.h have: class CTaskbarNotifier : public CWnd
///////
CTaskbarNotifier m_wndTaskbarNotifier;
\\\\\\\


file.cpp
///////


myfile::myfile(QWidget *parent) : QWidget(parent)
{

// create the layout
createLayout();

// create the animations
createAnimations();

m_wndTaskbarNotifier.Create(/*what_this?*/);
}

\\\\\\\


Include TaskbarNotifier.cpp
///////


int CTaskbarNotifier::Create(CWnd *pWndParent)
{
m_pWndParent=pWndParent;
CString strWndClass=AfxRegisterWndClass(0,AfxGetApp()->LoadStandardCursor(IDC_ARROW),GetSysColorBrush(COL OR_WINDOW),NULL);
return CreateEx(0,strWndClass,NULL,WS_POPUP,0,0,0,0,pWndP arent->m_hWnd,NULL);
}

\\\\\\\

Thanks!!!

mcosta
15th April 2011, 16:54
You are mixing Qt and MFC. Are you sure???

Try using QWidget::winId to extract Windows Native Handle of the Widget

vudvpro
26th April 2011, 06:08
Thank you very much!
But you can give me an example of it?

mcosta
26th April 2011, 07:22
Sorry but I don't know MFC.

squidge
26th April 2011, 08:25
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.

vudvpro
10th May 2011, 11:01
This ok:


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);
}