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

📄 wdefcntl.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    return  ( *template != NULL );
}

BOOL WdeControlTestEX ( WdeControlObject *obj, GLOBALHANDLE *template,
                        void *p2 )
{
    char         *Text;
    char         *Class;
    uint_32       style;
    uint_16       ID;

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

    Text = WdeResNameOrOrdinalToStr( GETCTL_TEXT( obj->control_info ), 10 );
    if ( !Text ) {
        Text = WdeStrDup ( "" );
        if ( !Text ) {
            return ( FALSE );
        }
    }

    Class = WdeControlClassToStr( GETCTL_CLASSID( obj->control_info ) );
    if ( !Class ) {
        Class = WdeStrDup ( "" );
        if ( !Class ) {
            WdeMemFree ( Text );
            return ( FALSE );
        }
    }

    style = GETCTL_STYLE( obj->control_info );

    ID = GETCTL_ID( obj->control_info );
    if( !stricmp(obj->window_class,"combobox")  ) {
        style = style &
            ( 0xffffffff ^ ( CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE ) );
    } else if( !stricmp(obj->window_class,"wde_borbtn")  ) {
        if( !WdeIsBorBtnIDSupported( GETCTL_ID( obj->control_info ) ) ) {
            ID = WDE_PREVIEW_ID;
        }
    }

    *template =
        AddControlEX( *template,
                    GETCTL_SIZEX( obj->control_info ),
                    GETCTL_SIZEY( obj->control_info ),
                    GETCTL_SIZEW( obj->control_info ),
                    GETCTL_SIZEH( obj->control_info ),
                    ID,
                    style,
                    GETCTL_EXSTYLE( obj->control_info ),
                    GETCTL_HELPID( obj->control_info ),
                    Class,
                    Text,
                    0, NULL );

    WdeMemFree(Text);
    WdeMemFree(Class);

    return  ( *template != NULL );
}

BOOL WdeControlIsMarkValid ( WdeControlObject *obj, BOOL *flag, void *p2 )
{
    uint_32 s;

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

    if ( ( obj->mode == WdeSelect ) && ( obj->window_handle != NULL ) ) {
        s = ( uint_32 ) GetWindowLong ( obj->window_handle, GWL_STYLE );
        *flag = ( ( s & WS_VISIBLE ) != 0 );
    } else {
        *flag = FALSE;
    }

    return ( TRUE );
}

BOOL WdeControlDestroy ( WdeControlObject *obj, BOOL *flag, void *p2 )
{
    RECT        rect;
    OBJPTR      next;
    Bool        check_scroll;

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

    check_scroll = ( obj->parent == obj->base_obj );

    if ( *flag ) {
        if ( obj->res_info ) {
            next = WdeGetNextObject(FALSE, obj->object_handle, obj->parent);
            if ( !next ) {
                next = obj->parent;
            }
            obj->res_info->next_current = next;
        }
    }

    Location ( obj->object_handle, &rect );

    if ( obj->parent && !Forward ( obj->parent, REMOVE_SUBOBJECT,
                                   obj->object_handle, NULL ) ) {
        WdeWriteTrail("WdeControlDestroy: RemoveObject failed!");
    }

    *flag = FALSE;

    if ( !Forward ( obj->o_item, DESTROY, flag, NULL ) ) {
        WdeWriteTrail("WdeControlDestroy: Failed to destroy OITEM!");
        if ( obj->parent ) {
            AddObject(obj->parent, obj->object_handle);
        }
        return ( FALSE );
    }

    if ( obj->window_handle != NULL ) {
        DestroyWindow(obj->window_handle);
    }

    if( obj->res_info ) {
        if( obj->res_info->next_current == obj->object_handle ) {
            obj->res_info->next_current = NULL;
        }
    }

    WdeFreeControlObject ( obj );

    MarkInvalid( &rect );

    if( check_scroll ) {
        WdeCheckBaseScrollbars( FALSE );
    }

    return( TRUE );
}

