Office 2000 style File Dialogs for Win 95/98/...

来源:百度文库 编辑:神马文学网 时间:2024/04/28 19:50:58

3,845,458 members and growing!   9,108 now online.sifter |My Settings |My Bookmarks |My Articles |Sign out
HomeMFC/C++C#ASP.NETVB.NETArchitectSQLAll Topics  Help!ArticlesMessage BoardsLounge
All Topics,MFC / C++ >>Dialog and Windows >>Windows 2000 Styles
Office 2000 style File Dialogs for Win 95/98/NT/Me
ByDavid Wulff.
Ever wanted to use the new Office 2000 file dialogs on Win 95/98/NT/Me, including the file previewing? Well now you can.
C++ (VC5, VC6)
Windows (Win95, Win98, NT4, Win2K, WinME)
MFC, Win32, VS (VS6)
Dev
Posted: 6 Aug 2000
Updated: 20 Oct 2003
Views: 191,344
Announcements
Vista API competition$10,000 in prizes
Vista Gadget comp: $2,000 in prizes
Monthly Competition

Search   Articles Authors   Advanced Search
Sitemap
PrintBroken Article?BookmarkDiscussSend to a friend
187 votes for this article.
Popularity: 10.27. Rating: 4.52 out of 5.
Download source files - 23.9 KbDownload demo project - 35.7 KbDownload demo executables - 17.2 Kb

