Ejemplo n.º 1
0
void GUISetMetrics( gui_text_metrics *metrics, WPI_TEXTMETRIC *tm )
{
    metrics->avg.x = AVGXCHAR( *tm );
    metrics->avg.y = AVGYCHAR( *tm );
    metrics->max.x = MAXXCHAR( *tm );
    metrics->max.y = MAXYCHAR( *tm );
    GUIScreenToScaleR( &metrics->avg );
    GUIScreenToScaleR( &metrics->max );
}
Ejemplo n.º 2
0
void GUIGetTextMetrics( gui_window * wnd, gui_text_metrics * metrics )
{
    wnd = wnd;
    if( metrics != NULL ) {
        metrics->avg.x = 1;
        metrics->avg.y = 1;
        metrics->max.x = 1;
        metrics->max.y = 1;
        GUIScreenToScaleR( &metrics->avg );
        GUIScreenToScaleR( &metrics->max );
    }
}
Ejemplo n.º 3
0
bool GetControlExtent( gui_window * wnd, unsigned id, const char *text, size_t length, gui_coord *coord )
{
    int         my_length;
    WPI_PRES    dc;
    WPI_FONT    old;
    WPI_FONT    first;
    HWND        hwnd;

    if( text && GetControlInfo( wnd, id, &hwnd, &dc ) ) {
        my_length = strlen( text );
        if( length != (size_t)-1 ) {
            if( my_length > length ) {
                my_length = length;
            }
        }
        if( wnd->font != NULL ) {
            old = _wpi_selectfont( dc, wnd->font );
        } else {
            old = NULL;
        }
        _wpi_gettextextent( dc, text, my_length, &coord->x, &coord->y );
        if( old != NULL ) {
            first = _wpi_selectfont( dc, old );
        }
        _wpi_releasepres( hwnd, dc );
        GUIScreenToScaleR( coord );
        return( true );
    }
    return( false );
}
Ejemplo n.º 4
0
void GUIDoResize( gui_window *wnd, HWND hwnd, gui_coord *size )
{
    hwnd = hwnd;
    if( wnd->style & GUI_CHANGEABLE_FONT ) {
        GUIEnableSysMenuItem( wnd, GUI_CHANGE_FONT, TRUE );
    }
    if( wnd->hwnd != NULLHANDLE ) {
        GUIResizeStatus( wnd );
        GUIResizeBackground( wnd, FALSE );
    }
    GUIResizeToolBar( wnd );
    if( !(wnd->flags & NEEDS_RESIZE_REDRAW ) ) {
        wnd->old_rows = wnd->num_rows;
    }
    GUISetRowCol( wnd, size );
    wnd->flags |= NEEDS_RESIZE_REDRAW;
    GUISetScroll( wnd );
    if( wnd->flags & SENT_INIT ) {
        GUIScreenToScaleR( size );
        GUIEVENTWND( wnd, GUI_RESIZE, size );
    }
    GUIInvalidatePaintHandles( wnd );
#ifdef __OS2_PM__
    //_wpi_invalidaterect( hwnd, NULL, TRUE );
#endif
    GUIInvalidateResize( wnd );
    //_wpi_updatewindow( hwnd );
}
Ejemplo n.º 5
0
bool GUIGetHotSpotSize( int hot_spot, gui_coord *size )
{
    if( ( size == NULL ) || ( hot_spot > GUINumHotSpots ) ||
        ( hot_spot < 1 ) ) {
        return( FALSE );
    }
    size->x = GUIHotSpots[hot_spot-1].size.x;
    size->y = GUIHotSpots[hot_spot-1].size.y;
    GUIScreenToScaleR( size );
    return( TRUE );
}
Ejemplo n.º 6
0
gui_ord GUIGetVScroll( gui_window * wnd )
{
    gui_coord coord;

    if( wnd->vgadget == NULL ) {
        return( 0 );
    } else {
        coord.y = wnd->vgadget->pos;
        GUIScreenToScaleR( &coord );
        return( coord.y );
    }
}
Ejemplo n.º 7
0
void GUIResizeBackground( gui_window *wnd, bool force_msg )
{
    WPI_RECT    status;
    int         t_height, s_height;
    GUI_RECTDIM left, top, right, bottom;
    gui_coord   size;

    if( wnd->root == NULLHANDLE ) {
        if( wnd->hwnd != NULLHANDLE ) {
            _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client );
        }
        return;
    }

    t_height = 0;
    s_height = 0;

    if( ( wnd->toolbar != NULL ) && ( wnd->toolbar->info.is_fixed ) ) {
        t_height = _wpi_getheightrect( wnd->toolbar->fixedrect );
    }

    if( wnd->status != NULLHANDLE ) {
        _wpi_getwindowrect( wnd->status, &status );
        s_height = _wpi_getheightrect( status );
    }

    _wpi_getclientrect( wnd->root_frame, &wnd->root_client );
    _wpi_getrectvalues( wnd->root_client, &left, &top, &right, &bottom );
    bottom -= top;
    right  -= left;
    top = left = 0;

