|
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.
|
|
|
|
|
sorry, i don't. but if you'd like to add it.. .
-c
For men use, if they have an evil turn, to write it in marble:
and whoso doth us a good turn we write it in dust.
-- Sir Thomas More
|
|
|
|
|
Precisly what i don't want to do.
|
|
|
|
|
thank you so much ,this source code give me so much help.
regard!
Bruce
2002/07/22
http://www.cpper.com
|
|
|
|
|
Ive tried overriding on notify, but i guess im just not doing it right..
when one of the pages gains focus i want to call a function of that page.. plz help?
thanks
-dz
|
|
|
|
|
i did this in the version of the dialog that i use in my own stuff.
in CSAPrefsDialog::ShowPage, make the following changes:
in the "turn off the current page" section
if (::IsWindow(pPS->pDlg->m_hWnd))
{
pPS->pDlg->OnSAPrefsShow(false);
pPS->pDlg->ShowWindow(SW_HIDE);
}
...
...
...
pPS->pDlg->MoveWindow(...);
pPS->pDlg->ShowWindow(SW_SHOW);
pPS->pDlg->SetFocus();
pPS->pDlg->OnSAPrefsShow(true);
then, add this to the protected section of SAPrefsSubDlg.h:
virtual void OnSAPrefsShow(bool bShow);
and add this to SAPrefsSubDlg.cpp:
void CSAPrefsSubDlg::OnSAPrefsShow(bool bShow)
{
}
ok, now you can add OnSAPrefsShow functions to any of the sub-dialogs that you want. the OnSAPrefsShow function will (obviously) get called with a "false" when the dialog is losing focus and "true" when it is gaining focus.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
thanks a ton for the quick responce, and for the cool prefs dialog!
-dz
|
|
|
|
|
This is really excellent and gets full marks from me.
Keep up the good work!
JohnJ
http://www.rainbow-innov.co.uk
|
|
|
|
|
I am using your code in a UNICODE project, so I had to modify bit. It works fine so far.
However, I have a question:
Why didn't you base your CSAPrefsSubDlg on CPropertyPage. This way it is very easy to implement OnApply and the like in the pages
Did I miss anything?
|
|
|
|
|
no real reason. i think when i wrote this, the settings pages i was using were already dialogs, not property pages. i just carried it along.
-c
Civilization is the limitless multiplication of unnecessary necessities.
Mark Twain
|
|
|
|
|
I wrote to Chris about it six month ago, and sent my code fix... But with no effect.
Chris, thanks, your class was really helpful for me!
|
|
|
|
|
Can you post here your fix?
thanks
|
|
|
|
|
in SAPrefsSubDlg.cpp / PreTranslateMessage:
change this:
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE))
{
return TRUE;
}
to this:
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE))
{
GetParent()->PostMessage(WM_CLOSE);
return TRUE;
}
Civilization is the limitless multiplication of unnecessary necessities.
Mark Twain
|
|
|
|
|
Here's my fix (for that version of SAPrefs I downloaded in September 2001):
BOOL CSAPrefsSubDlg::PreTranslateMessage(MSG* pMsg)
{
// Don't let CDialog process the Escape key.
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE))
{
GetParent()->PostMessage(WM_COMMAND, IDCANCEL);
return TRUE;
}
// Don't let CDialog process the Return key, if a multi-line edit has focus
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN))
{
// Special case: if control with focus is an edit control with
// ES_WANTRETURN style, let it handle the Return key.
TCHAR szClass[10];
CWnd* pWndFocus = GetFocus();
if (((pWndFocus = GetFocus()) != NULL) &&
IsChild(pWndFocus) &&
(pWndFocus->GetStyle() & ES_WANTRETURN) &&
GetClassName(pWndFocus->m_hWnd, szClass, 10) &&
(lstrcmpi(szClass, _T("EDIT")) == 0))
{
pWndFocus->SendMessage(WM_CHAR, pMsg->wParam, pMsg->lParam);
return TRUE;
}
return FALSE;
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
Chris,
Excellent work! Top marks! I have incorporated it into my main project and it works beautifully. I also took your code and made a new class that would make SAPrefs perform as a wizard with next/previous/finish buttons, and I only added about 40 lines. Excellent!
Thanks again!
Alexander Wiseman
a.k.a Farseer
|
|
|
|
|
some comments:
1.support for OnApply and OnKillActive will be very suitable. TVN_SELCHANGING is good way to support OnKillActive. OnApply can be called from parent's OnOK handler.
2.Calling childs UpdateData from parent seems to be useless.
The interface itself is very nice. Thanks.
Serge.
|
|
|
|
|
I like this approach. It provides for a more organized, intuitive property page.
Another useful thing might be to make this into a view class. I might tackle that this summer unless someone beats me to it.
|
|
|
|
|
NISH IS A DISH ! HAHAHAHAH I AM FUNNY
|
|
|
|
|
Has anyone built the sample code under VC7?
I tried and found the by changing the definition of OnSetText from BOOL to LRESULT and removing the Enable3dControls() functions, it seems to work ok.
Can anyone verify this.
Thanks,
Rene Laviolette
|
|
|
|
|
I was just about to implement a settings page using this class, but we are getting in .NET on friday of next week and I don't want to work on it unless im sure it will work.. I would think it would work in .NET, but I am already worried about what I've written so far and its compatibility. I'll be checking this post to see if anyone can comfirm the .NET compatibility.
-dz
|
|
|
|
|
Yeah,I've used the great code in my app and it works well on the .Net.;P
|
|
|
|
|
Your code and sample are worthless bro! And you had the NERVE to say on another person's sample that yours was better! It isn't! You have no idea about how a prefs dialog is used? A prefs dialog is launched ALWAYS modeless from within a mainframe in common practice. Consider the OUTLOOK application! It is impossible to use your code in an Outlook like application where the Prefs dialog will, in most cases, be launched from a child window in a splitter! Your code will NOT lend itself to being launcjed in as modeless because your oref dialog are are modal and defined from OUTSIDE the main prefs dialog! Your approach is terrible and uselss bro!
But you did do a nice job drawing the comment bar above the list.
Bill SerGio
Bill Sergio
|
|
|
|