Introduction
The included source files will allow you to use the Office 2000 and VS.NET style file dialogs in your applications, which will appear on all versions of Windows 95/98/NT/Me, as well as 2000. To use the dialog, simply add the source files to your project and use the standard CFileDialog calling functions to show / manipulate it.
Quick GuideUsing it in Your App The Resource ScriptHandling Multiple File Types Layout / Size / Enabling ResizingContext HelpPreview Panel Using the VS.NET styleCommon QuestionsCreditsLicenseUpdate History
Quick Guide
For example, to load the dialog with an "Open" button, use the code below
BXFileDialog dlg(TRUE); dlg.m_ofn.lpstrTitle = "Open Document"; dlg.DoModal();
To show the save button, use FALSE instead of TRUE when creating the dialog:
BXFileDialog dlg(FALSE); dlg.m_ofn.lpstrTitle = "Save Document"; dlg.DoModal();
To show the bitmap preview panel, pass TRUE as the second parameter to the constructor:
BXFileDialog dlg(FALSE, TRUE); dlg.m_ofn.lpstrTitle = "Save Document"; dlg.DoModal();
To allow the dialog to be resized, pass TRUE as the third parameter to the constructor:
BXFileDialog dlg(TRUE, FALSE, TRUE); dlg.m_ofn.lpstrTitle = "Open Document"; dlg.DoModal();
To set up file type filters, add this before your call to DoModal() (this is optional):
CString szFilter = "HTML Documents (.Htm;.Html)|*.Htm;*.Html|"; szFilter += "Active Server Pages (.Asp)|*.Asp|"; szFilter += "Text Files (.Txt)|*.Txt|"; szFilter += "All Supported Files (.Htm;.Html;.Asp;.Txt;)" "|*.Htm;*.Html;*.Asp;*.Txt;|"; szFilter += "All Files (*.*)|*.*|"; LPTSTR pch = szFilter.GetBuffer(0); // modify the buffer in place // MFC delimits with ‘|‘ not ‘\0‘ while ((pch = _tcschr(pch, ‘|‘)) != NULL) *pch++ = ‘\0‘; dlg.m_ofn.lpstrFilter = szFilter; Using it in Your App
Below I will attempt to explain using it instead of the default file ‘open‘ / ‘save as‘ dialogs. I will use a method that in my opinion is easier than using multiple versions of the same code for each of your documents‘ Open and Save As commands. To do this, define (public) and add the following function to your CWinApp derived class (make sure you include the dialog header in this file).
Collapse
BOOL CMyApp::DoPromptFileName(CString &fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpen, BOOL bPreview, BOOL bSizing) { BXFileDialog dlg(bOpen, bPreview, bSizing); CString szFilter = ".HTML Documents (.Htm;.Html)|*.Htm;*.Html|"; szFilter += "Active Server Pages (.Asp)|*.Asp|"; szFilter += "Text Files (.Txt)|*.Txt|"; szFilter += "All Supported Files (.Htm;.Html;.Asp;.Txt;)" "|*.Htm;*.Html;*.Asp;*.Txt;|"; szFilter += "All Files (*.*)|*.*|"; LPTSTR pch = szFilter.GetBuffer(0); // modify the buffer in place // MFC delimits with ‘|‘ not ‘\0‘ while ((pch = _tcschr(pch, ‘|‘)) != NULL) *pch++ = ‘\0‘; CString strTitle; strTitle.LoadString(nIDSTitle); dlg.m_ofn.lpstrFilter = szFilter ; dlg.m_ofn.lpstrTitle = strTitle; dlg.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); dlg.m_ofn.hwndOwner = AfxGetMainWnd()->m_hWnd; if (dlg.DoModal() == IDOK) return TRUE; return FALSE; }
Also make sure that in your app header, theApp is defined, to make it easier to access your class. Eg:
extern CMyApp theApp;
Now open your document source file. Make sure it includes the main app header (so you can use theApp), and unless you already have an override for OnOpenDocument(...), use the class wizard to insert one for you. Then modify as follows (IDS_FILE_OPEN is a string ID for the dialog title):
BOOL CMyDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!theApp.DoPromptFileName(lpszPathName, IDS_FILE_OPEN, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, TRUE, FALSE, TRUE)) return FALSE; return TRUE; }
The override the documents‘ OnSaveDocument(...) function, as follows (again, IDS_FILE_SAVEAS is a string ID for the dialog title):
BOOL CMyDoc::OnSaveDocument(LPCTSTR lpszPathName) { if (!theApp.DoPromptFileName(lpszPathName, IDS_FILE_SAVEAS, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, FALSE, FALSE, TRUE)) return FALSE; return TRUE; }
That is all you need to add. If you have more than one CDocument derived class, simply repeat as necessary.
Handling Multiple File Types
If you want to display different commands in the OK button‘s drop-down menu, you can override the virtual void OnFileTypeChange(DWORD dwNewFilterIndex) function. This function is called whenever the user selects a new file type from the ‘File Type‘ combo box. The dwNewFilterIndex parameter contains the index of the new file type in the array passed to the dialog in the OPENFILENAME structure you pass to the dialog before showing it. You can switch on this DWORD to load different commands depending on the file type, e.g.:
// destroy the current menu (remove all items) m_btn.m_menu.DestroyMenu(); // recreate the popup menu m_btn.m_menu.CreatePopupMenu(); // add the new items, depending on the file type selected switch(dwNewFilterIndex) { case 0: m_btn.AddMenuItem(ID_START,"&Open",0); m_btn.AddMenuItem(ID_START+1,"Open with &Filter",0); break; case 1: m_btn.AddMenuItem(ID_START,"&Open",0); case 2: m_btn.AddMenuItem(ID_START,"&Open",0); m_btn.AddMenuItem(ID_START+1,"Open As &HTML",0); default: break; // do nothing } The Resource Script
In order to make including the dialog in your existing projects as simple as possible, you will no longer need to copy the individual resources to your own project‘s resource file. To use the resources, follow these steps:
Select the ResourceView pane in Developer Studio (the VC++ IDE). Select the resource script used by your project. Select View | Resource Includes... from the menu. In the ‘Compile-time directives‘ edit box, add the line #include "cmn.rc" before the final #endif statement. Press OK and accept the changes.
You have just told the resource compiler to compile the separate resource script (named cmn.rc) when it compiles your project. The header defining the ID‘s in this script will automatically be made available to you.
Layout / Size
By default the initial size of the dialog will be that of the static control in the dialog template called IDC_SIZE_TEMPLATE. Changing this size will cause the dialog and all it‘s controls to be resized too. The width of the grey static control is used to calculate the width of the ‘side bar‘.
You can change the #define CONTROL_GAP to change the default spacing between controls used when updating the dialog‘s layout. Microsoft Office uses a value of 3. The default for this code is 5, as it looks better (in my opinion).
Sizing Support
On Windows 98 and NT 5 and later, the default Windows file dialogs can be resized. To enable this dialog to be resized in this way, pass TRUE (or FALSE to disable it) as the third parameter to the dialog constructor. For an example, see theQuick Guide section above.
Context Help
By default, Windows can‘t display context help for the custom controls we add to the dialog (in this case the ‘side bar‘), as it is not meant to be there. In order to be able to display context help for the buttons in this bar (and to override any of the default controls), simple make sure you have the HtmlHelp header and library files in your projects include path (freely available from Microsoft - search for HtmlHelp Workshop onMSDN) and compile your project with _USE_HTMLHELP defined.
The strings used to display the text in the context help windows is obtained from the string resource in cmn.rc.
Refer to the source to see how the DoPopupHelp() function is implemented. Feel free to use this function elsewhere in your projects, without credit.
Preview Panel
You can now optionally display a ‘preview panel‘ to the right of the listbox, in the same fashion as Office 2000 does. To show this panel, pass TRUE as the second parameter in the creation statement (shown in the examples above).
This preview panel will display any images that your system will, using the IPicture interface.
Visual Studio.NET style
You can now make the sidebar buttons appear in the new VS.NET style (see screenshot at the top of this page). To do this, simply call SetAppearance(...) before calling DoModal(), and pass in APPEARANCE_VSDOTNET. E.g.:
BXFileDialog dlg(); dlg.SetAppearance(BXFileDialog::eAppearance::APPEARANCE_VSDOTNET); dlg.DoModal();
Possible values to pass to SetAppearance(...) are:
APPEARANCE_DEFAULT // Office 2000 APPEARANCE_VSDOTNET // VS.NET Common Questions
Why can‘t I compile the project?
There can be many reasons for your project not compiling, but the most common related to the use of this dialog are:
You do not have the HtmlHelp SDK installed on your machine, and have not undefined _USE_HTMLHELP in the project settings. You have not set up the paths in Devloper Studio correctly, if you do have the HtmlHelp SDK installed. OLE containment support must be enabled for your project, and you have not enabled it. Call AfxEnableControlContainer() from your CWinApp::InitInstance() function.
Why isn‘t the new dialog showing instead of the old one?
You have to override the OnSaveDocument() function for each of your document types, and OnFileOpen() in your main CWinApp derived class, and use the new dialog in place of the old one. See theUsing it in Your App section above for an example.
Credits
Based on the original code by Norm Almond. Maintained by David Wulff. Contains some code by Joel Bernard, Anatoly Danekin, Wes Rogers, Tak^Shoran and Chris Maunder.
And a special thank you to all of you who have posted bug reports and/or fixes, or have simply said "Hey, this would be cool...".
License
This code is provided on an "AS-IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. You can use the code and any segments hereof, in any product, commercial or otherwise, provided that any copyright information contained in the source files remains unaltered and intact. If you contribute to the source in any way, regardless of whether you release said changes, you must comment them and identify them as your own to prevent confusion as to the author of said changes. Use of this code in any application gives me marital rights to your first-born daughter. (Okay, maybe not that last sentence...)
I would appreciate a quick email [dwulff@battleaxesoftware.com] if you are going to use the code in a commercial application, purely out of interest. You are NOT required to do this, nor are you required to credit the original authors in your application or its documentation.
Update History
Previous Update History 22 March 2001 - David Wulff - Updated the source to include the VS.NET style for the sidebar. Cleaned up some minor problems with the picture preview not updating if the dialog was dragged off screen (thanks to James Millson for bringing it to my attention). Added a new demo program to show off the VS.NET style dialogs. I added basic support for opening files from the Internet (by downloading them to the temp directory). This code uses Chris Maunder‘s CWebGrab class, and my implementation of it is still in testing and has only been used to download text files so far. 24 Mar 2001 - Tak^Shoran, working sizing support for dialogs with no image preview. 31 Mar 2001 - David Wulff, Major Update. A lot of the code has been updated, and the source files have been tidied up and re-commented. The sizing support now works for both preview-enabled and normal dialogs (Windows 98 and 2000 and later only). Sizing support and the new VS.NET style can now be dynamically specified rather than at compile time. Article content updated to reflect new code. 5 Aug 2001 - David Wulff, now when you select a non-image file, or a folder, the preview pane is cleared. Added a handler for the CDN_TYPECHANGE message, so you can customise the OK button‘s drop-down menu. Article content updated to reflect new code. The debug build of the sample program will now 19 October 2003 - David Wulff - Updated the source to support Windows XP (which uses a combobox instead of an edit control for the file name).
David Wulff