#ifdef __OS2_PM__
    top    += s_height;
    bottom -= t_height;
#else
    top    += t_height;
    bottom -= s_height;
#endif

    /* if the root client is a separate window resize it too */
    _wpi_movewindow( wnd->hwnd, left, top, right - left, bottom - top, TRUE );

    _wpi_getclientrect( wnd->hwnd, &wnd->hwnd_client );

    if( force_msg && ( wnd->flags & SENT_INIT ) ) {
        size.x = right - left;
        size.y = bottom - top;
        GUIScreenToScaleR( &size );
        GUIEVENTWND( wnd, GUI_RESIZE, &size );
    }
}
Ejemplo n.º 8
0
bool GUIResizeWindow( gui_window *wnd, gui_rect *rect )
{
    gui_coord   pos;
    gui_coord   size;
    gui_window  *parent;
    HWND        frame;
    HWND        phwnd;
    HWND        rphwnd;
    WPI_POINT   pt;

    GUIInvalidatePaintHandles( wnd );
    if( wnd->hwnd != NULLHANDLE ) {
        frame = GUIGetParentFrameHWND( wnd );
        parent = wnd->parent;
        phwnd = HWND_DESKTOP;
        if( parent ) {
            phwnd = parent->hwnd;
        }
        GUICalcLocation( rect, &pos, &size, phwnd );
        if( wnd->flags & IS_DIALOG ) {
            // dialogs are owned by, but not children of, phwnd
            // so lets map pos to its real parent
            pt.x = pos.x;
            pt.y = pos.y;
            rphwnd = _wpi_getparent( frame );
            _wpi_mapwindowpoints( phwnd, rphwnd, &pt, 1 );
            _wpi_movewindow( frame, pt.x, pt.y, size.x, size.y, TRUE );

// The following is a bandaid 'till I find out why WM_SIZE's aren't
// generated for PM GUI dialogs by this fuction
#ifdef __OS2_PM__
            _wpi_getclientrect( frame, &wnd->hwnd_client );
            wnd->root_client = wnd->hwnd_client;
            GUISetRowCol( wnd, NULL );
            GUIScreenToScaleR( &size );
            GUIEVENTWND( wnd, GUI_RESIZE, &size );
#endif
        } else {
            _wpi_setwindowpos( frame, NULLHANDLE, pos.x, pos.y, size.x, size.y,
                               SWP_NOACTIVATE | SWP_NOZORDER | SWP_SIZE | SWP_MOVE );
                               //SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOZORDER | SWP_SIZE | SWP_MOVE );
        }
    }
    return( true );
}
Ejemplo n.º 9
0
bool GetExtent( gui_window * wnd, const char * text, size_t length, gui_coord *coord )
{
    size_t    my_length;
    bool      got_new;

    if( wnd && text ) {
        got_new = GUIGetTheDC( wnd );
        my_length = strlen( text );
        if( length != (size_t)-1 ) {
            if( my_length > length ) {
                my_length = length;
            }
        }
        GUIGetTextExtent( wnd, text, my_length, &coord->x, &coord->y );
        if( got_new ) {
            GUIReleaseTheDC( wnd );
        }
        GUIScreenToScaleR( coord );
        return( true );
    }
    return( false );
}
Ejemplo n.º 10
0
WPI_MRESULT CALLBACK GUIWindowProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam,
                                    WPI_PARAM2 lparam )
{
    gui_window          *wnd;
    gui_window          *root;
    WORD                param;
    WPI_POINT           currentpoint;
    gui_coord           point;
    gui_coord           size;
    WPI_MRESULT         ret;
    WPI_MINMAXINFO _W386FAR *info;
    WPI_RECT            rect;
    HWND                parent;
    CREATESTRUCT FAR    *lpcs;
    wmcreate_info _W386FAR *wmcreateinfo;
    gui_create_info     *createinfo;
    bool                use_defproc;
    unsigned            control_id;
    HWND                win;
#ifndef __OS2_PM__
    gui_key_state       key_state;
    RECT                rc;
#endif

    root = NULL;
    ret = 0L;
    use_defproc = FALSE;
    if( msg == WM_CREATE ) {
        lpcs = ( CREATESTRUCT FAR * )MK_FP32( (void *)lparam );
        wmcreateinfo = (wmcreate_info _W386FAR *)MK_FP32( _wpi_getcreateparms( lpcs ) );
        if ( wmcreateinfo != NULL ) {
            wnd = wmcreateinfo->wnd;
            createinfo = wmcreateinfo->info;
            if( wnd->hwnd == NULLHANDLE ) {
#ifdef __OS2_PM__
                if( wnd->root_frame != NULLHANDLE && wnd->root == NULLHANDLE ) {
                    wnd->root = hwnd;
                } else {
                    wnd->hwnd = hwnd;
                }
#else
                if( _wpi_getparent( hwnd ) == HWND_DESKTOP ) {
                    wnd->root       = hwnd;
                    wnd->root_frame = hwnd;
                } else {
                    wnd->hwnd       = hwnd;
                    wnd->hwnd_frame = hwnd;
                }
#endif
            }
            DoSetWindowLong( hwnd, wnd );
        }
    }
    wnd = GUIGetWindow( hwnd );
    if( wnd == NULL ) {
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
    }

    if( GUIMDIProcessMessage( wnd, hwnd, msg, wparam, lparam, &ret ) ) {
        return( ret );
    }

    if( wnd->root == hwnd ) {
        /* message for root window */
        switch( msg ) {
        case WM_CREATE :
#ifdef __OS2_PM__
            wnd->root_pinfo.normal_pres =
                _wpi_createos2normpres( GUIMainHInst, hwnd );
#endif
            _wpi_getclientrect( wnd->root_frame, &wnd->root_client );
            if( CreateBackgroundWnd( wnd, createinfo ) ) {
                return( 0 );
            }
            return( (WPI_MRESULT)WPI_ERROR_ON_CREATE );
            break;
        case WM_DESTROY :
            wnd->flags |= DOING_DESTROY;
            GUICloseToolBar( wnd );
            //ret =  _wpi_defwindowproc( hwnd, msg, wparam, lparam );
            //wnd->root       = NULL;
            //wnd->root_frame = NULL;
            return( 0L );
        }
    } else if( ( wnd->root != NULLHANDLE ) && ( hwnd == wnd->hwnd ) ) {
        /* message for container window */
        switch( msg ) {
        case WM_SIZE :
            if( !_wpi_isiconic( _wpi_getframe( hwnd ) ) ) {
                size.x = _wpi_getwmsizex( wparam, lparam );
                size.y = _wpi_getwmsizey( wparam, lparam );
                GUIDoResize( wnd, hwnd, &size );
            }
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
            break;
        case WM_MOVE :
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
            break;
        case WM_VSCROLL :
        case WM_HSCROLL :
        case WM_CLOSE :
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
            break;
        }
    }

    switch( msg ) {
    case WM_CREATE :
#ifdef __OS2_PM__
        wnd->hwnd_pinfo.normal_pres =
            _wpi_createos2normpres( GUIMainHInst, hwnd );
#endif
        NumWindows++; // even if -1 is returned, window will get WM_DESTROY
        win = GUIGetParentFrameHWND( wnd );
        if( (  wnd->root_frame != NULLHANDLE ) ||
            ( createinfo->style & GUI_POPUP ) ) {
            if( !GUIAddToSystemMenu( wnd, win, 0, NULL,
                                     createinfo->style ) ) {
                return( (WPI_MRESULT)WPI_ERROR_ON_CREATE );
            }
        } else {
            if( !GUIAddToSystemMenu( wnd, win, createinfo->num_menus,
                                createinfo->menu, createinfo->style ) ) {
                return( (WPI_MRESULT)WPI_ERROR_ON_CREATE );
            }
        }
        _wpi_getclientrect( hwnd, &wnd->hwnd_client );
        GUISetRowCol( wnd, NULL );
        if( ( hwnd == wnd->hwnd ) && ( wnd->root == NULLHANDLE ) ) {
            GUIMDINewWindow( hwnd );
        }
        if( GUIEVENTWND( wnd, GUI_INIT_WINDOW, NULL ) ) {
            wnd->flags |= SENT_INIT;
            GUISetScroll( wnd ); /* initalize scroll ranges */
            GUIBringToFront( wnd );
            return( 0 );
        } else {
            /* app decided not to create window */
            return( (WPI_MRESULT)WPI_ERROR_ON_CREATE );
        }
        break;
#if defined(__NT__) || defined(WILLOWS)
    case WM_CTLCOLORBTN :
    case WM_CTLCOLORDLG :
    //case WM_CTLCOLORLISTBOX :
    case WM_CTLCOLORSTATIC :
    //case WM_CTLCOLOREDIT :
        ret = (WPI_MRESULT)GUICtl3dCtlColorEx( msg, wparam, lparam );
        if( ret == (HBRUSH)NULL ) {
            SetBkColor( (HDC)wparam, GetNearestColor( (HDC)wparam,
                        GUIGetBack( wnd, GUI_BACKGROUND ) ) );
            ret = (WPI_MRESULT)wnd->bk_brush;
        }
        return( ret );
#elif !defined( __OS2_PM__ )
    case WM_CTLCOLOR :
        switch( HIWORD( lparam ) ) {
        case CTLCOLOR_BTN :
        case CTLCOLOR_DLG :
        case CTLCOLOR_EDIT :
        case CTLCOLOR_LISTBOX :
        case CTLCOLOR_MSGBOX :
        case CTLCOLOR_STATIC :
            ret = (WPI_MRESULT)GUICtl3dCtlColorEx( msg, wparam, lparam );
            if( ret == (HBRUSH)NULL ) {
                SetBkColor( (HDC)wparam, GetNearestColor( (HDC)wparam,
                            GUIGetBack( wnd, GUI_BACKGROUND ) ) );
                ret = (WPI_MRESULT)wnd->bk_brush;
            }
            break;
        }
        return( ret );
#endif
#ifndef __OS2_PM__
    case WM_INITMENUPOPUP :
        return( GUIProcessInitMenuPopup( wnd, hwnd, msg, wparam, lparam ) );

    case WM_MENUSELECT :
        return( GUIProcessMenuSelect( wnd, hwnd, msg, wparam, lparam ) );
#endif
    case WM_GETMINMAXINFO :
        info = (WPI_MINMAXINFO _W386FAR *)MK_FP32( (void *)lparam );
        ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam );
        if( wnd->root == NULLHANDLE ) {
            parent = _wpi_getparent( hwnd );
            _wpi_getclientrect( parent, &rect );
            _wpi_setmaxposition( *info, 0, 0 );
            _wpi_setmaxtracksize( info, _wpi_getwidthrect( rect ),
                             _wpi_getheightrect( rect ) );
        }
        return( ret );
    case WM_ERASEBKGND:
#ifdef __OS2_PM__
        //GUIInvalidatePaintHandles( wnd );
        return( (WPI_MRESULT)TRUE );
#else
        if( !_wpi_isiconic( hwnd ) ) {
            GetClientRect( hwnd, &rc );
            FillRect( (HDC)wparam, &rc, wnd->bk_brush );
        }
        use_defproc = TRUE;
        break;
#endif
#if !defined(__OS2_PM__) && !defined(WILLOWS)
    case WM_PAINTICON :
    {
        HICON   old;
        old = SET_HICON( wnd->hwnd, wnd->icon );
        ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam );
        SET_HICON( wnd->hwnd, old );
        return( ret );
    }
