Example #1
0
/*------------------------------------------------------------------------
Procedure:     MsgMenuSelect ID:1
Purpose:       Shows in the status bar a descriptive explaation of
the purpose of each menu item.The message
WM_MENUSELECT is sent when the user starts browsing
the menu for each menu item where the mouse passes.
Input:         Standard windows.
Output:        The string from the resources string table is shown
Errors:        If the string is not found nothing will be shown.
------------------------------------------------------------------------*/
LRESULT MsgMenuSelect(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
	static char szBuffer[256];
	UINT   nStringID = 0;
	UINT   fuFlags = GET_WM_MENUSELECT_FLAGS(wparam, lparam) & 0xffff;
	UINT   uCmd    = GET_WM_MENUSELECT_CMD(wparam, lparam);
	HMENU  hMenu   = GET_WM_MENUSELECT_HMENU(wparam, lparam);

	szBuffer[0] = 0;                            // First reset the buffer
	if (fuFlags == 0xffff && hMenu == NULL)     // Menu has been closed
		nStringID = 0;

	else if (fuFlags & MFT_SEPARATOR)           // Ignore separators
		nStringID = 0;

	else if (fuFlags & MF_POPUP)                // Popup menu
	{
		if (fuFlags & MF_SYSMENU)               // System menu
			nStringID = IDS_SYSMENU;
		else
			// Get string ID for popup menu from idPopup array.
			nStringID = 0;
	}  // for MF_POPUP
	else                                        // Must be a command item
		nStringID = uCmd;                       // String ID == Command ID

	// Load the string if we have an ID
	if (0 != nStringID)
		LoadString(hInst, nStringID, szBuffer, sizeof(szBuffer));
	// Finally... send the string to the status bar
	UpdateStatusBar(szBuffer, 0, 0);
	return 0;
}
Example #2
0
void WHandleMenuSelect( WStatBar *wsb, HMENU menu, WPARAM wParam, LPARAM lParam )
{
    HMENU   popup;
    WORD    flags;

    if( wsb == NULL || menu == NULL ) {
        return;
    }

    flags = GET_WM_MENUSELECT_FLAGS( wParam, lParam );

    if( flags == (WORD)-1 && GET_WM_MENUSELECT_HMENU( wParam, lParam ) == (HMENU)NULL ) {
        WSetStatusText( wsb, NULL, "" );
    } else if( flags & (MF_SYSMENU | MF_SEPARATOR) ) {
        WSetStatusText( wsb, NULL, "" );
    } else if( flags & MF_POPUP ) {
        popup = (HMENU)GET_WM_MENUSELECT_ITEM( wParam, lParam );
#ifdef __NT__
        popup = GetSubMenu( (HMENU)lParam, (int)popup );
#endif
        WHandlePopupHint( wsb, menu, popup );
    } else {
        WDisplayHint( wsb, (int)GET_WM_MENUSELECT_ITEM( wParam, lParam ) );
    }
}
Example #3
0
void 
GetMenuSelect ( HWND hWndStatus, UINT message, 
			WPARAM wParam, LPARAM lParam) 
{
	UINT nStringID = 0;

	UINT fuFlags = GET_WM_MENUSELECT_FLAGS(wParam, lParam) & 0xffff;
	UINT uCmd = GET_WM_MENUSELECT_CMD(wParam, lParam);
	HMENU hMenu = GET_WM_MENUSELECT_HMENU(wParam, lParam);

	if (fuFlags == 0xffff && hMenu == (HMENU)NULL)
		nStringID = (UINT) -1;

	else if (fuFlags & MF_SEPARATOR)
		nStringID = 0;

	else if (fuFlags & MF_POPUP)
	{
		if (fuFlags & MF_SYSMENU)
			nStringID = 0;
	}
	else
	{
		nStringID = uCmd;
	}
	DisplayStatusMenuHelp(hWndStatus, nStringID);
}
Example #4
0
void WHandleMenuSelect( WMenuEditInfo *einfo, WPARAM wParam, LPARAM lParam )
{
    WMenuEntry  *entry;
    HWND        lbox;
    HMENU       popup;
    WORD        flags;
    WORD        id;
    int         pos;

    if( !einfo || !einfo->menu || ! einfo->menu->first_entry ) {
        return;
    }

    lbox = GetDlgItem ( einfo->edit_dlg, IDM_MENUEDLIST );
    if( lbox == (HWND)NULL ) {
        return;
    }

    flags = GET_WM_MENUSELECT_FLAGS(wParam,lParam);

    entry = NULL;

    if( ( flags == (WORD)-1 ) &&
         ( GET_WM_MENUSELECT_HMENU(wParam,lParam) == (HMENU)NULL ) ) {
        // we ignore WM_MENUSELECT when a menu is closing
    } else if( flags & MF_SYSMENU ) {
        // we ignore WM_MENUSELECT for the system menu
    } else if( flags & MF_SEPARATOR ) {
        // we ignore WM_MENUSELECT for separators, for now...
    } else if( flags & MF_POPUP ) {
        popup = (HMENU) GET_WM_MENUSELECT_ITEM(wParam,lParam);
        #ifdef __NT__
            popup = GetSubMenu( (HMENU)lParam, (int)popup );
        #endif
        entry = WFindEntryFromPreviewPopup( einfo->menu->first_entry, popup );
    } else {
        id = GET_WM_MENUSELECT_ITEM(wParam,lParam);
        entry = WFindEntryFromPreviewID( einfo->menu->first_entry, id );
    }

    if( entry == NULL ) {
        return;
    }

    pos = 0;

    if ( WFindEntryLBPos( einfo->menu->first_entry, entry, &pos ) ) {
        pos--;
        einfo->current_entry = NULL;
        einfo->current_pos   = -1;
        if( SendMessage ( lbox, LB_SETCURSEL, (WPARAM) pos, 0 ) != LB_ERR ) {
            WHandleSelChange ( einfo );
        }
    }
}
Example #5
0
void setLastMenuSelect( WAccelEditInfo *einfo, WPARAM wParam, LPARAM lParam )
{
    WORD flags;

    flags = GET_WM_MENUSELECT_FLAGS( wParam, lParam );

    if( flags == (WORD)-1 && GET_WM_MENUSELECT_HMENU( wParam, lParam ) == (HMENU)NULL ) {
        einfo->last_menu_select = -1;
    } else if( flags & (MF_SYSMENU | MF_SEPARATOR | MF_POPUP) ) {
        einfo->last_menu_select = -1;
    } else {
        einfo->last_menu_select = GET_WM_MENUSELECT_ITEM( wParam, lParam );
    }
}
Example #6
0
void GUIPopupMenuSelect( WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    bool                menu_closed;
    gui_ctl_id          id;
    bool                is_hilite;
#ifdef __OS2_PM__
    WPI_MENUSTATE       mstate;
    HMENU               hmenu;
#endif

    lparam=lparam;
    id = GET_WM_MENUSELECT_ITEM( wparam, lparam );
    menu_closed = ( _wpi_is_close_menuselect( wparam, lparam ) != 0 );

#ifndef __OS2_PM__
    is_hilite = ( (GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_HILITE) != 0 );
#else
    hmenu = (HMENU)lparam;
    if( !menu_closed &&
        !WinSendMsg( hmenu, MM_QUERYITEM, MPFROM2SHORT(id, true),
                     MPFROMP(&mstate) ) ) {
        return;
    }
    is_hilite = ( (mstate.afAttribute & MF_HILITE) != 0 );
#endif

    if( menu_closed ) {
        CurrId = NO_SELECT;
    } else {
        if( !InitComplete ) {
            InitComplete = true;
        } else {
            if( is_hilite ) {
                CurrId = id;
            }
        }
    }
}
Example #7
0
void WdeHandleMenuSelect( WPARAM wParam, LPARAM lParam )
{
    HMENU   menu;
    HMENU   popup;
    WORD    flags;

    menu = WdeGetMenuHandle();
    flags = GET_WM_MENUSELECT_FLAGS( wParam, lParam );

    if( flags == (WORD)-1 && GET_WM_MENUSELECT_HMENU( wParam, lParam ) == (HMENU)NULL ) {
        WdeSetStatusText( NULL, "", TRUE );
    } else if( flags & (MF_SYSMENU | MF_SEPARATOR) ) {
        WdeSetStatusText( NULL, "", TRUE );
    } else if( flags & MF_POPUP ) {
        popup = (HMENU)GET_WM_MENUSELECT_ITEM( wParam, lParam );
#ifdef __NT__
        popup = GetSubMenu( (HMENU)lParam, (int)popup );
#endif
        WdeHandlePopupHint( menu, popup );
    } else {
        WdeDisplayHint( (int)GET_WM_MENUSELECT_ITEM( wParam, lParam ) );
    }
}
Example #8
0
/*
 * HintMenuSelect - handle the WM_MENUSELECT message
 */
