红联Linux门户
Linux帮助

请教关于结构体问题!!

发布时间:2007-04-13 17:49:26来源:红联作者:jk1983
有两个结构体:
其一:typedef struct _rcafilelist{
HWND hwnd ;
INT8U filelist_status ;
INT8U total_items ;
INT8U focused_item_index ;
INT8U first_item_index ;
INT8U list_levels ;
INT8U title_length ;

INT32U deactive_bmp ;
INT32U deactive_focused_bmp ;
INT32U unselected_bmp;
INT32U selected_bmp ;
INT32U selected_left_bmp ;
INT32U selected_right_bmp ;
INT32U selected_both_bmp ;
INT32U picked_bmp ;
INT32U focused_picked_bmp ;

INT16U deactive_bmp_type ;
INT16U deactive_focused_bmp_type ;
INT16U unselected_bmp_type;
INT16U selected_bmp_type ;
INT16U selected_left_bmp_type ;
INT16U selected_right_bmp_type ;
INT16U selected_both_bmp_type ;
INT16U picked_bmp_type ;
INT16U focused_picked_bmp_type ;

INT16U filelist_bmp_start_x ;
INT16U filelist_bmp_start_y ;
INT16U filelist_title_start_x ;
INT16U filelist_title_start_y ;

DRAWINFO list_up_arrow_info;
DRAWINFO list_down_arrow_info;
DRAWINFO filelist_hint_info ;
TFILELISTITEM* filelist_items;

GETFILEENTRYS get_next_entrys ;
GETFILEENTRYS get_prev_entrys ;
CDNEWENTRY cd_new_entry ;
GETENTRYFULLNAMEANDTYPE get_entry_full_name ;
CDROOTENTRY cd_root_entry ;

INT16U index[MAX_INDEX_BAK];
INT16U focus[MAX_INDEX_BAK];
}TFILELIST ;
其二:
typedef struct _hwnd {
PHWND parent;
PHWND children;
PHWND siblings;
PWNDCLASS pClass;
INT32U style;
RECT winrect;
CHARSTR win_name[MAX_LENGTH_OF_WIN_CONTROL_NAME];
INT16U win_id ;
INT8U draw_info_num;
PDRAWINFO draw_info ;
WINPROC WinProc ;
INT32S userdata;
} HWND ;

而后定义了:1、PHWND hwnd;
2、TFILELIST *pList = (TFILELIST *)hwnd ;
3、 pList->filelist_hint_info.draw_data = (INT32U)EMPTY_FOLDER_HELP_STR ;
问题只是在第二句:
结构体之间的强制类型转换,到底内部是如何进行偏移地址转换的?
文章评论

共有 57 条评论

  1. 81.183.198.* 于 2007-05-16 03:21:15发表:

    http://85d77f617255ff6c6a29750ef9d717db-t.qwoypw.info 85d77f617255ff6c6a29750ef9d717db http://85d77f617255ff6c6a29750ef9d717db-b1.qwoypw.info 85d77f617255ff6c6a29750ef9d717db http://85d77f617255ff6c6a29750ef9d717db-b3.qwoypw.info b43a48a848da56275457e93295654b68

  2. jk1983 于 2007-04-16 15:30:54发表:

    struct list_head {
    struct list_head *next, *prev;
    };
    typedef struct list_head list_t;
    //上面的这个应该是结构体内嵌,作用是定义了两个指针,长度需要看所移植的处理器位数
    typedef struct {
    list_t link;
    char* p_name;
    char class_name[MAX_LENGTH_OF_CLASS_NAME];
    INT32U extra_bytes;
    WINPROC ClassProc ;
    }*PWNDCLASS;

    typedef struct _hwnd {
    PHWND parent;
    PHWND children;
    PHWND siblings;
    PWNDCLASS pClass;
    INT16U win_id ;
    INT8U draw_info_num;
    ......
    } HWND ;

    typedef struct _hwnd *PHWND;
    另外一个结构体://和一楼定义的一样
    typedef struct _rcafilelist{
    HWND hwnd ;
    INT8U filelist_status ;
    INT8U total_items ;
    INT8U focused_item_index ;
    INT8U first_item_index ;
    INT8U list_levels ;
    INT8U title_length ;

    INT32U deactive_bmp ;
    INT32U deactive_focused_bmp ;
    ........
    }TFILELIST ;

    typedef struct {
    INT16U draw_pos_x ;
    INT16U draw_pos_y ;
    INT16U draw_width;
    INT16U draw_height;
    INT32U draw_data;
    INT16U draw_type ;
    } DRAWINFO ,*PDRAWINFO;
    那么按照一楼所提的几个问题:
    1、PHWND hwnd;

    2、TFILELIST *pList = (TFILELIST *)hwnd ;

    3、 pList->filelist_hint_info.draw_data = (INT32U)EMPTY_FOLDER_HELP_STR ;//此句的意思是系统窗口显示中读到的文件列表为文件夹的扩展名时,那么先初始化文件夹项
    pList->filelist_items[index].filelist_item_bmp = (INT32U)0 ;//显示文件夹的图标

    [ 本帖最后由 jk1983 于 2007-4-16 15:51 编辑 ]

  3. jk1983 于 2007-04-16 13:37:39发表:

    自己顶一下先!有没有人帮忙解读一下啊?谢谢了!