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

📄 wdefcust.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    if ( !Forward ( obj->control, DESTROY, flag, NULL ) ) {
        WdeWriteTrail("WdeCustomDestroy: Control DESTROY failed");
        return ( FALSE );
    }

    if ( obj->win_class != NULL ) {
        WdeMemFree( obj->win_class );
    }

    WdeMemFree( obj );

    return ( TRUE );
}

BOOL WdeCustomValidateAction ( WdeCustomObject *obj, ACTION *act, void *p2 )
{
    int     i;

    for ( i = 0; i < MAX_ACTIONS; i++ ) {
        if( WdeCustomActions[i].id == *act ) {
            return ( TRUE );
        }
    }

    return ( ValidateAction( (OBJPTR) obj->control, *act, p2 ) );
}

BOOL WdeCustomCopyObject ( WdeCustomObject *obj, WdeCustomObject **new,
                           WdeCustomObject *handle )
{
    if (new == NULL) {
        WdeWriteTrail("WdeCustomCopyObject: Invalid new object!");
        return ( FALSE );
    }

    *new = (WdeCustomObject *) WdeMemAlloc ( sizeof(WdeCustomObject) );

    if ( *new == NULL ) {
        WdeWriteTrail("WdeCustomCopyObject: Object malloc failed");
        return ( FALSE );
    }

    (*new)->dispatcher = obj->dispatcher;
    (*new)->win_proc   = obj->win_proc;
    (*new)->win_extra  = obj->win_extra;
    (*new)->object_id  = obj->object_id;
    (*new)->cust_info  = obj->cust_info;
    (*new)->cust_type  = obj->cust_type;

    (*new)->win_class  = WdeStrDup ( obj->win_class );
    if ( (*new)->win_class == NULL ) {
        WdeWriteTrail("WdeCustomCopyObject: Class alloc failed!");
        WdeMemFree ( (*new) );
        return ( FALSE );
    }

    if ( handle ==  NULL ) {
        (*new)->object_handle = *new;
    } else {
        (*new)->object_handle = handle;
    }

    if (!CopyObject(obj->control, &((*new)->control), (*new)->object_handle)) {
        WdeWriteTrail("WdeCustomCopyObject: Control not created!");
        WdeMemFree ( (*new) );
        return ( FALSE );
    }

    return ( TRUE );
}

BOOL WdeCustomIdentify ( WdeCustomObject *obj, OBJ_ID *id, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    *id = obj->object_id;

    return ( TRUE );
}

BOOL WdeCustomGetWndProc( WdeCustomObject *obj, WNDPROC *proc, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(obj);
    _wde_touch(p2);

    *proc = WdeCustomSuperClassProc;

    return ( TRUE );
}

BOOL WdeCustomGetWindowClass ( WdeCustomObject *obj, char **class, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(obj);
    _wde_touch(p2);

    *class = obj->win_class;

    return ( TRUE );
}

