⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hwproc.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
*
*                            Open Watcom Project
*
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
*  ========================================================================
*
*    This file contains Original Code and/or Modifications of Original
*    Code as defined in and that are subject to the Sybase Open Watcom
*    Public License version 1.0 (the 'License'). You may not use this file
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
*    provided with the Original Code and Modifications, and is also
*    available at www.sybase.com/developer/opensource.
*
*    The Original Code and all software distributed under the License are
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
*    NON-INFRINGEMENT. Please see the License for the specific language
*    governing rights and limitations under the License.
*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/


#include <stdio.h>
#include <string.h>
#include "heapwalk.h"
#include "aboutdlg.h"
#include "wwinhelp.h"
#include "jdlg.h"

static  BOOL    NoRefresh = FALSE;

/*
 * HideResources - hide all resource display windows
 */
static void HideResources( BOOL hide ) {

    int         cmd;
    WORD        i;

    cmd = hide ? SW_HIDE : SW_SHOWNOACTIVATE;
    for( i=0; i < MAX_RES; i++ ) {
        if( ResHwnd[i] != NULL ) {
            ShowWindow( ResHwnd[i], cmd );
        }
    }
} /* HideResources */

static HWND *SetUpPushWindows( HWND hwnd, WORD type ) {

    HWND        *ret;

    if( type == HEAPMENU_DISPLAY_DPMI ) {
        ret = MakePushWin( hwnd, HeapDPMITitles, 8, HEAPMENU_SORT_HANDLE,
                                HEAPMENU_SORT_ADDR, HEAPMENU_SORT_SIZE,
                                HEAPMENU_SORT_GRAN, HEAPMENU_SORT_TYPE,
                                HEAPMENU_SORT_DPL, 0 ,0 );
    } else {
        ret = MakePushWin( hwnd, HeapTitles, 8, HEAPMENU_SORT_HANDLE,
                        HEAPMENU_SORT_ADDR, HEAPMENU_SORT_SIZE,
                        HEAPMENU_SORT_MODULE, HEAPMENU_SORT_FLAG,
                        0, 0, HEAPMENU_SORT_TYPE );
    }
    return( ret );
}

/*
 * SetDisplayType - changes the heap display type to 'type' unless type is
 *                  'HEAPMENU_DISPLAY_INIT' in which case this is assumed to
 *                  be the first call to SetDisplayType and the heap display
 *                  type is set to 'HeapType'
 */