void HintMenuSelect( statwnd *wnd, HWND hwnd, WPARAM wparam, LPARAM lparam )
{
    HMENU       hmenu;
    WORD        flags;
    msg_id      msgid;

    if( MENU_CLOSED( wparam, lparam ) ) {
        updateHintText( wnd, HINT_EMPTY );
    } else {
        hmenu = GetMenu( hwnd );
        flags = GET_WM_MENUSELECT_FLAGS( wparam, lparam );
        if( flags & (MF_SYSMENU | MF_SEPARATOR) ) {
            updateHintText( wnd, HINT_EMPTY );
        } else if( flags & MF_POPUP ) {
            //
            // NYI handle popup message hints
            //
        } else {
            msgid = getItemMsg( wnd, GET_WM_MENUSELECT_ITEM( wparam, lparam ) );
            updateHintText( wnd, msgid );
        }
    }

} /* HintMenuSelect */
Example #9
0
/*
 * ImgEdFrameProc - handle messages for the image editor application
 */
WPI_MRESULT CALLBACK ImgEdFrameProc( HWND hwnd, WPI_MSG msg,
                                 WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static BOOL         window_destroyed = FALSE;
    static HMENU        hmenu;
    ctl_id              cmdid;
    img_node            *node;
    WPI_RECT            rcmain;
#ifndef __OS2_PM__
    about_info          ai;
#endif
    WPI_RECTDIM         left, top;

    if( !window_destroyed ) {
        enableMainItems( hmenu );
    }

    switch( msg ) {
    case UM_EXIT:
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );
        /* fall through */

    case UM_EXIT_NO_SAVE:
        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            break;
        }