Clickhere to view David Wulff‘s online profile.
Other popular Dialog and Windows articles:
A Beginners Guide to Dialog Based Applications - Part One A step by step tutorial showing how to create your first windows program using MFC
Layout Manager for Dialogs, Formviews, DialogBars and PropertyPages A framework to provide automatic layout control for dialogs and forms
A Visual Framework (Views, Tabs and Splitters) Creating SDI/MDI applications with splitter and tab windows
Beginners Guide to Dialog Based Applications - Part Two A step by step tutorial showing how to create your first Windows program using MFC.
[Top] Rate this Article for us!     PoorExcellent


FAQ  Message score threshold 1.0 2.0 3.0 4.0 5.0    Search comments
View Normal (slow) Preview (slow) Message View Topic View Thread View Expanded (Supporters only)    Per page 10 25 50
New Message Msgs 1 to 25 of 163 (Total: 163) (Refresh) First PrevNext
Subject  Author  Date

 Vista problem  Box2020  10:59 24 Nov ‘06
  Hi - I‘ve recently adapted some of this code for my own similar dialog but have come across a problem when running on Vista
code from SetSpecialDirectory
CListCtrl* pLCtrl = (CListCtrl*)GetParent()->GetDlgItem(lst1);
// Simulate a refresh to clear the current file name
// .. this can take a LONG time if the history folder is selected!
//
// If you find a better way of doing this, please let me know.
pLCtrl->PostMessage(WM_KEYDOWN,VK_F5,0x0020001);
pLCtrl->PostMessage(WM_KEYUP,VK_F5,0xC0020001);
// Add selection to edit box
pWnd->SetWindowText(m_szFile);
// Simulate a ‘Return‘ key to make selection
m_bClear = TRUE;
pWnd->PostMessage(WM_KEYDOWN,VK_RETURN,0x0020001);
pWnd->PostMessage(WM_KEYUP,VK_RETURN,0xC0020001);
This does NOT change directory correctly but
CListCtrl* pLCtrl = (CListCtrl*)GetParent()->GetDlgItem(lst1);
// Simulate a refresh to clear the current file name
// .. this can take a LONG time if the history folder is selected!
//
// If you find a better way of doing this, please let me know.
pLCtrl->PostMessage(WM_KEYDOWN,VK_F5,0x0020001);
pLCtrl->PostMessage(WM_KEYUP,VK_F5,0xC0020001);
// Add selection to edit box
pWnd->SetWindowText(m_szFile);
AfxMessageBox(m_szFile);
// Simulate a ‘Return‘ key to make selection
m_bClear = TRUE;
pWnd->PostMessage(WM_KEYDOWN,VK_RETURN,0x0020001);
pWnd->PostMessage(WM_KEYUP,VK_RETURN,0xC0020001);
For some reason having the AfxMessageBox makes it work.
Anyone know of a workround for this or encountered anything similar?
Many thanks
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: Vista problem  Box2020  5:49 27 Nov ‘06
  Ok fixed this, ( a bit nasty but here‘s the fix for other users)
