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

📄 wdeinfo.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
            if( str2 ) {
                str2[0] = '"';
                strcpy( &str2[1], str1 );
                str2[len-2] = '"';
                str2[len-1] = '\0';
                WdeSetComboWithStr( str2, WdeInfoWindow, IDB_INFO_IDSTR );
                WdeMemFree( str2 );
                ok = TRUE;
            }
            WdeMemFree( str1 );
        }
        if( !ok ) {
            WdeSetComboWithStr( "", WdeInfoWindow, IDB_INFO_IDSTR );
        }
        WdeSetEditWithStr( "", WdeInfoWindow, IDB_INFO_IDNUM );
    } else {
        if( is->symbol ) {
            WdeSetComboWithStr( is->symbol, WdeInfoWindow,
                                IDB_INFO_IDSTR );
        } else {
            WdeSetEditWithSINT16( (int_16) name->ID.Num, 10,
                                  WdeInfoWindow, IDB_INFO_IDSTR );
        }
        WdeSetEditWithSINT16( (int_16) name->ID.Num, 10,
                              WdeInfoWindow, IDB_INFO_IDNUM );
    }

}

void WdeDisplayControlInfo ( WdeInfoStruct *is )
{
    char             *str;
    char             *cp;

    str = NULL;
    cp = WdeResNameOrOrdinalToStr( is->c.text, 10 );
    if( cp != NULL ) {
        str = WRConvertStringFrom( cp, "\t\n", "tn" );
        WdeMemFree( cp );
    }

    if( str != NULL ) {
        WdeSetEditWithStr( str, WdeInfoWindow, IDB_INFO_CAPTION );
        WdeMemFree( str );
    } else {
        WdeSetEditWithStr( "", WdeInfoWindow, IDB_INFO_CAPTION );
    }

    if( is->symbol ) {
        WdeSetComboWithStr( is->symbol, WdeInfoWindow, IDB_INFO_IDSTR );
    } else {
        WdeSetEditWithSINT16( (int_16) is->c.id, 10,
                              WdeInfoWindow, IDB_INFO_IDSTR );
    }

    WdeSetEditWithSINT16( (int_16) is->c.id, 10,
                          WdeInfoWindow, IDB_INFO_IDNUM );
}

void WdeChangeInfo ( void )
{
    if ( WdeCurrentInfo.obj_id == DIALOG_OBJ ) {
        WdeChangeDialogInfo ( &WdeCurrentInfo );
    } else if ( WdeCurrentInfo.obj_id == CONTROL_OBJ ) {
        WdeChangeControlInfo ( &WdeCurrentInfo );
    }
}

void WdeChangeDialogInfo ( WdeInfoStruct *is )
{
    WdeInfoStruct       c_is;
    char                *str;
    char                *cp;
    Bool                quoted_str;
    Bool                str_is_ordinal;
    uint_16             ord;
    Bool                found;
    WdeHashValue        value;

    c_is = *is;

    str = NULL;
    cp = WdeGetStrFromEdit( WdeInfoWindow, IDB_INFO_CAPTION, NULL );
    if( cp ) {
        str = WRConvertStringTo( cp, "\t\n", "tn" );
        WdeMemFree( cp );
    }
    c_is.d.caption = str;

    str = WdeGetStrFromCombo( WdeInfoWindow, IDB_INFO_IDSTR );
    if( str == NULL ) {
        WdeMemFree( c_is.d.caption );
        c_is.d.caption = NULL;
        return;
    }

    WRStripSymbol( str );

    quoted_str = FALSE;
    if( _mbclen( str ) == 1 && str[0] == '"' ) {
        char    *s;
        str[0] = ' ';
        cp = NULL;
        for( s=str; *s; s=_mbsinc(s) ) {
            if( _mbclen( s ) == 1 && *s == '"' ) {
                cp = s;
            }
        }
        if( cp ) {
            *cp = '\0';
        }
        WRStripSymbol( str );
        quoted_str = TRUE;
    }

    if( str[0] == '\0' ) {
        WdeMemFree( str );
        WdeMemFree( c_is.d.caption );
        c_is.d.caption = NULL;
        return;
    }

    ord = ( uint_16 )strtoul( str, &cp, 0 );
    str_is_ordinal = ( *cp == '\0' );

    c_is.symbol = NULL;

    if( quoted_str ) {
        c_is.d.name = WResIDFromStr( str );
        WdeMemFree( str );
    } else if( str_is_ordinal ) {
        c_is.d.name = WResIDFromNum( ord );
        WdeMemFree( str );
    } else {
        if( !WdeIsValidSymbol( str ) ) {
            WdeMemFree( str );
            WdeMemFree( c_is.d.caption );
            c_is.d.caption = NULL;
            return;
        }
        strupr( str );
        c_is.symbol = str;
        c_is.d.name = NULL;
    }

    Forward( is->obj, MODIFY_INFO, &c_is, NULL );

    if( c_is.symbol ) {
        WdeAddUniqueStringToCombo( WdeInfoWindow, IDB_INFO_IDSTR,
                                   c_is.symbol );
        value = WdeLookupName( c_is.res_info->hash_table, c_is.symbol, &found );
        if( found ) {
            WdeSetEditWithSINT32( (int_32) value, 10, WdeInfoWindow, IDB_INFO_IDNUM );
        }
    } else if( str_is_ordinal ) {
        WdeSetEditWithSINT32( (int_32)ord, 10, WdeInfoWindow, IDB_INFO_IDNUM );
    } else {
        WdeSetEditWithStr( "", WdeInfoWindow, IDB_INFO_IDNUM );
    }

    *is = c_is;
}

