Exemplo n.º 1
0
/* static */
void wxToolTip::UpdateVisibility()
{
    wxToolInfo ti(NULL, 0, wxRect());
    ti.uFlags = 0;

    if ( !SendTooltipMessage(ms_hwndTT, TTM_GETCURRENTTOOL, &ti) )
        return;

    wxWindow* const associatedWindow = wxFindWinFromHandle(ti.hwnd);
    if ( !associatedWindow )
        return;

    bool hideTT = false;
    if ( !associatedWindow->IsShownOnScreen() )
    {
        // If the associated window or its parent is hidden, the tooltip
        // shouldn't remain shown.
        hideTT = true;
    }
    else
    {
        // Even if it's not hidden, it could also be iconized.
        wxTopLevelWindow* const
            frame = wxDynamicCast(wxGetTopLevelParent(associatedWindow), wxTopLevelWindow);

        if ( frame && frame->IsIconized() )
            hideTT = true;
    }

    if ( hideTT )
        ::ShowWindow(ms_hwndTT, SW_HIDE);
}
Exemplo n.º 2
0
bool wxMDIChildFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd)
{
    // In case it's e.g. a toolbar.
    if ( hwnd )
    {
        wxWindow *win = wxFindWinFromHandle(hwnd);
        if (win)
            return win->MSWCommand(cmd, id);
    }

    if (wxCurrentPopupMenu)
    {
        wxMenu *popupMenu = wxCurrentPopupMenu;
        wxCurrentPopupMenu = NULL;
        if (popupMenu->MSWCommand(cmd, id))
            return true;
    }

    bool processed;
    if (GetMenuBar() && GetMenuBar()->FindItem(id))
    {
        processed = ProcessCommand(id);
    }
    else
    {
        processed = false;
    }

    return processed;
}
Exemplo n.º 3
0
// Returns the active MDI child window
wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
{
    HWND hWnd = (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
                                    WM_MDIGETACTIVE, 0, 0L);
    if ( hWnd == 0 )
        return NULL;
    else
        return (wxMDIChildFrame *)wxFindWinFromHandle((WXHWND) hWnd);
}
Exemplo n.º 4
0
wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
{
    HWND hWnd = (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
                                    WM_MDIGETACTIVE, 0, 0L);
    if ( !hWnd )
        return NULL;

    return static_cast<wxMDIChildFrame *>(wxFindWinFromHandle(hWnd));
}
Exemplo n.º 5
0
// show dialog modally
int wxDialog::ShowModal()
{
    wxASSERT_MSG( !IsModal(), _T("wxDialog::ShowModal() reentered?") );

    m_oldFocus = FindFocus();
    m_endModalCalled = false;

    Show();

    // EndModal may have been called from InitDialog handler (called from
    // inside Show()), which would cause an infinite loop if we didn't take it
    // into account
    if ( !m_endModalCalled )
    {
        // modal dialog needs a parent window, so try to find one
        wxWindow *parent = GetParent();
        if ( !parent )
        {
            parent = FindSuitableParent();
        }

        // remember where the focus was
        wxWindow *oldFocus = m_oldFocus;
        if ( !oldFocus )
        {
            // VZ: do we really want to do this?
            oldFocus = parent;
        }

        // We have to remember the HWND because we need to check
        // the HWND still exists (oldFocus can be garbage when the dialog
        // exits, if it has been destroyed)
        HWND hwndOldFocus = oldFocus ? GetHwndOf(oldFocus) : NULL;


        // enter and run the modal loop
        {
            wxDialogModalDataTiedPtr modalData(&m_modalData,
                                               new wxDialogModalData(this));
            modalData->RunLoop();
        }


        // and restore focus
        // Note that this code MUST NOT access the dialog object's data
        // in case the object has been deleted (which will be the case
        // for a modal dialog that has been destroyed before calling EndModal).
        if ( oldFocus && (oldFocus != this) && ::IsWindow(hwndOldFocus))
        {
            // This is likely to prove that the object still exists
            if (wxFindWinFromHandle((WXHWND) hwndOldFocus) == oldFocus)
                oldFocus->SetFocus();
        }
    }

    return GetReturnCode();
}
Exemplo n.º 6
0
LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd,
                                            UINT message,
                                            WPARAM wParam,
                                            LPARAM lParam)
{
    HWND hwndCombo = ::GetParent(hWnd);
    wxWindow *win = wxFindWinFromHandle((WXHWND)hwndCombo);

    switch ( message )
    {
        // forward some messages to the combobox to generate the appropriate
        // wxEvents from them
        case WM_KEYUP:
        case WM_KEYDOWN:
        case WM_CHAR:
        case WM_SYSCHAR:
        case WM_SYSKEYDOWN:
        case WM_SYSKEYUP:
        case WM_SETFOCUS:
        case WM_KILLFOCUS:
            {
                wxComboBox *combo = wxDynamicCast(win, wxComboBox);
                if ( !combo )
                {
                    // we can get WM_KILLFOCUS while our parent is already half
                    // destroyed and hence doesn't look like a combobx any
                    // longer, check for it to avoid bogus assert failures
                    if ( !win->IsBeingDeleted() )
                    {
                        wxFAIL_MSG( wxT("should have combo as parent") );
                    }
                }
                else if ( combo->MSWProcessEditMsg(message, wParam, lParam) )
                {
                    // handled by parent
                    return 0;
                }
            }
            break;

        case WM_GETDLGCODE:
            {
                wxCHECK_MSG( win, 0, wxT("should have a parent") );

                if ( win->GetWindowStyle() & wxTE_PROCESS_ENTER )
                {
                    // need to return a custom dlg code or we'll never get it
                    return DLGC_WANTMESSAGE;
                }
            }
            break;
    }

    return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam);
}
Exemplo n.º 7
0
WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
{
    HDC hdc = (HDC)pDC;

    WXHBRUSH hbr = 0;
    if ( !colBg.IsOk() )
    {
        if ( wxWindow *win = wxFindWinFromHandle(hWnd) )
            hbr = win->MSWGetBgBrush(pDC);

        // if the control doesn't have any bg colour, foreground colour will be
        // ignored as the return value would be 0 -- so forcefully give it a
        // non default background brush in this case
        if ( !hbr && m_hasFgCol )
            colBg = GetBackgroundColour();
    }

    // use the background colour override if a valid colour is given: this is
    // used when the control is disabled to grey it out and also if colBg was
    // set just above
    if ( colBg.IsOk() )
    {
        wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg);
        hbr = (WXHBRUSH)brush->GetResourceHandle();
    }

    // always set the foreground colour if we changed the background, whether
    // m_hasFgCol is true or not: if it true, we must do it, of course, but
    // even if it isn't, we must set the default foreground explicitly as by
    // default just the simple black is used
    if ( hbr )
    {
        ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
    }

    // finally also set the background colour for text drawing: without this,
    // the text in an edit control is drawn using the default background even
    // if we return a valid brush
    if ( colBg.IsOk() || m_hasBgCol )
    {
        if ( !colBg.IsOk() )
            colBg = GetBackgroundColour();

        ::SetBkColor(hdc, wxColourToRGB(colBg));
    }

    return hbr;
}
Exemplo n.º 8
0
MRESULT EXPENTRY wxFrameWndProc(
  HWND                              hWnd
, ULONG                             ulMsg
, MPARAM                            wParam
, MPARAM                            lParam
)
{
    //
    // Trace all ulMsgs - useful for the debugging
    //
    HWND                            parentHwnd;
    wxFrame*                        pWnd  = NULL;

    parentHwnd  = WinQueryWindow(hWnd,QW_PARENT);
    pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd);

    //
    // When we get the first message for the HWND we just created, we associate
    // it with wxWindow stored in wxWndHook
    //

    MRESULT                         rc = (MRESULT)0;

    //
    // Stop right here if we don't have a valid handle in our wxWindow object.
    //
    if (pWnd && !pWnd->GetHWND())
    {
        pWnd->SetHWND((WXHWND) hWnd);
        rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam );
        pWnd->SetHWND(0);
    }
    else
    {
        if (pWnd)
            rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam);
        else
            rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
    }
    return rc;
} // end of wxFrameWndProc
Exemplo n.º 9
0
wxRadioBox::~wxRadioBox()
{
    m_isBeingDeleted = true;

    if (m_hWnd)
        wxRemoveHandleAssociation(this);
    if (m_ahRadioButtons)
    {
        for (int i = 0; i < m_nNoItems; i++)
        {
            wxWindow* pWin = wxFindWinFromHandle((WXHWND)m_ahRadioButtons[i]);
            wxRemoveHandleAssociation(pWin);
            ::WinDestroyWindow((HWND)m_ahRadioButtons[i]);
        }
        delete[] m_ahRadioButtons;
    }
    if (m_pnRadioWidth)
        delete[] m_pnRadioWidth;
    if (m_pnRadioHeight)
        delete[] m_pnRadioHeight;
} // end of wxRadioBox::~wxRadioBox
Exemplo n.º 10
0
wxWindow *wxDialog::FindSuitableParent() const
{
    // first try to use the currently active window
    HWND hwndFg = ::GetForegroundWindow();
    wxWindow *parent = hwndFg ? wxFindWinFromHandle((WXHWND)hwndFg)
                              : NULL;
    if ( !parent )
    {
        // next try the main app window
        parent = wxTheApp->GetTopWindow();
    }

    // finally, check if the parent we found is really suitable
    if ( !parent || parent == (wxWindow *)this || !parent->IsShown() )
    {
        // don't use this one
        parent = NULL;
    }

    return parent;
}
Exemplo n.º 11
0
Arquivo: frame.cpp Projeto: EdgarTx/wx
bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
{
    if ( control )
    {
        // In case it's e.g. a toolbar.
        wxWindow *win = wxFindWinFromHandle(control);
        if ( win )
            return win->MSWCommand(cmd, id);
    }

    // handle here commands from menus and accelerators
    if ( cmd == 0 || cmd == 1 )
    {
#if wxUSE_MENUS_NATIVE
        if ( wxCurrentPopupMenu )
        {
            wxMenu *popupMenu = wxCurrentPopupMenu;
            wxCurrentPopupMenu = NULL;

            return popupMenu->MSWCommand(cmd, id);
        }
#endif // wxUSE_MENUS_NATIVE

#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
        // handle here commands from Smartphone menu bar
        if ( wxTopLevelWindow::HandleCommand(id, cmd, control ) )
        {
            return true;
        }
#endif // __SMARTPHONE__ && __WXWINCE__

        if ( ProcessCommand(id) )
        {
            return true;
        }
    }

    return false;
}
Exemplo n.º 12
0
bool wxFrame::HandleCommand( WXWORD nId,
                             WXWORD nCmd,
                             WXHWND hControl )
{
    if (hControl)
    {
        //
        // In case it's e.g. a toolbar.
        //
        wxWindow*                   pWin = wxFindWinFromHandle(hControl);

        if (pWin)
            return pWin->OS2Command( nCmd, nId );
    }

    //
    // Handle here commands from menus and accelerators
    //
    if (nCmd == CMDSRC_MENU || nCmd == CMDSRC_ACCELERATOR)
    {
#if wxUSE_MENUS_NATIVE
        if (wxCurrentPopupMenu)
        {
            wxMenu*                 pPopupMenu = wxCurrentPopupMenu;

            wxCurrentPopupMenu = NULL;

            return pPopupMenu->OS2Command( nCmd, nId );
        }
#endif

        if (ProcessCommand(nId))
        {
            return true;
        }
    }
    return false;
} // end of wxFrame::HandleCommand
Exemplo n.º 13
0
LRESULT APIENTRY
wxComboEditWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HWND hwndCombo = ::GetParent(hWnd);
    wxWindow *win = wxFindWinFromHandle((WXHWND)hwndCombo);

    if ( ShouldForwardFromEditToCombo(message) )
    {
        wxComboBox *combo = wxDynamicCast(win, wxComboBox);
        if ( !combo )
        {
            // we can get WM_KILLFOCUS while our parent is already half
            // destroyed and hence doesn't look like a combobx any
            // longer, check for it to avoid bogus assert failures
            if ( !win->IsBeingDeleted() )
            {
                wxFAIL_MSG( wxT("should have combo as parent") );
            }
        }
        else if ( combo->MSWProcessEditMsg(message, wParam, lParam) )
        {
            // handled by parent
            return 0;
        }
    }
    else if ( message == WM_GETDLGCODE )
    {
        wxCHECK_MSG( win, 0, wxT("should have a parent") );

        if ( win->GetWindowStyle() & wxTE_PROCESS_ENTER )
        {
            // need to return a custom dlg code or we'll never get it
            return DLGC_WANTMESSAGE;
        }
    }

    return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam);
}
Exemplo n.º 14
0
wxWindow* wxFrame::GetClient()
{
    return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT));
}
Exemplo n.º 15
0
// ---------------------------------------------------------------------------
// Main Frame window proc
// ---------------------------------------------------------------------------
MRESULT EXPENTRY wxFrameMainWndProc( HWND   hWnd,
                                     ULONG  ulMsg,
                                     MPARAM wParam,
                                     MPARAM lParam )
{
    MRESULT  rc = (MRESULT)0;
    bool     bProcessed = false;
    wxFrame* pWnd  = NULL;

    pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd);
    switch (ulMsg)
    {
        case WM_QUERYFRAMECTLCOUNT:
            if(pWnd && pWnd->m_fnOldWndProc)
            {
                USHORT              uItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam));

                rc = MRFROMSHORT(uItemCount);
            }
            break;

        case WM_FORMATFRAME:
/////////////////////////////////////////////////////////////////////////////////
// Applications that subclass frame controls may find that the frame is already
// subclassed the number of frame controls is variable.
// The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
// subclassed by calling the previous window procedure and modifying its result.
////////////////////////////////////////////////////////////////////////////////
            {
                int                 nItemCount;
                int                 i;
                PSWP                pSWP = NULL;
                RECTL               vRectl;
                RECTL               vRstb;
                RECTL               vRtlb;
                int                 nHeight = 0;
                int                 nHeight2 = 0;
                int                 nWidth = 0;

                pSWP = (PSWP)PVOIDFROMMP(wParam);
                nItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam));
                if(pWnd->m_frameStatusBar)
                {
                    ::WinQueryWindowRect(pWnd->m_frameStatusBar->GetHWND(), &vRstb);
                    pWnd->m_frameStatusBar->GetSize(NULL, &nHeight);
                }
                if(pWnd->m_frameToolBar)
                {
                    ::WinQueryWindowRect(pWnd->m_frameToolBar->GetHWND(), &vRtlb);
                    pWnd->m_frameToolBar->GetSize(&nWidth, &nHeight2);
                }
                ::WinQueryWindowRect(pWnd->m_hFrame, &vRectl);
                ::WinMapWindowPoints(pWnd->m_hFrame, HWND_DESKTOP, (PPOINTL)&vRectl, 2);
                ::WinCalcFrameRect(pWnd->m_hFrame, &vRectl, TRUE);
                ::WinMapWindowPoints(HWND_DESKTOP, pWnd->m_hFrame, (PPOINTL)&vRectl, 2);
                for(i = 0; i < nItemCount; i++)
                {
                    if(pWnd->m_hWnd && pSWP[i].hwnd == pWnd->m_hWnd)
                    {
                        if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_TOP)
                        {
                            pSWP[i].x    = vRectl.xLeft;
                            pSWP[i].y    = vRectl.yBottom + nHeight;
                            pSWP[i].cx   = vRectl.xRight - vRectl.xLeft;
                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2);
                        }
                        else if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_BOTTOM)
                        {
                            pSWP[i].x    = vRectl.xLeft;
                            pSWP[i].y    = vRectl.yBottom + nHeight + nHeight2;
                            pSWP[i].cx   = vRectl.xRight - vRectl.xLeft;
                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2);
                         }
                        else if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_LEFT)
                        {
                            pSWP[i].x    = vRectl.xLeft + nWidth;
                            pSWP[i].y    = vRectl.yBottom + nHeight;
                            pSWP[i].cx   = vRectl.xRight - (vRectl.xLeft + nWidth);
                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - nHeight;
                        }
                        else
                        {
                            pSWP[i].x    = vRectl.xLeft;
                            pSWP[i].y    = vRectl.yBottom + nHeight;
                            pSWP[i].cx   = vRectl.xRight - (vRectl.xLeft + nWidth);
                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - nHeight;
                        }
                        pSWP[i].fl   = SWP_SIZE | SWP_MOVE | SWP_SHOW;
                        pSWP[i].hwndInsertBehind = HWND_TOP;
                    }
                }
                bProcessed = true;
                rc = MRFROMSHORT(nItemCount);
            }
            break;

       default:
            if(pWnd && pWnd->m_fnOldWndProc)
                rc = pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam);
            else
                rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
    }
    return rc;
} // end of wxFrameMainWndProc
Exemplo n.º 16
0
void wxNotebook::OnSize(wxSizeEvent& event)
{
    if ( GetPageCount() == 0 )
    {
        // Prevents droppings on resize, but does cause some flicker
        // when there are no pages.
        Refresh();
        event.Skip();
        return;
    }
#ifndef __WXWINCE__
    else
    {
        // Without this, we can sometimes get droppings at the edges
        // of a notebook, for example a notebook in a splitter window.
        // This needs to be reconciled with the RefreshRect calls
        // at the end of this function, which weren't enough to prevent
        // the droppings.

        wxSize sz = GetClientSize();

        // Refresh right side
        wxRect rect(sz.x-4, 0, 4, sz.y);
        RefreshRect(rect);

        // Refresh bottom side
        rect = wxRect(0, sz.y-4, sz.x, 4);
        RefreshRect(rect);

        // Refresh left side
        rect = wxRect(0, 0, 4, sz.y);
        RefreshRect(rect);
    }
#endif // !__WXWINCE__

    // fit all the notebook pages to the tab control's display area

    RECT rc;
    rc.left = rc.top = 0;
    GetSize((int *)&rc.right, (int *)&rc.bottom);

    // save the total size, we'll use it below
    int widthNbook = rc.right - rc.left,
        heightNbook = rc.bottom - rc.top;

    // there seems to be a bug in the implementation of TabCtrl_AdjustRect(): it
    // returns completely false values for multiline tab controls after the tabs
    // are added but before getting the first WM_SIZE (off by ~50 pixels, see
    //
    // http://sf.net/tracker/index.php?func=detail&aid=645323&group_id=9863&atid=109863
    //
    // and the only work around I could find was this ugly hack... without it
    // simply toggling the "multiline" checkbox in the notebook sample resulted
    // in a noticeable page displacement
    if ( HasFlag(wxNB_MULTILINE) )
    {
        // avoid an infinite recursion: we get another notification too!
        static bool s_isInOnSize = false;

        if ( !s_isInOnSize )
        {
            s_isInOnSize = true;
            SendMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED,
                    MAKELPARAM(rc.right, rc.bottom));
            s_isInOnSize = false;
        }

        // The best size depends on the number of rows of tabs, which can
        // change when the notepad is resized.
        InvalidateBestSize();
    }

