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

📄 combobox.c

📁 libminigui-1.3.0.tar.gz。 miniGUI的库函数源代码!
💻 C
📖 第 1 页 / 共 3 页
字号:
                    SendMessage (pData->ListBoxControl, MSG_KEYDOWN, SCANCODE_PAGEDOWN, 0);                else                    SendMessage (pData->ListBoxControl, MSG_KEYDOWN, SCANCODE_PAGEUP, 0);                break;            case CBS_AUTOSPIN:            {                char buffer [LEN_SPINVALUE+1];                int cur_value, new_value;                GetWindowText (pData->EditControl, buffer, LEN_SPINVALUE);#if 0                cur_value = new_value = strtol (buffer, NULL, 0);#else                sscanf (buffer, pData->str_format, &cur_value);                new_value = cur_value;#endif                if (wParam) {                    new_value -= pData->fastspin_pace;                }                else {                    new_value += pData->fastspin_pace;                }                if (dwStyle & CBS_AUTOLOOP) {                    if (new_value > pData->spin_max)                        new_value = pData->spin_min;                    else if (new_value < pData->spin_min)                        new_value = pData->spin_max;                }                else {                    if (new_value > pData->spin_max)                        new_value = pData->spin_max;                    else if (new_value < pData->spin_min)                        new_value = pData->spin_min;                }                if (new_value != cur_value) {                    snprintf (buffer, LEN_SPINVALUE, pData->str_format, new_value);                    SetWindowText (pData->EditControl, buffer);                    if (dwStyle & CBS_NOTIFY)                        NotifyParent (hwnd, pCtrl->id, CBN_EDITCHANGE);                }                break;            }            }            break;        break;    }        if ((dwStyle & CBS_TYPEMASK) == CBS_AUTOSPIN) {        switch (message) {            case CB_SETSPINFORMAT:            {                free (pData->str_format);                if ((pData->str_format = strdup ((const char*)lParam)))                    return CB_OKAY;                return CB_ERR;            }            case CB_SETSPINRANGE:            {                char buffer [LEN_SPINVALUE+1];                int new_min = (int)wParam;                int new_max = (int)lParam;                int cur_value;                if (new_min > new_max)                    return CB_ERR;                pData->spin_min = (int)wParam;                pData->spin_max = (int)lParam;                GetWindowText (pData->EditControl, buffer, LEN_SPINVALUE);#if 0                cur_value = strtol (buffer, NULL, 0);#else                sscanf (buffer, pData->str_format, &cur_value);#endif                if (cur_value < pData->spin_min) {                    snprintf (buffer, LEN_SPINVALUE, pData->str_format, pData->spin_min);                    SetWindowText (pData->EditControl, buffer);                }                else if (cur_value > pData->spin_max) {                    snprintf (buffer, LEN_SPINVALUE, pData->str_format, pData->spin_max);                    SetWindowText (pData->EditControl, buffer);                }                return CB_OKAY;            }            case CB_GETSPINRANGE:            {                int* spin_min = (int*)wParam;                int* spin_max = (int*)lParam;                if (spin_min) *spin_min = pData->spin_min;                if (spin_max) *spin_max = pData->spin_max;                return CB_OKAY;            }            case CB_SETSPINVALUE:            {                int new_value = (int)wParam;                char buffer [LEN_SPINVALUE+1];                if (new_value < pData->spin_min || new_value > pData->spin_max)                    return CB_ERR;                snprintf (buffer, LEN_SPINVALUE, pData->str_format, new_value);                SetWindowText (pData->EditControl, buffer);                return CB_OKAY;            }            case CB_GETSPINVALUE:            {                char buffer [LEN_SPINVALUE+1];                int value;                GetWindowText (pData->EditControl, buffer, LEN_SPINVALUE);                sscanf (buffer, pData->str_format, &value);                return value;                // return strtol (buffer, NULL, 0);            }            case CB_SETSPINPACE:            {                int pace = (int)wParam;                int fastpace = (int)lParam;                if (pace != 0)                    pData->spin_pace = pace;                if (fastpace != 0)                    pData->fastspin_pace = fastpace;                return CB_OKAY;            }            case CB_GETSPINPACE:            {                int *pace = (int*)wParam;                int *fastpace = (int*)lParam;                if (pace)                    *pace = pData->spin_pace;                if (*fastpace)                    *fastpace = pData->fastspin_pace;                return CB_OKAY;            }        }        return DefaultControlProc (hwnd, message, wParam, lParam);    }    else        return DefCBProc (hwnd, message, wParam, lParam);}static int DefCBProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam){    PCOMBOBOXDATA pData;    int len, index;    char *selection;    int  rc;    pData = (COMBOBOXDATA *) Control(hWnd)->dwAddData2;    switch (message) {        /* messages specific to the listbox control */        case CB_SETSTRCMPFUNC:            return SendMessage (pData->ListBoxControl, LB_SETSTRCMPFUNC, wParam, lParam);        case CB_ADDSTRING:            rc = SendMessage (pData->ListBoxControl, LB_ADDSTRING, wParam, lParam);            if (rc >= 0)                pData->nListItems++;             return rc;        case CB_DELETESTRING:            rc = SendMessage (pData->ListBoxControl, LB_DELETESTRING, wParam, lParam);            if (rc == 0)                pData->nListItems--;            return rc;        case CB_DIR:            return SendMessage (pData->ListBoxControl, LB_DIR, wParam, lParam);                    case CB_FINDSTRING:            return SendMessage (pData->ListBoxControl, LB_FINDSTRING, wParam, lParam);                    case CB_FINDSTRINGEXACT:               return SendMessage (pData->ListBoxControl, LB_FINDSTRINGEXACT, wParam, lParam);                    case CB_GETCOUNT:            return SendMessage (pData->ListBoxControl, LB_GETCOUNT, wParam, lParam);                    case CB_GETITEMADDDATA:            return SendMessage (pData->ListBoxControl, LB_GETITEMADDDATA, wParam, lParam);                    case CB_SETITEMADDDATA:            return SendMessage (pData->ListBoxControl, LB_SETITEMADDDATA, wParam, lParam);                    case CB_GETITEMHEIGHT:            return SendMessage (pData->ListBoxControl, LB_GETITEMHEIGHT, wParam, lParam);                    case CB_SETITEMHEIGHT:            return SendMessage (pData->ListBoxControl, LB_SETITEMHEIGHT, wParam, lParam);                    case CB_GETLBTEXT:            return SendMessage (pData->ListBoxControl, LB_GETTEXT, wParam, lParam);                    case CB_GETLBTEXTLEN:            return SendMessage (pData->ListBoxControl, LB_GETTEXTLEN, wParam, lParam);                    case CB_INSERTSTRING:            return SendMessage (pData->ListBoxControl, LB_INSERTSTRING, wParam, lParam);                    case CB_GETCURSEL:            return SendMessage (pData->ListBoxControl, LB_GETCURSEL, wParam, lParam);        case CB_SETCURSEL:            if (SendMessage (pData->ListBoxControl, LB_SETCURSEL, wParam, lParam) == LB_ERR)                return CB_ERR;            index = SendMessage (pData->ListBoxControl, LB_GETCURSEL, wParam, lParam);            len = SendMessage (pData->ListBoxControl, LB_GETTEXTLEN, index, 0);            if (len <= 0)                return CB_ERR;            //selection = alloca (len + 1);              selection = FixStrAlloc (len + 1);              SendMessage (pData->ListBoxControl, LB_GETTEXT, (WPARAM)index, (LPARAM)selection);            SetWindowText (pData->EditControl, selection);            FreeFixStr (selection);            break;        /* messages specific to the edit control */        case CB_GETEDITSEL:            return SendMessage (pData->EditControl, EM_GETSEL, wParam, lParam);        case CB_LIMITTEXT:            return SendMessage (pData->EditControl, EM_LIMITTEXT, wParam, lParam);        case CB_SETEDITSEL:            return SendMessage (pData->EditControl, EM_SETSEL, wParam, lParam);        case MSG_GETTEXTLENGTH:            return SendMessage (pData->EditControl, MSG_GETTEXTLENGTH, wParam, lParam);        case MSG_GETTEXT:            return SendMessage (pData->EditControl, MSG_GETTEXT, wParam, lParam);        case MSG_SETTEXT:            return SendMessage (pData->EditControl, MSG_SETTEXT, wParam, lParam);        /* messages handled by the combobox itself */        case CB_GETDROPPEDCONTROLRECT:            if (pData->ListBoxControl) {                CopyRect ((PRECT)lParam, &pData->ListBoxRect);                return 0;            }            return CB_ERR;        case CB_GETDROPPEDSTATE:            return IS_SET (pData, CSF_CAPTUREACTIVE);        case CB_RESETCONTENT:            SendMessage (pData->ListBoxControl, LB_RESETCONTENT, 0, 0);            SetWindowText (pData->EditControl, "");            return 0;        case CB_SELECTSTRING:            index = SendMessage (pData->ListBoxControl, LB_SELECTSTRING, wParam, lParam);            if (index == LB_ERR)               return CB_ERR;            len = SendMessage (pData->ListBoxControl, LB_GETTEXTLEN, index, 0);            if (len <= 0)               return CB_ERR;            //selection = alloca (len + 1);              selection = FixStrAlloc (len + 1);              rc = SendMessage (pData->ListBoxControl, LB_GETTEXT, (WPARAM)index, (LPARAM)selection);            SetWindowText (pData->EditControl, selection);            FreeFixStr (selection);            break;     }    return DefaultControlProc (hWnd, message, wParam, lParam);}#endif /* _CTRL_COMBOBOX */

⌨️ 快捷键说明

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