void WdeChangeControlInfo ( WdeInfoStruct *is )
{
    char                *str;
    char                *cp;
    WdeInfoStruct       c_is;
    Bool                str_is_ordinal;
    uint_16             ord;
    Bool                found;
    WdeHashValue        value;

    c_is = *is;

    str = NULL;
    cp = WdeGetStrFromEdit( WdeInfoWindow, IDB_INFO_CAPTION, NULL );
    if( cp ) {
        str = WRConvertStringTo( cp, "\t\n", "tn" );
        WdeMemFree( cp );
    }

    if( str ) {
        c_is.c.text = ResStrToNameOrOrd( str );
        WdeMemFree( str );
    } else {
        c_is.c.text = NULL;
    }

    str = WdeGetStrFromCombo ( WdeInfoWindow, IDB_INFO_IDSTR );
    if( str == NULL ) {
        WdeMemFree( c_is.c.text );
        c_is.c.text = NULL;
        return;
    }

    WRStripSymbol( str );

    if( str[0] == '\0' ) {
        WdeMemFree( str );
        WdeMemFree( c_is.c.text );
        c_is.c.text = NULL;
        return;
    }

    ord = ( uint_16 )strtoul( str, &cp, 0 );
    str_is_ordinal = ( *cp == '\0' );

    c_is.symbol = NULL;

    if( str_is_ordinal ) {
        c_is.c.id = ord;
        WdeMemFree( str );
    } else {
        if( !WdeIsValidSymbol( str ) ) {
            WdeMemFree( str );
            WdeMemFree( c_is.c.text );
            c_is.c.text = NULL;
            return;
        }
        strupr( str );
        c_is.symbol = str;
    }

    Forward( c_is.obj, MODIFY_INFO, &c_is, NULL );

    if( c_is.symbol ) {
        WdeAddUniqueStringToCombo( WdeInfoWindow, IDB_INFO_IDSTR,
                                   c_is.symbol );
        value = WdeLookupName( c_is.res_info->hash_table, c_is.symbol, &found );
        if( found ) {
            WdeSetEditWithSINT32( (int_32) value, 10, WdeInfoWindow, IDB_INFO_IDNUM );
        }
    } else if( str_is_ordinal ) {
        WdeSetEditWithSINT32( (int_32)ord, 10, WdeInfoWindow, IDB_INFO_IDNUM );
    } else {
        WdeSetEditWithStr( "", WdeInfoWindow, IDB_INFO_IDNUM );
    }

    *is = c_is;
}

void WdeWriteObjectDimensions ( int x, int y, int width, int height )
{
    char str[56];

    sprintf ( str, "(%d,%d) (%d,%d) %dx%d",
              x, y, x + width, y + height, width, height );

    WdeSetEditWithStr ( str, WdeInfoWindow, IDB_INFO_SIZE );
}

