15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CCtrlView, no Notify!

Kyle Green -- kyle@a.crl.com
Sunday, January 26, 1997

Hello,

Environment: NT 4.0, VC++ 4.0

I can't get my CCtrlView to receive NOTIFY messages. I first tried
CTreeView, then backed off to CCtrlView. In the CCtrlView version I use a
derivative of CTreeCtrl. the CTreeCtrl derivative does not receive any
NOTIFY_REFLECT message either (these are all removed for now).

This is in a splitter window, and the control view is associated with a
docview template. The other view in the splitter is not associated with a
doc view template. The splitter is created from a regular frame window.


It has been suggested that the problem here is that the view doesn't receive
the messages - the control associated with the view does. But from what I
understand of message flow, the parent of the control is definitely
supposed to get the message unless the control has a NOTIFY_REFLECT entry
in the message map.


Thanks for any insights or clues as to why these message may not be making
it to my window.

Kyle




Syed -- sxs296@psu.edu
Tuesday, January 28, 1997

At 10:34 PM 1/26/97 -0800, you wrote:
>Hello,
>
>Environment: NT 4.0, VC++ 4.0
>
>I can't get my CCtrlView to receive NOTIFY messages. I first tried
>CTreeView, then backed off to CCtrlView. In the CCtrlView version I use a
>derivative of CTreeCtrl. the CTreeCtrl derivative does not receive any
>NOTIFY_REFLECT message either (these are all removed for now).
>
>This is in a splitter window, and the control view is associated with a
>docview template. The other view in the splitter is not associated with a
>doc view template. The splitter is created from a regular frame window.


I have no idea what is wrong with your code considering many possibilities
that could cause it. However, I have completed an application which
basically do the
very same thing - creating a splitter windows with two panes and at the left
pane, there's a CTreeView. I'm using VC++ 4.0 and have no problem at all
with notification (reflects). Here's the only I could advise you:-
1)Derive OnCreateClient of your CMainFrame, and create your splitter windows
there. example code may look like this:-
{
	if (!m_wndSplitter1.CreateStatic(this, 1, 2) ||
		!m_wndSplitter1.CreateView(0,1, RUNTIME_CLASS(CFileView),
		CSize(1,1), pContext) ||
		!m_wndSplitter2.CreateStatic(&m_wndSplitter1, 2, 1) ||
		!m_wndSplitter2.CreateView(0,0, RUNTIME_CLASS(CDirectoryTree),
		CSize(1, 1), pContext) ||
		!m_wndSplitter2.CreateView(1,0, RUNTIME_CLASS(CDirectoryTree),
		CSize(1, 1), pContext))
		return FALSE;
// then.. set your SetColumInfo(...)
..
return true;
}

The code above creates two directory trees at the left pane and a list view
and the right view.
That's it.. nothing fancy there.. in case you have done the same thing, the
error should be somewhere else (where else??). And if you still cannot
figure out what the real problem is, I suggest you create the module back
from scratch (if the module is not large) and develop the necessary things
step by step and if you are lucky, you will know where the culprit is. 




Kyle Green -- kyle@a.crl.com
Thursday, January 30, 1997

[Mini-digest: 2 responses]

Syed, Thank you for the response. I still have the problem, and no way no
how are any TVN_ notification messages getting thru. So here are more
details in hopes that someone may have a further idea:

1) I have a CMyCtrlView.

2) In CMyCtrlView::OnCreate, I create a CMyTreeCtrl

3) I create CMyCtrlView in the main frame OnCreateClient, in a splitter
with a ListView, like this:
BOOL CrkgMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,CCreateContext*
pContext)
  {
  BOOL bRet;
  bRet = m_wndSplitter.CreateStatic( this, 1, 2);
  if(bRet == FALSE)  return FALSE;

  CRect rc;
  GetClientRect(rc);

  bRet = m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMyCtrlView),
CSize(rc.right / 4, 0), pContext);
  if(bRet == FALSE)  return FALSE;

  bRet = m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyListView),