#endif
    case WM_PAINT:
        if( _wpi_isiconic( hwnd ) ) {
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
        } else {
            GUIPaint( wnd, hwnd, FALSE );
        }
        break;
#ifndef __OS2_PM__
    case WM_ACTIVATEAPP :
        root = GUIGetRootWindow();
        ActivateNC( root, wparam );
        if( GUICurrWnd != NULL ) {
            ActivateNC( GUICurrWnd, wparam );
        }
        use_defproc = (bool)wparam; // I'm cheating and using 'use_defproc'
                                    // outside of its self-documented purpose
        if( root ) GUIEVENTWND( root, GUI_ACTIVATEAPP, &use_defproc );
        use_defproc = TRUE;
        break;
#if 0
    // this repaints the nc client area when the window loses focus to
    // a window that is not a descendant of a GUI window
    case WM_KILLFOCUS :
        if( !GUIIsGUIChild( (HWND)wparam ) ) {
            ActivateNC( wnd, FALSE );
        }
        break;
#endif
    case WM_SETFOCUS :
        if( !_wpi_ismsgsetfocus( msg, lparam ) ) {
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
        }
        if( !EditControlHasFocus ) {
            if( SetFocusToParent() ) {
                return( 0L );
            }
        }
        break;
#endif
    case WM_VSCROLL :
    case WM_HSCROLL :
        GUIProcessScrollMsg( wnd, msg, wparam, lparam );
        return( 0L );
