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

📄 wdefutil.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
            if( entry ) {
                SETCTL_ID( o_info->info.c.info, entry->value );
            }
        }

    }

    WdeMemFree( str );
}

/* JPK - added function for help id */
void WdeGetDefineObjectHelpSymbolInfo( WdeDefineObjectInfo *o_info, HWND hDlg )
{
    char                *str;
    char                *cp;
    Bool                dup;
    Bool                quoted_str;
    Bool                str_is_ordinal;
    uint_32             ord;
    WdeHashEntry        *entry;

    if( !o_info ) {
        return;
    }

    if( o_info->helpsymbol ) {
        WdeMemFree( o_info->helpsymbol );
    }
    o_info->helpsymbol = NULL;

    str = WdeGetStrFromCombo( hDlg, IDB_HELPSYMBOL );
    if( str == NULL ) {
        return;
    }

    WRStripSymbol( str );

    quoted_str = FALSE;
    if( 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 );
        return;
    }

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

    if( o_info->obj_id == DIALOG_OBJ ) {

        if( str_is_ordinal ) {
            SETHDR_HELPID( o_info->info.d.header, ord );
        } else {
            dup = TRUE;
            o_info->helpsymbol = WdeStrDup( str );
            o_info->info.d.header->helpsymbol = WdeStrDup( str );
            strupr( o_info->helpsymbol );
            ord = GETHDR_HELPID(o_info->info.d.header);
            if (ord > 0) {
                entry = WdeAddHashEntry( o_info->res_info->hash_table,
                                         str, ord, &dup );
            } else {
                entry = WdeDefAddHashEntry( o_info->res_info->hash_table,
                                            str, &dup );
            }
            if( entry ) {
                SETHDR_HELPID( o_info->info.d.header, entry->value );
            }
        }

    } else {

        if( str_is_ordinal ) {
            SETCTL_HELPID( o_info->info.c.info, ord );
        } else {
            dup = FALSE;
            o_info->helpsymbol = WdeStrDup( str );
            o_info->info.c.info->helpsymbol = WdeStrDup( str );
            strupr( o_info->helpsymbol );
            ord = GETCTL_HELPID(o_info->info.c.info);
            if (ord > 0) {
                entry = WdeAddHashEntry( o_info->res_info->hash_table,
                                         str, ord, &dup );
            } else {
                entry = WdeDefAddHashEntry( o_info->res_info->hash_table,
                                            str, &dup );
            }
            if( entry ) {
                SETCTL_HELPID( o_info->info.c.info, entry->value );
            }
        }
    }

    WdeMemFree( str );
}

void WdeAddSymbolToObjectHashTable ( WdeResInfo *res_info, char *symbol,
                                     WdeHashValue val )
{
    Bool          force;

    if ( res_info && symbol ) {
        if ( !res_info->hash_table ) {
            res_info->hash_table = WdeInitHashTable ();
        }
        if ( res_info->hash_table ) {
            force = TRUE;
            WdeAddHashEntry( res_info->hash_table, symbol, val, &force );
        }
    }
}

UINT WdeTranslateNCMouseMsg ( UINT ncm )
{
    int i;

    for ( i = 0; WdeMouseMapper[i].ncm; i++ ) {
        if ( WdeMouseMapper[i].ncm == ncm ) {
            return ( WdeMouseMapper[i].m );
        }
    }
    return ( 0 );
}