CSize(0, 0),            pContext);
  if(bRet == FALSE)  return FALSE;

  return bRet;
  }


4) the message map for CMyTreeCtrl:
BEGIN_MESSAGE_MAP(CMyTreeCtrl, CTreeCtrl)
  ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelChanged) //message is not received!
  ON_WM_DESTROY()
  //mouse messages LBUTTONDOWN, move etc are received just fine
END_MESSAGE_MAP()

5) the message map for CMyCtrlView:
BEGIN_MESSAGE_MAP(CMyCtrlView, CCtrlView)
  ON_WM_CREATE()
  ON_WM_DESTROY()
  ON_WM_SIZE()
END_MESSAGE_MAP()

6) the message map for the frame is empty

7) this is all set as a doc view

8) everything works as expected, except that TVN_ notification messages are
not received

9) I have tried: 
a) blocking the ON_NOTIFY_REFLECT macro in the tree control, and using
ON_NOTIFY in the CMyCtrlView, no luck
b) blocking both places and trapping in the frame, no luck


I have spent six full days on this, and a deadline looms ever nearer. Has
anyone had experience with this type of arrangement? Any ideas are welcome,
I will pursue them.

Thanks,

Kyle




-----From: Kyle Green 

Environment: MSVC 4.0, NT 4.0

Syed, Thank you for the response. I still have the problem, and no way no
how are any TVN_ notification messages getting thru. So here are more
details in hopes that someone may have a further idea:

1) I have a CMyCtrlView.

2) In CMyCtrlView::OnCreate, I create a CMyTreeCtrl

3) I create CMyCtrlView in the main frame OnCreateClient, in a splitter
with a ListView, like this:
BOOL CrkgMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,CCreateContext*
pContext)
  {
  BOOL bRet;
  bRet = m_wndSplitter.CreateStatic( this, 1, 2);
  if(bRet == FALSE)  return FALSE;

  CRect rc;
  GetClientRect(rc);

  bRet = m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMyCtrlView),
CSize(rc.right / 4, 0), pContext);
  if(bRet == FALSE)  return FALSE;

  bRet = m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyListView),
CSize(0, 0),            pContext);
  if(bRet == FALSE)  return FALSE;

  return bRet;
  }


4) the message map for CMyTreeCtrl:
BEGIN_MESSAGE_MAP(CMyTreeCtrl, CTreeCtrl)
  ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelChanged) //message is not received!
  ON_WM_DESTROY()
  //mouse messages LBUTTONDOWN, move etc are received just fine
END_MESSAGE_MAP()

5) the message map for CMyCtrlView:
BEGIN_MESSAGE_MAP(CMyCtrlView, CCtrlView)
  ON_WM_CREATE()
  ON_WM_DESTROY()
  ON_WM_SIZE()
END_MESSAGE_MAP()

6) the message map for the frame is empty

7) this is all set as a doc view

8) everything works as expected, except that TVN_ notification messages are
not received

9) I have tried: 
a) blocking the ON_NOTIFY_REFLECT macro in the tree control, and using
ON_NOTIFY in the CMyCtrlView, no luck
b) blocking both places and trapping in the frame, no luck


I have spent six full days on this, and a deadline looms ever nearer. Has
anyone had experience with this type of arrangement? Any ideas are welcome,
I will pursue them.

Thanks,

Kyle







Jim Leavitt -- jimll@halcyon.com
Sunday, February 02, 1997

Kyle:

What you're trying to do should work, I've done something similar. My =
project involved creating a CtabView from CctrlView. It wasn't tough. I =
used the CtabView to hold several tree controls that aided the user in =
browsing a database.

>From your postings, it appears you're not getting messages back from =
your tree control. I have a sample that shows how I once solved the =
problem. I haven't looked at this code in a long time. I do have a =
sample that compiles and runs in 4.2b.=20

I used an override on OnChildNotify() instead of message reflection. At =
the time I wrote it, I didn't really understand message reflection. =
Anyway, you'll see in the sample that both the tree controls and the tab =
controls respond to user interactions. The tree controls can be expanded =
and contracted from menu choices as well.

