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
790 Views

Similar Articles

[PageSpeed] 7

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 (3236)
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 (3236)
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 (3236)
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 (3236)
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:

Administrative Groups
I have 2 Administrative groups with a Exchange 2003 Server in each group. One group is on the other side of campus and is controlled by their Exchange Server Tech. I have delegated control of my server to myself. There are also users from the other server that do not belong in my server and would like to remove them. The problem is, that when I go to remove them it will not , because the user or group is inherited from the organization. How can I remove them from my server and yet not remove them from their server? It sounds like that if I remove them from the orgainization that they wi...

MS Money 95 data files
I hope that some one can answer this for me. I have used MS Money 95 for years, and it works just fine for me on Windows XP, however, I now have to reformat my hard drive, and have discovered that I can nolonger find my original install disk. Will the latest versions of Money still read the MS Money 95 data files. All that I have ever used the program for is to track my investments, and am unlikely to do any different in the future. Thanks Stan B In microsoft.public.money, Stan Banner wrote: >I hope that some one can answer this for me. >I have used MS Money 95 for years, and...

Standard MFC controls behave different when showing polish characters
Hello all, I have a rather simple to describe but difficult to solve problem. Our customers want to use our ANSI MFC program to show different languages. For example Polish. When I set the font for the different controls they behave different. For example the CEdit shows the polish characters just right but the CButton with checkbox style shows glyphs instead of the special characters. Every control that is owner draw and uses for example the DrawText() function of the device context shows the characters right. I've experimented with _UNICODE for the display part and everything I could ...

Exchange update problem
I have tried to upgrade exch2k3 sp1 to sp2, but the update fails with "the file pcproxy.dll is in use, and setup cannot identify the app or srvc. setup cannot continue" Any clues/ideas/suggestions? Please. -- ----------------------------------------------------------------------------------------------------------------------- This message has been checked for all known viruses. The information contained in this e-mail and any attachments is confidential and may be the subject of legal, professional or other privilege. It is intended for the named addressee only and may not ...

multiple Domain name delivery problem
hi, I currently have Exchange Server 2003 Build 7638:2 SP2,. We have multiple domain names being delivered to the exchange store. I have nothad any problems, but i currently have one user that is not receiving emails with attachments from one certain "internet" sender to one of her email addresses, but the other address works fine & if they send emails without attachments, everything works fine from either address. I have had the user send them message with attachments to me & the user with the problem & i get the message, but not the other user! I even use message...

SQL deadlock problem
I am currently having a big issue with sql deadlocking on the PrincipalObjectAccess table. The last few months I have been working on a synchronization process using a Biztalk orchestration. The sync uses the crm webservices to create and update account and contact records in CRM. But now deployment to the production environment gives me some problems. It seems that when trying to update account records (which is one of the first actions in the sync process) the webservice gives me Generic SQL errors and SQL timeouts. After extensive profiling and tracing in SQL I found that there are...

Input Excel 'Password to Open' through control in access form
Hi All, We know,Excel has prompt password to open it files. Is it possible to create a code that can supplies the excel prompt password?.So that when we open the excel file through our access control in a form, the excel files can be opened automatically.But when the excel files opened from its default icon,it will prompt a password first. ...

Create a distribution list from addresses in the 'To' list
Hi all, I belong to a social group, and our co-ordinator sends out an email from time to time with all the latest addresses in the To list. I already have a distribution list for the group, which then needs to be checked through and updated. Is there a simple way of transferring those addresses into my own distribution list? I'm using Outlook 2002. Everybody's fiddling around with bits of paper - I'll be a hero if I can make it easy for them! Thanks. Astley http://www.outlook-tips.net/archives/2004/20041105.htm -- Russ Valentine [MVP-Outlook] "Astley" <ast@...

docmd.transfertext problem
Hi, I am using access 97 and tried to import a csv file to the mdb table. I run a code as following: DoCmd.TransferText acImportDelim, "Specification4", "input", DEFAULT_PATH & "online.txt", 1 In online.txt, there is a field which is 10 digit number and I specified it as a double datatype in the specification4. After the import, I found out that the 10 digit number data in the field get empty in the destined table while other fields are all right. Therefore I import manually using specification4 instead of running code. This time the 1...

