-void wxWindowMSW::MSWDetachWindowMenu()
-{
-#ifndef __WXUNIVERSAL__
- if ( m_hMenu )
- {
- wxChar buf[1024];
- HMENU hMenu = (HMENU)m_hMenu;
-
- int N = ::GetMenuItemCount(hMenu);
- for ( int i = 0; i < N; i++ )
- {
- if ( !::GetMenuString(hMenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION) )
- {
- wxLogLastError(wxT("GetMenuString"));
-
- continue;
- }
-
- if ( wxStrcmp(buf, _("&Window")) == 0 )
- {
- if ( !::RemoveMenu(hMenu, i, MF_BYPOSITION) )
- {
- wxLogLastError(wxT("RemoveMenu"));
- }
-
- break;
- }
- }
- }
-#endif
-}
-
-bool wxWindowMSW::MSWCreate(int id,
- wxWindow *parent,
- const wxChar *wclass,
- wxWindow * WXUNUSED(wx_win),
- const wxChar *title,
- int x,
- int y,
- int width,
- int height,
- WXDWORD style,
- const wxChar *dialog_template,
- WXDWORD extendedStyle)
-{
- int x1 = CW_USEDEFAULT;
- int y1 = 0;
- int width1 = CW_USEDEFAULT;
- int height1 = 100;
-
- // Find parent's size, if it exists, to set up a possible default
- // panel size the size of the parent window
- RECT rectParent;
- if ( parent )
- {
- ::GetClientRect(GetHwndOf(parent), &rectParent);
-
- width1 = rectParent.right - rectParent.left;
- height1 = rectParent.bottom - rectParent.top;
- }
-
- if ( x != -1 )
- x1 = x;
- if ( y != -1 )
- y1 = y;
- if ( width != -1 )
- width1 = width;
- if ( height != -1 )
- height1 = height;
-
- // unfortunately, setting WS_EX_CONTROLPARENT only for some windows in the
- // hierarchy with several embedded panels (and not all of them) causes the
- // program to hang during the next call to IsDialogMessage() due to the bug
- // in this function (at least in Windows NT 4.0, it seems to work ok in
- // Win2K)
-#if 0
- // if we have wxTAB_TRAVERSAL style, we want WS_EX_CONTROLPARENT or
- // IsDialogMessage() won't work for us
- if ( GetWindowStyleFlag() & wxTAB_TRAVERSAL )
- {
- extendedStyle |= WS_EX_CONTROLPARENT;
- }
-#endif // 0
-
- HWND hParent;
- if ( GetWindowStyleFlag() & wxPOPUP_WINDOW )
- {
- // popup windows should have desktop as parent because they shouldn't
- // be limited to the parents client area as child windows usually are
- hParent = ::GetDesktopWindow();
- }
- else if ( parent )
- {
- hParent = GetHwndOf(parent);
- }
- else
- {
- // top level window
- hParent = NULL;
- }
-
- wxWndHook = this;
-
-#ifndef __WXMICROWIN__
- if ( dialog_template )
- {
- // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
- // app window as parent - this avoids creating modal dialogs without
- // parent
- if ( !hParent && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
- {
- wxWindow *winTop = wxTheApp->GetTopWindow();
- if ( winTop )
- hParent = GetHwndOf(winTop);
- }
-
- m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(),
- dialog_template,
- hParent,
- (DLGPROC)wxDlgProc);
-
- if ( m_hWnd == 0 )
- {
- wxLogError(_("Can't find dialog template '%s'!\nCheck resource include path for finding wx.rc."),
- dialog_template);
-
- return FALSE;
- }
-
- if ( extendedStyle != 0 )
- {
- ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, extendedStyle);
- ::SetWindowPos(GetHwnd(), NULL, 0, 0, 0, 0,
- SWP_NOSIZE |
- SWP_NOMOVE |
- SWP_NOZORDER |
- SWP_NOACTIVATE);
- }
-
-#if defined(__WIN95__)
- // For some reason, the system menu is activated when we use the
- // WS_EX_CONTEXTHELP style, so let's set a reasonable icon
- if (extendedStyle & WS_EX_CONTEXTHELP)
- {
- wxFrame *winTop = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame);
- if ( winTop )
- {
- wxIcon icon = winTop->GetIcon();
- if ( icon.Ok() )
- {
- ::SendMessage(GetHwnd(), WM_SETICON,
- (WPARAM)TRUE,
- (LPARAM)GetHiconOf(icon));
- }
- }
- }
-#endif // __WIN95__
-
-
- // JACS: is the following still necessary? The above seems to work.
-
- // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try
- // to take care of (at least some) extended style flags ourselves
- if ( extendedStyle & WS_EX_TOPMOST )
- {
- if ( !::SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
- SWP_NOSIZE | SWP_NOMOVE) )
- {
- wxLogLastError(wxT("SetWindowPos"));
- }
- }