// ----------------------------------------------------------------------------
// standard dialog size for the old Windows systems where the dialog wasn't
-// resizeable
+// resizable
static wxRect gs_rectDialog(0, 0, 428, 266);
// ============================================================================
{
switch ( iMsg )
{
+#ifndef __WXWINCE__
+ case WM_INITDIALOG:
+ {
+ OPENFILENAME* ofn = reinterpret_cast<OPENFILENAME *>(lParam);
+ reinterpret_cast<wxFileDialog *>(ofn->lCustData)
+ ->MSWOnInitDialogHook((WXHWND)hDlg);
+ }
+ break;
+#endif // __WXWINCE__
+
case WM_NOTIFY:
{
OFNOTIFY *pNotifyCode = reinterpret_cast<OFNOTIFY *>(lParam);
paths.Empty();
wxString dir(m_dir);
- if ( m_dir.Last() != _T('\\') )
- dir += _T('\\');
+ if ( m_dir.Last() != wxT('\\') )
+ dir += wxT('\\');
size_t count = m_fileNames.GetCount();
for ( size_t n = 0; n < count; n++ )
files = m_fileNames;
}
-void wxFileDialog::SetPath(const wxString& path)
-{
- wxString ext;
- wxSplitPath(path, &m_dir, &m_fileName, &ext);
- if ( !ext.empty() )
- m_fileName << _T('.') << ext;
-}
-
void wxFileDialog::DoGetPosition(int *x, int *y) const
{
if ( x )
void wxFileDialog::MSWOnInitDone(WXHWND hDlg)
{
- // note the the dialog is the parent window: hDlg is a child of it when
+ // note the dialog is the parent window: hDlg is a child of it when
// OFN_EXPLORER is used
HWND hFileDlg = ::GetParent((HWND)hDlg);
{
// this can happen if the default file name is invalid, try without it
// now
- of->lpstrFile[0] = _T('\0');
+ of->lpstrFile[0] = wxT('\0');
success = DoShowCommFileDialog(of, style, &errCode);
}
return true;
}
+#ifndef __WXWINCE__
+void wxFileDialog::MSWOnInitDialogHook(WXHWND hwnd)
+{
+ SetHWND(hwnd);
+
+ CreateExtraControl();
+
+ SetHWND(NULL);
+}
+#endif // __WXWINCE__
+
int wxFileDialog::ShowModal()
{
HWND hWnd = 0;
in the upper left of the frame, it does not center
automatically.
*/
- if (m_bMovedWindow) // we need these flags.
+ if (m_bMovedWindow || HasExtraControlCreator()) // we need these flags.
{
msw_flags |= OFN_EXPLORER|OFN_ENABLEHOOK;
#ifndef __WXWINCE__
of.lpstrFileTitle = titleBuffer;
of.nMaxFileTitle = wxMAXFILE + 1 + wxMAXEXT;
+#ifndef __WXWINCE__
+ GlobalPtr hgbl;
+ if ( HasExtraControlCreator() )
+ {
+ msw_flags |= OFN_ENABLETEMPLATEHANDLE;
+
+ hgbl.Init(256, GMEM_ZEROINIT);
+ GlobalPtrLock hgblLock(hgbl);
+ LPDLGTEMPLATE lpdt = static_cast<LPDLGTEMPLATE>(hgblLock.Get());
+
+ // Define a dialog box.
+
+ lpdt->style = DS_CONTROL | WS_CHILD | WS_CLIPSIBLINGS;
+ lpdt->cdit = 0; // Number of controls
+ lpdt->x = 0;
+ lpdt->y = 0;
+
+ // convert the size of the extra controls to the dialog units
+ const wxSize extraSize = GetExtraControlSize();
+ const LONG baseUnits = ::GetDialogBaseUnits();
+ lpdt->cx = ::MulDiv(extraSize.x, 4, LOWORD(baseUnits));
+ lpdt->cy = ::MulDiv(extraSize.y, 8, HIWORD(baseUnits));
+
+ // after the DLGTEMPLATE there are 3 additional WORDs for dialog menu,
+ // class and title, all three set to zeros.
+
+ of.hInstance = (HINSTANCE)lpdt;
+ }
+#endif // __WXWINCE__
+
// Convert forward slashes to backslashes (file selector doesn't like
// forward slashes) and also squeeze multiple consecutive slashes into one
// as it doesn't like two backslashes in a row neither
wxChar ch = m_dir[i];
switch ( ch )
{
- case _T('/'):
+ case wxT('/'):
// convert to backslash
- ch = _T('\\');
+ ch = wxT('\\');
// fall through
- case _T('\\'):
+ case wxT('\\'):
while ( i < len - 1 )
{
wxChar chNext = m_dir[i + 1];
- if ( chNext != _T('\\') && chNext != _T('/') )
+ if ( chNext != wxT('\\') && chNext != wxT('/') )
break;
// ignore the next one, unless it is at the start of a UNC path
size_t items = wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, wildFilters);
- wxASSERT_MSG( items > 0 , _T("empty wildcard list") );
+ wxASSERT_MSG( items > 0 , wxT("empty wildcard list") );
wxString filterBuffer;
//=== Setting defaultFileName >>=========================================
- wxStrlcpy(fileNameBuffer, m_fileName, WXSIZEOF(fileNameBuffer));
+ wxStrlcpy(fileNameBuffer, m_fileName.c_str(), WXSIZEOF(fileNameBuffer));
of.lpstrFile = fileNameBuffer; // holds returned filename
of.nMaxFile = wxMAXPATH;
i += wxStrlen(&fileNameBuffer[i]) + 1;
}
#else
- wxStringTokenizer toke(fileNameBuffer, _T(" \t\r\n"));
+ wxStringTokenizer toke(fileNameBuffer, wxT(" \t\r\n"));
m_dir = toke.GetNextToken();
m_fileName = toke.GetNextToken();
m_fileNames.Add(m_fileName);
#endif // OFN_EXPLORER
wxString dir(m_dir);
- if ( m_dir.Last() != _T('\\') )
- dir += _T('\\');
+ if ( m_dir.Last() != wxT('\\') )
+ dir += wxT('\\');
m_path = dir + m_fileName;
m_filterIndex = (int)of.nFilterIndex - 1;