Pointer to Dialog Instance
Hello, all: I have an edit control that I would like to assign some text. I assign a variable -- called m_Name -- to the control, and I tried calling m_Name.SetWindowText("Blagh"). It didn't work. I looked at my code and realized that the function is external to the dialog box class. So, how can I obtain a pointer to the dialog from within my separate function, so I can call SetWindowText as follows... pointer->m_Name.SetWindowText("Blagh"); Thank you, Saul > It didn't work. What happened? Assert? Was m_Name subclassed correclty and it was alre...

Creating new attributes
When using Schema Manager to create new attributes, I'm not able to create a new attribute with "Lookup" as type, "Lookup" is not availabe as one of the type options. But yet some of the exist fields, for example, in Account table came with "Lookup" as type. Why? Is there a work-around? Please help. Thanks. You cannot add custom lookup's to the current release of MSCRM. The only way around is to build a custom .aspx page and build your own. Might be possible in the next release. "HEC" wrote: > When using Schema Manager to crea...

worksheet tabs 01-06-10
Hi In the 2003 excel-- Is there a way to have the worksheet tabs automatically go in alphabetical order-- or do you have to do in manually? -- Thank-you! Ruth Ruth, Use this code: Sub ArrangeSheetsInOrder() Dim iCount As Integer Application.ScreenUpdating = False iCount = Sheets.Count For i = 1 To iCount - 1 For j = i + 1 To iCount If Sheets(j).Name < Sheets(i).Name Then Sheets(j).Move Before:=Sheets(i) End If Next j Next i End Sub "Ruth" wrote: > Hi > > In the 2003 excel-- Is there a way to have the worksheet tabs automatically ...

adding name /creating field/query?
Hello, I can create an invoice_number field in a query using the primary field ID from the main table as invoice_number: ID but if ID say is 100, I cannot work out how to create renewal_invoice_100 Cheers Geoff Geoff We aren't there. We can't see what you're looking at. Where did "renewal_invoice_100" come from and what does it mean? Please post the SQL statement of the query you are trying to use. -- Regards Jeff Boyce www.InformationFutures.net Microsoft Office/Access MVP http://mvp.support.microsoft.com/ Microsoft IT Academy Program Mentor http://micro...

Drag and Drop file/directory names on Tree Control.
hi, I am writing an application in which i have one Tree control. Now i want that , when user drag & drop any file/folder on tree control the file name/folder name should be add in the tree control item. User may drag and drop file from desktop or may be from directory. I just want the path of that file/foder name nothing else. so plz tell me will it be possible ... Plz Help me............. Klic..... > I am writing an application in which i have one Tree control. >Now i want that , when user drag & drop any file/folder on tree >control the file nam...

Where is the workspace file stored?
I was given a project folder containing several dozen files. So where is the workspace file normally located? If I don't have a workspace file how can I cerate one? Using VC version 6. TIA I haven't used VC6 for some time, but if I remember right you can just open the .dsp file and it will create a .dsw file for you. It typically goes in the same folder with the code. Tom "Phisherman" <noone@nobody.com> wrote in message news:be93539ccf8a6f25ibh4vt6ggmtbi024mq@4ax.com... >I was given a project folder containing several dozen files. So where > is the wor...

How do I create several NEW templates from start to finish please?
Hi knowledgeable people. I am looking for instructions on how to create a range of basic templates that I can use, perhaps even by selecting them as 'stationery', for example; if I go to >New >Format >Apply stationery, or any other similar method. I can create new html stationery backgrounds, but this is NOT what I am looking for, as a lot of people still read email in plain text only...does this make sense? Plain text templates would be fine. I simply can't find any info on creating email templates anywhere to suit this Windows Live Mail Desktop versio...

Change File Locations to Private Drive (not Folder)
Hi, I know that I can use "File Locations" in "Options" so that whenever I use the "Open..." command in Word, it will open to a specific folder. I'm wondering if there is a way that this can be applied not to a folder but to a specific drive on a network. Our company has a main public drive and has also assigned each of the Staff their own private drive. Is there a way to access the "main page" (for lack of a better term) of my private drive each time I use "Open..." in Word? Right now it goes to "My Computer" or ...

