CFileDialog - change the "Save" button's caption

hi all,
I inherite CFileDialog, and implement it as File Open and File Save.
I change the caption of the "Open" button in function CMyFileDlg::OnNotify this way, I know the Id of the button (it is 1), I get the handle of the button and SetWindowText does the rest:

const int cOpenId = 1;
CWnd *pCcommDlg = GetParent();

hWndControl = FindWindow(pCcommDlg->m_hWnd, _T("Button"), cOpenId) ;
// Set Control's text from OK to Do.
if (hWndControl)
{
    CWnd *aWnd = FromHandle(hWndControl) ;
    ASSERT(aWnd) ;
    aWnd->SetWindowText (_T("Do"));
}

unfortuanally, it works only in the "File Open" mode, but in "Save as" mode it remains "Save".
does anybody have idea how I can change the caption, without losing its capacities?
10x, RanBN
RanBNAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

abancroftCommented:
Are the button ID's the same in the open & save modes?
0
SuperMarioCommented:
In the CFileDialog constructor:

CFileDlg dlg(FALSE);

Use FALSE as the first parameter, That sets the dialog to a Save As box.

-D
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

How U came to know that Open button's ID is 1? And is it same for Save As button also?. I think IDs may not be same. Thats why it is not working. Follow the same method to find the ID of Save As button also. (Or U have assumed thet it will be same as IDOK that is 1? - sorry).

Try it out.

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

RanBNAuthor Commented:
I know that the id of the "Save As" button is 1, because I move it to another location in the dialog by using the id.
my problem is that I change the text in the button, but after me, CFileDialog:":OnNotify is called, and changes the caption again to Save.
the original caption is "Open"
10x for your responses,
Ran
 
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

The problem exists, but I too don't know where it exists!!!. I have a work around solution for it. But I am not satiafied with it. Anyway take a look at the fix.

1. Map the OnInitDialog(), OnTimer() and OnDestroy() functions     for Ur derived class.

2. In OnInitDialog(), set the timer
3. In OnTimer() update the caption
4. In OnDestroy() kill the timer

The code looks like
BOOL MyOpenDlg::OnInitDialog()
{
   CFileDialog::OnInitDialog();
   SetTimer(1,20,NULL);
   return TRUE;
}

void MyOpenDlg::OnTimer(UINT nIDEvent)
{      
    CWnd *pCcommDlg = GetParent();
    pCcommDlg->GetDlgItem(1)->SetWindowText("&Do");
    CFileDialog::OnTimer(nIDEvent);
}

void MyOpenDlg::OnDestroy()
{
    KillTimer(1);
    CFileDialog::OnDestroy();
    // TODO: Add your message handler code here
}

I have commented Ur code in OnNotify() as it is no more required. Try it out.
0
RanBNAuthor Commented:
10x VinExpert,
your work around solution actually works, but is there a way to avoid the multiple refreshings?
anyway thanks alot.
please send your comment as an answer and I pass you the points which you deserve!
RanBN
0
PIGCommented:
Overwrite PreTranslateMessage and do not pass WM_NOTIFY to windwow. Call owen function directly.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

!!!!????
0
RanBNAuthor Commented:
10x PIG,
I override OnNotify for many operation, I cannot lose it..
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Here is the comment as an answer!!!.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RanBNAuthor Commented:
10x all of you
RanBN
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.