#ifndef __OS2_PM__
        _wpi_destroywindow( _wpi_getframe( hwnd ) );
#else
        _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 );
#endif

        break;

    case UM_SAVE_ALL:
        SaveAllImages();
        break;

    case WM_CREATE:
        hmenu = _wpi_getmenu( _wpi_getframe( hwnd ) );
#ifndef __OS2_PM__
        createClientWindow( hwnd );
#endif
        if( !InitStatusLine( hwnd ) ) {
            return( -1 );
        }

        InitFunctionBar( hwnd );
        InitIconInfo();
        InitializeCursors();

        /*
         * Set values from profile information ...
         */
        if( ImgedConfigInfo.brush_size <= 5 && ImgedConfigInfo.brush_size >= 2 ) {
            checkBrushItem( hmenu, IMGED_2x2 - 2 + ImgedConfigInfo.brush_size );
        }
        if( ImgedConfigInfo.grid_on ) {
            CheckGridItem( hmenu );
        }
        if( ImgedConfigInfo.square_grid ) {
            CheckSquareGrid( hmenu );
        }
        if( ImgedConfigInfo.show_state & SET_SHOW_VIEW ) {
            CheckViewItem( hmenu );
        }

        _wpi_enablemenuitem( hmenu, IMGED_CRESET, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE );
#ifndef __OS2_PM__
        // not necessary for PM
        InitMenus( hmenu );
#endif
        SetHintText( IEAppTitle );
        return( 0 );
#ifdef __NT__
    case WM_DROPFILES:
        OpenImage( (HANDLE)wparam );
        break;
#endif
    case WM_MOVE:
        _wpi_getwindowrect( hwnd, &rcmain );
        if( !ImgedConfigInfo.ismaximized ) {
            ImgedConfigInfo.last_xpos = ImgedConfigInfo.x_pos;
            ImgedConfigInfo.last_ypos = ImgedConfigInfo.y_pos;
            _wpi_getrectvalues( rcmain, &left, &top, NULL, NULL );
            ImgedConfigInfo.x_pos = (short)left;
            ImgedConfigInfo.y_pos = (short)top;
        }
        return( 0 );

    case WM_SIZE:
        ResizeFunctionBar( lparam );
        ResizeStatusBar( lparam );
#ifndef __OS2_PM__
        if( ClientWindow != NULL ) {
            setClientSize( hwnd );
        }
#else
        resizeClientArea( lparam );
#endif

        if( !_imgwpi_issizeminimized( wparam ) && !_imgwpi_issizemaximized( wparam ) ) {
            _wpi_getwindowrect( hwnd, &rcmain );
            ImgedConfigInfo.width = (short)_wpi_getwidthrect( rcmain );
            ImgedConfigInfo.height = (short)_wpi_getheightrect( rcmain );
            ImgedConfigInfo.ismaximized = FALSE;
        } else {
            ImgedConfigInfo.x_pos = ImgedConfigInfo.last_xpos;
            ImgedConfigInfo.y_pos = ImgedConfigInfo.last_ypos;
            ImgedConfigInfo.ismaximized = _imgwpi_issizemaximized( wparam );
        }
        return( FALSE );

    case WM_MENUSELECT:
#ifndef __OS2_PM__
        if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SEPARATOR ) {
            break;
        }
        if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SYSMENU ) {
            PrintHintTextByID( WIE_SYSMENUOPERATIONS, NULL );
            break;
        }