void BXFileDialog::SetSpecialDirectory(int nFolder)
{
LPITEMIDLIST lpIDList;
// get the "special folder" path for the passed folder
SHGetSpecialFolderLocation(0, nFolder, &lpIDList);
SHGetPathFromIDList(lpIDList, m_szFile);
CWnd *pWnd = GetParent()->GetDlgItem(edt1); // File Name
if (!pWnd)
m_edtFile.SubclassDlgItem(cmb13,GetParent());
else
m_edtFile.SubclassDlgItem(edt1,GetParent());
CListCtrl* pLCtrl = (CListCtrl*)GetParent()->GetDlgItem(lst1);
// Simulate a refresh to clear the current file name
// .. this can take a LONG time if the history folder is selected!
//
// If you find a better way of doing this, please let me know.
pLCtrl->PostMessage(WM_KEYDOWN,VK_F5,0x0020001);
pLCtrl->PostMessage(WM_KEYUP,VK_F5,0xC0020001);
// clear message queue
MSG msg;
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Add selection to edit box
pWnd->SetWindowText(m_szFile);
// Simulate a ‘Return‘ key to make selection
m_bClear = TRUE;
pWnd->PostMessage(WM_KEYDOWN,VK_RETURN,0x0020001);
pWnd->PostMessage(WM_KEYUP,VK_RETURN,0xC0020001);
}
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 good file,you are a likesome fallow  xfxty1  21:24 10 Oct ‘06
  hehe
