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

📄 wdefdiag.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
            WdeWriteTrail("WdeDBIFromObject: GET_OBJECT_HELPINFO failed!");
            WdeFreeDialogBoxInfo ( info );
            return ( NULL );
        }

        control = WdeCopyDialogBoxControl( control );

        control->symbol     = WdeStrDup( symbol );
        control->helpsymbol = WdeStrDup( helpsymbol );

        if( obj->dialog_info->is32bit ) {
            if( ( control->HelpId != 0 ) || ( control->ExtendedStyle != 0 ) ) {
                is32bitEx = TRUE;
            }
        }

        if( end ) {
            ListInsertElt ( end, control );
            end = ListNext ( end );
        } else {
            ListAddElt ( &(info->control_list), control );
            end = info->control_list;
        }
    }

    dh = info->dialog_header;
    if( obj->dialog_info->is32bit ) {
        if( ( dh->HelpId != 0 ) || ( dh->ExtendedStyle != 0 ) ||
            dh->FontWeightDefined || dh->FontItalicDefined ) {
            is32bitEx = TRUE;
        }
    } else {
        dh->is32bit = FALSE;
    }

    dh->is32bitEx = is32bitEx;

    return ( info );
}

static uint_32 NumDialogTitles = 0;

WResID *WdeCreateDialogTitle( void )
{
    char        *text;
    char        *title;
    WResID      *name;

    NumDialogTitles++;

    name = NULL;
    text = WdeAllocRCString( WDE_DEFDIALOGNAME );
    if( text ) {
        title = (char *)WdeMemAlloc( strlen(text) + 10 + 1 );
        if( title ) {
            title[0] = '\0';
            sprintf( title, text, NumDialogTitles );
            name = WResIDFromStr( title );
            WdeMemFree( title );
        }
        WdeFreeRCString( text );
    }

    return( name );
}

RECT *WdeGetDefaultDialogNCSize ( void )
{
    static RECT nc_size;
    static Bool nc_size_set = FALSE;

    if ( !nc_size_set ) {
        nc_size.left    = GetSystemMetrics (SM_CXDLGFRAME) +
                          GetSystemMetrics (SM_CXBORDER);
        nc_size.right   = nc_size.left;

        nc_size.bottom  = GetSystemMetrics (SM_CYDLGFRAME);
        nc_size.top     = nc_size.bottom;
        nc_size.bottom += GetSystemMetrics (SM_CYBORDER);
        nc_size.top    += GetSystemMetrics (SM_CYCAPTION);

        nc_size_set = TRUE;
    }

    return ( &nc_size );
}

Bool WdeKludgeDialogSize( WdeDialogObject *obj, Bool adjust_for_nc,
                          Bool snap_to_grid )
{
    RECT        old_rect;
    RECT        new_rect;
    Bool        user_action;
    POINT       pt;

    Location( (OBJPTR)obj, &old_rect );

    if( snap_to_grid ) {
        pt.x = GETHDR_SIZEX( obj->dialog_info );
        pt.y = GETHDR_SIZEY( obj->dialog_info );
        WdeSnapPointToGrid( &pt );
        SETHDR_SIZEX( obj->dialog_info, pt.x );
        SETHDR_SIZEY( obj->dialog_info, pt.y );
    }

    if( !WdeDialogToScreen( obj, &(obj->resizer),
                            GETHDR_PSIZE(obj->dialog_info), &new_rect ) ) {
        WdeWriteTrail("WdeKludgeDialogSize: WdeDialogToScreen failed!");
        return( FALSE );
    }

    if ( adjust_for_nc ) {
        /* adjust for the size of the non-client area */
        new_rect.left   -= obj->nc_size.left;
        new_rect.top    -= obj->nc_size.top;
        new_rect.right  += obj->nc_size.right;
        new_rect.bottom += obj->nc_size.bottom;
    }

    user_action = FALSE;

    /* YIKES!!! what a kludge */
    if ( !EqualRect ( &new_rect, &old_rect ) ) {
        if ( !WdeDialogResize ( obj, &new_rect, &user_action ) ) {
            WdeWriteTrail("WdeKludgeDialogSize: Resize failed!");
            return ( FALSE );
        }
    }

    return ( TRUE );
}