#ifdef __NT__
    case WM_MOUSEWHEEL :
        {
        // Try to handle mousewheel messages...
        // Fake them into GUIProcessScrollMsg()
        // as "normal" vertical scroll messages.
        short gcWheelDelta; //wheel delta from roll
        WORD  wKey;

        // The wnd I get is not the same as WM_VSCROLL : above gets...
        // Note to self: Fix it...
        // Seems like the main app window gets the message, rather than
        // the MDI clients...

        gcWheelDelta = HIWORD(wparam);
        wKey = LOWORD(wparam);
        // Scroll wheel upwards  gives  120
        //    "     "   downward   "   -120
        if( wnd != GUICurrWnd ) // Send to child window with focus
            wnd = GUICurrWnd;
        if( gcWheelDelta > 0 ) {
            // positive - scroll up
            if( wKey == MK_CONTROL || wKey == MK_SHIFT )
               GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_PAGEUP, 0L );
            else
               GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_LINEUP, 0L );
        } else {
            // negative - scroll down
            if( wKey == MK_CONTROL || wKey == MK_SHIFT )
               GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_PAGEDOWN, 0L );
            else
               GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_LINEDOWN, 0L );
        }
        // Inform GUI system we are done with scrolling for now.
        GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_ENDSCROLL, 0 );
        }
        return( 0L );
