Exemplo n.º 1
0
/*
 * SpyWindowProc - handle messages for the spy appl.
 */
LRESULT CALLBACK SpyWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    int         check;
    HWND        selwin;
    HWND        hinthwnd;
    WORD        cmdid = 0;
    RECT        area;
    BOOL        pausestate;
    BOOL        spyallstate;
    about_info  ai;
    HMENU       mh;

    switch ( msg ) {
    case WM_CREATE:
        GetClientRect( hwnd, &area );
        mh = GetMenu( hwnd );
        area.top = area.bottom - statusHite;
        StatusHdl = HintWndCreate( hwnd, &area, Instance, NULL );
        statusHite = SizeHintBar( StatusHdl );
        SetHintText( StatusHdl, (MenuItemHint *)menuHints,
                     sizeof( menuHints ) / sizeof( MenuItemHint ) );
        if( SpyMainWndInfo.show_hints ) {
            CheckMenuItem( mh, SPY_SHOW_HELP, MF_CHECKED | MF_BYCOMMAND );
        } else {
            hinthwnd = GetHintHwnd( StatusHdl );
            ShowWindow( hinthwnd, SW_HIDE );
        }
        CreateSpyBox( hwnd );
        SET_WNDINFO( hwnd, (LONG_PTR)SpyListBox );
        CreateSpyTool( hwnd );
        ShowSpyTool( SpyMainWndInfo.show_toolbar );
        if( SpyMainWndInfo.show_toolbar ) {
            CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_CHECKED | MF_BYCOMMAND );
        }
        LogInit( hwnd, Instance, SpyLogTitle );
        CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_CHECKED );
        EnableMenuItem( SpyMenu, SPY_ADD_WINDOW, MF_GRAYED );
        EnableMenuItem( SpyMenu, SPY_STOP, MF_GRAYED );
        EnableMenuItem( SpyMenu, SPY_OFFON, MF_GRAYED );
        if( SpyMainWndInfo.on_top ) {
            CheckMenuItem( mh, SPY_TOP, MF_CHECKED | MF_BYCOMMAND );
            SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
                          SWP_NOMOVE | SWP_NOSIZE );
        }
        break;
    case WM_TIMER:
        // See comment on setUpForPick
        KillTimer( hwnd, wparam );
        switch( wparam ) {
        case SPY_ADD_WINDOW:
            selwin = DoPickDialog( wparam );
            if( selwin != NULL ) {
                setMultipleWindows( hwnd );
                AddSelectedWindow( selwin );
            }
            break;
        case SPY_PEEK_WINDOW:
            DoPickDialog( wparam );
            break;
        case SPY_WINDOW:
            selwin = DoPickDialog( cmdid );
            if( selwin != NULL ) {
                ClearSelectedWindows();
                setSingleWindow( hwnd, selwin );
                enableSpy();
                AddSelectedWindow( selwin );
            }
            break;
        }
        break;
#ifdef __NT__
    case WM_COPYDATA:
        HandleMessage( (LPMSG)((COPYDATASTRUCT *)lparam)->lpData );
        break;