void WdeFreeControlObject ( WdeControlObject *obj )
{
    if ( obj->symbol ) {
        WdeMemFree ( obj->symbol ) ;
    }

    if ( obj->helpsymbol ) {
        WdeMemFree ( obj->helpsymbol ) ;
    }

    if ( obj->control_info ) {
        WdeFreeDialogBoxControl ( &(obj->control_info) ) ;
    }

    WdeMemFree( obj );
}

BOOL WdeChangeControlSize( WdeControlObject *obj, BOOL widths_only,
                           BOOL snap_to_grid )
{
    RECT      t;
    RECT      size;
    RECT      obj_rect;
    POINT     origin;
    POINT     pt;

    Location( obj->object_handle, &obj_rect );

    if( snap_to_grid ) {
        pt.x = GETCTL_SIZEX( obj->control_info );
        pt.y = GETCTL_SIZEY( obj->control_info );
        WdeSnapPointToGrid( &pt );
        SETCTL_SIZEX( obj->control_info, pt.x );
        SETCTL_SIZEY( obj->control_info, pt.y );
    }

    if( obj->parent != obj->base_obj ) {
        GetOffset( &origin );
        size.left   = (int_16) GETCTL_SIZEX( obj->control_info );
        size.right  = size.left + (int_16) GETCTL_SIZEW( obj->control_info );
        size.top    = (int_16) GETCTL_SIZEY( obj->control_info );
        size.bottom = size.top + (int_16) GETCTL_SIZEH( obj->control_info );
        MapDialogRect( obj->parent_handle, &size );
        WdeMapWindowRect(obj->parent_handle, obj->res_info->edit_win, &size);
        OffsetRect( &size, origin.x, origin.y );
    } else {
        WdeDialogToScreen( obj->object_handle, NULL,
                           GETCTL_PSIZE( obj->control_info ), &size );
    }

    if( widths_only ) {
        t = obj_rect;
        t.right  = t.left + ( size.right  - size.left );
        t.bottom = t.top  + ( size.bottom - size.top );
        size = t;
    }

    if ( !EqualRect ( &size, &obj_rect ) ) {
        if ( !Resize ( obj->object_handle, &size, FALSE ) ) {
            WdeWriteTrail("WdeChangeControlSize: RESIZE failed!");
            return ( FALSE );
        }
    }

    return ( TRUE );
}

BOOL WdeControlSetFont ( WdeControlObject *obj, HFONT *font,
                         WdeResizeRatio *resizer )
{
    ControlClass        *control_class;
    ResNameOrOrdinal    *rname;
    char                *name;
    char                temp[10];

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

    obj->font = *font;

    if (!Forward ( obj->parent, GET_WINDOW_HANDLE,
                   &(obj->parent_handle), NULL) ) {
        WdeWriteTrail("WdeControlSetFont: GET_WINDOW_HANDLE failed!");
        return ( FALSE );
    }

    if ( !WdeChangeControlSize ( obj, FALSE, FALSE ) ) {
        WdeWriteTrail("WdeControlSetFont: WdeChangeControlSize failed!");
        return ( FALSE );
    }

    if( obj->window_handle != NULL ) {

        control_class = GETCTL_CLASSID( obj->control_info );
        if( ( control_class->Class == CLASS_STATIC ) &&
            ( (GETCTL_STYLE(obj->control_info) & 0x0000000f) == SS_ICON ) ) {
            return ( TRUE );
        }

        name = NULL;
        rname = GETCTL_TEXT( obj->control_info );
        if( rname->ord.fFlag == 0xff ) {
            ultoa ( (uint_32) rname->ord.wOrdinalID, temp, 10 );
            name = temp;
        } else {
            if( rname->name[0] ) {
                name = rname->name;
            }
        }

        SendMessage ( obj->window_handle, WM_SETFONT, (WPARAM) *font,
                      (LPARAM) TRUE);

        SendMessage ( obj->window_handle, WM_SETTEXT, 0, (LPARAM) name);

    }

    return ( TRUE );
}