#endif
    case WM_MOVE :
        use_defproc = TRUE;
        if( wnd->flags & DOING_CLOSE ) {
            break;
        }
        if( !GUIParentHasFlags( wnd, IS_MINIMIZED ) ) {
            GUIEVENTWND( wnd, GUI_MOVE, NULL );
        }
        use_defproc = TRUE;
        break;
    case WM_SIZE:
        use_defproc = TRUE;
        if( wnd->flags & DOING_CLOSE ) {
            break;
        }
        if( _wpi_isiconic( _wpi_getframe( hwnd ) ) ) {
            wnd->flags |= IS_MINIMIZED;
            if( wnd->style & GUI_CHANGEABLE_FONT ) {
                GUIEnableSysMenuItem( wnd, GUI_CHANGE_FONT, FALSE );
            }
            GUIEVENTWND( wnd, GUI_ICONIFIED, NULL );
            if( GUIMDI ) {
                GUIBringNewToFront( wnd );
            }
        } else {
            wnd->flags &= ~IS_MINIMIZED;
            size.x = _wpi_getwmsizex( wparam, lparam );
            size.y = _wpi_getwmsizey( wparam, lparam );
            GUIDoResize( wnd, hwnd, &size );
            if( wnd->flags & IS_ROOT ) {
                win = GUIGetParentFrameHWND( wnd );
                if( !_wpi_isiconic( win ) ) {
                    GUIMaximizeZoomedChildren( wnd );
                }
            }
        }
        //Call back to tell about resizing so system tray can be used
        WndSizeChange( hwnd, wparam, lparam );
        break;
    case WM_MOUSEMOVE:
        currentpoint.x = GET_WM_MOUSEMOVE_POSX( wparam, lparam );
        currentpoint.y = GET_WM_MOUSEMOVE_POSY( wparam, lparam );
        point.x = currentpoint.x;
        point.y = currentpoint.y;
        GUIScreenToScaleR( &point );
        if( ( currentpoint.x != prevpoint.x ) ||
            ( currentpoint.y != prevpoint.y ) ) {
            prevpoint.x = currentpoint.x;
            prevpoint.y = currentpoint.y;
            SendPointEvent( wparam, lparam, wnd, GUI_MOUSEMOVE, TRUE );
        }
        break;
