MiniGUI原理分析 控件

五.控件分析

5.1 控件管理的基本数据结构

typedef struct _CTRLCLASSINFO
{
    char      name[MAXLEN_CLASSNAME + 1];// class name
    /*
     * common properties of this class
     */
    DWORD     dwStyle;          // Default control styles.
    DWORD     dwExStyle;        // Default control extended styles.
    HCURSOR   hCursor;          // control cursor
    int       iBkColor;         // control background color.
    int (*ControlProc)(HWND, int, WPARAM, LPARAM); // control procedure.
    DWORD dwAddData;            // the additional data.
    int nUseCount;              // use count.
    struct _CTRLCLASSINFO*  next;  // next class info
}CTRLCLASSINFO;


 

5.2 控件管理全局变量

static PCTRLCLASSINFO ccitable[LEN_CCITABLE];


 

5.3 控件注册到ccitable

BOOL mg_InitControlClass ()      //注册控件
{
    int i;
    for (i=0; i<LEN_CCITABLE; i++)
        ccitable[i] = NULL;
    // Register system controls here.
#ifdef _MGCTRL_STATIC
    if (!RegisterStaticControl ())
        return FALSE;
#endif
#ifdef _MGCTRL_BUTTON
    if (!RegisterButtonControl())
        return FALSE;
#endif
#ifdef _MGCTRL_SLEDIT
    if (!RegisterSLEditControl())
        return FALSE;
#endif
#ifdef _MGCTRL_BIDISLEDIT
    if (!RegisterBIDISLEditControl())
        return FALSE;
#endif
#ifdef _MGCTRL_PROGRESSBAR
    if (!RegisterProgressBarControl())
        return FALSE;
#endif
#ifdef _MGCTRL_LISTBOX
    if (!RegisterListboxControl())
        return FALSE;
#endif
#ifdef _MGCTRL_NEWTOOLBAR
    if (!RegisterNewToolbarControl())
        return FALSE;
#endif
#ifdef _MGCTRL_MENUBUTTON
    if (!RegisterMenuButtonControl())
        return FALSE;
#endif
#ifdef _MGCTRL_TRACKBAR
    if (!RegisterTrackBarControl())
        return FALSE;
#endif
#ifdef _MGCTRL_COMBOBOX
    if (!RegisterComboBoxControl())
        return FALSE;
#endif

#ifdef _MGCTRL_PROPSHEET
    if (!RegisterPropSheetControl())
        return FALSE;
#endif
#ifdef _MGCTRL_SCROLLVIEW
    if (!RegisterScrollViewControl ())
        return FALSE;
    if (!RegisterScrollWndControl ())
        return FALSE;
#endif
#ifdef _MGCTRL_TEXTEDIT
    if (!RegisterTextEditControl ())
        return FALSE;
#endif
#ifdef _MGCTRL_TREEVIEW
    if (!RegisterTreeViewControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: TreeView.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_TREEVIEW_RDR
    if (!RegisterTreeViewRdrControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: TreeView_rdr.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_MONTHCAL
    if (!RegisterMonthCalendarControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: MonthCalendar.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_SPINBOX
    if (!RegisterSpinControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: Spin.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_COOLBAR
    if (!RegisterCoolBarControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: CoolBar.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_LISTVIEW
    if (!RegisterListViewControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: ListView.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_GRIDVIEW
    if (!RegisterGridViewControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: GridView.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_ICONVIEW
    if (!RegisterIconViewControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: IconView.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_ANIMATION
    if (!RegisterAnimationControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: Animation.\n");
        return FALSE;
    }
#endif
#ifdef _MGCTRL_SCROLLBAR
    if (!RegisterScrollBarControl ()) {
        _MG_PRINTF ("Init MiniGUI control error: ScrollBar.\n");
        return FALSE;
    }
#endif
    return TRUE;
}


 

5.4 控件的创建和主窗口的创建

控件:

#define CreateWindow(class_name, caption, style, id, x, y, w, h, parent, add_data)       \
        CreateWindowEx(class_name, caption, style, 0, id, x, y, w, h, parent, add_data)

主窗口:

static inline HWND GUIAPI CreateMainWindow (PMAINWINCREATE pCreateInfo)
{
    return CreateMainWindowEx (pCreateInfo, NULL, NULL, NULL, NULL);
}



 

你可能感兴趣的:(MiniGUI原理分析 控件)