Bool WdeProcessMouse( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    UINT    new_message;
    WPARAM  new_wparam;
    POINT   mouse_location;
    Bool    ret;

    ret = FALSE;

    switch( message ) {

        case WM_LBUTTONDBLCLK:
        case WM_LBUTTONDOWN:
        case WM_LBUTTONUP:
        case WM_RBUTTONDBLCLK:
        case WM_RBUTTONDOWN:
        case WM_RBUTTONUP:
        case WM_MBUTTONDBLCLK:
        case WM_MBUTTONDOWN:
        case WM_MBUTTONUP:
        case WM_MOUSEMOVE:
            MAKE_POINT( mouse_location, lParam );
            ClientToScreen( hWnd, &mouse_location );
            ScreenToClient( WdeGetEditWindowHandle ( NULL ),
                            &mouse_location );
            WdePassToEdit ( message, wParam, MAKELONG( mouse_location.x,
                                                       mouse_location.y ) );
            ret = TRUE;
            break;

        case WM_NCLBUTTONDBLCLK:
        case WM_NCLBUTTONDOWN:
        case WM_NCLBUTTONUP:
        case WM_NCRBUTTONDBLCLK:
        case WM_NCRBUTTONDOWN:
        case WM_NCRBUTTONUP:
        case WM_NCMBUTTONDBLCLK:
        case WM_NCMBUTTONDOWN:
        case WM_NCMBUTTONUP:
        case WM_NCMOUSEMOVE:
            new_wparam  = WdeGetKeys();
            new_message = WdeTranslateNCMouseMsg ( message );
            MAKE_POINT( mouse_location, lParam );
            ScreenToClient ( WdeGetEditWindowHandle ( NULL ),
                             &mouse_location );
            WdePassToEdit ( new_message, new_wparam,
                            MAKELONG ( mouse_location.x, mouse_location.y ) );
            ret = TRUE;
            break;
    }

    return ( ret );
}

BOOL WdeControlDefine( WdeDefineObjectInfo *o_info )
{
    char                *symbol;
    char                *helpsymbol;
    char                *dlg_template;
    BOOL                redraw;
    FARPROC             def_proc;
    HINSTANCE           app_inst;
    WdeOrderMode        mode;

    if( Forward( o_info->obj, GET_ORDER_MODE, &mode, NULL ) &&
        ( mode != WdeSelect ) ) {
        return( TRUE );
    }

    if( !Forward( o_info->obj, GET_OBJECT_INFO,
                  &(o_info->info.c.info), &symbol ) ) {
        WdeWriteTrail( "WdeControlDefine: GET_OBJECT_INFO failed!" );
        return( FALSE );
    }

    /* JPK - added for help id */
    if( !Forward( o_info->obj, GET_OBJECT_HELPINFO,
                  &(o_info->info.c.info), &helpsymbol ) ) {
        WdeWriteTrail( "WdeControlDefine: GET_OBJECT_HELPINFO failed!" );
        return( FALSE );
    }

    o_info->symbol      = WdeStrDup( symbol );
    o_info->helpsymbol  = WdeStrDup( helpsymbol );
    o_info->res_info    = WdeGetCurrentRes();

    if( o_info->win == NULL ) {
        if( !Forward( o_info->obj, GET_WINDOW_HANDLE, &o_info->win, NULL ) ) {
            WdeWriteTrail( "WdeControlDefine: GET_WINDOW_HANDLE failed!" );
            return( FALSE );
        }
    }

    if( !WdeGetOption( WdeOptUseDefDlg ) ) {
        return( WdeGenericDefine( o_info ) );
    }

    WdeSetStatusText( NULL, "", FALSE );
    WdeSetStatusByID( WDE_DEFININGCONTROL, -1 );

    app_inst = WdeGetAppInstance();

    dlg_template = WdeGetDefineProcFromOBJID( o_info->obj_id );
    if( dlg_template == NULL ) {
        WdeWriteTrail( "WdeControlDefine: Invalid OBJECT_ID!" );
        return( FALSE );
    }

    redraw = -1;

    def_proc = MakeProcInstance( (FARPROC) WdeControlDefineProc, app_inst );

    if( def_proc ) {
        redraw = JDialogBoxParam( app_inst, dlg_template, o_info->win,
                                  (DLGPROC) def_proc, (LPARAM) o_info );
        FreeProcInstance( def_proc );
    }

    if( redraw == -1 ) {
        WdeWriteTrail( "WdeControlDefine: Dialog not created!" );
        return( FALSE );
    } else if( redraw ) {
        if( !Forward( o_info->obj, SET_OBJECT_INFO, NULL, o_info->symbol ) ) {
            WdeWriteTrail("WdeControlDefine: SET_OBJECT_INFO failed!");
            return ( FALSE );
        }
        /* JPK - added this for help id */
        if( !Forward( o_info->obj, SET_OBJECT_HELPINFO, NULL, o_info->helpsymbol ) ) {
            WdeWriteTrail("WdeControlDefine: SET_OBJECT_HELPINFO failed!");
            return ( FALSE );
        }
        if( o_info->symbol ) {
            WdeAddSymbolToObjectHashTable( o_info->res_info, o_info->symbol,
                                           GETCTL_ID(o_info->info.c.info) );
        }
        if( o_info->helpsymbol ) {
            WdeAddSymbolToObjectHashTable( o_info->res_info, o_info->helpsymbol,
                                           GETCTL_HELPID(o_info->info.c.info) );
        }
        if( !Forward( o_info->obj, DESTROY_WINDOW, NULL, NULL ) ) {
            WdeWriteTrail( "WdeControlDefine: DESTROY_WINDOW failed!" );
            return( FALSE );
        }
        if( !Forward( o_info->obj, CREATE_WINDOW, NULL, NULL ) ) {
            WdeWriteTrail( "WdeControlDefine: CREATE_WINDOW failed!" );
            return( FALSE );
        }
        Notify( o_info->obj, PRIMARY_OBJECT, NULL );
    }

    if( o_info->symbol ) {
        WdeMemFree( o_info->symbol );
        o_info->symbol = NULL;
    }

    if( o_info->helpsymbol ) {
        WdeMemFree( o_info->helpsymbol );
        o_info->helpsymbol = NULL;
    }

    WdeSetStatusReadyText( );

    return( TRUE );
}

