problems in creating file dialog in tab control

Hi,I am creating a tab control and want to pop up a file dialog when
clicking one tab page. but now, the file dialog was shown up at the
same time with tab control, not after selecting one page. Could some
guys help me? Thanks

David

	GetClientRect(hwndParent,&rcClient);
	InitCommonControls();

	hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
		WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndParent,NULL,g_hinst,NULL);
	if(hwndTabCtrl==NULL)
		AfxMessageBox("can't create tab control window");

	m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
	m_tcitem.iImage=-1;

	for(int i=0;i<TAB_PAGE_COUNT;i++)
	{
		m_tcitem.pszText=g_achTemp[i];
		if(TabCtrl_InsertItem(hwndTabCtrl,0,&m_tcitem)==-1)
		{
	    	AfxMessageBox("can't insert");
	    	DestroyWindow(hwndTabCtrl);
		}
	}

	TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);

                hdwp=BeginDeferWindowPos(1);
	DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);

	EndDeferWindowPos(hdwp);

	//try to get the current focus of tab page
	if(TabCtrl_SetCurSel(hwndTabCtrl,3)==3)
	{
	  CFileDialog partFileDlg


(TRUE,"prt",".prt",OFN_HIDEREADONLY,szFilter,CWnd::FromHandle(hwndTabCtrl));
		if(partFileDlg.DoModal()==IDOK)
		{
			AfxMessageBox("create part file dialog");
		}
	}

0
clamayi (19)
8/1/2006 2:29:17 PM
vc.mfc 33608 articles. 0 followers. Follow

10 Replies
383 Views

Similar Articles

[PageSpeed] 12

In order for one dialog to be created as part of another window the Dialog
must have the WS_CHILD style, and by default CFileDialog has the WS_POPUP
style. There are ways around that, you can override the dialog template of
the file dialog and telling CFileDialog to load that instead.

http://www.codeproject.com/dialog/xfiledialog.asp

The other thing is that you will have to use CFileDialog::Create method
instead of DoModal.

AliR.


"lfsym" <clamayi@gmail.com> wrote in message
news:1154442557.063598.252610@i42g2000cwa.googlegroups.com...
> Hi,I am creating a tab control and want to pop up a file dialog when
> clicking one tab page. but now, the file dialog was shown up at the
> same time with tab control, not after selecting one page. Could some
> guys help me? Thanks
>
> David
>
> GetClientRect(hwndParent,&rcClient);
> InitCommonControls();
>
> hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
>
WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
arent,NULL,g_hinst,NULL);
> if(hwndTabCtrl==NULL)
> AfxMessageBox("can't create tab control window");
>
> m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> m_tcitem.iImage=-1;
>
> for(int i=0;i<TAB_PAGE_COUNT;i++)
> {
> m_tcitem.pszText=g_achTemp[i];
> if(TabCtrl_InsertItem(hwndTabCtrl,0,&m_tcitem)==-1)
> {
>     AfxMessageBox("can't insert");
>     DestroyWindow(hwndTabCtrl);
> }
> }
>
> TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
>
>                 hdwp=BeginDeferWindowPos(1);
>
DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
>
> EndDeferWindowPos(hdwp);
>
> //try to get the current focus of tab page
> if(TabCtrl_SetCurSel(hwndTabCtrl,3)==3)
> {
>   CFileDialog partFileDlg
>
>
>
(TRUE,"prt",".prt",OFN_HIDEREADONLY,szFilter,CWnd::FromHandle(hwndTabCtrl));
> if(partFileDlg.DoModal()==IDOK)
> {
> AfxMessageBox("create part file dialog");
> }
> }
>


0
AliR3470 (3235)
8/1/2006 4:12:00 PM
Thanks,AliR. I modify my codes according to your suggestion. but there
still the same  problem.What I want is like this: when I select the
first page,one dialog is shown up(not automatically) and when I select
the second page the other dialog is up. because I use DLL, it is not
easy to process the message TCN_SELCHANGE. i use the macro
TabCtrl_GetCurSel(), but I don't know why the return value is always
zero. Please help me!

The codes are like:
	//create tab control handler
	hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
		WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndParent,NULL,g_hinst,NULL);
	if(hwndTabCtrl==NULL)
		AfxMessageBox("can't create tab control window");


    //create dialog for file

	pDialog[0]=new CPartDlg();
	pDialog[0]->Create(IDD_DIALOG_FOR_PART,NULL);

	//create dialog for machine
//	CMachineDlg *pMachineDlg;
	pDialog[1]=new CMachineDlg();
	pDialog[1]->Create(IDD_DIALOG_FOR_MACHINE,NULL);

	//CREATE dialog for process
//	CProcessDlg *pProcessDlg;
	pDialog[2]=new CProcessDlg();
	pDialog[2]->Create(IDD_DIALOG_FOR_PROCESS,NULL);



	//fill tab control's information
	m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
	m_tcitem.iImage=-1;

	for(int i=0;i<TAB_PAGE_COUNT;i++)
	{
		m_tcitem.pszText=g_tabName[i];
		if(TabCtrl_InsertItem(hwndTabCtrl,i,&m_tcitem)==-1)
		{
	    	AfxMessageBox("can't insert");
	    	DestroyWindow(hwndTabCtrl);
		}
	}
             TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);

	TabCtrl_GetItemRect(hwndTabCtrl,0,&rcTab);  //Get the tab page
