Changing 'Open' to 'OK' in a CFileDialog
beriksen@cda.com Monday, October 21, 1996 Environment: VC++ 4.1, Win 95 / Win NT 4.0 Hello All! I'm trying to something that I feel should be quite simple: I want to use an instance of CFileDialog to specify a file name. With this in mind, the Open button should probably say OK, right? Well, I've provided a hook function. I'm using OFN_EXPLORER, so in my hook function I can catch CDN_INITDONE during a WM_NOTIFY. What I want to do is use the CommDlg_OpenSave_SetControlText macro to send a CDM_SETCONTROLTEXT message, but this macro (and message) takes the ID of the control for which you want to set the text. Where do I find that ID? I've been looking all over, and have so far consulted the faq, msdn, and my personal archive of this list. If you know this number (and in what file/article/sample you found it), could you let me know? Thanks! Brian Eriksen CDA/Wiesenberger PS - I've got this working under Win3.1 (under win32s) and on NT 3.51, because these platforms used the old style file open that was based on a template that was published (i.e., I know the ID of the Open/Save/Save As button). It's this new 95/NT40 stuff that's got me baffled.
Randy Taylor -- drt@ebt.com Tuesday, October 22, 1996 [Mini-digest: 10 responses] The ID's of the controls on the common dialogs can be found in \msdev\include\dlgs.h If you're not sure which is which, after looking at dlgs.h, just use spyxx.exe to examine the control you're interested in to determine it's id. Then, cross-reference your findings witht he dlgs.h. randy_taylor@ebt.com > Environment: VC++ 4.1, Win 95 / Win NT 4.0 > > Hello All! > > I'm trying to something that I feel should be quite simple: I want to > use an instance of CFileDialog to specify a file name. With this in > mind, the Open button should probably say OK, right? Well, I've > provided a hook function. I'm using OFN_EXPLORER, so in my hook > function I can catch CDN_INITDONE during a WM_NOTIFY. What I want to > do is use the CommDlg_OpenSave_SetControlText macro to send a > CDM_SETCONTROLTEXT message, but this macro (and message) takes the ID > of the control for which you want to set the text. Where do I find > that ID? I've been looking all over, and have so far consulted the > faq, msdn, and my personal archive of this list. > > If you know this number (and in what file/article/sample you found > it), could you let me know? > > Thanks! > > Brian Eriksen > CDA/Wiesenberger > > PS - I've got this working under Win3.1 (under win32s) and on NT 3.51, > because these platforms used the old style file open that was based on > a template that was published (i.e., I know the ID of the > Open/Save/Save As button). It's this new 95/NT40 stuff that's got me > baffled. > > -----From: "Robertson David"Override and implement the following: void CYourFileDialog::OnInitDone() // Called for EXPLORER's only!! { // Make the OK button say "OK". SetControlText(IDOK, _T("OK")); } -----From: Christine Hagberg Environment: VC++ 4.1, Win 95 / Win NT 4.0 Hi Brian, I had to do the same thing. I derived a class from CFileDialog and overrode the OnInitDialog Below is the code for the OnInitDialog. //we are doing this so we can change the prompt on the OK button of the dialog -Chris Hagberg BOOL CPlayMpegDlg::OnInitDialog() { CFileDialog::OnInitDialog(); CString sButton; sButton.LoadString( IDS_PLAYMPEG_BUTTON ); if (this->m_ofn.Flags & OFN_EXPLORER) { CWnd *pOKbutton = this->GetDlgItem( IDOK ); if (pOKbutton != NULL) pOKbutton->SetWindowText( sButton ); // send the message //to the dialogs parent GetParent()->SendMessage( CDM_SETCONTROLTEXT, IDOK, (LPARAM) (LPSTR)(LPCTSTR)sButton); } else { CWnd *pOKbutton = this->GetDlgItem( IDOK ); if (pOKbutton != NULL) pOKbutton->SetWindowText( sButton ); } return TRUE; } -----From: Mike Geldens G'day Brian, September DDJ (Dr Dobbs Jnl) has a good article on customizing the explorer open dialog. Pick up the mag or take a look at www.ddj.com... regards Mike -----From: John Young Hi Brian, It's IDOK. Check the "Explorer - Style Control Identifiers" in the Win32 SDK topic, it lists all the identifiers used on the common dialogs. > PS - I've got this working under Win3.1 (under win32s) and on NT 3.51, > because these platforms used the old style file open that was based on > a template that was published (i.e., I know the ID of the > Open/Save/Save As button). It's this new 95/NT40 stuff that's got me > baffled. Check out FILEOPEN.DLG in your MSDEV\INCLUDE sub-directory. -John John Young, Yaesu Musen Co., Ltd., Japan. If only computers did what you wanted, not what you tell them. -----From: Ian Pepper Hi Brian, A brief poke around with the Spy++ tool reveals that the id of the Open button is 1 and the Cancel button 2. Hope this helps, Ian ian@flexicom.ie -----From: Mario Contestabile >...CFileDialog to specify a file name....[snip]...takes the ID > of the control for which you want to set the text. Where do I find > that ID? msdev\include\*.dlg -----From: Serge Lalonde Hi there! For changing the OK button use the IDOK id. You can find the description for the dialog in c:\msdev\include\fileopen.dlg. In fact, all of the common dialogs are described there. Just look at the .dlg files in the same directory. The proper place to change it is in your OnInitDone() method or when catching CDN_INITDONE during a WM_NOTIFY (as you are doing). Good luck. -- Have a tremendous day! _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/ _/_/_/_// 300 Leo Parizeau, Suite 2222 _/ _/ _/ _/ _/ _/ / Montreal, PQ, Canada H2W 2P4 _/_/_/_/ _/_/_/ _/_/_/_/ _/ _/_/ _/_/_/ / Voice: (514) 849-8752 x236 _/ _/ _/ _/ _/ _/ _/ /__Fax: (514) 849-4239__ _/_/_/_/ _/_/_/_/ _/ _/ _/_/_/ _/_/_/_/ Lalonde, Infolytica Corp. -----From: Igor Nedelko Hi Brian, The default dialog box templates can be found in the \MSVC\INCLUDE with .DLG file extension.Note that the default dialog box templates contain constant identifiers such as cmb1, lst1, stc1, and so forth. These constants are defined in the DLGS.H file, located in the \\MSVC\INCLUDE directory. You must include this file in your application's .RC file as well. Regards, Igor
| Вернуться в корень Архива |