BOOL WINEXPORT WdeControlDefineProc ( HWND hDlg, UINT message,
                                      WPARAM wParam, LPARAM lParam )
{
    static WdeDefineObjectInfo *o_info   = NULL;
    static BOOL                 init_done = FALSE;
    BOOL                        ret;

    ret = FALSE;

    if ( init_done && o_info ) {
        if ( o_info->hook_func ) {
            ret = (*(o_info->hook_func)) ( hDlg, message, wParam, lParam, 0 );
        }

        if ( !ret ) {
            ret = WdeProcessSymbolCombo ( hDlg, message, wParam, lParam,
                                          o_info->res_info->hash_table,
                                          GETCTL_ID(o_info->info.c.info), TRUE );
        }

        /* JPK - added for help id support */
        if ( !ret ) {
            ret = WdeProcessHelpSymbolCombo ( hDlg, message, wParam, lParam,
                                              o_info->res_info->hash_table,
                                              GETCTL_HELPID(o_info->info.c.info),
                                              TRUE );
        }

        if ( ret ) {
            return ( ret );
        }
    }

    switch (message) {

        case WM_SYSCOLORCHANGE:
            WdeCtl3dColorChange ();
            break;

        case WM_INITDIALOG:
            init_done = TRUE;
            o_info = (WdeDefineObjectInfo *) lParam;
            if ( !o_info ) {
                EndDialog ( hDlg, FALSE );
                init_done = FALSE;
                ret = TRUE;
            } else {
                WdeSetDefineControlInfo ( o_info, hDlg );
            }
            ret = TRUE;
            break;

        case WM_COMMAND:
            switch ( LOWORD(wParam) ) {
                case IDB_HELP:
                    WdeHelpRoutine();
                    break;

                case IDOK:
                    WdeGetDefineControlInfo ( o_info, hDlg );
                    EndDialog ( hDlg, TRUE );
                    ret       = TRUE;
                    init_done = FALSE;
                    o_info   = NULL;
                    break;

                case IDCANCEL:
                    EndDialog ( hDlg, FALSE );
                    ret       = TRUE;
                    init_done = FALSE;
                    o_info   = NULL;
                    break;

            }
    }

    return ( ret );
}


Bool WdeWinStylesHook ( HWND hDlg, UINT message,
                        WPARAM wParam, LPARAM lParam, DialogStyle mask )
{
    DialogStyle  tstyle;

⌨️ 快捷键说明

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