dimension

    hdwp=BeginDeferWindowPos(1);
	DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
	EndDeferWindowPos(hdwp);
	int i_nPage=TabCtrl_GetCurSel(hwndTabCtrl);
	if(pDialog[i_nPage]->m_hWnd)
		pDialog[i_nPage]->ShowWindow(SW_HIDE);
	for(int j=0;j<3;j++)
	{
		pDialog[j]->SetWindowPos(&pDialog[j]->wndTop,
			rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
			(rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_HIDEWINDOW);
	}
	pDialog[i_nPage]->SetWindowPos(&pDialog[j]->wndTop,
			rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
			(rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_SHOWWINDOW);
	pDialog[i_nPage]->ShowWindow(SW_SHOW);

Thanks

David

AliR wrote:
> In order for one dialog to be created as part of another window the Dialog
> must have the WS_CHILD style, and by default CFileDialog has the WS_POPUP
> style. There are ways around that, you can override the dialog template of
> the file dialog and telling CFileDialog to load that instead.
>
> http://www.codeproject.com/dialog/xfiledialog.asp
>
> The other thing is that you will have to use CFileDialog::Create method
> instead of DoModal.
>
> AliR.
>
>
> "lfsym" <clamayi@gmail.com> wrote in message
> news:1154442557.063598.252610@i42g2000cwa.googlegroups.com...
> > Hi,I am creating a tab control and want to pop up a file dialog when
> > clicking one tab page. but now, the file dialog was shown up at the
> > same time with tab control, not after selecting one page. Could some
> > guys help me? Thanks
> >
> > David
> >
> > GetClientRect(hwndParent,&rcClient);
> > InitCommonControls();
> >
> > hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
> >
> WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
> arent,NULL,g_hinst,NULL);
> > if(hwndTabCtrl==NULL)
> > AfxMessageBox("can't create tab control window");
> >
> > m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> > m_tcitem.iImage=-1;
> >
> > for(int i=0;i<TAB_PAGE_COUNT;i++)
> > {
> > m_tcitem.pszText=g_achTemp[i];
> > if(TabCtrl_InsertItem(hwndTabCtrl,0,&m_tcitem)==-1)
> > {
> >     AfxMessageBox("can't insert");
> >     DestroyWindow(hwndTabCtrl);
> > }
> > }
> >
> > TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
> >
> >                 hdwp=BeginDeferWindowPos(1);
> >
> DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> >
> > EndDeferWindowPos(hdwp);
> >
> > //try to get the current focus of tab page
> > if(TabCtrl_SetCurSel(hwndTabCtrl,3)==3)
> > {
> >   CFileDialog partFileDlg
> >
> >
> >
> (TRUE,"prt",".prt",OFN_HIDEREADONLY,szFilter,CWnd::FromHandle(hwndTabCtrl));
> > if(partFileDlg.DoModal()==IDOK)
> > {
> > AfxMessageBox("create part file dialog");
> > }
> > }
> >

0
clamayi (19)
8/2/2006 2:34:16 PM
Hi David,

I am sorry but I can't really tell what is going on from the code you
provided.

AliR.

"lfsym" <clamayi@gmail.com> wrote in message
news:1154529256.800375.224700@p79g2000cwp.googlegroups.com...
> Thanks,AliR. I modify my codes according to your suggestion. but there
> still the same  problem.What I want is like this: when I select the
> first page,one dialog is shown up(not automatically) and when I select
> the second page the other dialog is up. because I use DLL, it is not
> easy to process the message TCN_SELCHANGE. i use the macro
> TabCtrl_GetCurSel(), but I don't know why the return value is always
> zero. Please help me!
>
> The codes are like:
> //create tab control handler
> hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
>
WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
arent,NULL,g_hinst,NULL);
> if(hwndTabCtrl==NULL)
> AfxMessageBox("can't create tab control window");
>
>
>     //create dialog for file
>
> pDialog[0]=new CPartDlg();
> pDialog[0]->Create(IDD_DIALOG_FOR_PART,NULL);
>
> //create dialog for machine
> // CMachineDlg *pMachineDlg;
> pDialog[1]=new CMachineDlg();
> pDialog[1]->Create(IDD_DIALOG_FOR_MACHINE,NULL);
>
> //CREATE dialog for process
> // CProcessDlg *pProcessDlg;
> pDialog[2]=new CProcessDlg();
> pDialog[2]->Create(IDD_DIALOG_FOR_PROCESS,NULL);
>
>
>
> //fill tab control's information
> m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> m_tcitem.iImage=-1;
>
> for(int i=0;i<TAB_PAGE_COUNT;i++)
> {
> m_tcitem.pszText=g_tabName[i];
> if(TabCtrl_InsertItem(hwndTabCtrl,i,&m_tcitem)==-1)
> {
>     AfxMessageBox("can't insert");
>     DestroyWindow(hwndTabCtrl);
> }
> }
>              TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
>
> TabCtrl_GetItemRect(hwndTabCtrl,0,&rcTab);  //Get the tab page
> dimension
>
>     hdwp=BeginDeferWindowPos(1);
>
DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> EndDeferWindowPos(hdwp);
> int i_nPage=TabCtrl_GetCurSel(hwndTabCtrl);
> if(pDialog[i_nPage]->m_hWnd)
> pDialog[i_nPage]->ShowWindow(SW_HIDE);
> for(int j=0;j<3;j++)
> {
> pDialog[j]->SetWindowPos(&pDialog[j]->wndTop,
> rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
>
(rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_HIDEWI
NDOW);
> }
> pDialog[i_nPage]->SetWindowPos(&pDialog[j]->wndTop,
> rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
>
(rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_SHOWWI
NDOW);
> pDialog[i_nPage]->ShowWindow(SW_SHOW);
>
> Thanks
>
> David
>
> AliR wrote:
> > In order for one dialog to be created as part of another window the
Dialog
> > must have the WS_CHILD style, and by default CFileDialog has the
WS_POPUP
> > style. There are ways around that, you can override the dialog template
of
> > the file dialog and telling CFileDialog to load that instead.
> >
> > http://www.codeproject.com/dialog/xfiledialog.asp
> >
> > The other thing is that you will have to use CFileDialog::Create method
> > instead of DoModal.
> >
> > AliR.
> >
> >
> > "lfsym" <clamayi@gmail.com> wrote in message
> > news:1154442557.063598.252610@i42g2000cwa.googlegroups.com...
> > > Hi,I am creating a tab control and want to pop up a file dialog when
> > > clicking one tab page. but now, the file dialog was shown up at the
> > > same time with tab control, not after selecting one page. Could some
> > > guys help me? Thanks
> > >
> > > David
> > >
> > > GetClientRect(hwndParent,&rcClient);
> > > InitCommonControls();
> > >
> > > hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
> > >
> >
WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
> > arent,NULL,g_hinst,NULL);
> > > if(hwndTabCtrl==NULL)
> > > AfxMessageBox("can't create tab control window");
> > >
> > > m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> > > m_tcitem.iImage=-1;
> > >
> > > for(int i=0;i<TAB_PAGE_COUNT;i++)
> > > {
> > > m_tcitem.pszText=g_achTemp[i];
> > > if(TabCtrl_InsertItem(hwndTabCtrl,0,&m_tcitem)==-1)
> > > {
> > >     AfxMessageBox("can't insert");
> > >     DestroyWindow(hwndTabCtrl);
> > > }
> > > }
> > >
> > > TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
> > >
> > >                 hdwp=BeginDeferWindowPos(1);
> > >
> >
DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> > t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> > >
> > > EndDeferWindowPos(hdwp);
> > >
> > > //try to get the current focus of tab page
> > > if(TabCtrl_SetCurSel(hwndTabCtrl,3)==3)
> > > {
> > >   CFileDialog partFileDlg
> > >
> > >
> > >
> >
(TRUE,"prt",".prt",OFN_HIDEREADONLY,szFilter,CWnd::FromHandle(hwndTabCtrl));
> > > if(partFileDlg.DoModal()==IDOK)
> > > {
> > > AfxMessageBox("create part file dialog");
> > > }
> > > }
> > >
>


0
AliR3470 (3235)
8/2/2006 3:18:49 PM
Hi AliR,
    I am sorry. the code is like this:
(1) create the tab control
      hwndTabCtrl=CreateWindow
(WC_TABCONTROL,"",WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndParent,NULL,g_hinst,NULL);
     if(hwndTabCtrl==NULL)
         AfxMessageBox("can't create tab control window");
(2) create three dialogs
     pDialog[0]=new CPartDlg();
     pDialog[0]->Create(IDD_DIALOG_FOR_PART,NULL);
     pDialog[1]=new CMachineDlg();
     pDialog[1]->Create(IDD_DIALOG_FOR_MACHINE,NULL);
     pDialog[2]=new CProcessDlg();
     pDialog[2]->Create(IDD_DIALOG_FOR_PROCESS,NULL);

(3) insert items to Tab control
   m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
    m_tcitem.iImage=-1;
    for(int i=0;i<TAB_PAGE_COUNT;i++)
   {
      m_tcitem.pszText=g_tabName[i];
      if(TabCtrl_InsertItem(hwndTabCtrl,i,&m_tcitem)==-1)
     {
           AfxMessageBox("can't insert");
           DestroyWindow(hwndTabCtrl);
     }

(4)set the display area for tab control

DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien

t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
    EndDeferWindowPos(hdwp);

(5) select the page and show the window
     int i_nPage=TabCtrl_GetCurSel(hwndTabCtrl);
    pDialog[i_nPage]->ShowWindow(i_nPage);
   (this maybe a little different)

the big problem here is I always get the value of i_nPage=0, when I
select the second page, this value is still zero. Does it mean that I
have to process the message TCN_SELCHANGE? I remeber from MSDN saying
that can use the macro TabCtrl_GetCurSel() replace sending
TCN_SELCHANGE message explicitly? I don't know why. thanks again.

David




AliR wrote:
> Hi David,
>
> I am sorry but I can't really tell what is going on from the code you
> provided.
>
> AliR.
>
> "lfsym" <clamayi@gmail.com> wrote in message
> news:1154529256.800375.224700@p79g2000cwp.googlegroups.com...
> > Thanks,AliR. I modify my codes according to your suggestion. but there
> > still the same  problem.What I want is like this: when I select the
> > first page,one dialog is shown up(not automatically) and when I select
> > the second page the other dialog is up. because I use DLL, it is not
> > easy to process the message TCN_SELCHANGE. i use the macro
> > TabCtrl_GetCurSel(), but I don't know why the return value is always
> > zero. Please help me!
> >
> > The codes are like:
> > //create tab control handler
> > hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
> >
> WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
> arent,NULL,g_hinst,NULL);
> > if(hwndTabCtrl==NULL)
> > AfxMessageBox("can't create tab control window");
> >
> >
> >     //create dialog for file
> >
> > pDialog[0]=new CPartDlg();
> > pDialog[0]->Create(IDD_DIALOG_FOR_PART,NULL);
> >
> > //create dialog for machine
> > // CMachineDlg *pMachineDlg;
> > pDialog[1]=new CMachineDlg();
> > pDialog[1]->Create(IDD_DIALOG_FOR_MACHINE,NULL);
> >
> > //CREATE dialog for process
> > // CProcessDlg *pProcessDlg;
> > pDialog[2]=new CProcessDlg();
> > pDialog[2]->Create(IDD_DIALOG_FOR_PROCESS,NULL);
> >
> >
> >
> > //fill tab control's information
> > m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> > m_tcitem.iImage=-1;
> >
> > for(int i=0;i<TAB_PAGE_COUNT;i++)
> > {
> > m_tcitem.pszText=g_tabName[i];
> > if(TabCtrl_InsertItem(hwndTabCtrl,i,&m_tcitem)==-1)
> > {
> >     AfxMessageBox("can't insert");
> >     DestroyWindow(hwndTabCtrl);
> > }
> > }
> >              TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
> >
> > TabCtrl_GetItemRect(hwndTabCtrl,0,&rcTab);  //Get the tab page
> > dimension
> >
> >     hdwp=BeginDeferWindowPos(1);
> >
> DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> > EndDeferWindowPos(hdwp);
> > int i_nPage=TabCtrl_GetCurSel(hwndTabCtrl);
> > if(pDialog[i_nPage]->m_hWnd)
> > pDialog[i_nPage]->ShowWindow(SW_HIDE);
> > for(int j=0;j<3;j++)
> > {
> > pDialog[j]->SetWindowPos(&pDialog[j]->wndTop,
> > rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
> >
> (rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_HIDEWI
> NDOW);
> > }
> > pDialog[i_nPage]->SetWindowPos(&pDialog[j]->wndTop,
> > rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
> >
> (rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_SHOWWI
> NDOW);
> > pDialog[i_nPage]->ShowWindow(SW_SHOW);
> >
> > Thanks
> >
> > David
> >
> > AliR wrote:
> > > In order for one dialog to be created as part of another window the
> Dialog
> > > must have the WS_CHILD style, and by default CFileDialog has the
> WS_POPUP
> > > style. There are ways around that, you can override the dialog template
> of
> > > the file dialog and telling CFileDialog to load that instead.
> > >
> > > http://www.codeproject.com/dialog/xfiledialog.asp
> > >
> > > The other thing is that you will have to use CFileDialog::Create method
> > > instead of DoModal.
> > >
> > > AliR.
> > >
> > >
> > > "lfsym" <clamayi@gmail.com> wrote in message
> > > news:1154442557.063598.252610@i42g2000cwa.googlegroups.com...
> > > > Hi,I am creating a tab control and want to pop up a file dialog when
> > > > clicking one tab page. but now, the file dialog was shown up at the
> > > > same time with tab control, not after selecting one page. Could some
> > > > guys help me? Thanks
> > > >
> > > > David
> > > >
> > > > GetClientRect(hwndParent,&rcClient);
> > > > InitCommonControls();
> > > >
> > > > hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
> > > >
> > >
> WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
> > > arent,NULL,g_hinst,NULL);
> > > > if(hwndTabCtrl==NULL)
> > > > AfxMessageBox("can't create tab control window");
> > > >
> > > > m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> > > > m_tcitem.iImage=-1;
> > > >
> > > > for(int i=0;i<TAB_PAGE_COUNT;i++)
> > > > {
> > > > m_tcitem.pszText=g_achTemp[i];
> > > > if(TabCtrl_InsertItem(hwndTabCtrl,0,&m_tcitem)==-1)
> > > > {
> > > >     AfxMessageBox("can't insert");
> > > >     DestroyWindow(hwndTabCtrl);
> > > > }
> > > > }
> > > >
> > > > TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
> > > >
> > > >                 hdwp=BeginDeferWindowPos(1);
> > > >
> > >
> DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> > > t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> > > >
> > > > EndDeferWindowPos(hdwp);
> > > >
> > > > //try to get the current focus of tab page
> > > > if(TabCtrl_SetCurSel(hwndTabCtrl,3)==3)
> > > > {
> > > >   CFileDialog partFileDlg
> > > >
> > > >
> > > >
> > >
> (TRUE,"prt",".prt",OFN_HIDEREADONLY,szFilter,CWnd::FromHandle(hwndTabCtrl));
> > > > if(partFileDlg.DoModal()==IDOK)
> > > > {
> > > > AfxMessageBox("create part file dialog");
> > > > }
> > > > }
> > > >
> >

0
clamayi (19)
8/2/2006 3:52:38 PM
TabCtrl_GetCurSel(hWnd) is a the same as
SendMessage(hWnd,TCM_GETCURSEL,0,0);

I saw that you are creating the tab and adding items to it.  In the code
that you have posted (assuming that this is all in the same function)  the
current selection is always going to be 0 because you have just added a
bunch of items and haven't set an index other than 0. So GetCurSel will
always return a 0.

If you want to display a different dialog box when the tab's selection is
changed then you will need to catch the TCN_SELCHANGE notification in the
WinProc of the parent window of the tab control, and do you showing and
hiding of the dialog there.

AliR.



"lfsym" <clamayi@gmail.com> wrote in message
news:1154533958.860695.26360@s13g2000cwa.googlegroups.com...
> Hi AliR,
>     I am sorry. the code is like this:
> (1) create the tab control
>       hwndTabCtrl=CreateWindow
>
(WC_TABCONTROL,"",WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcC
lient.bottom,hwndParent,NULL,g_hinst,NULL);
>      if(hwndTabCtrl==NULL)
>          AfxMessageBox("can't create tab control window");
> (2) create three dialogs
>      pDialog[0]=new CPartDlg();
>      pDialog[0]->Create(IDD_DIALOG_FOR_PART,NULL);
>      pDialog[1]=new CMachineDlg();
>      pDialog[1]->Create(IDD_DIALOG_FOR_MACHINE,NULL);
>      pDialog[2]=new CProcessDlg();
>      pDialog[2]->Create(IDD_DIALOG_FOR_PROCESS,NULL);
>
> (3) insert items to Tab control
>    m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
>     m_tcitem.iImage=-1;
>     for(int i=0;i<TAB_PAGE_COUNT;i++)
>    {
>       m_tcitem.pszText=g_tabName[i];
>       if(TabCtrl_InsertItem(hwndTabCtrl,i,&m_tcitem)==-1)
>      {
>            AfxMessageBox("can't insert");
>            DestroyWindow(hwndTabCtrl);
>      }
>
> (4)set the display area for tab control
>
>
DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
>
> t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
>     EndDeferWindowPos(hdwp);
>
> (5) select the page and show the window
>      int i_nPage=TabCtrl_GetCurSel(hwndTabCtrl);
>     pDialog[i_nPage]->ShowWindow(i_nPage);
>    (this maybe a little different)
>
> the big problem here is I always get the value of i_nPage=0, when I
> select the second page, this value is still zero. Does it mean that I
> have to process the message TCN_SELCHANGE? I remeber from MSDN saying
> that can use the macro TabCtrl_GetCurSel() replace sending
> TCN_SELCHANGE message explicitly? I don't know why. thanks again.
>
> David
>
>
>
>
> AliR wrote:
> > Hi David,
> >
> > I am sorry but I can't really tell what is going on from the code you
> > provided.
> >
> > AliR.
> >
> > "lfsym" <clamayi@gmail.com> wrote in message
> > news:1154529256.800375.224700@p79g2000cwp.googlegroups.com...
> > > Thanks,AliR. I modify my codes according to your suggestion. but there
> > > still the same  problem.What I want is like this: when I select the
> > > first page,one dialog is shown up(not automatically) and when I select
> > > the second page the other dialog is up. because I use DLL, it is not
> > > easy to process the message TCN_SELCHANGE. i use the macro
> > > TabCtrl_GetCurSel(), but I don't know why the return value is always
> > > zero. Please help me!
> > >
> > > The codes are like:
> > > //create tab control handler
> > > hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
> > >
> >
WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
> > arent,NULL,g_hinst,NULL);
> > > if(hwndTabCtrl==NULL)
> > > AfxMessageBox("can't create tab control window");
> > >
> > >
> > >     //create dialog for file
> > >
> > > pDialog[0]=new CPartDlg();
> > > pDialog[0]->Create(IDD_DIALOG_FOR_PART,NULL);
> > >
> > > //create dialog for machine
> > > // CMachineDlg *pMachineDlg;
> > > pDialog[1]=new CMachineDlg();
> > > pDialog[1]->Create(IDD_DIALOG_FOR_MACHINE,NULL);
> > >
> > > //CREATE dialog for process
> > > // CProcessDlg *pProcessDlg;
> > > pDialog[2]=new CProcessDlg();
> > > pDialog[2]->Create(IDD_DIALOG_FOR_PROCESS,NULL);
> > >
> > >
> > >
> > > //fill tab control's information
> > > m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> > > m_tcitem.iImage=-1;
> > >
> > > for(int i=0;i<TAB_PAGE_COUNT;i++)
> > > {
> > > m_tcitem.pszText=g_tabName[i];
> > > if(TabCtrl_InsertItem(hwndTabCtrl,i,&m_tcitem)==-1)
> > > {
> > >     AfxMessageBox("can't insert");
> > >     DestroyWindow(hwndTabCtrl);
> > > }
> > > }
> > >              TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
> > >
> > > TabCtrl_GetItemRect(hwndTabCtrl,0,&rcTab);  //Get the tab page
> > > dimension
> > >
> > >     hdwp=BeginDeferWindowPos(1);
> > >
> >
DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> > t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> > > EndDeferWindowPos(hdwp);
> > > int i_nPage=TabCtrl_GetCurSel(hwndTabCtrl);
> > > if(pDialog[i_nPage]->m_hWnd)
> > > pDialog[i_nPage]->ShowWindow(SW_HIDE);
> > > for(int j=0;j<3;j++)
> > > {
> > > pDialog[j]->SetWindowPos(&pDialog[j]->wndTop,
> > > rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
> > >
> >
(rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_HIDEWI
> > NDOW);
> > > }
> > > pDialog[i_nPage]->SetWindowPos(&pDialog[j]->wndTop,
> > > rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
> > >
> >
(rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_SHOWWI
> > NDOW);
> > > pDialog[i_nPage]->ShowWindow(SW_SHOW);
> > >
> > > Thanks
> > >
> > > David
> > >
> > > AliR wrote:
> > > > In order for one dialog to be created as part of another window the
> > Dialog
> > > > must have the WS_CHILD style, and by default CFileDialog has the
> > WS_POPUP
> > > > style. There are ways around that, you can override the dialog
template
> > of
> > > > the file dialog and telling CFileDialog to load that instead.
> > > >
> > > > http://www.codeproject.com/dialog/xfiledialog.asp
> > > >
> > > > The other thing is that you will have to use CFileDialog::Create
method
> > > > instead of DoModal.
> > > >
> > > > AliR.
> > > >
> > > >
> > > > "lfsym" <clamayi@gmail.com> wrote in message
> > > > news:1154442557.063598.252610@i42g2000cwa.googlegroups.com...
> > > > > Hi,I am creating a tab control and want to pop up a file dialog
when
> > > > > clicking one tab page. but now, the file dialog was shown up at
the
> > > > > same time with tab control, not after selecting one page. Could
some
> > > > > guys help me? Thanks
> > > > >
> > > > > David
> > > > >
> > > > > GetClientRect(hwndParent,&rcClient);
> > > > > InitCommonControls();
> > > > >
> > > > > hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
> > > > >
> > > >
> >
WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
> > > > arent,NULL,g_hinst,NULL);
> > > > > if(hwndTabCtrl==NULL)
> > > > > AfxMessageBox("can't create tab control window");
> > > > >
> > > > > m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> > > > > m_tcitem.iImage=-1;
> > > > >
> > > > > for(int i=0;i<TAB_PAGE_COUNT;i++)
> > > > > {
> > > > > m_tcitem.pszText=g_achTemp[i];
> > > > > if(TabCtrl_InsertItem(hwndTabCtrl,0,&m_tcitem)==-1)
> > > > > {
> > > > >     AfxMessageBox("can't insert");
> > > > >     DestroyWindow(hwndTabCtrl);
> > > > > }
> > > > > }
> > > > >
> > > > > TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
> > > > >
> > > > >                 hdwp=BeginDeferWindowPos(1);
> > > > >
> > > >
> >
DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> > > > t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> > > > >
> > > > > EndDeferWindowPos(hdwp);
> > > > >
> > > > > //try to get the current focus of tab page
> > > > > if(TabCtrl_SetCurSel(hwndTabCtrl,3)==3)
> > > > > {
> > > > >   CFileDialog partFileDlg
> > > > >
> > > > >
> > > > >
> > > >
> >
(TRUE,"prt",".prt",OFN_HIDEREADONLY,szFilter,CWnd::FromHandle(hwndTabCtrl));
> > > > > if(partFileDlg.DoModal()==IDOK)
> > > > > {
> > > > > AfxMessageBox("create part file dialog");
> > > > > }
> > > > > }
> > > > >
> > >
>


0
AliR3470 (3235)
8/2/2006 4:13:26 PM
Hi AliR,
     I am developing a MFC DLL project. I don't know how to catch
TCN_SELCHANGE notification. Could you give me some ideas?

David
AliR wrote:
> TabCtrl_GetCurSel(hWnd) is a the same as
> SendMessage(hWnd,TCM_GETCURSEL,0,0);
>
> I saw that you are creating the tab and adding items to it.  In the code
> that you have posted (assuming that this is all in the same function)  the
> current selection is always going to be 0 because you have just added a
> bunch of items and haven't set an index other than 0. So GetCurSel will
> always return a 0.
>
> If you want to display a different dialog box when the tab's selection is
> changed then you will need to catch the TCN_SELCHANGE notification in the
> WinProc of the parent window of the tab control, and do you showing and
> hiding of the dialog there.
>
> AliR.
>
>
>
> "lfsym" <clamayi@gmail.com> wrote in message
> news:1154533958.860695.26360@s13g2000cwa.googlegroups.com...
> > Hi AliR,
> >     I am sorry. the code is like this:
> > (1) create the tab control
> >       hwndTabCtrl=CreateWindow
> >
> (WC_TABCONTROL,"",WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcC
> lient.bottom,hwndParent,NULL,g_hinst,NULL);
> >      if(hwndTabCtrl==NULL)
> >          AfxMessageBox("can't create tab control window");
> > (2) create three dialogs
> >      pDialog[0]=new CPartDlg();
> >      pDialog[0]->Create(IDD_DIALOG_FOR_PART,NULL);
> >      pDialog[1]=new CMachineDlg();
> >      pDialog[1]->Create(IDD_DIALOG_FOR_MACHINE,NULL);
> >      pDialog[2]=new CProcessDlg();
> >      pDialog[2]->Create(IDD_DIALOG_FOR_PROCESS,NULL);
> >
> > (3) insert items to Tab control
> >    m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> >     m_tcitem.iImage=-1;
> >     for(int i=0;i<TAB_PAGE_COUNT;i++)
> >    {
> >       m_tcitem.pszText=g_tabName[i];
> >       if(TabCtrl_InsertItem(hwndTabCtrl,i,&m_tcitem)==-1)
> >      {
> >            AfxMessageBox("can't insert");
> >            DestroyWindow(hwndTabCtrl);
> >      }
> >
> > (4)set the display area for tab control
> >
> >
> DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> >
> > t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> >     EndDeferWindowPos(hdwp);
> >
> > (5) select the page and show the window
> >      int i_nPage=TabCtrl_GetCurSel(hwndTabCtrl);
> >     pDialog[i_nPage]->ShowWindow(i_nPage);
> >    (this maybe a little different)
> >
> > the big problem here is I always get the value of i_nPage=0, when I
> > select the second page, this value is still zero. Does it mean that I
> > have to process the message TCN_SELCHANGE? I remeber from MSDN saying
> > that can use the macro TabCtrl_GetCurSel() replace sending
> > TCN_SELCHANGE message explicitly? I don't know why. thanks again.
> >
> > David
> >
> >
> >
> >
> > AliR wrote:
> > > Hi David,
> > >
> > > I am sorry but I can't really tell what is going on from the code you
> > > provided.
> > >
> > > AliR.
> > >
> > > "lfsym" <clamayi@gmail.com> wrote in message
> > > news:1154529256.800375.224700@p79g2000cwp.googlegroups.com...
> > > > Thanks,AliR. I modify my codes according to your suggestion. but there
> > > > still the same  problem.What I want is like this: when I select the
> > > > first page,one dialog is shown up(not automatically) and when I select
> > > > the second page the other dialog is up. because I use DLL, it is not
> > > > easy to process the message TCN_SELCHANGE. i use the macro
> > > > TabCtrl_GetCurSel(), but I don't know why the return value is always
> > > > zero. Please help me!
> > > >
> > > > The codes are like:
> > > > //create tab control handler
> > > > hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
> > > >
> > >
> WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
> > > arent,NULL,g_hinst,NULL);
> > > > if(hwndTabCtrl==NULL)
> > > > AfxMessageBox("can't create tab control window");
> > > >
> > > >
> > > >     //create dialog for file
> > > >
> > > > pDialog[0]=new CPartDlg();
> > > > pDialog[0]->Create(IDD_DIALOG_FOR_PART,NULL);
> > > >
> > > > //create dialog for machine
> > > > // CMachineDlg *pMachineDlg;
> > > > pDialog[1]=new CMachineDlg();
> > > > pDialog[1]->Create(IDD_DIALOG_FOR_MACHINE,NULL);
> > > >
> > > > //CREATE dialog for process
> > > > // CProcessDlg *pProcessDlg;
> > > > pDialog[2]=new CProcessDlg();
> > > > pDialog[2]->Create(IDD_DIALOG_FOR_PROCESS,NULL);
> > > >
> > > >
> > > >
> > > > //fill tab control's information
> > > > m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> > > > m_tcitem.iImage=-1;
> > > >
> > > > for(int i=0;i<TAB_PAGE_COUNT;i++)
> > > > {
> > > > m_tcitem.pszText=g_tabName[i];
> > > > if(TabCtrl_InsertItem(hwndTabCtrl,i,&m_tcitem)==-1)
> > > > {
> > > >     AfxMessageBox("can't insert");
> > > >     DestroyWindow(hwndTabCtrl);
> > > > }
> > > > }
> > > >              TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
> > > >
> > > > TabCtrl_GetItemRect(hwndTabCtrl,0,&rcTab);  //Get the tab page
> > > > dimension
> > > >
> > > >     hdwp=BeginDeferWindowPos(1);
> > > >
> > >
> DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> > > t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> > > > EndDeferWindowPos(hdwp);
> > > > int i_nPage=TabCtrl_GetCurSel(hwndTabCtrl);
> > > > if(pDialog[i_nPage]->m_hWnd)
> > > > pDialog[i_nPage]->ShowWindow(SW_HIDE);
> > > > for(int j=0;j<3;j++)
> > > > {
> > > > pDialog[j]->SetWindowPos(&pDialog[j]->wndTop,
> > > > rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
> > > >
> > >
> (rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_HIDEWI
> > > NDOW);
> > > > }
> > > > pDialog[i_nPage]->SetWindowPos(&pDialog[j]->wndTop,
> > > > rcClient.left,rcClient.top+100+rcTab.bottom-rcTab.top,
> > > >
> > >
> (rcClient.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,SWP_SHOWWI
> > > NDOW);
> > > > pDialog[i_nPage]->ShowWindow(SW_SHOW);
> > > >
> > > > Thanks
> > > >
> > > > David
> > > >
> > > > AliR wrote:
> > > > > In order for one dialog to be created as part of another window the
> > > Dialog
> > > > > must have the WS_CHILD style, and by default CFileDialog has the
> > > WS_POPUP
> > > > > style. There are ways around that, you can override the dialog
> template
> > > of
> > > > > the file dialog and telling CFileDialog to load that instead.
> > > > >
> > > > > http://www.codeproject.com/dialog/xfiledialog.asp
> > > > >
> > > > > The other thing is that you will have to use CFileDialog::Create
> method
> > > > > instead of DoModal.
> > > > >
> > > > > AliR.
> > > > >
> > > > >
> > > > > "lfsym" <clamayi@gmail.com> wrote in message
> > > > > news:1154442557.063598.252610@i42g2000cwa.googlegroups.com...
> > > > > > Hi,I am creating a tab control and want to pop up a file dialog
> when
> > > > > > clicking one tab page. but now, the file dialog was shown up at
> the
> > > > > > same time with tab control, not after selecting one page. Could
> some
> > > > > > guys help me? Thanks
> > > > > >
> > > > > > David
> > > > > >
> > > > > > GetClientRect(hwndParent,&rcClient);
> > > > > > InitCommonControls();
> > > > > >
> > > > > > hwndTabCtrl=CreateWindow(WC_TABCONTROL,"",
> > > > > >
> > > > >
> > >
> WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,0,0,rcClient.right,rcClient.bottom,hwndP
> > > > > arent,NULL,g_hinst,NULL);
> > > > > > if(hwndTabCtrl==NULL)
> > > > > > AfxMessageBox("can't create tab control window");
> > > > > >
> > > > > > m_tcitem.mask=TCIF_TEXT|TCIF_IMAGE;
> > > > > > m_tcitem.iImage=-1;
> > > > > >
> > > > > > for(int i=0;i<TAB_PAGE_COUNT;i++)
> > > > > > {
> > > > > > m_tcitem.pszText=g_achTemp[i];
> > > > > > if(TabCtrl_InsertItem(hwndTabCtrl,0,&m_tcitem)==-1)
> > > > > > {
> > > > > >     AfxMessageBox("can't insert");
> > > > > >     DestroyWindow(hwndTabCtrl);
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > TabCtrl_AdjustRect(hwndTabCtrl,FALSE,&rcClient);
> > > > > >
> > > > > >                 hdwp=BeginDeferWindowPos(1);
> > > > > >
> > > > >
> > >
> DeferWindowPos(hdwp,hwndTabCtrl,NULL,rcClient.left,rcClient.top+100,(rcClien
> > > > > t.right-rcClient.left)/4,(rcClient.bottom-rcClient.top)/3,0);
> > > > > >
> > > > > > EndDeferWindowPos(hdwp);
> > > > > >
> > > > > > //try to get the current focus of tab page
> > > > > > if(TabCtrl_SetCurSel(hwndTabCtrl,3)==3)
> > > > > > {
> > > > > >   CFileDialog partFileDlg
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > >
> (TRUE,"prt",".prt",OFN_HIDEREADONLY,szFilter,CWnd::FromHandle(hwndTabCtrl));
> > > > > > if(partFileDlg.DoModal()==IDOK)
> > > > > > {
> > > > > > AfxMessageBox("create part file dialog");
> > > > > > }
> > > > > > }
> > > > > >
> > > >
> >

0
clamayi (19)
8/2/2006 4:37:34 PM
The fact that it is a MFC DLL doesn't really tell me much.

Is the parent of the Tab control a CWnd class or a CDialog class?

If so then add this line to the message map
ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL,OnTcnSelChangeTabCtrl)

and this method

void CMyWnd::OnTcnSelChangeTabCtrl(NMHDR *,LRESULT *pResult)
{
    here you can ask the tab control which tab is selected.
}

and this to your header
afx_msg void OnTcnSelChangeTabCtrl(NMHDR *,LRESULT *pResult);

When I was coming up with the message map I was looking for the control ID
of the tab control in your code, and I realized that you are not passing a
valid control id to it. Pass it a control id instead of NULL. It's the 10th
parameter of CreateWindow (HMENU hMenu), this parameter is the control ID
instead of menu handle when you are creating controls.
Use the same id in the message map.

If you are not using CWnd or CDialog as the parent of the tab control let me
know
AliR.

"lfsym" <clamayi@gmail.com> wrote in message
news:1154536654.205661.321660@h48g2000cwc.googlegroups.com...
> Hi AliR,
>      I am developing a MFC DLL project. I don't know how to catch
> TCN_SELCHANGE notification. Could you give me some ideas?
>
> David


0
AliR3470 (3235)
8/2/2006 5:00:20 PM
Hi AliR,

    Thanks a lot. Yes, the parent of my tab control is a CWND class. I
will try it now .

David
AliR wrote:
> The fact that it is a MFC DLL doesn't really tell me much.
>
> Is the parent of the Tab control a CWnd class or a CDialog class?
>
> If so then add this line to the message map
> ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL,OnTcnSelChangeTabCtrl)
>
> and this method
>
> void CMyWnd::OnTcnSelChangeTabCtrl(NMHDR *,LRESULT *pResult)
> {
>     here you can ask the tab control which tab is selected.
> }
>
> and this to your header
> afx_msg void OnTcnSelChangeTabCtrl(NMHDR *,LRESULT *pResult);
>
> When I was coming up with the message map I was looking for the control ID
> of the tab control in your code, and I realized that you are not passing a
> valid control id to it. Pass it a control id instead of NULL. It's the 10th
> parameter of CreateWindow (HMENU hMenu), this parameter is the control ID
> instead of menu handle when you are creating controls.
> Use the same id in the message map.
>
> If you are not using CWnd or CDialog as the parent of the tab control let me
> know
> AliR.
>
> "lfsym" <clamayi@gmail.com> wrote in message
> news:1154536654.205661.321660@h48g2000cwc.googlegroups.com...
> > Hi AliR,
> >      I am developing a MFC DLL project. I don't know how to catch
> > TCN_SELCHANGE notification. Could you give me some ideas?
> >
> > David

0
clamayi (19)
8/2/2006 5:16:01 PM
Hi AliR,
     I just modified my codes. in my header file, I added
            //{{AFX_MSG(CFiledllApp)
           // NOTE - the ClassWizard will add and remove member
functions here.
          //    DO NOT EDIT what you see in these blocks of generated
code !
             afx_msg void OnTcnSelChangeTabCtrl(NMHDR *pNmhdr,LRESULT
*pResult);
          //}}AFX_MSG

   and in my cpp file , I added
          BEGIN_MESSAGE_MAP(CFiledllApp, CWinApp)
            //{{AFX_MSG_MAP(CFiledllApp)
            // NOTE - the ClassWizard will add and remove mapping
macros here.
            //    DO NOT EDIT what you see in these blocks of generated
code!
	ON_NOTIFY(TCN_SELCHANGE,IDC_TABCTRL,OnTcnSelChangeTabCtrl)
           //}}AFX_MSG_MAP

          END_MESSAGE_MAP()
when I try to build it, there are one error:

           PartDlg.obj : error LNK2005: "struct tagRECT rcClient" (?

                                  rcClient@@3UtagRECT@@A) already
defined in filedll.obj
I think maybe because I defined three dialog classes, and the dialog's
cpp file includes this header file(filedll.h).when I comment this
header file, another error occur: can't find the identifier of the
dialog. Could you help me again?

Thanks

David

lfsym wrote:
> Hi AliR,
>
>     Thanks a lot. Yes, the parent of my tab control is a CWND class. I
> will try it now .
>
> David
> AliR wrote:
> > The fact that it is a MFC DLL doesn't really tell me much.
> >
> > Is the parent of the Tab control a CWnd class or a CDialog class?
> >
> > If so then add this line to the message map
> > ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL,OnTcnSelChangeTabCtrl)
> >
> > and this method
> >
> > void CMyWnd::OnTcnSelChangeTabCtrl(NMHDR *,LRESULT *pResult)
> > {
> >     here you can ask the tab control which tab is selected.
> > }
> >
> > and this to your header
> > afx_msg void OnTcnSelChangeTabCtrl(NMHDR *,LRESULT *pResult);
> >
> > When I was coming up with the message map I was looking for the control ID
> > of the tab control in your code, and I realized that you are not passing a
> > valid control id to it. Pass it a control id instead of NULL. It's the 10th
> > parameter of CreateWindow (HMENU hMenu), this parameter is the control ID
> > instead of menu handle when you are creating controls.
> > Use the same id in the message map.
> >
> > If you are not using CWnd or CDialog as the parent of the tab control let me
> > know
> > AliR.
> >
> > "lfsym" <clamayi@gmail.com> wrote in message
> > news:1154536654.205661.321660@h48g2000cwc.googlegroups.com...
> > > Hi AliR,
> > >      I am developing a MFC DLL project. I don't know how to catch
> > > TCN_SELCHANGE notification. Could you give me some ideas?
> > >
> > > David

0
clamayi (19)
8/2/2006 6:53:00 PM
hi AliR,
     I got it. I am so mistaken that put some variables in the header
file "filedll.h". anyway thanks a lot.

  David

lfsym wrote:
> Hi AliR,
>      I just modified my codes. in my header file, I added
>             //{{AFX_MSG(CFiledllApp)
>            // NOTE - the ClassWizard will add and remove member
> functions here.
>           //    DO NOT EDIT what you see in these blocks of generated
> code !
>              afx_msg void OnTcnSelChangeTabCtrl(NMHDR *pNmhdr,LRESULT
> *pResult);
>           //}}AFX_MSG
>
>    and in my cpp file , I added
>           BEGIN_MESSAGE_MAP(CFiledllApp, CWinApp)
>             //{{AFX_MSG_MAP(CFiledllApp)
>             // NOTE - the ClassWizard will add and remove mapping
> macros here.
>             //    DO NOT EDIT what you see in these blocks of generated
> code!
> 	ON_NOTIFY(TCN_SELCHANGE,IDC_TABCTRL,OnTcnSelChangeTabCtrl)
>            //}}AFX_MSG_MAP
>
>           END_MESSAGE_MAP()
> when I try to build it, there are one error:
>
>            PartDlg.obj : error LNK2005: "struct tagRECT rcClient" (?
>
>                                   rcClient@@3UtagRECT@@A) already
> defined in filedll.obj
> I think maybe because I defined three dialog classes, and the dialog's
> cpp file includes this header file(filedll.h).when I comment this
> header file, another error occur: can't find the identifier of the
> dialog. Could you help me again?
>
> Thanks
>
> David
>
> lfsym wrote:
> > Hi AliR,
> >
> >     Thanks a lot. Yes, the parent of my tab control is a CWND class. I
> > will try it now .
> >
> > David
> > AliR wrote:
> > > The fact that it is a MFC DLL doesn't really tell me much.
> > >
> > > Is the parent of the Tab control a CWnd class or a CDialog class?
> > >
> > > If so then add this line to the message map
> > > ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL,OnTcnSelChangeTabCtrl)
> > >
> > > and this method
> > >
> > > void CMyWnd::OnTcnSelChangeTabCtrl(NMHDR *,LRESULT *pResult)
> > > {
> > >     here you can ask the tab control which tab is selected.
> > > }
> > >
> > > and this to your header
> > > afx_msg void OnTcnSelChangeTabCtrl(NMHDR *,LRESULT *pResult);
> > >
> > > When I was coming up with the message map I was looking for the control ID
> > > of the tab control in your code, and I realized that you are not passing a
> > > valid control id to it. Pass it a control id instead of NULL. It's the 10th
> > > parameter of CreateWindow (HMENU hMenu), this parameter is the control ID
> > > instead of menu handle when you are creating controls.
> > > Use the same id in the message map.
> > >
> > > If you are not using CWnd or CDialog as the parent of the tab control let me
> > > know
> > > AliR.
> > >
> > > "lfsym" <clamayi@gmail.com> wrote in message
> > > news:1154536654.205661.321660@h48g2000cwc.googlegroups.com...
> > > > Hi AliR,
> > > >      I am developing a MFC DLL project. I don't know how to catch
> > > > TCN_SELCHANGE notification. Could you give me some ideas?
> > > >
> > > > David

0
clamayi (19)
8/2/2006 6:58:05 PM
Reply:

Similar Artilces:

Problem shortcuts in Word
Hello, I work with Word 2008. In the beginning there is no problem, but suddenly i have problem with shortcuts. When i want to do "cmd c" it make an other shortcuts same thing for "cmd s", "cmd v" and surly some other. But when i write there is no problem "c" is "c"... If somebody have an idea please help me. Thank you. Unless you indicate your specific update level of Office as well as OS X & describe what the keystrokes *are* doing contrary to what you expect there isn't much we can offer. -- Regards |:>)...

encoding problem in Outlook 2007 importing Outlook 2000 personal folders
I use Outlook 2007 to import the pst file of Outlook 2000. The Chinese characters in the subject became unreadable but it's ok to display in message body. In Outlook 2000, there's no problem to display the Chinese characters in the subject. What's wrong with Outlook 2007? What setttings should I change to fix the problem? Thanks. cyl <u8526505@gmail.com> wrote: > I use Outlook 2007 to import the pst file of Outlook 2000. The Chinese > characters in the subject became unreadable but it's ok to display in > message body. In Outlook 2000, there's no problem t...

Outlook 2003 PST problems
I just installed Office 2003 professional on a new computer & am having problems with outlook. I copied my Outlook.pst file into the appropriate directory & although it is recognized the calendar is not working properly. I cannot attach any of the colored labels to my appointments - so everything is pretty much in black & white. I totally uninstalled & reinstalled office... first removing my pst file... but there appears to be an ini file... or something that is retaining some information... does anyone know of a fix for the labels... or how to TOTALLY uninstall office (so I...

How do I link data workbooks to a create a graph?
I am attempting to take workbooks from the last 4 months, each with a daily data sheet, and link Mondays, Tuesdays, Wednesdays, etc. to time of day and staffing levels. I want the final result to be charts that show the relationship between staffing levels, incoming call volume, and time of day. hi Andrea, Many things are possible in Excel & I'd say that you could probably find a way of linking all the workbooks. However, I think any "easier" approach would involve opening each file & copying the data from each sheet in each file to a single sheet in one file (with...

Problem with Authentication
The CRM application was running smooth. But now I can't logging. It ask my credentials and than return a 401.1 error. I had already reinstalled the CRM server but it won't work. I'm accessing it in the same local network. I'm running CRM 3.0 in SBS. Best regards, Erico Hi When you open a Internet explorer and type the name of the CRM server, it prompts for user and password ? Are you logged in with domain credentials ( AD user ) ? If you are, so add url of the crm server in Local intranet. Enable "Automatic logon only in intranet", this is under security,c...

calendar problem
Dear all, I am using both mail and calendar function in outlook 2002. Everything is ok until recently, when I try to make a new appointment or checking any old appointments, an error message "out of memory or resource, try to close some windows..." pop up. The mail function is still ok. Can anyone tell me how can I solve this? I have already installed sp2. The version of office is the professional one with frontpage. Thanks. tp ...

Create a Variable from First 4-5 chars of a existing value ??
In a current table, the values in a particular field are all items like: MD45 Tuesday PM or TX341 Friday AM or FL12 Monday PM ...in other words...2 parts seperated by a space. The first part is always a State Abbrv. followed by either a 2 or 3 char. number. That first part will always be 4-5 characters long (or...everthing before the first Space). I'm needing to create a varible that is the First Part of the existing value.. ..in other words...the variable would need to be (from the above examples)... MD45 or TX341 or FL12 I'm kind of familiar with LEFT command. Would usin...

Vista blue screen problem...please help!
I've seen some other threads, here are the dump files: 'RapidShare: 1-CLICK Web hosting - Easy Filehosting' (http://rapidshare.com/files/347103149/Minidump.rar.html) Please, help me out here. -- ceVil It might be better to know at what point the bsod occurs and what the actual err.msg given is "ceVil" <guest@unknown-email.com> wrote in message news:0b9a0c60b90bf6c0be88bda30f2820ab@nntp-gateway.com... > > I've seen some other threads, here are the dump files: > 'RapidShare: 1-CLICK Web hosting - Easy Filehosting' > (...

format of emailed excel file
In excel 2003 when I email a a particulat worksheet in a workbook I lose all the formating when it is recieved in Outlook 2003. Is there anyway to preserve the excel "look"? Thnaks, Craig S ...

problem #4
Hi, I am facing this new problem... i.e a user has installed Office 2003 on win2k prof platform.. whenever she is working on a outlook.. she gets a Microsoft error message... saying to send the report or don't send the report... Usually I have seen this problem in IE... But for outlook it is new to me... after clicking on send or don't send report.. the outlook closes. And there are no IE open..... and if atall it is open.. the IE does not close... Need your help regards, KAH What is logged to the Event Viewer regarding this? Try one of the following already; http://www.howt...

Show file location in title bar?
Is there a way to make Excel or Word show the location of a file in the title bar. Right now, it just shows the name of the file. I was thinking in 2003, it showed the file location, or perhaps there was an option to show it? I can't find the same thing in 2007 and it would be extremely helpful to have it! I use template files with the same name (for easy searching) but save in different client folders, which is why I want it to display the full path. Otherwise, I wouldn't care. Thanks!! Add "Document Location" to the QAT. You'll find it in the "Com...

95 and 97 problem
For some unknown reason there is Excel 95 and 97 on this pc.When i double click on an Excel file, the pc defaults to the 95 program (Which incidently doesn't work properly). So my question is how do i get the pc to default to 97. Cheers Craig Craig, Have a look at Windows Help. From Windows 2000 Help (Index under Programs Associating with File Types) To change which program starts when you open a file In My Computer or Windows Explorer, on the View menu, click Folder Options. Click the File Types tab. In the list of file types, click the one you want to change. Click Edit. In Act...

Can not Create cases
I'm having a problem creating cases. Everytime I try to create a new case I get the message Duplicate Record. A record of this type with this name already exists. Please choose a different name and try again. No what I use for the account, title or subject. Even Log Error Category: None Event ID 3 Description MSCRM Platform Error Report: ---------------------------------------------------------------------------- ---------------------------- Error: The statement has been terminated. Error Message: The statement has been terminated. Error Details: Details on this error have not be...

Can an activity be created and managed by a Team Member?
Hello, I was thinking that TM where allowed to create and manage activities because in the Security Team Member Group the “Create New Proposal or Activity” box is checked. But when trying it, a problem occurred. They are allowed to fill the Summary Information for a new activity, but after clicking on the save button, nothing appear in the Proposal and Actities view, neither in the project Center. Looking at it from an administrator account the activities do exist but are not visible for the TM who created them. So what’s the problem? ...

Embedded activex control and auto install
Hi, I've written an activex control which is to be used in any Office application. The user can modify and save/load the document hosting the control just fine. But how about if a user inserts my activex control in his document, and then emails the document to another user who doesn't have my activex control installed? What happens is that the office application pops up an alert saying that the control cannot be activated since it is not installed on the computer. What I would like is that the control autoinstalls (after a confirm) and the user doesn't have to do it manuall...

Date problem
I can't believe there's no post on this, but I can't find it. I've tried the solutions I could find (see below) and still get the error: "The expression is typed incorrectly or it is too complex to be evaluated. For example....Try simplifying...." I have a date field, formatted as Date/Time, General Date, default Value = Now(). I like having the date and the time - in case we need it. I want to run a report on calls taken just for one day. I have CallDate: CallDateAndTime in my query, with "criteria" as Between ([Forms]![frmReports]![txtStartDate]) A...

sync problems
I have all of my info on an HP Ipac. I had to reformat the hard drive and I did not make a back-up file. I am trying to move everything back to the computer but it says there is an error with syncing it. How can I move everything from the PDA back to Outlook again? Please help- thanks ...

Office 2007 - HELP
I have used Word for many years and love it - not too thrilled with the changes in Office 2007, but my bigger issue is with Publisher 2007. I have an image that I have used in Word just fine - meaning, the on screen colors are correct and when printed the colors are correct. Someone sent me a Publisher file and asked me to add the image - I did this - now the image is messed up - the colors are correct on screen, but when printed FROM MY computer the image colors are all wrong - but if I transport the file to a different computer it prints fine I have reinstalled Office - no good Any id...

Installation Problem!!
I am having a problem installing MSCRM 1.2. My configuration consists of a Domain Controller running Win 2000 Server SP4 . I am trying to install MSCRM on a member of the domain running Windows 2000 Server SP4. There is a DNS Server on the DC which is integrated with AD, and a SQL Server 2000 running on the Win 2K machine. The install errors out when CRM creates the root business with the message: Setup was unable to install Microsoft CRM Server. Setup was unable to provision your organization. Setup was unable to create the root business. The configuration of ASP.NET seems to be ok, the pr...

Extender-Create a new data entry window
Is it possible to create a new extender form or window (not sure of the terminology) to enter data into Dynamics? Specifically the Sales Forecast Window in Manufacturing is terrible for entering data, everytime you move to the right, it the scrolling window jumps back to the top and you have to find the item again. Anyway, I would like a new window to enter a sales forecast, is this possible? thanks -- Doug Unfortunately Extender data is stored in Extender tables and cannot be stored in the Sales Forecast tables. I agree with you that the data entry screen is horrible. I am tal...

How to get a Dial-up Connection dialog box?
I just got Outlook 2003 with new laptop which I carry back and forth to work. I use the same ISP at both locations, but with different dial-up phone numbers. When I launch Internet Explorer, I get a "Dial-up Connection" dialog box that lets me select which phone number to use. I want to get that same dialog box if I'm not already online and I launch Outlook 2003, but I can't figure out a way to get Outlook to give it to me. I had Outlook Express on my old laptop, and it gave me the same dialog box as IE. Is that function no longer available? -- Friday714 Set th...

Problems Creating a disclaimer in Exchange 2003
I am trying to create a server based disclaimer that will stamp all of my smtp emails going to the internet. I have been following KB article 317680 with no luck. I get an error like the one below. Binding Display Name Specified: smtpscriptinghost ** Registration Failed ** Err.Number (HRESULT) = 0x1AD Err.Description = ActiveX component can't create object ProgID = cdo.ss_smtponarrival COM Category = {FF3CAA23-00B9-11d2-9DFB-00C04FA322BA} Corresponding Event = onarrival ** Have you registered your sink COM class on this machine? I am puttin...

Resource editor problems
Hello all, Under VC++ 7.1... Please consider these two lines: IDC_ARROW_ADD_CANCEL DISCARDABLE "res\\cur00004.cur" IDC_ARROW_ADD_CANCEL CURSOR DISCARDABLE "res\\cur00004.cur" The second is a hand-edited change to the first. Both will compile just fine in the resource compiler. However, after I use a text editor to make this change, I cannot open the .rc file in the resource editor. The resource editor issues the following error open attempting to open the .rc file: error RC2135 : file not found: CURSOR Can anyone shed light on what's going on here? Thanks, Dave ...

XBox 360 controller not installing
I just got an XBox 360 controller for the PC ("XBox 360 Wireless Controller via Play & Charge Kit") and the driver from http://www.microsoft.com/hardware/download/DownloadResult.aspx?category=Gaming&type=Gaming&name=JR9-00001&os=XP_SP2&lang=en but it's still not showing in the Game Controllers control panel, nor being recognized by my games. I've tried uninstalling/reinstalling the drivers with no luck. I press the "X" button and the ring flashes green: Three fast, then 12 slow. Ports are OK, no other USB devices connected. Any...

Directory Replication Problem #2
Hi, recently my Exchange Server directory database receives changes from other servers but does not send out its own changes. Check from the knowledge base, to correct the USN discrepancy need to use Authrest.exe (need to amke changes for about 100+ users). Does anybody know where to get this file 'Authrest.exe' for exchange server 5.5? Exchange server 5.5 CD only provide this file for ver.4.0. Have anyone use it before? Regards, "Sharon Tan" <sharon_tansk@yahoo.com.sg> wrote: >Hi, recently my Exchange Server directory database >receives changes from ot...