void WdeInfoLookupComboEntry ( HWND hWnd, WORD hw )
{
    char                *cp;
    char                *str;
    WdeHashValue        value;
    Bool                found;
    LRESULT             index;
    int                 count;

    if ( !WdeCurrentInfo.res_info->hash_table ) {
        return;
    }

    count = SendDlgItemMessage ( hWnd, IDB_INFO_IDSTR, CB_GETCOUNT, 0, 0 );
    if ( !count || (count == CB_ERR) ) {
        return;
    }

    str = NULL;
    if ( hw == CBN_EDITCHANGE ) {
        str = WdeGetStrFromCombo ( hWnd, IDB_INFO_IDSTR );
    } else {
        index = SendDlgItemMessage ( hWnd, IDB_INFO_IDSTR,
                                     CB_GETCURSEL, 0, 0 );
        if ( index != CB_ERR ) {
            str = WdeGetStrFromComboLBox ( hWnd, IDB_INFO_IDSTR, index );
        }
    }

    if( str == NULL ) {
        return;
    }

    WRStripSymbol( str );

    // if the string numeric or empty then return
    strtoul( str, &cp, 0 );
    if( *cp == '\0' ) {
        WdeMemFree( str );
        return;
    }

    if( _mbclen( str ) == 1 && str[0] == '"' ) {
        value = WdeLookupName ( WdeCurrentInfo.res_info->hash_table,
                                str, &found );
        if( found ) {
            WdeSetEditWithSINT32 ( (int_32) value, 10, hWnd, IDB_INFO_IDNUM );
        }
    }

    WdeMemFree ( str );
}

LRESULT WINEXPORT WdeInfoWndProc( HWND hWnd, UINT message,
                                  WPARAM wParam, LPARAM lParam )
{
    WORD w;
    RECT r;
    HDC  dc;

    _wde_touch(lParam);

    switch ( message ) {

#if defined (__NT__)
        case WM_INITDIALOG:
            SetWindowLong( hWnd, GWL_STYLE, WS_CHILD );
        break;
#endif
        case WM_SYSCOLORCHANGE:
#if defined (__NT__)
            WdeInfoColor = GetSysColor( COLOR_BTNFACE );
            DeleteObject( WdeInfoBrush );
            WdeInfoBrush = CreateSolidBrush( WdeInfoColor );
#endif
            WdeCtl3dColorChange ();
            break;

#ifdef __NT__
        case WM_CTLCOLORBTN :
        case WM_CTLCOLORSTATIC:
            dc = (HDC)  wParam;
            SetBkColor ( dc, WdeInfoColor );
            return ( (LRESULT) WdeInfoBrush );

        case WM_CTLCOLORMSGBOX:
        case WM_CTLCOLOREDIT:
            return ( (LRESULT) NULL );
#else
        case WM_CTLCOLOR:
            w = HIWORD(lParam);
            if ( ( w != CTLCOLOR_MSGBOX ) && ( w != CTLCOLOR_EDIT ) ) {
                dc = (HDC) wParam;
                SetBkColor ( dc, WdeInfoColor );
                return ( (LRESULT) WdeInfoBrush );
            } else {
                return ( (LRESULT) NULL );
            }
#endif

        case WM_ERASEBKGND:
#if defined (__NT__)
            if( WdeInfoColor != GetSysColor( COLOR_BTNFACE )) {
                /* Fake it, this proc does not get it ... */
                SendMessage( hWnd, WM_SYSCOLORCHANGE, (WPARAM)0, (LPARAM)0);
            }
#endif
            GetClientRect( hWnd, &r );
            UnrealizeObject( WdeInfoBrush );
            FillRect( (HDC)wParam, &r, WdeInfoBrush );
            return ( TRUE );

        case WM_COMMAND:
            w = GET_WM_COMMAND_CMD(wParam,lParam);
            switch ( LOWORD(wParam) ) {
                case IDB_INFO_IDSTR:
                    if ( ( w == CBN_EDITCHANGE ) ||
                         ( w == CBN_SELCHANGE ) ) {
                        WdeInfoLookupComboEntry ( hWnd, w );
                    }
                    break;

                case IDB_INFO_SET:
                    WdeChangeInfo();
                    SetFocus( WdeGetMainWindowHandle() );
                    break;

                case IDB_INFO_RESET:
                    WdeResetInfo();
                    break;

                case IDCANCEL:
                    WdeResetInfo();
                    SetFocus( WdeGetMainWindowHandle() );
                    break;

            }
            break;
    }

    return ( FALSE );
}

⌨️ 快捷键说明

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