#endif
    case WM_MENUSELECT:
        hinthwnd = GetHintHwnd( StatusHdl );
        HintMenuSelect( StatusHdl, hwnd, wparam, lparam );
        break;
    case WM_COMMAND:
        cmdid = LOWORD( wparam );
        switch( cmdid ) {
        case SPY_SHOW_HELP:
            SpyMainWndInfo.show_hints = !SpyMainWndInfo.show_hints;
            mh = GetMenu( hwnd );
            hinthwnd = GetHintHwnd( StatusHdl );
            if( SpyMainWndInfo.show_hints ) {
                CheckMenuItem( mh, SPY_SHOW_HELP, MF_CHECKED | MF_BYCOMMAND );
                showHintBar( hwnd );
            } else {
                CheckMenuItem( mh, SPY_SHOW_HELP, MF_UNCHECKED | MF_BYCOMMAND );
                ShowWindow( hinthwnd, SW_HIDE );
            }
            GetClientRect( hwnd, &area );
            ResizeSpyBox( area.right - area.left, area.bottom - area.top );
            break;
        case SPY_SHOW_TOOLBAR:
            SpyMainWndInfo.show_toolbar = !SpyMainWndInfo.show_toolbar;
            mh = GetMenu( hwnd );
            if( SpyMainWndInfo.show_toolbar ) {
                CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_CHECKED | MF_BYCOMMAND );
            } else {
                CheckMenuItem( mh, SPY_SHOW_TOOLBAR, MF_UNCHECKED | MF_BYCOMMAND );
            }
            ShowSpyTool( SpyMainWndInfo.show_toolbar );
            GetClientRect( hwnd, &area );
            ResizeSpyBox( area.right - area.left, area.bottom - area.top );
            break;
        case SPY_TOP:
            SpyMainWndInfo.on_top = !SpyMainWndInfo.on_top;
            mh = GetMenu( hwnd );
            if( SpyMainWndInfo.on_top ) {
                CheckMenuItem( mh, SPY_TOP, MF_CHECKED | MF_BYCOMMAND );
                SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
                              SWP_NOMOVE | SWP_NOSIZE );
            } else {
                CheckMenuItem( mh, SPY_TOP, MF_UNCHECKED | MF_BYCOMMAND );
                SetWindowPos( hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
                              SWP_NOMOVE | SWP_NOSIZE );
            }
            break;
        case SPY_MARK:
            pausestate = SpyMessagesPaused;
            SpyMessagesPaused = FALSE;              /* make sure marks are
                                                     * always added */
            ProcessMark( hwnd, Instance, markCallback );
            SpyMessagesPaused = pausestate;
            break;
        case SPY_SET_FONT:
            if( ChooseMonoFont( hwnd ) )  {
                statusHite = SizeHintBar( StatusHdl );
                ResetSpyListBox();
                showHintBar( hwnd );
            }
            break;
        case SPY_SAVE_AS:
            SaveListBox( SLB_SAVE_AS, SaveExtra, "", SpyName, hwnd, SpyListBox );
            break;
        case SPY_SAVE:
            SaveListBox( SLB_SAVE_TMP, SaveExtra, ".\\wspy.txt", SpyName, hwnd,
                         SpyListBox );
            break;
        case SPY_LOG:
            if( LogToggle() ) {
                CheckMenuItem( SpyMenu, SPY_LOG, MF_BYCOMMAND | MF_CHECKED );
            } else {
                CheckMenuItem( SpyMenu, SPY_LOG, MF_BYCOMMAND | MF_UNCHECKED );
                CheckMenuItem( SpyMenu, SPY_PAUSE_LOG, MF_BYCOMMAND | MF_UNCHECKED );
            }
            break;
        case SPY_CONFIG_LOG:
            LogConfigure();
            break;
        case SPY_EXIT:
            ClearFilter();
            DestroyWindow( hwnd );
            break;
        case SPY_LIST_BOX:
            switch( GET_WM_COMMAND_CMD( wparam, lparam ) ) {
            case LBN_ERRSPACE:
                ClearSpyBox();
                break;
            case LBN_DBLCLK:
                DoMessageSelDialog( hwnd );
                break;
            }
            break;
        case SPY_SHOW_SELECTED_WINDOWS:
            spyallstate = spyAll;
            DoShowSelectedDialog( hwnd, &spyallstate );
            if( spyallstate ) {
                doSpyAll( hwnd, spyallstate );
                if( spyAll ) {
                    SetSpyState( ON );
                }
                break;
            }
            if( WindowCount == 0 ) {
                SetWindowText( hwnd, SpyName );
                disableSpy();
                break;
            }

            if( WindowCount == 1 ) {
                setSingleWindow( hwnd, WindowList[0] );
            } else {
                setMultipleWindows( hwnd );
            }
            if( SpyState == NEITHER ) {
                enableSpy();
            }
            break;
        case SPY_HELP_CONTENTS:
            if( !WHtmlHelp( hwnd, "spy.chm", HELP_CONTENTS, 0 ) ) {
                WWinHelp( hwnd, "spy.hlp", HELP_CONTENTS, 0 );
            }
            break;
        case SPY_HELP_SRCH:
            if( !WHtmlHelp( hwnd, "spy.chm", HELP_PARTIALKEY, (HELP_DATA)"" ) ) {
                WWinHelp( hwnd, "spy.hlp", HELP_PARTIALKEY, (HELP_DATA)"" );
            }
            break;
        case SPY_HELP_ON_HELP:
            WWinHelp( hwnd, "winhelp.hlp", HELP_HELPONHELP, 0 );
            break;
        case SPY_ABOUT:
            ai.owner = hwnd;
            ai.inst = Instance;
            ai.name = AllocRCString( STR_ABOUT_NAME );
            ai.version = AllocRCString( STR_ABOUT_VERSION );
            ai.first_cr_year = "1993";
            ai.title = AllocRCString( STR_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.version );
            FreeRCString( ai.title );
            break;
        case SPY_AUTO_SCROLL:
            if( SpyMessagesAutoScroll ) {
                SpyMessagesAutoScroll = FALSE;
                CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_UNCHECKED );
            } else {
                SpyMessagesAutoScroll = TRUE;
                CheckMenuItem( SpyMenu, SPY_AUTO_SCROLL, MF_CHECKED );
            }
            break;
        case SPY_PAUSE_LOG:
            if( SpyLogPauseToggle() ) {
                CheckMenuItem( SpyMenu, SPY_PAUSE_LOG,
                               MF_BYCOMMAND | MF_CHECKED );
            } else {
                CheckMenuItem( SpyMenu, SPY_PAUSE_LOG,
                               MF_BYCOMMAND | MF_UNCHECKED );
            }
            break;
        case SPY_PAUSE_MESSAGES:
            SpyMessagePauseToggle();
            break;
        case SPY_CLEAR_MESSAGES:
            ClearSpyBox();
            ClearMessageCount();
            break;
        case SPY_MESSAGES_ASCFG:
            if( AutoSaveConfig ) {
                check = MF_UNCHECKED;
                AutoSaveConfig = FALSE;
            } else {
                AutoSaveConfig = TRUE;
                check = MF_CHECKED;
            }
            CheckMenuItem( SpyMenu, SPY_MESSAGES_ASCFG, check );
            break;
        case SPY_MESSAGES_SAVE:
            DoSaveSpyConfig();
            break;
        case SPY_MESSAGES_LOAD:
            DoLoadSpyConfig();
            break;
        case SPY_MESSAGES_WATCH:
        case SPY_MESSAGES_STOP:
            DoMessageDialog( hwnd, cmdid );
            break;
        case SPY_OFFON:
            if( SpyState != NEITHER ) {
                SetSpyState( !SpyState );
            }
            break;
        case SPY_STOP:
            disableSpy();
            ClearSelectedWindows();
            SetWindowText( hwnd, SpyName );
            break;
        case SPY_ANOTHER_WINDOW:
            if( SpyState == NEITHER || spyAll ) {
                SendMessage( hwnd, WM_COMMAND,
                             GET_WM_COMMAND_MPS( SPY_WINDOW, 0, 0 ) );
            } else {
                SendMessage( hwnd, WM_COMMAND,
                             GET_WM_COMMAND_MPS( SPY_ADD_WINDOW, 0, 0 ) );
            }
            break;
        case SPY_PEEK_WINDOW:
        case SPY_ADD_WINDOW:
        case SPY_WINDOW:
            setUpForPick( hwnd, cmdid );
            break;
        case SPY_ALL_WINDOWS:
            doSpyAll( hwnd, !spyAll );
            if( spyAll ) {
                SetSpyState( ON );
            }
            break;
        }
        break;
