LONG APIENTRY _EXPORT
wxDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
-// ----------------------------------------------------------------------------
-// globals
-// ----------------------------------------------------------------------------
-
-// the name of the default wxWidgets class
-#ifdef __WXWINCE__
-extern wxChar *wxCanvasClassName;
-#else
-extern const wxChar *wxCanvasClassName;
-#endif
-
// ----------------------------------------------------------------------------
// wxTLWHiddenParentModule: used to manage the hidden parent window (we need a
// module to ensure that the window is always deleted)
m_fsIsMaximized = false;
m_fsIsShowing = false;
- m_winLastFocused = (wxWindow *)NULL;
+ m_winLastFocused = NULL;
#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
m_MenuBarHWND = 0;
if ( !parent )
{
// this flag doesn't make sense then and will be ignored
- wxFAIL_MSG( _T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
+ wxFAIL_MSG( wxT("wxFRAME_FLOAT_ON_PARENT but no parent?") );
}
else
{
// no dialogs support under MicroWin yet
return CreateFrame(title, pos, size);
#else // !__WXMICROWIN__
- wxWindow *parent = GetParent();
-
- // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
- // app window as parent - this avoids creating modal dialogs without
- // parent
- if ( !parent && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
- {
- parent = wxTheApp->GetTopWindow();
-
- if ( parent )
- {
- // don't use transient windows as parents, this is dangerous as it
- // can lead to a crash if the parent is destroyed before the child
- //
- // also don't use the window which is currently hidden as then the
- // dialog would be hidden as well
- if ( (parent->GetExtraStyle() & wxWS_EX_TRANSIENT) ||
- !parent->IsShown() )
- {
- parent = NULL;
- }
- }
- }
+ // static cast is valid as we're only ever called for dialogs
+ wxWindow * const
+ parent = static_cast<wxDialog *>(this)->
+ GetParentForModalDialog(GetParent());
m_hWnd = (WXHWND)::CreateDialogIndirect
(
exflags |= WS_EX_LAYOUTRTL;
#endif
- return MSWCreate(wxCanvasClassName, title.wx_str(), pos, sz, flags, exflags);
+ return MSWCreate(MSWGetRegisteredClassName(),
+ title.wx_str(), pos, sz, flags, exflags);
}
bool wxTopLevelWindowMSW::Create(wxWindow *parent,
wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
{
+ SendDestroyEvent();
+
#if defined(__SMARTPHONE__) || defined(__POCKETPC__)
SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo;
delete info;
m_maximizeOnShow = false;
}
+ else if ( m_iconized )
+ {
+ // iconize and show
+ nShowCmd = SW_MINIMIZE;
+ }
else // just show
{
// we shouldn't use SW_SHOW which also activates the window for
void wxTopLevelWindowMSW::Iconize(bool iconize)
{
- DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
+ if ( IsShown() )
+ {
+ // change the window state immediately
+ DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
+ }
+ else // hidden
+ {
+ // iconizing the window shouldn't show it so just remember that we need
+ // to become iconized when shown later
+ m_iconized = true;
+ }
}
bool wxTopLevelWindowMSW::IsIconized() const
#ifdef __WXWINCE__
return false;
#else
+ if ( !IsShown() )
+ return m_iconized;
+
// don't use m_iconized, it may be briefly out of sync with the real state
// as it's only modified when we receive a WM_SIZE and we could be called
// from an event handler from one of the messages we receive before it,
return;
}
- wxLogLastError(_T("GetWindowPlacement"));
+ wxLogLastError(wxT("GetWindowPlacement"));
}
//else: normal case
return;
}
- wxLogLastError(_T("GetWindowPlacement"));
+ wxLogLastError(wxT("GetWindowPlacement"));
}
//else: normal case
return GetLabel();
}
-void wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
+bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
int smX,
int smY,
int i)
if ( icon.Ok() )
{
::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon));
+ return true;
}
+
+ return false;
}
void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
{
wxTopLevelWindowBase::SetIcons(icons);
- DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL);
- DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG);
+ if ( icons.IsEmpty() )
+ {
+ // FIXME: SetIcons(wxNullIconBundle) should unset existing icons,
+ // but we currently don't do that
+ wxASSERT_MSG( m_icons.IsEmpty(), "unsetting icons doesn't work" );
+ return;
+ }
+
+ bool anySet =
+ DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL);
+ if ( DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG) )
+ anySet = true;
+
+ if ( !anySet )
+ {
+ wxFAIL_MSG( "icon bundle doesn't contain any suitable icon" );
+ }
}
bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
MF_BYCOMMAND |
(enable ? MF_ENABLED : MF_GRAYED)) == -1 )
{
- wxLogLastError(_T("EnableMenuItem(SC_CLOSE)"));
+ wxLogLastError(wxT("EnableMenuItem(SC_CLOSE)"));
return false;
}
// update appearance immediately
if ( !::DrawMenuBar(GetHwnd()) )
{
- wxLogLastError(_T("DrawMenuBar"));
+ wxLogLastError(wxT("DrawMenuBar"));
}
#endif
#endif // !__WXMICROWIN__
bool wxTopLevelWindowMSW::SetShape(const wxRegion& region)
{
wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
- _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
+ wxT("Shaped windows must be created with the wxFRAME_SHAPED style."));
// The empty region signifies that the shape should be removed from the
// window.
{
if (::SetWindowRgn(GetHwnd(), NULL, TRUE) == 0)
{
- wxLogLastError(_T("SetWindowRgn"));
+ wxLogLastError(wxT("SetWindowRgn"));
return false;
}
return true;
DWORD dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE);
DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE);
::GetClientRect(GetHwnd(), &rect);
- ::AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
+ ::AdjustWindowRectEx(&rect, dwStyle, ::GetMenu(GetHwnd()) != NULL, dwExStyle);
::OffsetRgn(hrgn, -rect.left, -rect.top);
// Now call the shape API with the new region.
if (::SetWindowRgn(GetHwnd(), hrgn, TRUE) == 0)
{
- wxLogLastError(_T("SetWindowRgn"));
+ wxLogLastError(wxT("SetWindowRgn"));
return false;
}
return true;
static FlashWindowEx_t s_pfnFlashWindowEx = NULL;
if ( !s_pfnFlashWindowEx )
{
- wxDynamicLibrary dllUser32(_T("user32.dll"));
+ wxDynamicLibrary dllUser32(wxT("user32.dll"));
s_pfnFlashWindowEx = (FlashWindowEx_t)
- dllUser32.GetSymbol(_T("FlashWindowEx"));
+ dllUser32.GetSymbol(wxT("FlashWindowEx"));
// we can safely unload user32.dll here, it's going to remain loaded as
// long as the program is running anyhow
if ( pSetLayeredWindowAttributes == (PSETLAYEREDWINDOWATTR)-1 )
{
- wxDynamicLibrary dllUser32(_T("user32.dll"));
+ wxDynamicLibrary dllUser32(wxT("user32.dll"));
// use RawGetSymbol() and not GetSymbol() to avoid error messages under
// Windows 95: there is nothing the user can do about this anyhow
{
// restore focus to the child which was last focused unless we already
// have it
- wxLogTrace(_T("focus"), _T("wxTLW %p activated."), m_hWnd);
+ wxLogTrace(wxT("focus"), wxT("wxTLW %p activated."), m_hWnd);
wxWindow *winFocus = FindFocus();
if ( !winFocus || wxGetTopLevelParent(winFocus) != this )
}
}
- wxLogTrace(_T("focus"),
- _T("wxTLW %p deactivated, last focused: %p."),
+ wxLogTrace(wxT("focus"),
+ wxT("wxTLW %p deactivated, last focused: %p."),
m_hWnd,
m_winLastFocused ? GetHwndOf(m_winLastFocused) : NULL);
{
if ( !::DestroyWindow(ms_hwnd) )
{
- wxLogLastError(_T("DestroyWindow(hidden TLW parent)"));
+ wxLogLastError(wxT("DestroyWindow(hidden TLW parent)"));
}
ms_hwnd = NULL;
{
if ( !::UnregisterClass(ms_className, wxGetInstance()) )
{
- wxLogLastError(_T("UnregisterClass(\"wxTLWHiddenParent\")"));
+ wxLogLastError(wxT("UnregisterClass(\"wxTLWHiddenParent\")"));
}
ms_className = NULL;
{
if ( !ms_className )
{
- static const wxChar *HIDDEN_PARENT_CLASS = _T("wxTLWHiddenParent");
+ static const wxChar *HIDDEN_PARENT_CLASS = wxT("wxTLWHiddenParent");
WNDCLASS wndclass;
wxZeroMemory(wndclass);
if ( !::RegisterClass(&wndclass) )
{
- wxLogLastError(_T("RegisterClass(\"wxTLWHiddenParent\")"));
+ wxLogLastError(wxT("RegisterClass(\"wxTLWHiddenParent\")"));
}
else
{
(HMENU)NULL, wxGetInstance(), NULL);
if ( !ms_hwnd )
{
- wxLogLastError(_T("CreateWindow(hidden TLW parent)"));
+ wxLogLastError(wxT("CreateWindow(hidden TLW parent)"));
}
}