static void SetDisplayType( HWND hwnd, HWND **title, WORD type ) {

    HMENU       mh;
    char        buf[256];
    char        *typename;

    if( type == HeapType ) return;
    if( type == HEAPMENU_DISPLAY_DPMI && !WDebug386 ) {
        RCMessageBox( HeapWalkMainWindow, STR_INSTALL_WDEBUG,
                      HeapWalkName, MB_OK | MB_ICONEXCLAMATION );
        return;
    }
    mh = GetMenu( hwnd );
    if( type == HEAPMENU_DISPLAY_INIT ) {
        type = HeapType;
        HeapType = HEAPMENU_DISPLAY_INIT;
    } else {
        CheckMenuItem( mh, HeapType, MF_UNCHECKED | MF_BYCOMMAND );
    }

    /* undo anything done for the previous state */
    switch( HeapType ) {
    case HEAPMENU_DISPLAY_DPMI:
        EnableMenuItem( mh, HEAPMENU_ADD, MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_DISCARD,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_OLDEST,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_NEWEST,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_LOCAL_LOCALWALK,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_COMPACT_AND_LOCALWALK,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_GET_SELECTOR,
                        MF_BYCOMMAND | MF_ENABLED );
        EnableMenuItem( mh, HEAPMENU_LOCAL_MONITOR,
                        MF_BYCOMMAND | MF_ENABLED );
        ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP,
                    (UINT)LoadMenu( Instance, "SORTMENU" ),
                    GetRCString( STR_SORT ) );
        KillPushWin( *title );
        *title = SetUpPushWindows( hwnd, HEAPMENU_DISPLAY_ENTIRE );
        if( GSortType == HEAPMENU_SORT_GRAN ||
            GSortType == HEAPMENU_SORT_DPL ) GSortType = HEAPMENU_SORT_HANDLE;
        break;
    case HEAPMENU_DISPLAY_LRU:
        DeleteMenu( mh, HEAPMENU_SORT_LRU, MF_BYCOMMAND );
        if( GSortType == HEAPMENU_SORT_LRU ) GSortType = HEAPMENU_SORT_HANDLE;
        break;
    case HEAPMENU_DISPLAY_INIT:
        if( type != HEAPMENU_DISPLAY_DPMI ) {
            *title = SetUpPushWindows( hwnd, type );
            ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP,
                    (UINT)LoadMenu( Instance, "SORTMENU" ),
                    GetRCString( STR_SORT ) );
        } else {
            *title = NULL;
        }
        break;
    }
    /* do things for the new state */
    switch( type ) {
    case HEAPMENU_DISPLAY_DPMI:
        ModifyMenu( mh, 2, MF_BYPOSITION | MF_POPUP,
                    (UINT)LoadMenu( Instance, "SORTDPMIMENU" ),
                    GetRCString( STR_SORT ) );
        EnableMenuItem( mh, HEAPMENU_ADD, MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_DISCARD,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_OLDEST,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_NEWEST,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_LOCAL_LOCALWALK,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_COMPACT_AND_LOCALWALK,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_OBJECT_GET_SELECTOR,
                        MF_BYCOMMAND | MF_GRAYED );
        EnableMenuItem( mh, HEAPMENU_LOCAL_MONITOR,
                        MF_BYCOMMAND | MF_GRAYED );
        if( GSortType == HEAPMENU_SORT_MODULE ||
                GSortType == HEAPMENU_SORT_TYPE ) {
            CheckMenuItem( mh, GSortType, MF_UNCHECKED | MF_BYCOMMAND );
            GSortType = HEAPMENU_SORT_ADDR;
        }
//      SetTitle( HeapDPMITitles, title );
        KillPushWin( *title );
        *title = SetUpPushWindows( hwnd, type );
        typename = AllocRCString( STR_SELECTOR_LIST_ITEMS );
        break;
    case HEAPMENU_DISPLAY_LRU:
        InsertMenu( mh, HEAPMENU_SORT_FLAG, MF_BYCOMMAND, HEAPMENU_SORT_LRU,
                   GetRCString( STR_BY_AGE ) );
        typename = AllocRCString( STR_LRU_ITEMS );
        break;
    case HEAPMENU_DISPLAY_ENTIRE:
        typename = AllocRCString( STR_ENTIRE_HEAP );
        break;
    case HEAPMENU_DISPLAY_FREE:
        typename = AllocRCString( STR_FREE_ITEMS );
        break;
    default:
        typename = "";
        break;
    }
    CheckMenuItem( mh, type, MF_CHECKED | MF_BYCOMMAND );
    CheckMenuItem( mh, GSortType, MF_CHECKED | MF_BYCOMMAND );
    DrawMenuBar( hwnd );
    sprintf( buf, "%s - %s", HeapWalkName, typename );
    FreeRCString( typename );
    SetWindowText( hwnd, buf );
    HeapType = type;
} /* SetDisplayType */

/*
 * ResetFont - refresh all windows after a font change
 */

static void ResetFont( GblWndInfo *info ) {

    KillPushWin( info->list.title );
    info->list.title = SetUpPushWindows( HeapWalkMainWindow, HeapType );
    PositionListBox( &info->list, HeapWalkMainWindow );
    SetBoxFont( info->list.box, GetMonoFont() );
    ResetLocalFont();
    PaintAllWindows();
}

/*
 * CheckForLocalSelect - return the index of the current item if it
 *                       has a local heap otherwise print an appropriate
 *                       message and return LB_ERR
 */
static DWORD CheckForLocalSelect( GblWndInfo *info ) {

    LRESULT    index;

    index = SendMessage( info->list.box, LB_GETCURSEL, 0, 0 );
    if( index == LB_ERR ) {
        RCMessageBox( NULL, STR_NO_ITEM_SELECTED, HeapWalkName,
                    MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL );
    } else if( !HeapList[index]->info.ge.wHeapPresent ) {
        RCMessageBox( NULL, STR_HAS_NO_LCL_HEAP, HeapWalkName,
                    MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL );
        index = LB_ERR;
    }
    return( index );
}

/*
 * HeapWalkProc - show task status
 */
BOOL __export FAR PASCAL HeapWalkProc( HWND hwnd, UINT msg, WPARAM wparam,
                                    LPARAM lparam )
{
    HMENU       mh;
    HMENU       mh2;
    HCURSOR     hourglass;
    HCURSOR     oldcursor;
    FARPROC     fp;
    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_proc = MakeProcInstance( (FARPROC)AllocDlgProc, Instance );
        info->alloc_dialog = JCreateDialog( Instance, "ALLOC_DLG",
                                           hwnd, (DLGPROC)info->alloc_proc );
        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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -