D4D scroll bar

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

D4D scroll bar

跳至解决方案
843 次查看
michaelsthomas
Contributor I

I'm using D4D in an K22F, and have created a menu object INRAM.  I can easily change the data that is displayed on this menu, but if I change the number of items in the list, the scroll bar never changes.

It appears that the range of the scroll bar is set during the initialization of the screen with no way to add or subtract from that range value for the life of the screen.

Can anyone tell me how I might be able to dynamically change the position count of that scroll bar so that the menu will display any new menu items?

Thanks,

Mike Thomas

0 项奖励
回复
1 解答
754 次查看
EarlOrlando
Senior Contributor II

Hello Mike,

As you may know, a list is declared and defined trough macros. I show an example below.

_D4D_DECLARE_COMBO_BOX_BEGIN(D4D_NO_CONST, grpBx_name, SET_OFFSET_X, SET_RB_POS_Y(0), SET_SIZE_CB_X, SET_SIZE_CB_Y, 68, SET_RADIUS, NULL, &scrSett_grpBx_name, D4D_COMBO_BOX_F_DEFAULT, NULL, FONT_SYSTEM, 20, 0, 0, NULL, ComboBoxName_OnChange, NULL)

        D4D_DECLARE_COMBO_BOX_ITEM(D4D_DEFSTR("Example"), EXAMPLE)

D4D_DECLARE_COMBO_BOX_END()

If you expand these macros, you will see that the box items are stored in the array D4D_LIST_BOX_ITEM name##_items[] (where name## is replaced by the parameter name, in this case grpBx_name), this array ends with an item defined as NULL (D4D_DECLARE_COMBO_BOX_END()  is expanded as { NULL, NULL} };) so if you want to add a new item dynamically you need to replace this NULL element and then add a new NULL one.

I am thinking in a workaround where in compile time you declare all the items you think you will need to reserve the memory and in execution time replace the memory for this items for NULL.

Best regards,

Earl.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
755 次查看
EarlOrlando
Senior Contributor II

Hello Mike,

As you may know, a list is declared and defined trough macros. I show an example below.

_D4D_DECLARE_COMBO_BOX_BEGIN(D4D_NO_CONST, grpBx_name, SET_OFFSET_X, SET_RB_POS_Y(0), SET_SIZE_CB_X, SET_SIZE_CB_Y, 68, SET_RADIUS, NULL, &scrSett_grpBx_name, D4D_COMBO_BOX_F_DEFAULT, NULL, FONT_SYSTEM, 20, 0, 0, NULL, ComboBoxName_OnChange, NULL)

        D4D_DECLARE_COMBO_BOX_ITEM(D4D_DEFSTR("Example"), EXAMPLE)

D4D_DECLARE_COMBO_BOX_END()

If you expand these macros, you will see that the box items are stored in the array D4D_LIST_BOX_ITEM name##_items[] (where name## is replaced by the parameter name, in this case grpBx_name), this array ends with an item defined as NULL (D4D_DECLARE_COMBO_BOX_END()  is expanded as { NULL, NULL} };) so if you want to add a new item dynamically you need to replace this NULL element and then add a new NULL one.

I am thinking in a workaround where in compile time you declare all the items you think you will need to reserve the memory and in execution time replace the memory for this items for NULL.

Best regards,

Earl.

0 项奖励
回复
754 次查看
michaelsthomas
Contributor I

This is the same conclusion that we arrived at.  On startup, we calculate the number of items we will have in a menu, based on model information.  We fill the default Menu item with some junk text so that the scroll bar will calculate the correct amount of menu items.  Then we can later dynamically change the information on each line of the menu.

0 项奖励
回复