#ifdef __NT__
    case WM_NOTIFY:
        if( ((NMHDR *)lparam)->code == NM_DBLCLK &&
            ((NMHDR *)lparam)->idFrom == SPY_LIST_BOX ) {
            DoMessageSelDialog( hwnd );
        }
        break;
#endif
    case WM_CLOSE:
        PostMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( SPY_EXIT, 0, 0 ) );
        break;
    case WM_ENDSESSION:
        if( wparam ) {
            SpyFini();
        }
        break;
    case WM_DESTROY:
        HintWndDestroy( StatusHdl );
        HintFini();
        StatusWndFini();
        DestroyMonoFonts();
        DestroySpyTool();
        WWinHelp( hwnd, "spy.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;
    case WM_MOVE:
        GetWindowRect( hwnd, &area );
        if( !SpyMainWndInfo.minimized ) {
            SpyMainWndInfo.last_xpos = SpyMainWndInfo.xpos;
            SpyMainWndInfo.last_ypos = SpyMainWndInfo.ypos;
            SpyMainWndInfo.xpos = area.left;
            SpyMainWndInfo.ypos = area.top;
        }
        break;
    case WM_SIZE:
        if( wparam != SIZE_MAXIMIZED && wparam != SIZE_MINIMIZED ) {
            GetWindowRect( hwnd, &area );
            SpyMainWndInfo.xsize = area.right - area.left;
            SpyMainWndInfo.ysize = area.bottom - area.top;
        } else {
            SpyMainWndInfo.xpos = SpyMainWndInfo.last_xpos;
            SpyMainWndInfo.ypos = SpyMainWndInfo.last_ypos;
        }
        SpyMainWndInfo.minimized = ( wparam == SIZE_MINIMIZED );
        GetClientRect( hwnd, &area );
        area.top = area.bottom - statusHite;
        hinthwnd = GetHintHwnd( StatusHdl );
        MoveWindow( hinthwnd, area.left, area.top,
                    area.right - area.left, statusHite, TRUE );
        ResizeSpyBox( LOWORD( lparam ), HIWORD( lparam ) );
        ResizeSpyTool( LOWORD( lparam ), HIWORD( lparam ) );
        showHintBar( hwnd );
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
        break;
#if defined( __NT__ )
    case WM_ERASEBKGND: {
        static RECT r;
        GetClientRect( hwnd, &r );
        FillRect( (HDC)wparam, &r, (HBRUSH)(COLOR_BTNFACE + 1) );
        return 1;
    }
#endif
    default:
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
    }
    return( 0 );

} /* SpyWindowProc */
Exemplo n.º 2
0
/*
 * WindowProc - main window message handler
 */