#if wxUSE_UXTHEME
    // background bitmap size has changed, update the brush using it too
    UpdateBgBrush();
#endif // wxUSE_UXTHEME

    TabCtrl_AdjustRect(GetHwnd(), false, &rc);

    int width = rc.right - rc.left,
        height = rc.bottom - rc.top;
    size_t nCount = m_pages.Count();
    for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
        wxNotebookPage *pPage = m_pages[nPage];
        pPage->SetSize(rc.left, rc.top, width, height);
    }


    // unless we had already repainted everything, we now need to refresh
    if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) )
    {
        // invalidate areas not covered by pages
        RefreshRect(wxRect(0, 0, widthNbook, rc.top), false);
        RefreshRect(wxRect(0, rc.top, rc.left, height), false);
        RefreshRect(wxRect(0, rc.bottom, widthNbook, heightNbook - rc.bottom),
                    false);
        RefreshRect(wxRect(rc.right, rc.top, widthNbook - rc.right, height),
                    false);
    }

#if USE_NOTEBOOK_ANTIFLICKER
    // subclass the spin control used by the notebook to scroll pages to
    // prevent it from flickering on resize
    if ( !m_hasSubclassedUpdown )
    {
        // iterate over all child windows to find spin button
        for ( HWND child = ::GetWindow(GetHwnd(), GW_CHILD);
              child;
              child = ::GetWindow(child, GW_HWNDNEXT) )
        {
            wxWindow *childWindow = wxFindWinFromHandle((WXHWND)child);

            // see if it exists, if no wxWindow found then assume it's the spin
            // btn
            if ( !childWindow )
            {
                // subclass the spin button to override WM_ERASEBKGND
                if ( !gs_wndprocNotebookSpinBtn )
                    gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child);

                wxSetWindowProc(child, wxNotebookSpinBtnWndProc);
                m_hasSubclassedUpdown = true;
                break;
            }
        }
    }

    // Probably because of the games we play above to avoid flicker sometimes
    // the text controls inside notebook pages are not shown correctly (they
    // don't have their borders) when the notebook is shown for the first time.
    // It's not really clear why does this happen and maybe the bug is in
    // wxTextCtrl itself and not here but updating the page when it's about to
    // be shown doesn't cost much and works around the problem so do it here
    // for now.
    if ( !m_doneUpdateHack && IsShownOnScreen() )
    {
        m_doneUpdateHack = true;
        wxWindow* const page = GetCurrentPage();
        if ( page )
            page->Update();
    }