OBJPTR WdeCreateNewDialog( WResID *name, Bool is32bit )
{
    OBJPTR           base_obj;
    WdeDialogObject *new;
    RECT             new_rect;
    Bool             ok;


    ok = ( ( base_obj = GetMainObject() ) != NULL );

    if( ok ) {
        new_rect.left   = WDE_NEW_DIALOG_X;
        new_rect.top    = WDE_NEW_DIALOG_Y;
        new_rect.right  = WDE_NEW_DIALOG_WIDTH;
        new_rect.bottom = WDE_NEW_DIALOG_HEIGHT;
        ok = ((new = WdeDialogCreater(base_obj, &new_rect, NULL)) != NULL);
        if( !ok ) {
            WdeWriteTrail("WdeCreateNewDialog: Create failed!");
        }
    }

    if( ok ) {
        if( name != NULL ) {
            new->name = WdeCopyWResID( name );
        } else {
            new->name = WdeCreateDialogTitle();
        }
//      new->helpname = NULL;
        new->helpsymbol = NULL;
        ok = ( new->name != NULL );
        if( !ok ) {
            WdeWriteTrail("WdeDialogCreate: could not create dialog name!");
        }
    }

    if( ok ) {
        ok = WdeSetObjectInfo( new, &(new->res_info), &(new->dlg_item),
                               new->name );
    }

    if ( ok ) {
        new->dlg_item->is32bit = is32bit;
        SETHDR_SIZEX( WdeDefaultDialog, WDE_NEW_DIALOG_X );
        SETHDR_SIZEY( WdeDefaultDialog, WDE_NEW_DIALOG_Y );
        SETHDR_SIZEW( WdeDefaultDialog, WDE_NEW_DIALOG_WIDTH );
        SETHDR_SIZEH( WdeDefaultDialog, WDE_NEW_DIALOG_HEIGHT );

        new->dialog_info = WdeCopyDialogBoxHeader( WdeDefaultDialog );
        ok = ( new->dialog_info != NULL );
        if ( !ok ) {
            WdeWriteTrail("WdeDialogCreate: CopyDBH failed!");
        }
    }

    if ( ok ) {
        ok = WdeDialogCreateWindow ( new, NULL, NULL );
        if ( !ok ) {
            WdeWriteTrail("WdeDialogCreate: CREATE_WINDOW failed!");
        }
    }

    if ( ok ) {
        ok = Register ( (OBJPTR)new );
        if ( !ok ) {
            WdeWriteTrail("WdeCreateNewDialog: Register failed!");
        }
    }

    if ( ok ) {
        MakeObjectCurrent ( new );
    } else {
        if ( new ) {
            Destroy ( (OBJPTR)new, FALSE );
            new = NULL;
        }
    }

    return ( new );
}

OBJPTR WdeCreateDialogFromRes ( WdeResInfo *res_info, WdeResDlgItem *ditem )
{
    OBJPTR           base_obj;
    WdeDialogObject *new;
    RECT             new_rect;
    Bool             ok;
    Bool             show;

    ok = ( res_info && ditem );

    if ( ok ) {
        ok = ( ( base_obj = GetMainObject() ) != NULL );
    }

    if ( ok ) {
        new_rect.left   = WDE_NEW_DIALOG_X;
        new_rect.top    = WDE_NEW_DIALOG_Y;
        new_rect.right  = WDE_NEW_DIALOG_WIDTH;
        new_rect.bottom = WDE_NEW_DIALOG_HEIGHT;
        ok = ((new = WdeDialogCreater (base_obj, &new_rect, NULL)) != NULL);
    }

    if ( ok ) {
        new->name = WdeCopyWResID ( ditem->dialog_name );
//      new->helpname = WdeCopyWResHelpID ( ditem->helpname );
        ok = ( new->name != NULL );
    }

    if ( ok ) {
        new->res_info    = res_info;
        new->dlg_item    = ditem;
        new->mem_flags   = ditem->dialog_info->MemoryFlags;
        new->dialog_info =
            WdeCopyDialogBoxHeader ( ditem->dialog_info->dialog_header );
        ok = ( new->dialog_info != NULL );
    }

    if ( ok ) {
        show = FALSE;
        ok = WdeDialogCreateWindow ( new, &show, NULL );
    }

    if ( ok ) {
        ok = Register ( (OBJPTR)new );
    }

    if ( !ok ) {
        Destroy ( (OBJPTR)new, FALSE );
        new = NULL;
    }

    return ( new );
}

