VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

搜索
查看: 537|回复: 5

[已解决]2个关联的COMBO,第一个COMBO的索引,决定第二个COMBO的条目个数

[复制链接]
96_avatar_middle
最佳答案
2 
在线会员 发表于 2022-3-7 10:59:52 | 显示全部楼层 |阅读模式
请教一个问题。


第一个COMBO从32个值里面任意选择,如果选择下标是X   第二个COMBO显示的条目数是前 32-X个
比如第一个COMBO选择第6个,下标是6,那么第二个COMBO就只能显示前26个即下标0-25
怎么实现?
最佳答案
46_avatar_small
2022-3-7 18:13:14
必须得有中文!!!

2个关联的COMBO,第一个COMBO的索引,决定第二个COMBO的条目个数 Combo2.rar (13.98 KB, 下载次数: 4)




上一篇:自定义Visual Studio 2017字体、颜色
下一篇:求数组的大小main函数中没问题,自定义函数就出错,求助
60_avatar_middle
最佳答案
4 
在线会员 发表于 2022-3-7 17:16:43 | 显示全部楼层
每个combo都带着个SELCHANGE消息代表列表框中选择的行发生改变,盘他的响应函数,你想显示第几行就给其他的bombo控件set一下cursel就行了。但是最好是指定好顺序不要相互盘,不然可能会意外死程序。
96_avatar_middle
最佳答案
2 
ico_lz  楼主| 发表于 2022-3-7 18:08:47 | 显示全部楼层
netforfun 发表于 2022-3-7 17:16
每个combo都带着个SELCHANGE消息代表列表框中选择的行发生改变,盘他的响应函数,你想显示第几行就给其他的 ...

多谢回复
我是想根据第一个COMBO的设置,提供不同个数的选择条目出来,从这些条目中可以任选一个
46_avatar_middle
最佳答案
7 
在线会员 发表于 2022-3-7 18:13:14 | 显示全部楼层    本楼为最佳答案   
bestAnswer
必须得有中文!!!

2个关联的COMBO,第一个COMBO的索引,决定第二个COMBO的条目个数 Combo2.rar (13.98 KB, 下载次数: 4)
96_avatar_middle
最佳答案
2 
ico_lz  楼主| 发表于 2022-3-8 11:15:02 | 显示全部楼层
找到一个函数可以实现。


void set_DropDownSize(CComboBox& box, UINT LinesToDisplay)
/*--------------------------------------------------------------------------
* Purpose: Set the proper number of lines in a drop-down list or
* combo box.
* Description: Resizes the combo box window to fit the proper number
* of lines. The window must exist before calling this function.
* This function should be called when the combo box is created, and when
* the font of the combo box changes. (e.g. WM_SETTINGCHANGE)
* Testing needed:
* Are there cases where SM_CYBORDER should be used instead of SM_CYEDGE?
* owner-draw variable height combo box
* Subclassed combo box with horizontal scroll-bar
* Returns: nothing
* Author: KTM
*--------------------------------------------------------------------------*/
{
ASSERT(IsWindow(box)); // Window must exist or SetWindowPos won't work

CRect cbSize; // current size of combo box
int Height; // new height for drop-down portion of combo box

box.GetClientRect(cbSize);
Height = box.GetItemHeight(-1); // start with size of the edit-box portion
Height += box.GetItemHeight(0) * LinesToDisplay; // add height of lines of text

// Note: The use of SM_CYEDGE assumes that we're using Windows '95
// Now add on the height of the border of the edit box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges

// The height of the border of the drop-down box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges

// now set the size of the window
box.SetWindowPos(NULL, // not relative to any other windows
0, 0, // TopLeft corner doesn't change
cbSize.right, Height, // existing width, new height
SWP_NOMOVE | SWP_NOZORDER // don't move box or change z-ordering.
);
}
46_avatar_middle
最佳答案
7 
在线会员 发表于 2022-3-8 12:22:55 | 显示全部楼层
本帖最后由 screen_ok 于 2022-3-8 16:28 编辑
不说人过 发表于 2022-3-8 11:15
找到一个函数可以实现。


哦,原来还可以这么实现啊!受教!2个关联的COMBO,第一个COMBO的索引,决定第二个COMBO的条目个数
您需要登录后才可以回帖 登录 | 加入驿站 qq_login

本版积分规则

×【发帖 友情提示】
1、请回复有意义的内容,请勿恶意灌水;
2、纯数字、字母、表情等无意义的内容系统将自动删除;
3、若正常回复后帖子被自动删除,为系统误删的情况,请重新回复其他正常内容或等待管理员审核通过后会自动发布;
4、感谢您对VC驿站一如既往的支持,谢谢合作!

关闭

站长提醒上一条 /2 下一条

QQ|小黑屋|手机版|VC驿站 ( 辽ICP备09019393号-4 )|网站地图wx_jqr

GMT+8, 2023-9-29 19:36

Powered by CcTry.CoM

© 2009-2021 cctry.com

快速回复 返回顶部 返回列表