LONG CALLBACK MainWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD                        cmd;
    about_info                  ai;
    HMENU                       mh;
    CommunicationBuffer         *dbginfo;

    switch ( msg ) {
    case WM_CREATE:
        setupSystemMenu( hwnd );
        MainLBox = CreateListBox( hwnd );
        mh = GetMenu( hwnd );
        if( ConfigData.auto_attatch ) {
            CheckMenuItem( mh, MENU_AUTO_ATTATCH, MF_BYCOMMAND | MF_CHECKED );
        }
        if( ConfigData.continue_exception ) {
            CheckMenuItem( mh, MENU_EXCEPTION_CONTINUE,
                                MF_BYCOMMAND | MF_CHECKED );
        }
        LBPrintf( MainLBox, STR_DRNT_STARTED, AppName );
        break;
    case WM_SIZE:
        MoveListBox( MainLBox, 0, 0, LOWORD( lparam ), HIWORD( lparam ) );
        ClearAlert();
        break;
    case WM_SYSCOMMAND:
        switch( wparam ) {
        case MENU_LOG_CURRENT_STATE:
        case MENU_LOG_OPTIONS:
        case MENU_TASK_CTL:
            SendMessage( hwnd, WM_COMMAND, wparam, 0 );
            break;
        default:
            return( DefWindowProc( hwnd, msg, wparam, lparam ) );
        }
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case LISTBOX_1:
            break;
        case MENU_EXCEPTION_CONTINUE:
            ConfigData.continue_exception = !ConfigData.continue_exception;
            mh = GetMenu( hwnd );
            if( ConfigData.continue_exception ) {
                CheckMenuItem( mh, MENU_EXCEPTION_CONTINUE,
                                   MF_BYCOMMAND | MF_CHECKED );
            } else {
                CheckMenuItem( mh, MENU_EXCEPTION_CONTINUE,
                                   MF_BYCOMMAND | MF_UNCHECKED );
            }
            break;
        case MENU_LOG_VIEW:
            ViewLog();
            break;
        case MENU_NEW_TASK:
            CallProcCtl( MENU_NEW_TASK, NULL, NULL );
            break;
        case MENU_AUTO_ATTATCH:
            ConfigData.auto_attatch = ! ConfigData.auto_attatch;
            mh = GetMenu( hwnd );
            if( ConfigData.auto_attatch ) {
                CheckMenuItem( mh, MENU_AUTO_ATTATCH,
                               MF_BYCOMMAND | MF_CHECKED );
            } else {
                CheckMenuItem( mh, MENU_AUTO_ATTATCH,
                               MF_BYCOMMAND | MF_UNCHECKED );
            }
            break;
        case MENU_SHOW_DIP_STATUS:
            ShowDIPStatus( hwnd );
            break;
        case MENU_CLEAR:
            ClearListBox( MainLBox );
            break;
        case MENU_SAVE_AS:
            SaveListBox( SLB_SAVE_AS, SaveExtra, "", AppName, hwnd,
                         GetListBoxHwnd( MainLBox ) );
            break;
        case MENU_SAVE:
            SaveListBox( SLB_SAVE_TMP, SaveExtra, ".\\drwat.txt", AppName,
                         hwnd, GetListBoxHwnd( MainLBox ) );
            break;
        case MENU_FONT:
            if( ChooseMonoFont( hwnd ) ) {
                SetListBoxFont( MainLBox );
            }
            break;
        case MENU_MARK:
            ProcessMark( hwnd, Instance, MarkPrint );
            break;
        case MENU_ABOUT:
            ai.owner = hwnd;
            ai.inst = Instance;
            ai.name = AllocRCString( STR_ABOUT_NAME );
            ai.version = AllocRCString( STR_ABOUT_VERSION );
            ai.first_cr_year = "1993";
            ai.title = AllocRCString( STR_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.version );
            FreeRCString( ai.title );
            break;
        case MENU_HELP_CONTENTS:
            if( !WHtmlHelp( hwnd, DR_CHM_FILE, HELP_CONTENTS, 0 ) ) {
                WWinHelp( hwnd, DR_HELP_FILE, HELP_CONTENTS, 0 );
            }
            break;
        case MENU_HELP_SRCH:
            if( !WHtmlHelp( hwnd, DR_CHM_FILE, HELP_PARTIALKEY, (HELP_DATA)"" ) ) {
                WWinHelp( hwnd, DR_HELP_FILE, HELP_PARTIALKEY, (HELP_DATA)"" );
            }
            break;
        case MENU_HELP_ON_HELP:
            WWinHelp( hwnd, HELP_HELP_FILE, HELP_HELPONHELP, 0 );
            break;
        case MENU_TASK_CTL:
            DisplayProcList();
            break;
        case MENU_LOG_CURRENT_STATE:
            MakeLog( NULL );
            break;
        case MENU_ERASE_LOG_FILE:
            EraseLog();
            break;
        case MENU_LOG_OPTIONS:
            SetLogOptions( hwnd );
            break;
        case MENU_EXIT:
            SendMessage( hwnd, WM_CLOSE, 0, 0L );
            break;
        default:
            MessageBox( hwnd, "This function is not yet available",
                        AppName, MB_OK );
            break;
        }
        break;
    case DR_DEBUG_EVENT:
        dbginfo = (CommunicationBuffer *)lparam;
        dbginfo->action = DebugEventHandler( &dbginfo->dbginfo );
        break;
    case WM_COPYDATA:
        {
            COPYDATASTRUCT      *copydata;

            copydata = (COPYDATASTRUCT *)lparam;
            ProcessCommandLine( copydata->lpData );
        }
        break;
    case WM_CLOSE:
        if( QueryEnd( hwnd ) ) {
            SendMessage( hwnd, WM_DESTROY, 0, 0L );
        }
        break;
    case WM_DESTROY:
        FiniListBox( MainLBox );
        PutProfileInfo();
        DestroyMonoFonts();
        WWinHelp( hwnd, DR_HELP_FILE, HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;
    default:
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
    }
    return( 0L );

} /* WindowProc */
Exemplo n.º 3
0
/*
 * HeapWalkProc - show task status
 */