#endif
        ShowHintText( LOWORD( wparam ) );
        break;

    case WM_COMMAND:
        cmdid = LOWORD( wparam );
        if( !IEIsMenuIDValid( hmenu, cmdid ) ) {
            break;
        }
        switch( cmdid ) {
        case IMGED_NEW:
            if( !ImgedIsDDE ) {
                if( !NewImage( UNDEF_IMG, NULL ) ) {
                    PrintHintTextByID( WIE_NEIMAGENOTCREATED, NULL );
                }
            }
            break;

        case IMGED_CLOSE:
            node = GetCurrentNode();
            if( node != NULL ) {
                _wpi_sendmessage( node->hwnd, WM_CLOSE, 0, 0L );
            }
            break;

        case IMGED_CLOSEALL:
            CloseAllImages();
            break;

        case IMGED_HELP:
            IEHelpRoutine();
            break;

        case IMGED_HELP_SEARCH:
            IEHelpSearchRoutine();
            break;

        case IMGED_HELP_ON_HELP:
            IEHelpOnHelpRoutine();
            break;

        case IMGED_ABOUT:
#ifndef __OS2_PM__
            ai.owner = hwnd;
            ai.inst = Instance;
            ai.name = IEAllocRCString( WIE_ABOUTTEXT );
            ai.version = IEAllocRCString( WIE_ABOUTVERSION );
            ai.title = IEAllocRCString( WIE_ABOUTTITLE );
            DoAbout( &ai );
            if( ai.name != NULL ) {
                IEFreeRCString( ai.name );
            }
            if( ai.version != NULL ) {
                IEFreeRCString( ai.version );
            }
            if( ai.title != NULL ) {
                IEFreeRCString( ai.title );
            }
#endif
            break;

#ifndef __OS2_PM__
        case IMGED_DDE_UPDATE_PRJ:
            IEUpdateDDEEditSession();
            break;
#endif

        case IMGED_SAVE_AS:
            SaveFile( SB_SAVE_AS );
            break;

        case IMGED_SAVE:
            SaveFile( SB_SAVE );
            break;

        case IMGED_OPEN:
            if( !ImgedIsDDE ) {
                OpenImage( NULL );
            }
            break;

        case IMGED_CLEAR:
            ClearImage();
            break;

        case IMGED_NEWIMG:
            AddNewIcon();
            break;

        case IMGED_SELIMG:
            SelectIconImg();
            break;

        case IMGED_DELIMG:
            DeleteIconImg();
            break;

        case IMGED_UNDO:
            UndoOp();
            break;

        case IMGED_REDO:
            RedoOp();
            break;

        case IMGED_REST:
            RestoreImage();
            break;

        case IMGED_SNAP:
#ifndef __OS2_PM__
            SnapPicture();
#endif
            break;

        case IMGED_RIGHT:
        case IMGED_LEFT:
        case IMGED_UP:
        case IMGED_DOWN:
            ShiftImage( cmdid );
            break;

        case IMGED_FLIPHORZ:
        case IMGED_FLIPVERT:
            FlipImage( cmdid );
            break;

        case IMGED_ROTATECC:
        case IMGED_ROTATECL:
            RotateImage( cmdid );
            break;

        case IMGED_PASTE:
            PlaceAndPaste();
            break;

        case IMGED_COPY:
            IECopyImage();
            break;

        case IMGED_CUT:
            CutImage();
            break;

        case IMGED_COLOR:
            CheckPaletteItem( hmenu );
            break;

        case IMGED_VIEW:
            CheckViewItem( hmenu );
            break;

        case IMGED_TOOLBAR:
            CheckToolbarItem( hmenu );
            break;

        case IMGED_SQUARE:
            CheckSquareGrid( hmenu );
            break;

        case IMGED_SIZE:
            ChangeImageSize();
            break;

        case IMGED_GRID:
            CheckGridItem( hmenu );
            break;

        case IMGED_MAXIMIZE:
            MaximizeCurrentChild();
            break;

        case IMGED_SETTINGS:
            SelectOptions();
            break;

        case IMGED_2x2:
        case IMGED_3x3:
        case IMGED_4x4:
        case IMGED_5x5:
            checkBrushItem( hmenu, cmdid );
            break;

        case IMGED_CEDIT:
#ifndef __OS2_PM__
            EditColors();
#endif
            break;

        case IMGED_CRESET:
#ifndef __OS2_PM__
            RestoreColors();
#endif
            break;

        case IMGED_CSCREEN:
            ChooseBkColor();
            break;

        case IMGED_SCOLOR:
#ifndef __OS2_PM__
            SaveColorPalette();
#endif
            break;

        case IMGED_LCOLOR:
#ifndef __OS2_PM__
            if( LoadColorPalette() ) {
                _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, TRUE, FALSE );
            }
#endif
            break;

        case IMGED_RCOLOR:
            RestoreColorPalette();
            break;

        case IMGED_FREEHAND:
        case IMGED_LINE:
        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
        case IMGED_FILL:
        case IMGED_BRUSH:
        case IMGED_CLIP:
        case IMGED_HOTSPOT:
            SetToolType( cmdid );
            PushToolButton( cmdid );
            break;

        case IMGED_ARRANGE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDIICONARRANGE, 0, 0L );
#endif
            break;

        case IMGED_TILE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDITILE, MDITILE_VERTICAL, 0L );
#endif
            break;

        case IMGED_CASCADE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDICASCADE, MDITILE_SKIPDISABLED, 0L );
#endif
            break;

        case IMGED_EXIT:
            _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );

            if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
                break;
            }
#ifndef __OS2_PM__
            _wpi_destroywindow( _wpi_getframe( hwnd ) );
#else
            _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 );
#endif
            break;

        default:
#if 1
            return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) );
#else
            return( 0 );
#endif
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_COMPACTING:
        RelieveUndos();
        return 0;
#endif

    case WM_QUERYENDSESSION:
        if( _wpi_isiconic( _wpi_getframe( hwnd ) ) ) {
            if( ImgedConfigInfo.ismaximized ) {
                _wpi_maximizewindow( _wpi_getframe( hwnd ) );
            } else {
                _wpi_showwindow( _wpi_getframe( hwnd ), SW_SHOWNORMAL );
            }
        }
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );

        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            return( 0 );
        }
        return( (WPI_MRESULT)1 );

    case WM_CLOSE:
        // wParam is non-zero if the DDE connection died
        if( !wparam && !ImgEdEnableMenuInput ) {
            // this prevents the user from closing the editor during
            // DDE initialization
            return( 0 );
        }
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );
#ifdef __OS2_PM__
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
#else

        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            return( 0 );
        }
        window_destroyed = TRUE;
        _wpi_destroywindow( _wpi_getframe( hwnd ) );
        return( 0 );
#endif

    case WM_DESTROY:
#ifndef __OS2_PM__
        WWinHelp( HMainWindow, "resimg.hlp", HELP_QUIT, 0 );
#endif
        FiniStatusLine();
        CleanupClipboard();
        CleanupCursors();
        CloseToolBar();
        CloseFunctionBar();
        _wpi_deletefont( SmallFont );
        _wpi_postquitmessage( 0 );
        return( 0 );
    default:
        break;
    }
    return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) );

} /* ImgEdFrameProc */
Example #10
0
static void DisplayMenuHintText( gui_window *wnd, WPI_PARAM1 wparam,
                                 WPI_PARAM2 lparam, hint_type type )
{
    gui_window          *top_wnd;
    gui_menu_styles     style;
    gui_ctl_id          id;
    HMENU               hpopup;
    int                 menu_closed;
    int                 is_separator;
    int                 is_popup;
    int                 is_hilite;
    int                 is_enabled;
    int                 is_sysmenu;
#ifndef __OS2_PM__
    WORD                flags;
#else
    WPI_MENUSTATE       mstate;
    HMENU               hmenu;
#endif

    lparam = lparam;
    id = GET_WM_MENUSELECT_ITEM( wparam, lparam );
    menu_closed = _wpi_is_close_menuselect( wparam, lparam );

#ifndef __OS2_PM__
    flags = GET_WM_MENUSELECT_FLAGS( wparam, lparam );
    is_sysmenu = ( flags & MF_SYSMENU );
    is_separator = ( flags & MF_SEPARATOR );
    is_hilite = ( flags & MF_HILITE );
    is_popup = ( flags & MF_POPUP );
    is_enabled = ( ( flags & MF_GRAYED ) || ( flags & MF_DISABLED ) );
    hpopup = (HMENU)NULL;
    if( is_popup ) {
        hpopup = (HMENU)GET_WM_MENUSELECT_ITEM( wparam, lparam );
    }
#else
    hmenu = (HMENU) lparam;
    if( !menu_closed &&
        WinSendMsg( hmenu, MM_QUERYITEM, MPFROM2SHORT(id, true),
                    MPFROMP(&mstate) ) ) {
        is_sysmenu = ( mstate.afStyle & MF_SYSMENU );
        is_separator = false;
        is_popup = ( mstate.afStyle & MF_POPUP );
        is_hilite = ( mstate.afAttribute & MF_HILITE );
        is_enabled = ( mstate.afAttribute & MF_DISABLED );
        hpopup = (HMENU)NULL;
        if( is_popup ) {
            hpopup = mstate.hwndSubMenu;
        }
    } else {
        menu_closed = true;
    }
#endif

    if( !( menu_closed || is_separator || is_hilite ) ) {
        return;
    }

    top_wnd = GUIGetTopGUIWindow( wnd->hwnd );
    if( top_wnd == NULL ) {
        return;
    }


    if( menu_closed ) {
        style = GUI_IGNORE; /* will display blank */
    } else {
        if( is_separator ) {
            style = GUI_SEPARATOR; /* will display blank */
        } else {
            /* must be MF_HILITE */
            if( is_enabled ) {
                style = GUI_GRAYED;
            } else {
                style = GUI_ENABLED;
            }
            if( is_sysmenu ) {
                if( id > GUI_LAST_MENU_ID ) {
                    /* menu item added by GUI */
                    type = GUI_HINT;
                }
            }
            if( is_popup ) {
                if( !GetPopupId( wnd, hpopup, &id ) ) {
                    style = GUI_IGNORE; /* will display blank */
                }
            }
        }
    }

    GUIDisplayHintText( top_wnd, wnd, id, type, style );
}
Example #11
0
WINDOWPROC MainWndProc(
    HWND hwnd,
    UINT msg,
    WPARAM wParam,
    LONG lParam)
{
    switch (msg) {
        case WM_CREATE:
            {
                RECT rc;

                /*
                 * Create the status window.
                 */
                CreateDialog(ghInst, MAKEINTRESOURCE(DID_STATUS),
                        hwnd, StatusDlgProc);

                /*
                 * Save away its height for sizing later (like when
                 * the app is minimized then restored).
                 */
                GetWindowRect(hwndStatus, &rc);
                gcyStatus = rc.bottom - rc.top;

                ghwndSubClient = CreateWindow(szSubClientClass, NULL,
                        WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
                        hwnd, NULL, ghInst, NULL);

                ghMenuMain = GetMenu(hwnd);
                LoadMenuBitmaps(ghMenuMain);
            }

            break;

        case WM_ACTIVATE:
            /*
             * If the main window is getting activated, there is no
             * currently active dialog.
             */
            if (GET_WM_ACTIVATE_STATE(wParam, lParam))
                gidCurrentDlg = 0;

            goto DoDefault;

        case WM_INITMENU:
            if (GetMenu(ghwndMain) == (HMENU)wParam)
                InitMenu((HMENU)wParam);

            break;

        case WM_MENUSELECT:
            if (GET_WM_MENUSELECT_FLAGS(wParam, lParam) &
                    (MF_POPUP | MF_SYSMENU))
                gMenuSelected = 0;
            else
                gMenuSelected = GET_WM_MENUSELECT_CMD(wParam, lParam);

            break;

        case WM_COMMAND:
            DialogMenu(GET_WM_COMMAND_ID(wParam, lParam));
            break;

        case WM_KEYDOWN:
            switch (wParam) {
                case VK_UP:
                case VK_DOWN:
                case VK_LEFT:
                case VK_RIGHT:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Ignore it if we are not in a normal state
                     * (don't allow when dragging).
                     */
                    if (gState != STATE_NORMAL)
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    /*
                     * Move the control in the specified direction.
                     */
                    MoveControl(wParam);
                    break;

                case VK_TAB:
                    if (GetKeyState(VK_CONTROL) & 0x8000)
                        break;

                    /*
                     * Ignore it if we are not in a normal state
                     * (don't allow when dragging).
                     */
                    if (gState != STATE_NORMAL)
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    /*
                     * Is the shift key pressed also?
                     */
                    if (GetKeyState(VK_SHIFT) & 0x8000)
                        SelectPrevious();
                    else
                        SelectNext();

                    break;

                case VK_ESCAPE:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    if (gState == STATE_SELECTING)
                        OutlineSelectCancel();

                    /*
                     * Cancel any drag operation they might have been doing.
                     */
                    if (gState != STATE_NORMAL)
                        DragCancel();

                    break;

                case VK_RETURN:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    switch (gState) {
                        MPOINT mpt;
                        POINT pt;
                        DWORD dwPos;

                        case STATE_SELECTING:
                            /*
                             * In outline selection mode.  Map the
                             * location of the mouse at the time that
                             * the user pressed Enter into a point
                             * relative to the dialog client and complete
                             * the selection operation.
                             */
                            dwPos = GetMessagePos();
                            mpt = MAKEMPOINT(dwPos);
                            MPOINT2POINT(mpt, pt);
                            ScreenToClient(gcd.npc->hwnd, &pt);
                            OutlineSelectEnd(pt.x, pt.y);

                            break;

                        case STATE_DRAGGING:
                        case STATE_DRAGGINGNEW:
                            /*
                             * We are dragging something.  Map the
                             * location of the mouse at the time
                             * that the user pressed Enter into a
                             * point relative to the proper window
                             * and complete the drag operation.
                             */
                            dwPos = GetMessagePos();
                            mpt = MAKEMPOINT(dwPos);
                            MPOINT2POINT(mpt, pt);

                            /*
                             * The point must be changed to be relative to
                             * the window that the ending mouse up message
                             * would have come through, which will be the
                             * capture window for the drag.  This will be
                             * the dialog if we are adding a new control,
                             * or it will be the selected control if we are
                             * dragging an existing control.
                             */
                            ScreenToClient((gState == STATE_DRAGGING) ?
                                    gnpcSel->hwnd : gcd.npc->hwnd, &pt);

                            /*
                             * If the dialog is selected, map the points from
                             * the client area to the window.
                             */
                            if (gfDlgSelected)
                                MapDlgClientPoint(&pt, TRUE);

                            DragEnd(pt.x, pt.y);

                            break;
                    }

                    break;
            }

            break;

        case WM_NCCALCSIZE:
            /*
             * Save away what is going to be the new window position.
             */
            if (!IsIconic(hwnd) && !IsZoomed(hwnd))
                grcAppPos = *((LPRECT)lParam);

            /*
             * Now let the DefWindowProc calculate the client area normally.
             */
            goto DoDefault;

        case WM_MOVE:
            if (gfEditingDlg)
                RepositionDialog();

            break;

        case WM_SIZE:
            SizeRibbons(hwnd);

            /*
             * Did the app start minimized and is it being restored
             * for the first time?  If so, show the toolbox if
             * the user has requested it.
             */
            if (fStartAsIcon && !IsIconic(hwnd)) {
                if (gfShowToolbox)
                    ToolboxShow(TRUE);

                fStartAsIcon = FALSE;
            }

            break;

        case WM_SYSCOLORCHANGE:
            LoadSysColorBitmaps();
            break;

        case WM_CLOSE:
            if (ghwndTestDlg)
                DestroyTestDialog();

            if (DoWeSave(FILE_INCLUDE) == IDCANCEL ||
                    DoWeSave(FILE_RESOURCE) == IDCANCEL)
                break;

            /*
             * First destroy the Properties Bar.
             */
            DestroyWindow(hwndStatus);
            hwndStatus = NULL;

            DestroyWindow(hwnd);
            break;

        case WM_QUERYENDSESSION:
            if (ghwndTestDlg)
                DestroyTestDialog();

            if (DoWeSave(FILE_INCLUDE) == IDCANCEL ||
                    DoWeSave(FILE_RESOURCE) == IDCANCEL)
                return FALSE;
            else
                return TRUE;

        case WM_DESTROY:
            /*
             * Save the position of the app's window.
             */
            WriteWindowPos(&grcAppPos, IsZoomed(hwnd), szAppPos);

            WinHelp(hwnd, gszHelpFile, HELP_QUIT, 0L);
            FreeMenuBitmaps();
            PostQuitMessage(0);
            break;

        default:
            /*
             * Is this the registered help message from one of the common
             * dialogs?  If so, show the help for it.
             *
             * The check to be sure gmsgHelp is non-zero is just in
             * case the call to register the help message failed
             * (it will return zero) and there happens to be a zero
             * message that gets sent to this window somehow.
             */
            if (msg == gmsgHelp && gmsgHelp) {
                ShowHelp(FALSE);
                return 0;
            }

        DoDefault:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    return 0;
}