OBJPTR WINEXPORT WdeDialogCreate ( OBJPTR parent, RECT *obj_rect,
                                   OBJPTR handle)
{
    WdeDialogObject *new;
    RECT            *def_nc_size;

    def_nc_size = WdeGetDefaultDialogNCSize ();

    obj_rect->left   += def_nc_size->left;
    obj_rect->top    += def_nc_size->top;
    obj_rect->right  -= def_nc_size->right;
    obj_rect->bottom -= def_nc_size->bottom;

    if ( obj_rect->right < obj_rect->left ) {
        obj_rect->right = obj_rect->left;
    }

    if ( obj_rect->bottom < obj_rect->top ) {
        obj_rect->bottom = obj_rect->top;
    }

    new = WdeDialogCreater ( parent, obj_rect, handle);

    if ( new == NULL) {
        return ( NULL );
    }

    new->name = WdeCreateDialogTitle();
    if ( !new->name ) {
        WdeWriteTrail("WdeDialogCreate: WdeCreateDialogTitle failed!");
        Destroy ( (OBJPTR)new, FALSE );
        return ( NULL );
    }

    if ( !WdeSetObjectInfo ( new, &(new->res_info), &(new->dlg_item),
                             new->name ) ) {
        WdeWriteTrail("WdeDialogCreate: WdeSetObjectInfo failed!");
        Destroy ( (OBJPTR)new, FALSE );
        return ( NULL );
    }

    WdeScreenToDialog( new->parent, NULL, obj_rect,
                       GETHDR_PSIZE(WdeDefaultDialog) );

    new->dialog_info = WdeCopyDialogBoxHeader ( WdeDefaultDialog );
    if ( !new->dialog_info ) {
        WdeWriteTrail("WdeDialogCreate: CopyDBH failed!");
        Destroy ( (OBJPTR)new, FALSE );
        return ( NULL );
    }

    if ( !WdeDialogCreateWindow ( new, NULL, NULL ) ) {
        WdeWriteTrail("WdeDialogCreate: CREATE_WINDOW failed!");
        Destroy ( (OBJPTR)new, FALSE );
        return ( NULL );
    }

    return ( new );
}

OBJPTR WdeDialogCreater ( OBJPTR parent, RECT *obj_rect, OBJPTR handle)
{
    WdeDialogObject *new;
    OBJPTR           ancestor;
    OBJ_ID           ancestor_id;
    RECT             parent_rect;
    Bool             resize_dialog_height;
    Bool             resize_dialog_width;

    WdeDebugCreate("Dialog", parent, obj_rect, handle);

    if ( parent == NULL ) {
        WdeWriteTrail("WdeDialogCreater: Dialog has no parent!");
        return ( NULL );
    }

    new = (WdeDialogObject *) WdeMemAlloc ( sizeof(WdeDialogObject) );
    if ( new == NULL ) {
        WdeWriteTrail("WdeDialogCreater: Dialog object malloc failed");
        return ( new );
    }
    memset ( new, 0, sizeof(WdeDialogObject) );

    /* make sure we are setting the correct parent */
    ancestor = parent;
    Forward ((OBJPTR)ancestor, IDENTIFY, &ancestor_id, NULL);
    while ( ancestor_id != BASE_OBJ ) {

        GetObjectParent(ancestor, &ancestor);
        Forward ((OBJPTR)ancestor, IDENTIFY, &ancestor_id, NULL);

    }

    new->parent     = ancestor;
    new->object_id  = DIALOG_OBJ;
    new->mode       = WdeSelect;
    new->dispatcher = WdeDialogDispatch;
    new->mem_flags  = DEFAULT_MEMFLAGS;

    resize_dialog_height = FALSE;
    resize_dialog_width  = FALSE;

    if( (obj_rect->right - obj_rect->left) < DIALOG_MIN_WIDTH  ) {
        resize_dialog_width = TRUE;
    }

    if( (obj_rect->bottom - obj_rect->top) < DIALOG_MIN_HEIGHT ) {
        resize_dialog_height = TRUE;
    }

    if( resize_dialog_width || resize_dialog_height ) {
        Location( new->parent, &parent_rect );
    }

    if( resize_dialog_width ) {
        if( (obj_rect->left + DIALOG_MIN_WIDTH) >= parent_rect.right ) {
            obj_rect->left  = max ( 0, obj_rect->right - DIALOG_MIN_WIDTH);
        } else {
            obj_rect->right = obj_rect->left + DIALOG_MIN_WIDTH;
        }
    }

    if( resize_dialog_height ) {
        if( (obj_rect->top + DIALOG_MIN_HEIGHT) >= parent_rect.bottom ) {
            obj_rect->top  = max ( 0, obj_rect->bottom - DIALOG_MIN_HEIGHT);
        } else {
            obj_rect->bottom = obj_rect->top + DIALOG_MIN_WIDTH;
        }
    }

    if (!Forward ( new->parent, GET_WINDOW_HANDLE,
                   &(new->parent_handle), NULL)) {
        WdeWriteTrail("WdeDialogCreater: Couldn't get parent window handle!");
        WdeFreeDialogBoxHeader(&(new->dialog_info));
        WdeMemFree(new);
        return ( NULL );
    }

⌨️ 快捷键说明

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