Discussion:
Problem in CS_NOCLOSE dialog in msvs2010
(too old to reply)
d***@gmail.com
2014-07-03 07:40:28 UTC
Permalink
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);
....
....
CWnd::CreteEx(WS_EX_TOOLWINDOW, str, _("XXX"), WS_POPUP|WS_BORDER|WS_CAPTION, rect, pParent, NULL);
m_dlg1.Create();
m_dlg2.Create();
SetToolDlg(&m_dlg1);
ShowWindow(SW_SHOW);
}
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);

if (pWnd)
{
pWnd->GetParent()->SetWindowTextW(_T("Test"));
pWnd->ShowWindow(SW_SHOWA);
pWNd->SetWindowPos(&wndTop, 0, 0, 0, 0, SW_NOACTIVATE|SWP_NOZORDER);
}
}
}
///////////////////////////////////////

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?

Thanks in advance.

Denniel
ROHM LSI Design Philippines, Inc.
Research and Development - EDA
Geoff
2014-07-03 18:27:17 UTC
Permalink
Post by d***@gmail.com
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
{
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?
Post by d***@gmail.com
//....
//....
CWnd::CreteEx(WS_EX_TOOLWINDOW, str, _("XXX"), WS_POPUP|WS_BORDER|WS_CAPTION, rect, pParent, NULL);
^^^^^^^-- Do you mean CreateEx?
Post by d***@gmail.com
m_dlg1.Create();
m_dlg2.Create();
SetToolDlg(&m_dlg1);
ShowWindow(SW_SHOW);
^^^^^^^
Use SW_SHOWNORMAL on first display of the window.
Post by d***@gmail.com
}
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?
Post by d***@gmail.com
if (pWnd)
{
pWnd->GetParent()->SetWindowTextW(_T("Test"));
pWnd->ShowWindow(SW_SHOWA);
^^^^^^^^
This should be SW_SHOWNORMAL.
Post by d***@gmail.com
pWNd->SetWindowPos(&wndTop, 0, 0, 0, 0, SW_NOACTIVATE|SWP_NOZORDER);
^^^^^^^^^^^^^
Do you mean SWP_NOACTIVATE?
Post by d***@gmail.com
}
}
}
///////////////////////////////////////
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.

Loading...