ZSF
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Memory leak!Warnning  shengcheng_jin  2:45 7 Mar ‘06
 When I open a large bitmap file .
with the size 6400 x 6400 pixel about 32Mb
then I kill the image.But my project
still use 40Mb memory.If I open the file with
Normal CFileDialog....I can kill the memroy successfully.
I try to fixthe bug ,but failed.
Thanks for your help!
I like C Plus Plus
-- modified at 2:45 Tuesday 7th March, 2006
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 very nice! but a bug when set OFN_ALLOWMULTISELECT  xiaoyu7311  3:39 11 Oct ‘05
  In the BXFileDialog constructor, i rewrite:
m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLETEMPLATE |
OFN_ENABLEHOOK | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT |
(bSizing ? OFN_ENABLESIZING : 0);
when "desktop" [m_btnDeskTop] is clicked, the dialog is end!
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 WINDOWS XP without common extension displayed  Pancini Paolo  9:49 3 Jun ‘05
  Hi, I‘m using your interface but I have a little problem.
If I use Windows XP setting for not showing common file extension the function return but it‘s not correct(please see my comment in the code), in fact the GetFileName() function returns the whole file name with extension even if in Windows the user has set not to show it:
void BXFileDialog::OnFileNameChange()
{
CString strFilePath = (LPCSTR)GetPathName();
SHFILEINFO shfi;
CListCtrl* pLCtrl = GetListCtrl();
POSITION pos = pLCtrl->GetFirstSelectedItemPosition();
// we wont bother checking for multiple selections, as we can‘t preview
// .. mulitple files!
if (pos != NULL)
{
CString strSelName = pLCtrl->GetItemText(pLCtrl->GetNextSelectedItem(pos), 0);
// MY COMMENT
/* Maybe You want to check ";" char instead of "."
// HACK [DW]: Not the best way to do this! [3/8/2001]
if (strSelName.Find(_T(".")) == -1)
{
if(m_bPreview)
m_strPreviewPath = _T("\0"); // set image file to null
InvalidateRect(PreviewRect);
return;
}
}
MY COMMENT END*/
if (!GetFileName().IsEmpty())
Pancio
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 DLL?  Gerhard29  10:19 4 Jun ‘04
  Hi
great looking Open/Save Dialogs.
Any chance of a DLL version in order to be called by other programming languages?
regards
[Reply |Email |View Thread |Get Link] Score: 1.0 (1 vote). Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Great Class! Some workarounds for win2k suggested  Valerio Aimale  19:18 21 Nov ‘03
  David,
this is a great class and I found it very useful.
I too experienced some problems with it and I‘d like to suggest some workarounds.
I‘m using win2k and Visual C++ 6.0 EE.
Filename Edit Control disappearing:
in the method BXFileDialog::InitialResize() the EditControl is hidden before the repositioning, but it never re-drawn
adding the line
---
pWnd->ShowWindow(SW_SHOW);
---
after
-----------------
pWnd->ShowWindow(SW_HIDE);
pWnd->SetWindowPos(0, iTmp, eBot - CONTROL_GAP - (22 * 2),
(eRight - 90 - 30 - iTmp), 22, SWP_NOZORDER);
-------------------
solves it for me.
=================================================================================
in the method
void BXFileDialog::SetSpecialDirectory(int nFolder)
I had to comment out these lines
/*
if (!pWnd)
m_edtFile.SubclassDlgItem(cmb13,GetParent());
else
m_edtFile.SubclassDlgItem(edt1,GetParent());
*/
they were giving me all kinds of ASSERT failures,  like
-------------------
Error: Trying to use SubclassWindow with incorrect CWnd
derived class.
hWnd = $250A76 (nIDC=$0480) is not a CEdit.
-------------------------------
in BOOL CWnd::SubclassWindow(HWND hWnd)
@
#ifdef _DEBUG
else if (*lplpfn != oldWndProc)
{
TRACE0("Error: Trying to use SubclassWindow with incorrect CWnd\n");
TRACE0("\tderived class.\n");
TRACE3("\thWnd = $%04X (nIDC=$%04X) is not a %hs.\n", (UINT)hWnd,
_AfxGetDlgCtrlID(hWnd), GetRuntimeClass()->m_lpszClassName);
ASSERT(FALSE); // <----------------------- this is failing
// undo the subclassing if continuing after assert
::SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)oldWndProc);
}
#endif
--------------------------
probably those lines are for XP, but win2k does not like them.
============================================================================
Image preview is shown only when deselecting the filename:
I had to remove some lines in
void BXFileDialog::OnFileNameChange()
namely
--------------------
/*    // we wont bother checking for multiple selections, as we can‘t preview
// .. mulitple files!
if (pos != NULL)
{
CString strSelName = pLCtrl->GetItemText(pLCtrl->GetNextSelectedItem(pos), 0);
// HACK [DW]: Not the best way to do this! [3/8/2001]
if (strSelName.Find(_T(".")) == -1)
{
if(m_bPreview)
m_strPreviewPath = _T("\0"); // set image file to null
InvalidateRect(PreviewRect);
return;
}
}
*/
--------------------------------
to have the preview shown when the filename is clicked, otherwise the preview gets shown
when the filename is unselected (by clicking another file or in a blank area of the file selector)
==========================================================================================
last, the preview for some filetypes is not shown. By including the CxImage class in my project,
I was able to simplify the method DrawImage down to few lines (CxImage handles the resizing)
-----------------
BOOL BXFileDialog::DrawImage(CDC *pDC, CString csFile, CPoint ptCenter, HWND hWnd, CRect rectImage)
{
if (pDC == NULL || csFile.IsEmpty() || hWnd == NULL)
return FALSE;
CxImage image((LPCTSTR)csFile, CXIMAGE_FORMAT_UNKNOWN);
image.Draw(pDC->m_hDC, rectImage, NULL);
return TRUE;
}
-----------------
and get the preview for all filetypes supported by CxImage.
Again, great class! :-D
Valerio Aimale
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Too hard to implement ... much easier way at MSDN !  Robert Ibsen Voith  2:19 4 Nov ‘03
  I had a hardtime figuring out where to store all the resources, and how to get this control implemented. In addition I had strange problems like not seeing the field for the filename itself (!), and also experiencing the refresh-bug. Try to save a file with an existing name - the std. file dialog behaviour is to ask a question to make you confirm the potential overwrite. This control gos bananas with it‘s repaint logic - all the controls disappear, and the you have a bad bug on the rise...
