08-17-2010 01:48 PM
Hello,
I am looking for a way to display values onto a list by having the first value with a forward slash and the rest with an indentation.
In other words this way:
/value
value1
value2
value3
etc.....
Please see the attachment for a better reference of where the data is received and then populated to the window list.
Thanks for your input
Solved! Go to Solution.
08-17-2010 02:51 PM
Bebeto:
I'm not sure where you are having a problem, or what you goal is for the indents, or what criteria you use for indents. Generally it's more helpful to highlight the section of code you're struggling with.
You can try something like this.
int indent = 0; // initialize to don't indent
char displayValue[80];
// ...
// after you set the value for current_log_view,
if (indent)
sprintf(displayValue, " %s", current_log_view) ;
else
sprintf(displayValue, "/%s", current_log_view) ;
SetCtrlVal(log_panel, LOG_LOG_TB,displayValue);
// ...
// when you meet whatever criteria you need to indent
indent = 1;
08-17-2010 02:57 PM
Hello Al,
This section of the code is where I am guessing that I need to include a function to have a kind of tree structure display for the list,
// Extract File name and index
for(i=0;i<=UL_1_Header_Block.block_size-HEADER_SZ;i++)
{
cnfg_database_array[i]=*ptr_mem_index++;
}
Delay(.2);
// determine file name by search for ";" filename delimiter
for(i=0;i<UL_2_Header_Block.number_file;i++)
{
cnfg_file_comma_index = FindPattern (cnfg_database_array, cnfg_file_comma_index+1,
SEARCH_ENTIRE_STRING, ",", FALSE, FALSE);
cnfg_file_colon_index = FindPattern (cnfg_database_array, cnfg_file_colon_index+1,
SEARCH_ENTIRE_STRING,":", FALSE, FALSE);
if(i>=MAX_FILE_LIST)
{
fprintf(log_file.Open_fp_main,"%.2d:%.2d:%.2d DIR DATABASE LIST TOO LONG!\n",
ts.tm_hour,ts.tm_min,ts.tm_sec);
sprintf(current_log_view,"%.2d:%.2d:%.2d DIR DATABASE LIST TOO LONG!\n",
ts.tm_hour,ts.tm_min,ts.tm_sec);
SetCtrlVal(log_panel, LOG_LOG_TB,current_log_view);
break;
}
CopyString (cnfg_display_db[i], 0, cnfg_database_array, cnfg_file_comma_index+1,
(cnfg_file_colon_index-cnfg_file_comma_index)-1);
InsertListItem(dir_list_panel,DIR_LIST_RETR_LIST,i,cnfg_display_db[i],0);
}
}
break;
as you may see on the highlighted lines, is where I am thinking I need to do changes, but not sure how...
08-17-2010 03:10 PM
Bebeto:
What version of CVI are you using?
If you are listing directory names, do you want to use a tree control instead of a list control?
Look at the treemenu sample that ships with CVI.
Or if you really want to use a listbox, you can apply the same method for cnfg_display_db[i] as I showed for current_log_view.
08-17-2010 03:20 PM
9.0
well the content goes to a list box, so I will try to adapt the example you posted, thanks.
08-17-2010 03:29 PM
You are currently using a listbox, but I would suggest that you take a look at the treemenu sample that ships with CVI 9. You may decide to switch to a tree control once you see what it looks like.
In CVI 9, click on Help, then Find Examples..., then click the Search tab, and enter tree in the Enter keyword(s) box.
08-17-2010 04:03 PM
Bebeto,
the listbox control does permit you to have indentation, the same as "column alignment" and text colouring, by embedding the appropriate code into the string to display.
You may want to try using "\033p" escape codes to accomodate text position as you want; taking as an example AL code try this:
if (indent)
sprintf(displayValue, "\033p25l%s", current_log_view) ;
else
sprintf(displayValue, "%s", current_log_view) ;
SetCtrlVal(log_panel, LOG_LOG_TB,displayValue);
A complete reference for escape codes usable in the listbox control can be found in he online help for "Item label" field in InsertListBox function panel (simply right click on that field to disply it).
The right control to use depends both on application requirements and programmer's habits and ability; in my opinion a listbox is faster to use and execute than a tree; on the other hand the tree has several useful features like the ability to collaps tree branches. That is: it' up to you to decide which control to use, but completely understanding the possibilities of each control can help you in this choice.
08-18-2010 08:53 AM
thank you guys,
I endend up doing this:
if (i==0)
{
sprintf(current_log_view, "/%s", cnfg_display_db[i]) ;
}
else
{
sprintf(current_log_view, " %s", cnfg_display_db[i]) ;
}
SetCtrlVal(log_panel, LOG_LOG_TB,cnfg_display_db[i]);
InsertListItem(dir_list_panel,DIR_LIST_RETR_LIST,i,current_log_view,0);
and it work just fine!
thanks again