BOOL WdeCustomDefine ( WdeCustomObject *obj, POINT *pnt, void *p2 )
{
    BOOL                        redraw;
    HWND                        dialog_owner;
    HGLOBAL                     ctl_style;
    uint_32                     ctl_size;
    WDECTLSTYLE                 *ctl_data;
    WdeCustStyleProc            proc;
    WdeDialogBoxControl         *info;
    char                        *text;
    int                         tlen;
    WdeDefineObjectInfo         o_info;

    /* touch unused vars to get rid of warning */
    _wde_touch(pnt);
    _wde_touch(p2);

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

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

    if ( !WdeGetOption ( WdeOptUseDefDlg ) ) {
        o_info.obj       = obj->object_handle;
        o_info.obj_id    = obj->object_id;
        o_info.mask      = 0xffff;
        o_info.hook_func = WdeWinStylesHook;
        o_info.set_func  = NULL;
        o_info.get_func  = NULL;
        o_info.res_info  = WdeGetCurrentRes();
        return ( WdeGenericDefine ( &o_info ) );
    }

    info = o_info.info.c.info;

    dialog_owner = WdeGetMainWindowHandle();

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

    if ( obj->cust_info->ms_lib ) {
        ctl_size = sizeof ( CTLSTYLE );
    } else {
        ctl_size = sizeof ( WDECTLSTYLE );
    }

    ctl_style = GlobalAlloc ( GMEM_MOVEABLE | GMEM_ZEROINIT, ctl_size );
    if ( ctl_style == NULL ) {
        WdeWriteTrail("WdeCustomDefine: Could not GlobalAlloc ctl_style!");
        return ( FALSE );
    }

    ctl_data = ( WDECTLSTYLE *) GlobalLock ( ctl_style );
    if ( ctl_data == NULL ) {
        WdeWriteTrail("WdeCustomDefine: Could not GlobalLock ctl_data!");
        GlobalFree ( ctl_style );
        return ( FALSE );
    }

    ctl_data->wX      = GETCTL_SIZEX(info);
    ctl_data->wY      = GETCTL_SIZEY(info);
    ctl_data->wCx     = GETCTL_SIZEW(info);
    ctl_data->wCy     = GETCTL_SIZEH(info);
    ctl_data->wId     = GETCTL_ID(info);
    ctl_data->dwStyle = GETCTL_STYLE(info);

    if( text = WdeResNameOrOrdinalToStr( GETCTL_TEXT(info), 10 ) ) {
        tlen = strlen( text );
        if( tlen < CTLCLASS ) {
            strcpy( ctl_data->szTitle, text );
        } else {
            memcpy( ctl_data->szTitle, text, CTLCLASS );
            ctl_data->szTitle[CTLCLASS-1] = '\0';
        }
        WdeMemFree( text );
    } else {
         ctl_data->szTitle[0] = '\0';
    }

    strcpy ( ctl_data->szClass, obj->cust_info->control_info.ms.szClass );

    if( !obj->cust_info->ms_lib ) {
        ctl_data->CtlDataSize = 0;
        memset( ctl_data->CtlData, 0, CTLDATALENGTH );
    }

    GlobalUnlock ( ctl_style );

    proc = obj->cust_info->style_proc;

    redraw = (BOOL) ( (*proc) ( dialog_owner, ctl_style,
                                (LPFNSTRTOID) WdeStr2ID,
                                (LPFNIDTOSTR) WdeID2Str ) );

    if ( redraw ) {

        ctl_data = ( WDECTLSTYLE *) GlobalLock ( ctl_style );
        if ( ctl_data == NULL ) {
            WdeWriteTrail("WdeCustomDefine: Could not GlobalLock ctl_data!");
            GlobalFree ( ctl_style );
            return ( FALSE );
        }

        SETCTL_SIZEX( info, ctl_data->wX );
        SETCTL_SIZEY( info, ctl_data->wY );
        SETCTL_SIZEW( info, ctl_data->wCx );
        SETCTL_SIZEH( info, ctl_data->wCy );
        SETCTL_ID( info, ctl_data->wId );
        SETCTL_STYLE( info, ctl_data->dwStyle );

        WdeMemFree( GETCTL_TEXT( info ) );
        WdeMemFree( GETCTL_CLASSID( info ) );
        SETCTL_TEXT( info, ResStrToNameOrOrd( ctl_data->szTitle ) );
        SETCTL_CLASSID( info, WdeStrToControlClass ( ctl_data->szClass ) );

        GlobalUnlock ( ctl_style );

        if ( !Forward ( obj->object_handle, DESTROY_WINDOW, NULL, NULL ) ) {
            WdeWriteTrail("WdeCustumDefine: DESTROY_WINDOW failed!");
            return ( FALSE );
        }

        if (!Forward (obj->object_handle, CREATE_WINDOW, NULL, NULL)) {
            WdeWriteTrail("WdeCustumDefine: CREATE_WINDOW failed!");
            return ( FALSE );
        }

        Notify ( obj->object_handle, CURRENT_OBJECT, NULL );
    }

    GlobalFree( ctl_style );

    WdeSetStatusReadyText();

    return( TRUE );
}

WORD WINEXPORT WdeIDToStr ( WORD id, LPSTR str, WORD len )
{
    char s[11];
    WORD slen;

    utoa ( id, s, 10 );
    slen = strlen ( s );
    if ( slen > ( len-1 ) ) {
        return ( 0 );
    }
    strcpy ( str, s );

    return ( slen );
}

DWORD WINEXPORT WdeStrToID ( LPSTR str )
{
    uint_32  num;
    DWORD    ret;
    char    *ep;

    num = (uint_32) strtoul ( str, &ep, 0 );
    if ( *ep ) {
        ret = MAKELONG ( (UINT)0, (UINT)0 );
    } else {
        ret = MAKELONG ( (UINT)1, (UINT)num );
    }

    return ( ret );
}

LRESULT WINEXPORT WdeCustomSuperClassProc( HWND hWnd, UINT message,
                                           WPARAM wParam,
                                           volatile LPARAM lParam )
{
    WNDPROC           wnd_proc;
    uint_16           extra;
    LIST             *clist;
    WdeCustClassNode *node;

    if ( WdeProcessMouse ( hWnd, message, wParam, lParam ) ) {
        return ( FALSE );
    }

    extra = (uint_16) GetClassWord ( hWnd, GCW_CBWNDEXTRA );
    extra -= sizeof(WNDPROC);
    wnd_proc = (WNDPROC) GetWindowLong ( hWnd, extra );
    if ( wnd_proc == NULL ) {
        if ( !GetClassName ( hWnd, WdeClassName, MAX_NAME ) ) {
            WdeWriteTrail("WdeCustomSuperClassProc: GetClassName failed!");
            return ( FALSE );
        }
        clist = WdeFindClassInList ( &(WdeClassName[4]) );
        if ( clist == NULL ) {
            WdeWriteTrail("WdeCustomSuperClassProc: FindClassInList failed!");
            return ( FALSE );
        }
        node = (WdeCustClassNode *) ListElement ( clist );
        wnd_proc = node->win_proc;
        if ( wnd_proc == NULL ) {
            WdeWriteTrail("WdeCustomSuperClassProc: NULL wnd_proc!");
            return ( FALSE );
        }
        SetWindowLong ( hWnd, extra, (LONG) wnd_proc );
    }

    return ( CallWindowProc ( wnd_proc, hWnd, message, wParam, lParam ) );

}

⌨️ 快捷键说明

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