Instead, I foundthis article on MSDN from Paul DiLascia. Much cleaner, much easier to implement - IMHO
Proud Programmer!
[Reply |Email |View Thread |Get Link] [Modify |Delete]
Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: Too hard to implement ... much easier way at MSDN !  David Wulff  4:00 4 Nov ‘03
  The dialog with this article does indeed have several drawing problems (bananas sums it up well!) and uses the older style file dialog as its base to avoid problems, but still has advantages for situations where you either can‘t target Windows 2000 and later or need finer control over the actions of the dialog:
- it is supported on Windows 95, 98 and Me (any limitations are highlighted in the article)
- it allows you to add custom entries to the places bar that can have any action you like
- it allows you to define more than the standard open or save action, optionally decided by the file type
- it shows how to add your own controls to the common file dialog, including a method to provide context help
- it supports previewing any image file that your version of Windows does
- it goes some way to providing Office XP / VS.NET style dialogs
To address your specific problems...
Robert Ibsen Voith wrote:
I had a hardtime figuring out where to store all the resources
Have a look atthis section of the article for VC++ 6. For VS.NET either copy the resources to your project or import them at compile time using a similar approach.
Robert Ibsen Voith wrote:
I had strange problems like not seeing the field for the filename itself
Would you be able to provide more information about this, such as when (or if you know, why) it was experienced? Anything that could help find the problem and fix it would be most helpful!
Robert Ibsen Voith wrote:
Try to save a file with an existing name - the std. file dialog behaviour is to ask a question to make you confirm the potential overwrite
Indeed, I recognised this during development but left it as an exercise for the developer to handle if needed.
Robert Ibsen Voith wrote:
This control gos bananas with it‘s repaint logic - all the controls disappear
I have seen this during resizing, have you experienced it elsewhere? The fix for lower-right open/save button sometimes not moving during a resize has been fixed by James Krewson ina message below.
David Wulff
The Royal Woofle Museum
Putting the laughter back into slaughter
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Any chance of XP look?  Obliterator  10:47 20 Oct ‘03
  Any chance of standard XP look anyone?
