Re: Problem in CS_NOCLOSE dialog in msvs2010
On Thu, 3 Jul 2014 00:40:28 -0700 (PDT), denniel.andres@gmail.com
wrote:
Good day!
I'm new with MFC.. I have trouble on making dialog "CS_NOCLOSE" in visual studio 2010. Here is the snippet on how I create the these dialog.
///////////////////////////////////////
class CToolDlg : public CDialog
{
public:
CEditDlg1 m_dlg1;
CEditDlg2 m_dlg2;
void Create(CWnd *pParent) // the Parent is mainframe
{
CString str = AfxRegisterWndClass(CS_NOCLOSE,NULL, NULL, NULL);
CRect rect;
pPrent->GetWindowRect(rect);
^^^^^^-- Do you mean pParent?
//....
//....
CWnd::CreteEx(WS_EX_TOOLWINDOW, str, _("XXX"), WS_POPUP|WS_BORDER|WS_CAPTION, rect, pParent, NULL);
^^^^^^^-- Do you mean CreateEx?
m_dlg1.Create();
m_dlg2.Create();
SetToolDlg(&m_dlg1);
ShowWindow(SW_SHOW);
^^^^^^^
Use SW_SHOWNORMAL on first display of the window.
}
void SetToolDlg(CDlg * pWnd)
{
CRect rect(0, 0, 0, 0);
if (pWnd)
pWnd->GetWindowRect(rect);
else
m_dlg1.GetWindowRect(rect);
CalcWindowRect(rect, 0);
SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_NOACTIVTE|SWP_NOZORDER|SWP_NOMOVE);
^^^^^^^^^^^^^
Do you mean SWP_NOACTIVATE?
if (pWnd)
{
pWnd->GetParent()->SetWindowTextW(_T("Test"));
pWnd->ShowWindow(SW_SHOWA);
^^^^^^^^
This should be SW_SHOWNORMAL.
pWNd->SetWindowPos(&wndTop, 0, 0, 0, 0, SW_NOACTIVATE|SWP_NOZORDER);
^^^^^^^^^^^^^
Do you mean SWP_NOACTIVATE?
}
}
}
///////////////////////////////////////
The problem is when I click the toolbar for every dialog, the dialog will changed the size but the controls for that dialog didn't display.
Then when I click again the same toolbar the dialog size will change and the size is too small.
Is there anyone can help me to solve this problem?
Many typos suggest you are so confused and frustrated that you can't
copy-paste without introducing errors. I don't know how you got this
to compile past the third line of Create. Slow down, take a break.
Think about something else for a while.
Lack of a compilable example makes it impossible to reproduce your
problem but I think an entire isolation of the problem might be quite
a long post.