BOOL WdeControlDraw ( WdeControlObject *obj, RECT *area, HDC *dc )
{
    RECT    rect;
    RECT    trect;
    POINT   origin;
    UINT    flags;

    Location ( obj->object_handle, &rect );

    GetOffset(&origin);

    if ( dc && IntersectRect ( &trect, area, &rect ) ) {
        OffsetRect ( &trect, -origin.x, -origin.y );
        MapWindowPoints ( obj->res_info->edit_win, obj->window_handle,
                          (POINT *) &trect, 2 );
        RedrawWindow ( obj->window_handle, (RECT *) &trect, (HRGN) NULL,
                       RDW_INTERNALPAINT | RDW_UPDATENOW );
    }

    OffsetRect ( &rect, -origin.x, -origin.y );

    if ( obj->parent == obj->base_obj ) {
        flags = SWP_NOZORDER | SWP_NOSIZE;
        if ( !dc ) {
#if 1
            flags |= SWP_NOREDRAW | SWP_NOACTIVATE;
#endif
        }
        SetWindowPos ( obj->window_handle, (HWND) NULL,
                       rect.left, rect.top, 0, 0, flags );
    }

    return ( TRUE );
}

BOOL WdeControlOnTop ( WdeControlObject *obj, void *p1, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p1);
    _wde_touch(p2);

    WdeBringControlToTop ( obj );

    return ( TRUE );
}

BOOL WdeControlSetClearInt ( WdeControlObject *obj, BOOL *b, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    obj->clear_interior = *b;

    return ( TRUE );
}

BOOL WdeControlGetClearInt ( WdeControlObject *obj, BOOL *b, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    *b = obj->clear_interior;

    return ( TRUE );
}

BOOL WdeControlCreateWindow ( WdeControlObject *obj, void *p1, void *p2)
{
    ResNameOrOrdinal    *rname;
    char                *name;
    char                *cname;
    void                *crt_params;
    char                temp[10];
    POINT               pnt;
    RECT                obj_rect;
    DialogStyle         style;
    uint_32             exstyle;
    BOOL                set_font;
    BOOL                set_crt_params;
    POINT               origin;
    uint_16             ID;
    OBJ_ID              oid;
    WNDPROC             new_proc;

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

    if( !Forward( obj->parent, GET_WINDOW_HANDLE,
                  &obj->parent_handle, NULL ) ) {
        WdeWriteTrail("WdeControlCreateWindow: GET_WINDOW_HANDLE failed!");
        return ( FALSE );
    }

    if( !Forward( obj->object_handle, IDENTIFY, &oid, NULL ) ) {
        WdeWriteTrail("WdeControlCreateWindow: IDENTIFY failed!");
        return ( FALSE );
    }

    new_proc = (WNDPROC)NULL;
    if( !Forward( obj->object_handle, GET_WND_PROC, &new_proc, NULL ) ||
        new_proc == (WNDPROC)NULL ) {
        WdeWriteTrail("WdeControlCreateWindow: Could not get new wnd proc!");
        return ( FALSE );
    }

    set_font       = TRUE;
    set_crt_params = TRUE;

    Location( obj->object_handle, &obj_rect );

    GetOffset( &origin );

    pnt.x = obj_rect.left - origin.x;
    pnt.y = obj_rect.top  - origin.y;

    MapWindowPoints( obj->res_info->edit_win, obj->parent_handle, &pnt, 1);

    name  = NULL;
    cname = NULL;

    if( oid == ICON_OBJ ) {
        set_font = FALSE;
        name = "DefaultIcon";
    }

    if( !name ) {
        rname =  GETCTL_TEXT(obj->control_info);
        if( rname != NULL ) {
            if( rname->ord.fFlag == 0xff ) {
                ultoa( rname->ord.wOrdinalID, temp, 10 );
                name = temp;
            } else {
                if( rname->name[0] ) {
                    name = rname->name;
                }
            }
        }
    }

    style = GETCTL_STYLE( obj->control_info ) &
        (0xffffffff ^ ( WS_DISABLED | WS_MAXIMIZE | WS_MINIMIZE | WS_POPUP ));

#ifdef __NT__XX
    exstyle = GETCTL_EXSTYLE( obj->control_info );
#else
    exstyle = 0;
#endif

⌨️ 快捷键说明

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