ie. filename shows combo drop arrow, open/save button uses themed colours and the quick bar down the left looking all new and modern...
--
The Obliterator
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Problem: Open-Button position & resizing  Alexander Bischofberger  7:02 20 Oct ‘03
  I just downloaded the demo executable. When resizing the dialog the Open Save Button does not move but stays on the original position...
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: Problem: Open-Button position & resizing  David Wulff  8:57 20 Oct ‘03
  Which operating system are you using?
David Wulff
The Royal Woofle Museum
Putting the laughter back into slaughter
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: Problem: Open-Button position & resizing  Obliterator  10:39 20 Oct ‘03
  The problem occurs on Windows XP with your supplied demo exe.
Neither the open/save button nor the preview static resizes correctly on XP.
However the problem does not occur with your demo project in debug mode.
See the fix below by James Krewson.
--
The Obliterator
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Help...  crystalyd  4:28 1 Sep ‘03
  Why isn‘t there the header stated? How can I make the program work?
D:\Downloads\Win2KFileDlg\Office2000Dlg.cpp(51) : fatal error C1083: Cannot open include file: ‘htmlhelp.h‘: No such file or directory
Thanks...
[Reply |Email |View Thread |Get Link] Score: 1.0 (1 vote). Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: Help...  David Wulff  11:25 1 Sep ‘03
  Please refer to the "Common Questions" in the article: you either need to download the Microsoft HtmlHelp SDK from the MSDN web site, or else undefine _USE_HTMLHELP.
David Wulff
"Sanity is just a state of mind, insanity is a developed past-time for Mr Wulff" - Jonny Newman
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Filters  Anonymous  9:24 2 Jul ‘03
  Add new filters to Microsoft dialog box Save as
[Reply |Email |View Thread |Get Link] [Modify |Delete]
Rate this message:12345 (out of 5)
Report asSpam orAbuse


 DoModal() //error help  Kitasoo  9:12 2 May ‘03
  I try to use your code.
I include all needed files
when i try to show a dialog
BXFileDialog dlg(1, 1, 1)
if(dlg.DoModal() == IDOK) //error
i‘m use Windows 2003 RC2 and VS.NET
i can‘t fid problem HELP!!!
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: DoModal() //error help  DanPetitt  16:34 8 Sep ‘03
  I get the same problem, add this after your domodal to find out what error you are getting, then look in Cderr.h to find out what it means...
if( CommDlgExtendedError() != 0 )
{
CString strError;
strError.Format( _T("Could not display File dialog because of error %d."), CommDlgExtendedError() );
AfxMessageBox( strError, MB_OK | MB_ICONSTOP, NULL );
}
I get error 6 which means it cant find a resource. Which resource I have no idea and I just cant find out why? Help???
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: DoModal() //error help  DanPetitt  12:53 9 Sep ‘03
  Got it, I had to add all resources (dialog, strings, bitmaps) into my own project and then I removed the rc file that came with this dialog project.
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Move the toolbar  Spyro  4:15 12 Feb ‘03
  How can I move the buttons from the toolbar?