#endif // USE_NOTEBOOK_ANTIFLICKER

    event.Skip();
}
Exemplo n.º 17
0
bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd)
{
    // In case it's e.g. a toolbar.
    if ( hwnd )
    {
        wxWindow *win = wxFindWinFromHandle(hwnd);
        if ( win )
            return win->MSWCommand(cmd, id);
    }

    // is it one of standard MDI commands?
    WXWPARAM wParam = 0;
    WXLPARAM lParam = 0;
    int msg;
    switch ( id )
    {
        case IDM_WINDOWCASCADE:
            msg = WM_MDICASCADE;
            wParam = MDITILE_SKIPDISABLED;
            break;

        case IDM_WINDOWTILEHOR:
            wParam |= MDITILE_HORIZONTAL;
            // fall through

        case IDM_WINDOWTILEVERT:
            if ( !wParam )
                wParam = MDITILE_VERTICAL;
            msg = WM_MDITILE;
            wParam |= MDITILE_SKIPDISABLED;
            break;

        case IDM_WINDOWICONS:
            msg = WM_MDIICONARRANGE;
            break;

        case IDM_WINDOWNEXT:
            msg = WM_MDINEXT;
            lParam = 0;         // next child
            break;

        case IDM_WINDOWPREV:
            msg = WM_MDINEXT;
            lParam = 1;         // previous child
            break;

        default:
            msg = 0;
    }

    if ( msg )
    {
        ::SendMessage(GetWinHwnd(GetClientWindow()), msg, wParam, lParam);

        return true;
    }

    // FIXME VZ: what does this test do??
    if (id >= 0xF000)
    {
        return false; // Get WndProc to call default proc
    }

    if ( IsMdiCommandId(id) )
    {
        wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
        while ( node )
        {
            wxWindow *child = node->GetData();
            if ( child->GetHWND() )
            {
                long childId = wxGetWindowId(child->GetHWND());
                if (childId == (long)id)
                {
                    ::SendMessage( GetWinHwnd(GetClientWindow()),
                                   WM_MDIACTIVATE,
                                   (WPARAM)child->GetHWND(), 0);
                    return true;
                }
            }
            node = node->GetNext();
        }
    }
    else if ( m_parentFrameActive )
    {
        return ProcessCommand(id);
    }
    else if ( m_currentChild )
    {
        return m_currentChild->HandleCommand(id, cmd, hwnd);
    }
    else
    {
        // this shouldn't happen because it means that our messages are being
        // lost (they're not sent to the parent frame nor to the children)
        wxFAIL_MSG(wxT("MDI parent frame is not active, yet there is no active MDI child?"));
    }

    return false;
}
Exemplo n.º 18
0
//
// Replacement for Show(true) for modal dialogs - returns return code
//
int wxDialog::ShowModal()
{
    WX_HOOK_MODAL_DIALOG();

    wxASSERT_MSG( !IsModal(), wxT("wxDialog::ShowModal() reentered?") );

    m_endModalCalled = false;

    Show();

    // EndModal may have been called from InitDialog handler (called from
    // inside Show()), which would cause an infinite loop if we didn't take it
    // into account
    if ( !m_endModalCalled )
    {
        // modal dialog needs a parent window, so try to find one
        wxWindow * const parent = GetParentForModalDialog();

        // remember where the focus was
        wxWindow *oldFocus = m_pOldFocus;
        if ( !oldFocus )
        {
            // VZ: do we really want to do this?
            oldFocus = parent;
        }

        // We have to remember the HWND because we need to check
        // the HWND still exists (oldFocus can be garbage when the dialog
        // exits, if it has been destroyed)
        HWND hwndOldFocus = oldFocus ? GetHwndOf(oldFocus) : NULL;


        //
        // Before entering the modal loop, reset the "is in OnIdle()" flag (see
        // comment in app.cpp)
        //
        extern bool                     gbInOnIdle;
        bool                            bWasInOnIdle = gbInOnIdle;

        gbInOnIdle = false;

        // enter and run the modal loop
        {
            wxDialogModalDataTiedPtr modalData(&m_modalData,
                                               new wxDialogModalData(this));
            modalData->RunLoop();
        }
        gbInOnIdle = bWasInOnIdle;

        // and restore focus
        // Note that this code MUST NOT access the dialog object's data
        // in case the object has been deleted (which will be the case
        // for a modal dialog that has been destroyed before calling EndModal).
        if ( oldFocus && (oldFocus != this) && ::WinIsWindow(vHabmain, hwndOldFocus))
        {
            // This is likely to prove that the object still exists
            if (wxFindWinFromHandle((WXHWND) hwndOldFocus) == oldFocus)
                oldFocus->SetFocus();
        }
    }

    return GetReturnCode();
} // end of wxDialog::ShowModal
Exemplo n.º 19
0
WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
{
    HDC hdc = (HDC)pDC;

    WXHBRUSH hbr = 0;
    if ( !colBg.IsOk() )
    {
        wxWindow *win = wxFindWinFromHandle( hWnd );
        if ( !win )
        {
            // If this HWND doesn't correspond to a wxWindow, it still might be
            // one of its children for which we need to set the background
            // brush, e.g. this is the case for the EDIT control that is part
            // of wxComboBox. Check for this by asking the parent if it has it:
            HWND parent = ::GetParent(hWnd);
            if ( parent )
            {
                wxWindow *winParent = wxFindWinFromHandle( parent );
                if( winParent && winParent->ContainsHWND( hWnd ) )
                    win = winParent;
             }
        }

        if ( win )
            hbr = win->MSWGetBgBrush(pDC);

        // if the control doesn't have any bg colour, foreground colour will be
        // ignored as the return value would be 0 -- so forcefully give it a
        // non default background brush in this case
        if ( !hbr && m_hasFgCol )
            colBg = GetBackgroundColour();
    }

    // use the background colour override if a valid colour is given: this is
    // used when the control is disabled to grey it out and also if colBg was
    // set just above
    if ( colBg.IsOk() )
    {
        wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg);
        hbr = (WXHBRUSH)brush->GetResourceHandle();
    }

    // always set the foreground colour if we changed the background, whether
    // m_hasFgCol is true or not: if it true, we must do it, of course, but
    // even if it isn't, we must set the default foreground explicitly as by
    // default just the simple black is used
    if ( hbr )
    {
        ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
    }

    // finally also set the background colour for text drawing: without this,
    // the text in an edit control is drawn using the default background even
    // if we return a valid brush
    if ( colBg.IsOk() || m_hasBgCol )
    {
        if ( !colBg.IsOk() )
            colBg = GetBackgroundColour();

        ::SetBkColor(hdc, wxColourToRGB(colBg));
    }

    return hbr;
}
Exemplo n.º 20
0
LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd,
                                            UINT message,
                                            WPARAM wParam,
                                            LPARAM lParam)
{
    HWND hwndCombo = ::GetParent(hWnd);
    wxWindow *win = wxFindWinFromHandle((WXHWND)hwndCombo);

    switch ( message )
    {
        // forward some messages to the combobox to generate the appropriate
        // wxEvents from them
        case WM_KEYUP:
        case WM_KEYDOWN:
        case WM_CHAR:
        case WM_SYSCHAR:
        case WM_SYSKEYDOWN:
        case WM_SYSKEYUP:
        case WM_SETFOCUS:
        case WM_KILLFOCUS:
            {
                wxComboBox *combo = wxDynamicCast(win, wxComboBox);
                if ( !combo )
                {
                    // we can get WM_KILLFOCUS while our parent is already half
                    // destroyed and hence doesn't look like a combobx any
                    // longer, check for it to avoid bogus assert failures
                    if ( !win->IsBeingDeleted() )
                    {
                        wxFAIL_MSG( _T("should have combo as parent") );
                    }
                }
                else if ( combo->MSWProcessEditMsg(message, wParam, lParam) )
                {
                    // handled by parent
                    return 0;
                }
            }
            break;

        case WM_GETDLGCODE:
            {
                wxCHECK_MSG( win, 0, _T("should have a parent") );

                if ( win->GetWindowStyle() & wxPROCESS_ENTER )
                {
                    // need to return a custom dlg code or we'll never get it
                    return DLGC_WANTMESSAGE;
                }
            }
            break;

        // deal with tooltips here
#if wxUSE_TOOLTIPS && defined(TTN_NEEDTEXT)
        case WM_NOTIFY:
            {
                wxCHECK_MSG( win, 0, _T("should have a parent") );

                NMHDR* hdr = (NMHDR *)lParam;
                if ( hdr->code == TTN_NEEDTEXT )
                {
                    wxToolTip *tooltip = win->GetToolTip();
                    if ( tooltip )
                    {
                        TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
                        ttt->lpszText = (wxChar *)tooltip->GetTip().c_str();
                    }

                    // processed
                    return 0;
                }
            }
            break;
#endif // wxUSE_TOOLTIPS
    }

    return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam);
}