|
do you want *all* pages to be visible? if so, you can set the items to expanded when they are added to the tree; something like:
...
tvi.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_STATE;
tvi.item.state = TVIS_EXPANDED;
in CSAPrefsDialog::OnInitDialog.
or, if you just want to open a single node at start up:
add a member m_uStartPageID and set it 0 by default.
if (m_uStartPageID==0)
{
if (ShowPage(0))
{
m_iCurPage = 0;
}
}
else
{
for (int i=0;i<m_pages.GetSize();i++)
{
pageStruct *pPS = (pageStruct *)m_pages.GetAt(i);
ASSERT(pPS);
if (pPS)
{
ASSERT(pPS->pDlg);
if (pPS->id == m_uStartPageID)
{
ShowPage(i);
m_iCurPage = i;
break;
}
}
}
}
put that at the end of OnINitDialog, too.
then set m_uStartPageID to the page ID of the page you want to open
-c
|
|
|
|
|
We can find another similar idea here
Cheers and thanks to Chris and Sven Wiegand
Koundinya
|
|
|
|
|
yes.
and here :
http://www.codeproject.com/dialog/csettingsdlg.asp
and here :
http://www.codeproject.com/dialog/ezoptionsdlg.asp
and here :
http://www.codeguru.com/dialog/netscape_like_prefs_dialog.shtml
When history comes, it always takes you by surprise.
|
|
|
|
|
Should we call DestroyWindow() to clean up the Create() calls?
void CSAPrefsDialog::OnDestroy()
{
CDialog::OnDestroy();
// destroy windows to free resources
for (int i=0;i<m_pages.getsize();i++)
{
="" pagestruct="" *pps="(pageStruct" *)m_pages.getat(i);
="" if="" (pps)
="" pps-="">pDlg->DestroyWindow();
}
}
}
|
|
|
|
|
DestroyWindow is called on each of the Created sub-dialogs when CSAPrefsDialog's DestroyWindow is called (via CDialog::DestroyWindow). you don't need to explicitly destroy the child dialogs. override WM_DESTROY in your own sub dialog and put a breakpoint there, if you want to see it in action.
-c
I'm not the droid you're looking for.
|
|
|
|
|
Chris, I love this interface. Thanks for making the code available. I have a problem, though. I find that when I run my app and open the dialog, none of the controls inside the pages are sensitive to mouse clicks; they just sit there looking pretty but dead. The tree control works fine, and shows each separate page. This must be something pretty basic that I have done wrong, but I can't figure it out. Does this sound familiar? Anybody have any ideas?
|
|
|
|
|
hmm... are you doing any "SetCapture" calls anywhere? (longshot, but i can't think of anything else)
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
Thanks, Chris, for your prompt response. No, I am not making any SetCapture calls. Your answer convinced me that I was just making some simple mistake. I'm embarassed to say that after going down several blind alleys I discovered that I had set the Disabled style for the property pages. Problem Solved. I think this is the equivalent of calling in the TV repairman and then finding out that the set is unplugged.
Regards and thanks for the great interface.
|
|
|
|
|
Hi,
I realised that when a user is accessing one of the subdialog frames, if he presses F1, he will end up having a WinHelp error saying the topic does not exist. So is there a way to redirect the WinHelp request within the frames to the parent frame help request?
|
|
|
|
|
look at the article text, it shows how to assign a help ID to a page.
-c
If Ben Affleck is sexy, then the terrorists have won.
--Sheerly Avni
|
|
|
|
|
Chris,
Great article. If there is no special page for the parent node in the list and only the children have pages (subdialogs), how can I just expand the node when it is selected? Or even select the first child and display that page? Thanks for your help.
|
|
|
|
|
i'm not sure i follow...
do you want a root node with no associated page? if so, you'll have to do some work on the tree code. it would probably be much easier to just have a blank dialog associated with the root.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
That's what exactly I did. I have a dummy page whose primary purpose is to call ShowPage with the first child when it gains focus. THanks
|
|
|
|
|
I can't export members values from dlg2 to other, ex. dlg5. When you work with DoModal that's easy.Could somebody help me?
Thank Great job.
|
|
|
|
|
the easiest way to do this is to give dlg5 a pointer or a reference to dlg2. then, when dlg5 needs to get data from dlg2, it can just use the ptr or ref to call functions (or access the member variables directly) on dlg2.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
I did something like this:
Dlg1,
void CDlg1::OnKillfocusEdit2()
{
UpdateData(TRUE);
}
Dlg3,
#include "stdafx.h"
#include "prefs.h"
#include "Dlg3.h"
#include "Dlg1.h" <-
BOOL CDlg3::OnInitDialog()
{
CSAPrefsSubDlg::OnInitDialog();
m_prog.SetRange(0, 100);
CDlg1 m_pD1; <-
//m_sString = m_pD1.GetStrn(); <- member function
"or"
m_sString = m_pD1.m_sStrn; <--
UpdateData(FALSE);
And I haven'got any value, m_sString is empty.
What's my wrong
|
|
|
|
|
(is this a question about SAPrefs?)
anyway, you have no values in CDlg1 because you never called DoModal on it.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
I understand, I know that never I have called DoModal, Because you move from CDlg1 to CDlg3 by the tree.
So sorry, I'm beginner in VC. The question is How can I use a member from CDlg1 in CDlg3? and, this question is about SAPrefs. Thanks for your time.
|
|
|
|
|
here is one way:
add a member variable to CDlg3:
class CDlg3
{
...
public:
CDlg1 *m_pDlg1;
...
}
and be sure to set the pointer to NULL in CDlg3's constructor!
when you create the CSAPrefs dialog and add the pages to the tree, your code looks something like this:
CSAPrefsDlg dlg;
CDlg1 myDlg1;
CDlg2 myDlg2;
CDlg3 myDlg3;
dlg.AddPage(myDlg1);
dlg.AddPage(myDlg2);
dlg.AddPage(myDlg3);
myDlg3.m_pDlg1 = &myDlg1;
now, when dlg3 needs to access dlg1, it can use this pointer:
void CMyDlg3::Something()
{
if (m_pDlg1 != NULL)
{
CString csString = m_pDlg1->GetTheStringIWant();
}
}
there are more elegant methods, but this is the simplest.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
Thank you so, so much. That was so usefull to me. The person that help to other is a good one, I think that abou you.
|
|
|
|
|
Hi.
I want to start not with page 0, but with page 3.
In OnInitDialog, ShowPage is called, and ShowPage call SetFocus, then Call Focus make a call to OnSelchangedPageTree, and OnSelChange.. make a call to ShowPage, etc...
Can somebody help me ?
Pascal
|
|
|
|
|
add a new member variable to CSAPrefsDialog: UINT m_uStartPageID . initialize it to zero in the constructor.
in SAPrefsDialog.cpp / OnInitInstance, add this code after the big "for" loop:
if (m_uStartPageID==0)
{
if (ShowPage(0))
{
m_iCurPage = 0;
}
}
else
{
for (int i=0;i < m_pages.GetSize();i++)
{
pageStruct *pPS = (pageStruct *)m_pages.GetAt(i);
ASSERT(pPS);
if (pPS)
{
ASSERT(pPS->pDlg);
if (pPS->id == m_uStartPageID)
{
ShowPage(i);
m_iCurPage = i;
break;
}
}
}
}
now, when you want to start with a particular page, just set this variable to the page index that you want.
-c
"Half of the harm that is done in this world is due to people who want to feel important."
-- TS Elliot
|
|
|
|
|
Chris, thna for answer, but..
But this code always don't run in my app.
At first I try this in your sample, it run perfectly.
I explai what's happed in my app :
In ::OnInitDialog, ShowPage(..) is called. In ::ShowPage, when the code came about to //move, show, focus, in the call of SetFocus, I think a message is send to update the TREE control. I think so because ::OnSelchangedPageTree is called before ::ShowPage is finished in my prog, but it is not the case in your sample. Then OnSelchangedPageTree is called to update node index 0, bit I want to update for node 3..
Have an idea where I can search ?
Pascal
|
|
|
|
|
I think I solved the problem.
I modifiy ::ShowPage() as follow :
// move, show, focus
if (::IsWindow(pPS->pDlg->m_hWnd))
{
if (m_iCurPage >= 0)
{
pPS->pDlg->MoveWindow(m_frameRect.left, m_frameRect.top, m_frameRect.Width(), m_frameRect.Height());
pPS->pDlg->ShowWindow(SW_SHOW);
pPS->pDlg->SetFocus();
}
}
Now it's run correctly.
Second, the method suggest by Chris dont run if you use multiples pages with the same ID. I do this to edit multiple tools with the same mask.
Then, I used original code with SetStartPage
Best regards and thank's again to Chris for his excellent job
Pascal
|
|
|
|
|
Hey Chris.
Great job. Do you have a version that automaticly sizes the bounding frame and dialog to fit the largest page?. I am using it in more than one place in my project,and i have pages of different sizes,it's getting a lil messy.
Thanks.
|
|
|
|