Email me at jimll@halcyon.com for a copy of the sample. (It's 114KB =
zipped and is SAMPLE quality code).
Good luck, looming deadlines are always uncomfortable,
Jim Leavitt
Jimll@halcyon.com




Shaju Mathew -- shajum@hpptc51.rose.hp.com
Tuesday, February 04, 1997

Hi Kyle,
	A couple of month's earlier, I had a similar problem with the 
CTreeCtrl. I had a CDialogBar derivative with an embedded CTreeCtrl(to 
behave kinda like our MSVC 4.x class/file/resource browser), and I had
MAJOR problems trapping the TVN_ messages. On further research and 
a few calls, I found that these messages get handled by the parent. 
	Here's my message mapping:
	/////////////////////////////////////////////////////////////////////////////
// CBrowserBar dialog

BEGIN_MESSAGE_MAP(CBrowserBar, CDialogBar)
	//{{AFX_MSG_MAP(CBrowserBar)
	ON_NOTIFY(NM_DBLCLK, IDC_BROWSER, OnDblclkBrowser)
	ON_NOTIFY(TVN_ITEMEXPANDING, IDC_BROWSER, OnItemExpanding)
	ON_NOTIFY(TVN_SELCHANGED, IDC_BROWSER, OnSelChanged)
	ON_NOTIFY(TVN_DELETEITEM, IDC_BROWSER, OnDeleteItem)
	ON_CBN_SELCHANGE(IDC_PAGES, OnSelchangePages)
	ON_BN_CLICKED(IDC_CONFIGURE, OnConfigure)
	ON_UPDATE_COMMAND_UI(IDC_CONFIGURE, OnUpdateConfigure)
	ON_UPDATE_COMMAND_UI(IDC_FEEDBACK, OnUpdateFeedback)
	ON_BN_CLICKED(IDC_FEEDBACK, OnFeedback)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


	I've a dialog template res for my CDialogBar(just like Dialogs) and 
