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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Vinayak KumbarConnect With a Mentor Sr Program ManagerCommented:
Hi,

Here is the comment as an answer!!!.
0
 
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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
 
RanBNAuthor Commented:
10x all of you
RanBN
0
All Courses

From novice to tech pro — start learning today.