CDM_SETCONTROLTEXT not working
Christine Hagberg -- CHAGBERG@datx.com
Wednesday, August 14, 1996
Environment: VC++4.2/Win95
I am trying to change the "OK" button on the CFileDialog to "Compress".
this->SendMessage( CDM_SETCONTROLTEXT, IDOK, (LPARAM)
(LPSTR)"C&ompress");
This worked fine under VC++2.0 and now after going to 4.2 it does not do
anything. What am I doing wrong?
CCompressFileDlg derived from CFileDialog
BOOL CCompressFileDlg::OnInitDialog()
{
CFileDialog::OnInitDialog();
this->SendMessage( CDM_SETCONTROLTEXT, IDOK, (LPARAM)
(LPSTR)"C&ompress");
}
Joern Dahl-Stamnes -- Jorn.Dahl-Stamnes@fysel.unit.no
Friday, August 16, 1996
[Mini-digest: 7 responses]
>Environment: VC++4.2/Win95
>
>I am trying to change the "OK" button on the CFileDialog to "Compress".
>
> this->SendMessage( CDM_SETCONTROLTEXT, IDOK, (LPARAM)
>(LPSTR)"C&ompress");
>
>This worked fine under VC++2.0 and now after going to 4.2 it does not do
>anything. What am I doing wrong?
>
>CCompressFileDlg derived from CFileDialog
>
>BOOL CCompressFileDlg::OnInitDialog()
>{
> CFileDialog::OnInitDialog();
> this->SendMessage( CDM_SETCONTROLTEXT, IDOK, (LPARAM)
>(LPSTR)"C&ompress");
>}
Why not:
SetDlgItemText (IDOK,"C&ompress");
I do only use 1.52, so I can't tell if it work in 4.2, but it should.
--
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Joern Yngve Dahl-Stamnes, Norwegian University of Science and Technology |
| e-mail: Jorn.Dahl-Stamnes@fysel.unit.no |
| phone : +73 59 44 12, fax: +73 59 14 41 |
| Surfing the net? Try http://www.fysel.unit.no/dahls/dahls.html |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-----From: Mario Contestabile
You should use SendDlgItemMessage(). SendMessage() has to
scan the dialog looking for a control with the same ID.
mcontest@universal.com
-----From: Tim Hagemann
CFileDialog has a nice memberfunction doing the thing:
void CFileDialog::SetControlText(int nID, LPCSTR lpsz)
But the SendMessage-code you wrote in your mail should work too.=20
The problem is, that the whole OnInitDialog handler will not be called =
in common dialogs. Instead, use the CFileDialog::OnInitDone() member and =
override it.
Tim Hagemann
ifa informationssysteme
-----From: "Greg Tighe"
>From the MSVC++ 4.2 Online Help:
CDM_SETCONTROLTEXT
The CDM_SETCONTROLTEXT message sets the text for the specified control
in an Explorer-style Open or Save As common dialog box. The dialog box
must have been created with the OFN_EXPLORER flag; otherwise, the
message fails.
-Greg Tighe
Applied Intelligent Systems, Inc.
Ann Arbor, MI
gdt@aisinc.com
-----From: Greg Williams
Under Win95, the default File Open box is "Explorer style", which is
implemented differently from the old Win 3.1 File Open dialog. The
controls for the CFileDialog are now in its parent window, so you should
send the message to your parent:
GetParent()->SendMessage( CDM_SETCONTROLTEXT, IDOK, . . . );
If that doesn't work, I've been able to change the OK button text in the
following way:
1) Use ClassWizard to derive a dialog class from CFileDialog()
2) override OnInitDone()
3) change the label of the OK button in OnInitDone() as follows:
void CMyFileDialog::OnInitDone()
{
CFileDialog::OnInitDone();
CWnd* ctlOK = GetParent()->GetDlgItem(IDOK);
ctlOK->SetWindowText("&Hey");
}
Hope this helps.
--Greg Williams
====
Greg Williams
Senior Software Engineer
Softlab, Inc.
gwilliams@softlabna.com
-----From: Dean Wiles
This is just a shot in the dark, but according to the help in VC++4.2:
The CDM_SETCONTROLTEXT message sets the text for the specified control in an
Explorer-style Open or Save As common dialog box. The dialog box must have
been created with the OFN_EXPLORER flag; otherwise, the message fails.
Does your constructor or the instantiation of your CCompressFileDlg have
something like:
dwFlags |= OFN_EXPLORER;
If you look at the source for CFileDialog::CFileDialog() in
\MSDEV\MFC\SRC\DLGFILE.CPP, MFC only does that if your running Win95 or NT4.0.
If that doesn't help, try checking the return value of SendMessage for clues.
--------------------------------------------------------------------------
Dean Wiles (deanw@mail.isc-br.com) Olivetti North America
Phone: (509)927-7037 22425 East Appleway Ave
Fax: (509)927-2499 Liberty Lake, WA 99019-9534
If the Son sets you free, you will be free indeed. (John 8:36)
-----From: "Yury Kosov"
Yes,
Win95 added another level(layer) of windows to implement
FileOpen dialog box, so you have to talk to the parent of the
CFileDialog:
GetParent()->SendMessage( CDM_SETCONTROLTEXT, IDOK, (LPARAM)
(LPSTR)"C&ompress");
This will do the trick.
Yury Kosov
CoreTek, Inc.
yury@msn.com
| Вернуться в корень Архива
|