BOOL FAR PASCAL HeapWalkProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    HMENU       mh;
    HMENU       mh2;
    HCURSOR     hourglass;
    HCURSOR     oldcursor;
    DLGPROC     dlgproc;
    DWORD       index;
    heap_list   hl;
    GblWndInfo  *info;
    RECT        area;
    about_info  ai;

    info = (GblWndInfo *)GetWindowLong( hwnd, 0 );
    switch( msg ) {
    case WM_CREATE:
        InitPaintProc();
        info = MemAlloc( sizeof( GblWndInfo ) );
        if( info == NULL ) {
            ErrorBox( hwnd, STR_UNABLE_2_STARTUP, MB_OK | MB_ICONINFORMATION );
            PostQuitMessage( 0 );
        }
        memset( info, 0, sizeof( GblWndInfo ) );
        SetWindowLong( hwnd, 0, (DWORD)info );
//      hdc = GetDC( hwnd );
//      ReleaseDC(hwnd, hdc);
        SetDisplayType( hwnd, &( info->list.title ), HEAPMENU_DISPLAY_INIT );
        CreateListBox( hwnd, &info->list, GLOBAL_LB );
        info->alloc_dlgproc = MakeProcInstance_DLG( AllocDlgProc, Instance );
        info->alloc_dialog = JCreateDialog( Instance, "ALLOC_DLG", hwnd, info->alloc_dlgproc );
        memset( &ResHwnd, 0, MAX_RES * sizeof( HWND ) );
        break;
    case WM_MEASUREITEM:
        break;
    case WM_MOVE:
        GetWindowRect( hwnd, &area );
        if( !info->minimized ) {
            Config.last_glob_xpos = Config.glob_xpos;
            Config.last_glob_ypos = Config.glob_ypos;
            Config.glob_xpos = area.left;
            Config.glob_ypos = area.top;
        }
        break;
    case WM_SIZE:
        ResizeListBox( LOWORD( lparam ), HIWORD( lparam ), &( info->list ) );
        if( wparam == SIZE_MINIMIZED || wparam == SIZE_MAXIMIZED ) {
            Config.glob_xpos = Config.last_glob_xpos;
            Config.glob_ypos = Config.last_glob_ypos;
        }
        if( wparam == SIZE_MINIMIZED ) {
            info->minimized = TRUE;
            HideResources( TRUE );
        } else if( info->minimized ) {
            HideResources( FALSE );
            info->minimized = FALSE;
        } else if( wparam != SIZE_MAXIMIZED )  {
            GetWindowRect( hwnd, &area );
            Config.glob_xsize = area.right - area.left;
            Config.glob_ysize = area.bottom - area.top;
        }
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
        break;
    case WM_CLOSE:
        PostMessage( hwnd, WM_COMMAND, HEAPMENU_EXIT, 0L );
        return( TRUE );
    case WM_QUERYENDSESSION:
        SaveConfigFile( FALSE );
        return( TRUE );
        break;
    case WM_DESTROY:
        FiniPaintProc();
        KillPushWin( info->list.title );
        SaveConfigFile( FALSE );
        if( info != NULL ) {
            FreeProcInstance_DLG( info->alloc_dlgproc );
            MemFree( info );
        }
        DestroyMonoFonts();
        CvrCtl3dUnregister( Instance );
        CvrCtl3DFini( Instance );
        WWinHelp( hwnd, "heapwalk.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;
    case WM_ACTIVATEAPP:
        if( wparam && !NoRefresh ) {
            if( info->doing_add ) {
                info->need_refresh = TRUE;
            } else {
                InitHeapList( info->list.box, TRUE );
            }
        }
        break;
    case WM_MENUSELECT:
        if( LOWORD( lparam & MF_POPUP ) ) {
            mh = GetMenu( hwnd );
            mh2 = GetSubMenu( mh, 6 );
            if( (HMENU)wparam == mh2  ) {
                ShowWindow( info->alloc_dialog, SW_SHOWNOACTIVATE );
            } else if( (HMENU)wparam != GetSubMenu( mh2, 3 ) &&
                        (HMENU)wparam != GetSubMenu( mh2, 4 ) &&
                        (HMENU)wparam != GetSubMenu( mh2, 5 ) ) {
                ShowWindow( info->alloc_dialog, SW_HIDE );
            }
        }
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
        break;
    case WM_COMMAND:
        switch( wparam ) {
        case HEAPMENU_ABOUT:
            ai.owner = hwnd;
            ai.inst = Instance;
            ai.name = HWAllocRCString( STR_ABOUT_NAME );
            ai.version = HWAllocRCString( STR_ABOUT_VERSION );
            ai.title = HWAllocRCString( STR_ABOUT_TITLE );
            DoAbout( &ai );
            HWFreeRCString( ai.title );
            HWFreeRCString( ai.version );
            HWFreeRCString( ai.name );
            break;
        case HEAPMENU_HELP_CONTENTS:
            WWinHelp( hwnd, "heapwalk.hlp", HELP_CONTENTS, 0 );
            break;
        case HEAPMENU_HELP_SRCH:
            WWinHelp( hwnd, "heapwalk.hlp", HELP_PARTIALKEY, (HELP_DATA)(LPCSTR)"" );
            break;
        case HEAPMENU_HELP_ON_HELP:
            WWinHelp( hwnd, "winhelp.hlp", HELP_HELPONHELP, 0 );
            break;
        case HEAPEX_LIST:
            if( !info->doing_add ) {
                if( HIWORD( lparam ) == LBN_DBLCLK ) {
                    ShowHeapObject( (HWND)LOWORD( lparam ) );
                }
            } else {
                if( HIWORD( lparam ) == LBN_SELCHANGE
                    || HIWORD( lparam ) == LBN_DBLCLK ) {
                    RefreshAdd( info->add_dialog, info->list.box );
                    RedrawBox( info->list.box, index );
                }
            }
            break;
        case HEAPMENU_GLOBAL_REFRESH:
            InitHeapList( info->list.box, TRUE );
            break;
        case HEAPMENU_FONT:
            if( ChooseMonoFont( hwnd ) ) {
                ResetFont( info );
            }
            break;
        case HEAPMENU_EXIT:
            DestroyWindow( hwnd );
            FreeHeapList();
            break;
        case HEAPMENU_DISPLAY_DPMI:
        case HEAPMENU_DISPLAY_ENTIRE:
        case HEAPMENU_DISPLAY_LRU:
        case HEAPMENU_DISPLAY_FREE:
            SetDisplayType( hwnd, &( info->list.title ), wparam );
            InitHeapList( info->list.box, FALSE );
            break;
        case HEAPMENU_SORT_ADDR:
        case HEAPMENU_SORT_HANDLE:
        case HEAPMENU_SORT_MODULE:
        case HEAPMENU_SORT_SIZE:
        case HEAPMENU_SORT_TYPE:
        case HEAPMENU_SORT_GRAN:
        case HEAPMENU_SORT_DPL:
        case HEAPMENU_SORT_FLAG:
        case HEAPMENU_SORT_LRU:
            mh = GetMenu( hwnd );
            CheckMenuItem( mh, GSortType, MF_UNCHECKED | MF_BYCOMMAND );
            CheckMenuItem( mh, wparam, MF_CHECKED | MF_BYCOMMAND );
            if( GSortType != wparam ) {
                GSortType = wparam;
                SortHeapList();
                ReDisplayHeapList( info->list.box, NULL );
            }
            break;
        case HEAPMENU_OBJECT_SHOW:
            ShowHeapObject( info->list.box );
            break;
        case HEAPMENU_OBJECT_DISCARD:
            if( GlobDiscardObj( info->list.box ) ) {
                InitHeapList( info->list.box, TRUE );
            }
            break;
        case HEAPMENU_OBJECT_NEWEST:
            if( GlobSetObjPos( info->list.box, FALSE ) ) {
                if( GSortType == HEAPMENU_SORT_LRU ) {
                    InitHeapList( info->list.box, TRUE );
                }
            }
            break;
        case HEAPMENU_OBJECT_OLDEST:
            if( GlobSetObjPos( info->list.box, TRUE ) ) {
                if( GSortType == HEAPMENU_SORT_LRU ) {
                    InitHeapList( info->list.box, TRUE );
                }
            }
            break;
        case HEAPMENU_OBJECT_GET_SELECTOR:
            ShowSelector( info->list.box );
            break;
        case HEAPMENU_GLOBAL_HEAPINFO:
            DisplayGlobHeapInfo( hwnd );
            break;
        case HEAPMENU_GLOBAL_MEMORYINFO:
            DisplayMemManInfo( hwnd );
            break;
        case HEAPMENU_GLOBAL_COMPACT:
            GlobalCompact( 0 );
            InitHeapList( info->list.box, TRUE );
            break;
        case HEAPMENU_GLOBAL_COMP_DISC:
            GlobalCompact( -1 );
            InitHeapList( info->list.box, TRUE );
            break;
        case HEAPMENU_GLOBAL_CODE_SIZE:
            dlgproc = MakeProcInstance_DLG( SetCodeDlgProc, Instance );
            JDialogBox( Instance, "CODE_AREA_DLG", hwnd, dlgproc );
            FreeProcInstance_DLG( dlgproc );
            break;
        case HEAPMENU_FILE_SAVE:
            InitHeapList( info->list.box, TRUE );
            SaveListBox( SLB_SAVE_TMP, PutOutGlobalHeader, DumpGlobalLine, Config.gfname, HeapWalkName, hwnd, info->list.box );
            break;
        case HEAPMENU_FILE_SAVE_TO:
            InitHeapList( info->list.box, TRUE );
            SaveListBox( SLB_SAVE_AS, PutOutGlobalHeader, DumpGlobalLine, Config.gfname, HeapWalkName, hwnd, info->list.box );
            break;
        case HEAPMENU_SAVE_CONFIG:
            SaveConfigFile( TRUE );
            break;
        case HEAPMENU_CONFIGURE:
            HWConfigure();
            break;
        case HEAPMENU_LOCAL_MONITOR:
            index = CheckForLocalSelect( info );
            if( index != LB_ERR ) {
                BeginMonitor( HeapList[index] );
            }
            break;
        case HEAPMENU_COMPACT_AND_LOCALWALK:
            LocalCompact( -1 );
            /* fall through */
        case HEAPMENU_LOCAL_LOCALWALK:
            index = CheckForLocalSelect( info );
            if( index != LB_ERR ) {
                LocalWalk( HeapList[index] );
            }
            break;
        case HEAPMENU_GDI_LOCALWALK:
            if( GetDGroupItem( "GDI", &hl ) ) {
                LocalWalk( &hl );
            }
            break;
        case HEAPMENU_USER_LOCALWALK:
            if( GetDGroupItem( "USER", &hl ) ) {
                LocalWalk( &hl );
            }
            break;
        case HEAPMENU_FREE_ALL:
            MyFreeAllMem();
            UpdateAllocInfo( info->alloc_dialog );
            PaintAllWindows();
            break;
        case HEAPMENU_FREE_1K:
        case HEAPMENU_FREE_2K:
        case HEAPMENU_FREE_5K:
        case HEAPMENU_FREE_10K:
        case HEAPMENU_FREE_25K:
        case HEAPMENU_FREE_50K:
            hourglass = LoadCursor( NULL, IDC_WAIT );
            SetCapture( hwnd );
            oldcursor= SetCursor( hourglass );
            FreeSomeMem( wparam );
            UpdateAllocInfo( info->alloc_dialog );
            SetCursor( oldcursor );
            ReleaseCapture();
            PaintAllWindows();
            break;
        case HEAPMENU_ALLOC_1K:
        case HEAPMENU_ALLOC_2K:
        case HEAPMENU_ALLOC_5K:
        case HEAPMENU_ALLOC_10K:
        case HEAPMENU_ALLOC_25K:
        case HEAPMENU_ALLOC_50K:
            hourglass = LoadCursor( NULL, IDC_WAIT );
            SetCapture( hwnd );
            oldcursor= SetCursor( hourglass );
            AllocMore( wparam );
            UpdateAllocInfo( info->alloc_dialog );
            SetCursor( oldcursor );
            ReleaseCapture();
            PaintAllWindows();
            break;
        case HEAPMENU_ALLOC_ALL:
        case HEAPMENU_ALLOC_BUT_1K:
        case HEAPMENU_ALLOC_BUT_2K:
        case HEAPMENU_ALLOC_BUT_5K:
        case HEAPMENU_ALLOC_BUT_10K:
        case HEAPMENU_ALLOC_BUT_25K:
        case HEAPMENU_ALLOC_BUT_50K:
            hourglass = LoadCursor( NULL, IDC_WAIT );
            SetCapture( hwnd );
            oldcursor= SetCursor( hourglass );
            AllocAllBut( wparam );
            UpdateAllocInfo( info->alloc_dialog );
            SetCursor( oldcursor );
            ReleaseCapture();
            PaintAllWindows();
            break;
        case HEAPMENU_ALLOC_NK:
        case HEAPMENU_ALLOC_BUT_NK:
        case HEAPMENU_FREE_NK:
            DoNBytes( hwnd, wparam );
            UpdateAllocInfo( info->alloc_dialog );
            PaintAllWindows();
            break;
        case HEAPMENU_ADD:
            info->add_dialog = StartAdd( hwnd, &info->list );
            if( info->add_dialog != NULL ) {
                info->doing_add = TRUE;
                info->need_refresh = FALSE;
            } else {
                ErrorBox( hwnd, STR_UNABLE_TO_ADD,
                          MB_OK| MB_ICONINFORMATION );
            }
            break;
        }
        break;
    case WM_USER:
        /* an owned window is being destroyed make sure
         * Windows doesn't take the focus away from us*/
        NoRefresh = TRUE;
        SetFocus( hwnd );
        NoRefresh = FALSE;
        break;
    default:
        return( DefWindowProc( hwnd, msg, wparam, lparam ) );
    }
    return( FALSE );

} /* HeapWalkProc */