one of the resources in that template represent smy CTreeCtrl. 
	Everything's fine and dandy now..My suggestion is: 

	Handle these TVN_ messages from your parent(which's your CView) and 
do the same stuff, hopefully you can still meet that deadline(I know I didn't
that time!, but maybe this'll help you)
Regards
	-SHaju Mathew
> 
> [Mini-digest: 2 responses]
> 
> Syed, Thank you for the response. I still have the problem, and no way no
> how are any TVN_ notification messages getting thru. So here are more
> details in hopes that someone may have a further idea:
> 
> 1) I have a CMyCtrlView.
> 
> 2) In CMyCtrlView::OnCreate, I create a CMyTreeCtrl
> 
> 3) I create CMyCtrlView in the main frame OnCreateClient, in a splitter
> with a ListView, like this:
> BOOL CrkgMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,CCreateContext*
> pContext)
>   {
>   BOOL bRet;
>   bRet = m_wndSplitter.CreateStatic( this, 1, 2);
>   if(bRet == FALSE)  return FALSE;
> 
>   CRect rc;
>   GetClientRect(rc);
> 
>   bRet = m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMyCtrlView),
> CSize(rc.right / 4, 0), pContext);
>   if(bRet == FALSE)  return FALSE;
> 
>   bRet = m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyListView),
> CSize(0, 0),            pContext);
>   if(bRet == FALSE)  return FALSE;
> 
>   return bRet;
>   }
> 
> 
> 4) the message map for CMyTreeCtrl:
> BEGIN_MESSAGE_MAP(CMyTreeCtrl, CTreeCtrl)
>   ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelChanged) //message is not received!
>   ON_WM_DESTROY()
>   //mouse messages LBUTTONDOWN, move etc are received just fine
> END_MESSAGE_MAP()
> 
> 5) the message map for CMyCtrlView:
> BEGIN_MESSAGE_MAP(CMyCtrlView, CCtrlView)
>   ON_WM_CREATE()
>   ON_WM_DESTROY()
>   ON_WM_SIZE()
> END_MESSAGE_MAP()
> 
> 6) the message map for the frame is empty
> 
> 7) this is all set as a doc view
> 
> 8) everything works as expected, except that TVN_ notification messages are
> not received
> 
> 9) I have tried: 
> a) blocking the ON_NOTIFY_REFLECT macro in the tree control, and using
> ON_NOTIFY in the CMyCtrlView, no luck
> b) blocking both places and trapping in the frame, no luck
> 
> 
> I have spent six full days on this, and a deadline looms ever nearer. Has
> anyone had experience with this type of arrangement? Any ideas are welcome,
> I will pursue them.
> 
> Thanks,
> 
> Kyle
> 
> 
> 
> 
> -----From: Kyle Green 
> 
> Environment: MSVC 4.0, NT 4.0
> 
> Syed, Thank you for the response. I still have the problem, and no way no
> how are any TVN_ notification messages getting thru. So here are more
> details in hopes that someone may have a further idea:
> 
> 1) I have a CMyCtrlView.
> 
> 2) In CMyCtrlView::OnCreate, I create a CMyTreeCtrl
> 
> 3) I create CMyCtrlView in the main frame OnCreateClient, in a splitter
> with a ListView, like this:
> BOOL CrkgMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,CCreateContext*
> pContext)
>   {
>   BOOL bRet;
>   bRet = m_wndSplitter.CreateStatic( this, 1, 2);
>   if(bRet == FALSE)  return FALSE;
> 
>   CRect rc;
>   GetClientRect(rc);
> 
>   bRet = m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMyCtrlView),
> CSize(rc.right / 4, 0), pContext);
>   if(bRet == FALSE)  return FALSE;
> 
>   bRet = m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyListView),
> CSize(0, 0),            pContext);
>   if(bRet == FALSE)  return FALSE;
> 
>   return bRet;
>   }
> 
> 
> 4) the message map for CMyTreeCtrl:
> BEGIN_MESSAGE_MAP(CMyTreeCtrl, CTreeCtrl)
>   ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelChanged) //message is not received!
>   ON_WM_DESTROY()
>   //mouse messages LBUTTONDOWN, move etc are received just fine
> END_MESSAGE_MAP()
> 
> 5) the message map for CMyCtrlView:
> BEGIN_MESSAGE_MAP(CMyCtrlView, CCtrlView)
>   ON_WM_CREATE()
>   ON_WM_DESTROY()
>   ON_WM_SIZE()
> END_MESSAGE_MAP()
> 
> 6) the message map for the frame is empty
> 
> 7) this is all set as a doc view
> 
> 8) everything works as expected, except that TVN_ notification messages are
> not received
> 
> 9) I have tried: 
> a) blocking the ON_NOTIFY_REFLECT macro in the tree control, and using
> ON_NOTIFY in the CMyCtrlView, no luck
> b) blocking both places and trapping in the frame, no luck
> 
> 
> I have spent six full days on this, and a deadline looms ever nearer. Has
> anyone had experience with this type of arrangement? Any ideas are welcome,
> I will pursue them.
> 
> Thanks,
> 
> Kyle
> 
> 
> 
> 
> 


--
***********************************************************************
                              .---.         .---.
Shaju Mathew                 /" "  \  WWW  /  " "\    Off:(916)785-9018 
Performance Technology Lab  / / ""  \(*|*)/  "" \ \ 
WCSO Group R & D           //////   '. V .`   \\\\\\ Home:(916)722-4576
Hewlett-Packard Company   //// / // : """ : \\ \ \\\\
8000, Foothills Blvd     // /   /  /`.""" '\  \   \ \\Fax:(916)785-1264
MS 5723, Roseville      //          //.".\\          \\
CA 95747-5723        	     -------UU---UU-------
                                   '//|||\\`        Shaju_Mathew@hp.com
***********************************************************************




| Вернуться в корень Архива |