My problem is, that this toolbar isn‘t there,
where I want.
Can anybody help me?
Greetings
Stefan
[Reply |Email |View Thread |Get Link] [Modify |Delete]
Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: Move the toolbar  Min, Byeong-Don  21:32 24 Jun ‘03
  At WinXP, VS2003(also VS2002)
Toolbar Ctrl can‘t access in BXFileDialog::InitialReSize(..)
So I remove these lines in BXFileDialog::InitialReSize(..)
//HWND hWnd = FindWindowEx(GetParent()->m_hWnd, NULL,
// "ToolbarWindow32", NULL);
//CWnd wndToolbar;
//wndToolbar.Attach(hWnd);
pComboCtrl->SetWindowPos(0, iTmp, eTop, 250, 180, SWP_NOZORDER);
//wndToolbar.SetWindowPos(0, iTmp + CONTROL_GAP + 250, eTop, 0, 0,
// SWP_NOSIZE | SWP_NOZORDER);
//wndToolbar.Detach();
And cmn.rc open in resource editer.
Move stc32 piture control to Upper-left Position.
re-Complie and show the toolbar position changed~
Thanks.
Have a nice~ day~
[Reply |Email |View Thread |Get Link] [Modify |Delete]
Rate this message:12345 (out of 5)
Report asSpam orAbuse


 Placing the other controls  vingo_2001@yahoo.com  4:43 2 Dec ‘02
 hai
we saw your project , it is very nice. We have a small doubt that we couldn‘t able to include the Third Party Contorls into our dialog. If we insert it the application gets compiled, but it is not working. If we remove the third party control it is working fine.
pls help us
[Reply |Email |View Thread |Get Link] [Modify |Delete]
Score: 2.0 (1 vote). Rate this message:12345 (out of 5)
Report asSpam orAbuse


 why the dialog cann‘t show?  Bochen  21:08 19 Nov ‘02
 First,I copy the all files in Win2KFileDlg_src to my new project folder,Then I add these files to my new project.I also add cmn.rc with the same way,I see a messagebox,then I run build,it seems OK.
I add "#undef _USE_HTMLHELP"in Office2000Dlg.cpp to pass
the compile,
I add "#include "Office2000Dlg.h" in .h file and add "BXFileDialog::eAppearance GetStyle();" in the same .h
file which BXFileDialog will be used later.
I add "BXFileDialog dlg(TRUE);
dlg.m_ofn.lpstrTitle = "Open Document";
dlg.DoModal();" in my function of the .cpp file
After debug,I can‘t show the dialog.
And in demo it seems cann‘t display the picture which is choosed.
Where is my wrong?
thanks!
Bochen
[Reply |Email |View Thread |Get Link] [Modify |Delete]
Rate this message:12345 (out of 5)
Report asSpam orAbuse

 Re: why the dialog cann‘t show?  David Wulff  22:12 19 Nov ‘02
  Which OS are you using?
David Wulff
http://www.davidwulff.co.uk
David Wulff Born and Bred.
[Reply |Email |View Thread |Get Link] Rate this message:12345 (out of 5)
Report asSpam orAbuse

Last Visit: 20:54 Friday 23rd February, 2007 First PrevNext
General comment   News / Info   Question   Answer   Joke / Game   Admin message
Updated: 20 Oct 2003 Article content copyright David Wulff, 2000
everything else Copyright ©CodeProject, 1999-2007.
Web10 |Advertise on The Code Project |Privacy

The Ultimate Toolbox •ASP Alliance •Developer Fusion •Developersdex •DevGuru •Programmers Heaven •Planet Source Code •Tek-Tips Forums •
Help!
Articles
Message Boards
Lounge
What is ‘The Code Project‘?
General FAQ
Post a Question
Site Directory
About Us
Latest
Most Popular
Search
Site Directory
Submit an Article
Update an Article
Article Competition
Windows Vista
Visual C++
ATL / WTL / STL
COM
C++/CLI
C#
ASP.NET
VB.NET
Web Development
.NET Framework
Mobile Development
SQL / ADO / ADO.NET
XML / XSL
OS / SysAdmin
Work Issues
Article Requests
Collaboration
General Discussions
Hardware
Algorithms / Math
Design and Architecture
Subtle Bugs
Suggestions
The Soapbox