Discussion:
How to create a MDI type of child frame windows in SDI?
(too old to reply)
JiiPee
2016-01-02 01:46:12 UTC
Permalink
I want to have child frame windowses inside my SDI applications view
just like in MDI child frame windowses have boundaries inside the main
frame. How can I do this? I created my own frame windowses like this:

void CChildFrame::CreateAndShow(CView* pParentView)
{
CCreateContext ccc;
ccc.m_pNewViewClass = RUNTIME_CLASS(CChildFrameView);
ccc.m_pCurrentDoc = NULL;
ccc.m_pNewDocTemplate = NULL;
ccc.m_pLastView = NULL;
ccc.m_pCurrentFrame = this;
Create( NULL,m_parameters.title,WS_OVERLAPPEDWINDOW | WS_BORDER |
WS_CHILD
| WS_CLIPSIBLINGS | WS_VISIBLE | WS_CAPTION | WS_MAXIMIZEBOX |
WS_MINIMIZEBOX ,
m_parameters.rectWindow, pParentView, NULL, 0, &ccc);
ShowWindow(1);
SetWindowPos(&CWnd::wndBottom, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
}

where: pParentView is the view in the mainframe and is:
class CChildFrame : public CFrameWnd

It almost works: the frame CChildFrame window is inside the view and
they move. But:
- they seem to be inactive (some messages they do not receive plus the
titles of all of them seem to be inactive... greyed)
- they do not get focus immediately... sometimes needs to click couple
of times them to get the focus and come on top

I guess my create parameters are not correct? Can a Frame window be a
child window anyway?
JiiPee
2016-01-02 02:15:12 UTC
Permalink
I seem to have found the solution finally (It took long time to find
it). This website:
http://www.programmershare.com/3738146/

said that it can be a WS_POPUP window and also I have to set :
SetParent(pParentView); so using this function set the main frame view
to parent.

This code is the fixed version (now its active and receives also messages):

void CChildFrame::CreateAndShow(CView* pParentView)
{
CCreateContext ccc;
ccc.m_pNewViewClass = RUNTIME_CLASS(CChildFrameView);
ccc.m_pCurrentDoc = NULL;
ccc.m_pNewDocTemplate = NULL;
ccc.m_pLastView = NULL;
ccc.m_pCurrentFrame = this;
Create( NULL,m_parameters.title, WS_BORDER | WS_CHILD | WS_POPUP
| WS_CLIPSIBLINGS | WS_VISIBLE | WS_CAPTION | WS_MAXIMIZEBOX |
WS_MINIMIZEBOX /*| WS_POPUPWINDOW*/,
m_parameters.rectWindow, pParentView, NULL,
0, &ccc);
SetParent(pParentView);
ShowWindow(1);
SetWindowPos(&CWnd::wndTop, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
}

Plus in OnSetFocus(CWnd* pOldWnd) message handler needs to do:
SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

to make it top window.

Now if just somebody helps me with the toolbar question :).
Post by JiiPee
I want to have child frame windowses inside my SDI applications view
just like in MDI child frame windowses have boundaries inside the main
void CChildFrame::CreateAndShow(CView* pParentView)
{
CCreateContext ccc;
ccc.m_pNewViewClass = RUNTIME_CLASS(CChildFrameView);
ccc.m_pCurrentDoc = NULL;
ccc.m_pNewDocTemplate = NULL;
ccc.m_pLastView = NULL;
ccc.m_pCurrentFrame = this;
Create( NULL,m_parameters.title,WS_OVERLAPPEDWINDOW | WS_BORDER |
WS_CHILD
| WS_CLIPSIBLINGS | WS_VISIBLE | WS_CAPTION | WS_MAXIMIZEBOX |
WS_MINIMIZEBOX ,
m_parameters.rectWindow, pParentView, NULL, 0, &ccc);
ShowWindow(1);
SetWindowPos(&CWnd::wndBottom, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
}
class CChildFrame : public CFrameWnd
It almost works: the frame CChildFrame window is inside the view and
- they seem to be inactive (some messages they do not receive plus the
titles of all of them seem to be inactive... greyed)
- they do not get focus immediately... sometimes needs to click couple
of times them to get the focus and come on top
I guess my create parameters are not correct? Can a Frame window be a
child window anyway?
Loading...