cant start outlook pst file to large
Hi I hope somebody may be able to help im new to outlook and now I cant start outlook message says cannot open your default email folders pst file its too large as I cannot open outlook I cannot delete old folders See if this helps: http://support.microsoft.com/kb/296088 -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www.rolandschorr.com http://www.officeforlawyers.com/outlook.html Author: The Lawyer's Guide to Microsoft Outlook 2007: http://tinyurl.com/ol4law-amazon "Ray" <Ray@discussions.microsoft.com> wrote in message news:B3B824DC-3C9B-4B1B-8EF3-61...

Unexpected error message on closing an Excel file
Suddenly I am getting the following message when I try to close a workbook: "Your formula contains an invalid external reference to a worksheet. Verify that the path, workbook, and range name or cell reference are correct, and try again" The mysterious thing is that it does not happen consistently and that, after I click OK after the above message, I can still save the file. What might be the cause of this error message and can the "invalid reference" be tracked down using one of the utility add-ins such as J. Walkenbach's PUP? If it only happens when you close ...

Excel Problem
I have a 23.8 meg excel 2000 spreadsheet set for manual calculation saved to my local hard drive. Every time I try to open it, it takes forver and sometimes never opens but I do not get any error messages, let me just tell you that I am running a P4, 1 GB memory, Office 2K with SP3, and nothing else running when I try to open it. As I said it is set for manual calculation, and it is cleared to not auto calculate when opening or closing. Any idea's as to why this is happening? -- Todd I don't know why you're having this problem but I would like to point something out for w...

SOAP Exception
Hi, In my C# code, I have defined a Map object which is sent as part of a request to a web service, here's an extract of the part of the code: - Map map = new Map(); map.item = new mapItem[4] { new mapItem(), new mapItem(), new mapItem(), new mapItem() }; ................. But when I submit the request containing the Map object, the compiler throws an error with the following message:- org.xml.sax.SAXException: No deserializer for {http://xml.apache.org/ xml-soap}...

Strange Access Denied Problem with Windows 7
I got a new computer about six months ago that came with Windows Vista Home Premium 64bit. Before that I had done all of my .NET development either on an XP Pro VM or my former XP Pro computer at home. Shortly after getting my new computer at home, I also got a license for VMWare to be able to test my software on multiple platforms and configurations. I had wrote an application originally in VB.NET that was a simple backup utility. It supports mutiple backup configurations. Any given copnfiguration would define a backup which would be a list of files to backup, a list of folders to ...

Reverse created rules
I inadvertantly created a rule to automatically send emails from an email address directly into the deleted files. How do I reverse or delete the rule for this sender??????? If this is Outlook then select the Tools Menu > Rules Wizard > locate the Rule and delete it, if its Outlook Express then go to Tools > Message Rules "joebzii@everestkc.net" <anonymous@discussions.microsoft.com> wrote in message news:1c12401c4218b$fa8e7f70$a401280a@phx.gbl... > I inadvertantly created a rule to automatically send > emails from an email address directly into the deleted &...

Trying to read XML file into dataset
Hello. Developing a web site in VS2005, SP1, VB, .NET 2.0, ASP.NET 2.0 on XP Pro, SP2. I eventually want to use a gridview table to view xml data, but right now i can't seem to get my xml data into a dataset so that i can use it. I have an XML file and can open it in IE. There is no XSD or XSL file to go with it. I can't seem to get the XML data into a dataset. I tried using the following code, but it just does nothing. It doesn't give an error. It just executes the code and does nothing. Dim dataSet As DataSet = New DataSet dataSet.ReadXml("...

Tabs and record scrolling
Hi - I have a combo box that automatically sets the focus of one of 3 tab pages based on the value selected in the combo box. I'd like to be able to do the same thing when scrolling through records. Any help is appreciated!! Steve Hi Steve, Put the same code in the on current event of the form, remembering to check if the combo is null of course!! That way as you change records, it will trigger the event and set the focus as necessary. Damian. "sboegeman" wrote: > Hi - > > I have a combo box that automatically sets the focus of one of 3 tab pages > bas...