#ifndef __OS2_PM__
    case WM_NCLBUTTONDOWN :
    case WM_NCMBUTTONDOWN :
    case WM_NCRBUTTONDOWN :
        CheckDoFront( wnd );
        use_defproc = TRUE;
        break;
    case WM_RBUTTONDOWN:
        _wpi_setcapture( hwnd );
        CheckDoFront( wnd );
        SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDOWN, TRUE );
        break;
#else
    case WM_RBUTTONDOWN :
        WPI_MAKEPOINT( wparam, lparam, currentpoint );
        win = PM1632WinWindowFromPoint( hwnd, &currentpoint, FALSE );
        if( ( win != (HWND)NULL) && ( win != hwnd ) ) {
            control_id = _wpi_getdlgctrlid( win );
            if( control_id != 0 ) {
                GUIEVENTWND( wnd, GUI_CONTROL_RCLICKED, &control_id );
            }
        } else {
            _wpi_setcapture( hwnd );
            CheckDoFront( wnd );
            SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDOWN, TRUE );
        }
        break;
#endif
    case WM_LBUTTONDOWN:
        _wpi_setcapture( hwnd );
        CheckDoFront( wnd );
        SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONDOWN, TRUE );
        use_defproc = TRUE;
        break;
    case WM_LBUTTONUP:
        _wpi_releasecapture();
        SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONUP, TRUE );
        use_defproc = TRUE;
        break;
    case WM_RBUTTONUP:
        _wpi_releasecapture();
        SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONUP, TRUE );
        break;
    case WM_LBUTTONDBLCLK:
        CheckDoFront( wnd );
        SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONDBLCLK, TRUE );
        break;
    case WM_RBUTTONDBLCLK:
        CheckDoFront( wnd );
        SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDBLCLK, TRUE );
        break;
    case WM_SYSCOMMAND:
        param = _wpi_getid( wparam );
        switch( param ) {
            case SC_NEXTWINDOW :
                if( GUIMDI ) {
                    NextWndToFront( hwnd );
                    return( 0L );
                }
            default :
                if( ( param & 0xf000 ) == ( SC_NEXTWINDOW & 0xf000 ) ) {
                    /* top value same for all SC_* values */
                    return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
                } else {
                    ProcessMenu( wnd, param );
                }
                break;
        }
        break;
#ifdef __OS2_PM__
    case WM_CONTROL :
        GUIProcessControlNotification( SHORT1FROMMP(wparam),
                                       SHORT2FROMMP(wparam), wnd );
        break;
