Discussion:
MDI: Dynamically Open Dialog from Tree Click
(too old to reply)
Prayami
2007-01-07 21:26:00 UTC
Permalink
Hi...I am new to VC++.
My MDI contains following
(1) (Left Side) CDialog contains Tree, converted to CDialogBar
(2) (Right side) Another CDialog as a MDI child
Little bit similar to IDE of VC++ workspace.

When ever I click any leaf element from Tree on CDialogBar, I want to open the
similar document file listed in (2) but as a different Dialog and want to
pass some parameters with that. So that every new dialog will have it on
message on it.

I know it will be possible with following:
pDocTemplate->OpenDocumentFile(NULL);

But I have two problem here:
(1) pDocTemplate is declared in main application's header file. How can I
get the
same instance in my first Dialog which contains Tree Event.
(2) How can I pass some parameter with that Tree Click event to new Dialog.

So every time Dialog Template will be same but every new dialog will have its
own message string according to Tree leaf clicked.

It will be really helpful if there will be some sample coding or some step
by step
explaination or any link provided.

Thanks in advance...
RainMan
2007-01-18 05:39:00 UTC
Permalink
I need a little clarification:
You mentioned Another CDialog as a MDI child.
Could you explain that? Is it CFormView by any chance?
--
RainMan
Post by Prayami
Hi...I am new to VC++.
My MDI contains following
(1) (Left Side) CDialog contains Tree, converted to CDialogBar
(2) (Right side) Another CDialog as a MDI child
Little bit similar to IDE of VC++ workspace.
When ever I click any leaf element from Tree on CDialogBar, I want to open the
similar document file listed in (2) but as a different Dialog and want to
pass some parameters with that. So that every new dialog will have it on
message on it.
pDocTemplate->OpenDocumentFile(NULL);
(1) pDocTemplate is declared in main application's header file. How can I
get the
same instance in my first Dialog which contains Tree Event.
(2) How can I pass some parameter with that Tree Click event to new Dialog.
So every time Dialog Template will be same but every new dialog will have its
own message string according to Tree leaf clicked.
It will be really helpful if there will be some sample coding or some step
by step
explaination or any link provided.
Thanks in advance...
RainMan
2007-01-19 02:00:02 UTC
Permalink
That simplifies things greatly.
Creating new frame with view is not a big problem, passing value just a
little.
Since you are going to create window that uses different document instance,
the best place to store value you want to pass to new view in the application
object. You can also use main frame since both are easily accessible.

OnInitialUpdate of the view, you can retrieve this value and use it as you
need.

I think the best place to initiate new window creation is NM_CLICK
notification:

void CLeftView::OnClick(NMHDR* pNMHDR, LRESULT* pResult)
{
DWORD dwPos = GetMessagePos();
POINTS pts = MAKEPOINTS(dwPos);
CPoint pt(pts.x, pts.y);

ScreenToClient(&pt);
UINT uiFlags = 0;

HTREEITEM hItem = m_Tree.HitTest(pt, &uiFlags);

if(TVHT_ONITEMLABEL == (uiFlags & TVHT_ONITEMLABEL))
{
// set value to be passed. As an example I used string
theApp.m_csCurrInitialString = m_Tree.GetItemText(hItem);

CMDIFrameWnd *pWnd = (CMDIFrameWnd*)AfxGetMainWnd();

// this call will create new document/frame/view
pWnd->SendMessage(WM_COMMAND, ID_FILE_NEW);
}
*pResult = 0;
}
--
RainMan
Thanks for reply,
Yes it is CFormView.
Post by RainMan
You mentioned Another CDialog as a MDI child.
Could you explain that? Is it CFormView by any chance?
--
RainMan
Post by Prayami
Hi...I am new to VC++.
My MDI contains following
(1) (Left Side) CDialog contains Tree, converted to CDialogBar
(2) (Right side) Another CDialog as a MDI child
Little bit similar to IDE of VC++ workspace.
When ever I click any leaf element from Tree on CDialogBar, I want to open the
similar document file listed in (2) but as a different Dialog and want to
pass some parameters with that. So that every new dialog will have it on
message on it.
pDocTemplate->OpenDocumentFile(NULL);
(1) pDocTemplate is declared in main application's header file. How can I
get the
same instance in my first Dialog which contains Tree Event.
(2) How can I pass some parameter with that Tree Click event to new Dialog.
So every time Dialog Template will be same but every new dialog will have its
own message string according to Tree leaf clicked.
It will be really helpful if there will be some sample coding or some step
by step
explaination or any link provided.
Thanks in advance...
Loading...