#else
    case WM_PARENTNOTIFY:
        if( ( LOWORD(wparam) == WM_RBUTTONDOWN ) ||
            ( LOWORD(wparam) == WM_LBUTTONDOWN ) ||
            ( LOWORD(wparam) == WM_MBUTTONDOWN ) ) {
            if( wnd->root == NULLHANDLE ) {
                CheckDoFront( wnd );
            }
        }

        if( LOWORD(wparam) == WM_RBUTTONDOWN ) {
            WPI_MAKEPOINT( wparam, lparam, currentpoint );
            MapWindowPoints( hwnd, (HWND)NULL, &currentpoint, 1 );
            win = _wpi_windowfrompoint( currentpoint );
            control_id = _wpi_getdlgctrlid( win );
            if( control_id != 0 ) {
                if( _wpi_getparent(win) == hwnd ) {
                    GUIEVENTWND( wnd, GUI_CONTROL_RCLICKED, &control_id );
                }
            }
        }
        break;
    case WM_ENDSESSION : {
        gui_end_session     es;

        es.endsession = (bool)wparam;
        es.logoff = (bool)( lparam == 0x80000000L );
        GUIEVENTWND( wnd, GUI_ENDSESSION, &es );
        return( 0L );
    }
    case WM_QUERYENDSESSION : {
        gui_end_session     es;

        es.endsession = (bool)wparam;
        es.logoff = (bool)( lparam == 0x80000000L ); // ENDSESSION_LOGOFF
        if( !GUIEVENTWND( wnd, GUI_QUERYENDSESSION, &es ) ) {
            return( TRUE );
        }
        return( 0L );
    }
#endif
    case WM_COMMAND:
        if( _wpi_ismenucommand( wparam, lparam ) ||
            IsToolBarCommand( wnd, wparam, lparam ) ) { /* from menu or toolbar */
            ProcessMenu( wnd, _wpi_getid( wparam ) );
            //SetFocusToParent();
        } else {
            GUIProcessControlMsg( wparam, lparam, wnd, NULL );
        }
        use_defproc = TRUE;
        break;
#ifndef __OS2_PM__
    case WM_VKEYTOITEM :
        use_defproc = FALSE;
        ret = -1;
        GUIGetKeyState( &key_state.state );
        if( ( GUIWindowsMapKey( wparam, lparam, &key_state.key ) ) ) {
            ret = GUIEVENTWND( wnd, GUI_KEYTOITEM, &key_state );
        }
        break;
#endif
#ifdef __OS2_PM__
    case WM_CHAR :
    case WM_TRANSLATEACCEL :
#else
    case WM_MENUCHAR :
    case WM_SYSKEYDOWN :
    case WM_SYSKEYUP :
    case WM_KEYUP :
    case WM_KEYDOWN :
#endif
        return( GUIProcesskey( hwnd, msg, wparam, lparam ) );
    case WM_CLOSE :
        if( wnd->flags & DOING_CLOSE ) {
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
        } else if( wnd->style & GUI_CLOSEABLE ) {
            if( GUIEVENTWND( wnd, GUI_CLOSE, NULL ) ) {
                wnd->flags |= DOING_CLOSE;
                if( wnd->flags & IS_ROOT ) {
                    return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
                } else {
                    _wpi_destroywindow( wnd->hwnd_frame );
                }
            }
        }
        return( 0L );

    // Message to deal with tray icons (Win 95 and NT 4.0 ).
    case WM_TRAYCALLBACK :
        TrayCallBack( hwnd, wparam, lparam );
        return( 0L );

    case WM_DESTROY :
        wnd->flags |= DOING_DESTROY;
        NumWindows--;
        GUIEVENTWND( wnd, GUI_DESTROY, NULL );
        //ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam );
        GUIDestroyAllChildren( wnd );
        if( wnd->flags & IS_ROOT ) {
            GUIDestroyAllPopupsWithNoParent();
        }
        GUIFreeWindowMemory( wnd, FALSE, FALSE );
        if( NumWindows == 0 ) {
            _wpi_postquitmessage( 0 );
            Posted = TRUE;
        }
        return( 0L );
    default:
        use_defproc = TRUE;
    }

    if( use_defproc ) {
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
    } else {
        return( ret );
    }
}