ListBox

Int_ListAddButton, Int_ListAddString, Int_ListClose, Int_ListCreateWindow, Int_ListDefineFixed, Int_ListDeleteString, Int_ListGetData, Int_ListInsertString, Int_ListOutput, Int_ListReset, Int_ListSetHeader, Int_ListShow

Int_ListAddButton

Description 

int Int_ListAddButton(
   char *capt,
   char *com
);

This function adds buttons to the list box window.

Parameters

char *capt

Caption of the button. You can’t change the size of the buttons so use rather smaller lengths of the captions.

char *com

Command which will be executed after pressing the button.

Return Values

int

This function returns TRUE (1) if the button was created, else FALSE (0).

Int_ListAddString

Description 

int Int_ListAddString(
   char *str1
);

This function adds strings to the list box. Strings are added to the end of the list.

Parameters

char *str1

Pointer to str1

Return Values

int

This function returns TRUE (1) if the string was added, else FALSE (0).

Note

The tabs inside the added string define the columns. There can be four columns at most. The string can be defined by the sprintf function or simply like a constant, to mark the tabs use /t symbol. The maximal amount of items is limited by 1000.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListOutput, Int_ListGetData

Int_ListClose

Description 

int Int_ListClose();

This function closes the current listbox window.

Return Values

int

This function returns TRUE (1) if the window was closed, else FALSE (0).

Note

The listbox window is created by calling the function Int_ListCreateWindow and then displayed by the Int_ListShow function. The window can be also closed manually from the menu.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListOutput, Int_ListGetData

Int_ListCreateWindow

Description 

int Int_ListCreateWindow(
   char *Caption,
   int  Int_Position,
   int  Int_X,
   int  y,
   int  Width,
   int  Height
);

This function creates a window which can be used to display text data in the tabbed listbox.

Parameters

char *Caption

Text displayed in the caption.

int Int_Position

Position-code of the window

0

Top centered.

1, WP_TOPLEFT

Top left

2, WP_TOPRIGHT

Top right

3, WP_BOTTOMLEFT

Bottom left

4, WP_BOTTOMRIGHT

Bottom right

5, WP_TOTALUP

Total up

6, WP_UP

1/4 from top

7, WP_CENTERED

Centered

8

Top centered with menu visible

9

Top centered with menu and icons visible

int Int_X

X coordinate.

int y

Y-coordinate of top-left corner of window.

int Width

Image width in pixels.

int Height

Image height in pixels.

Return Values

int

This function returns TRUE (1) if the graph window is created, else FALSE (0).

//Int_ListCreateWindow example - this example shows how to create 
//and use simple listbox window.
int         tab[1],current_x,current_y;
dword       key,keys[2];
char        mess[256],coordinates[256]; 
tab[0] = 0;
key = 0;
keys[0] = VK_LBUTTON;
keys[1] = VK_RBUTTON;
strcpy(mess,"API Example - Int_ListCreateWindow");
Int_CreateTextWindow(mess,0,RGB(0,0,128),RGB_WHITE,100);
Wait(2);
strcpy(mess,"     Primary mouse button to add mouse coordinates\tSecondary mouse button to quit.     ");
Int_CreateTextWindow(mess,0,RGB(0,0,128),RGB_WHITE,100);
Int_ListCreateWindow("Listbox example",2,0,0,297,480);
Int_ListAddButton("Wait","Wait(1);");
strcpy(mess, "Data 1\tData 2\tData 3\tData 4");
Int_ListSetHeader(mess);
Int_ListDefineFixed(tab,1);
Int_ListShow();
Int_ListInsertString(0,"This\tline\tis\tfixed.",1);
SetCommandText("Listbox is working...");
while(key != keys[1])
   {
   key = Int_GetEvents(keys,2);
   if(key == keys[0])
   {
   Int_GetMousePos(&current_x,&current_y);
   sprintf(coordinates,"Position: \t%i\t%i\t ","current_x,current_y");
   Int_ListAddString(coordinates);
   }
   if(key == keys[1])
   {
   Int_ListClose();
   Int_CloseTextWindow();
   }
   }

See Also 
Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListOutput, Int_ListGetData

Int_ListDefineFixed

Description 

 Int_ListDefineFixed(
   int *lpdata,
   int  num
);

This function defines fixed lines within the listbox window.

Parameters

int *lpdata

Address of the table with fixed string definition. The table is array of ints with indexes.

int num

Number of indexes in the table.

Return Values

This function returns TRUE (1) if the lines were defined fixed, else FALSE (0).

Note

This function changes the global Int_ListFixed array. Using this function, old fixed lines are forgotten.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListOutput, Int_ListGetData

Int_ListDeleteString

Description 

int Int_ListDeleteString(
   int  Index
);

This function deletes the index string from the list box. The index of the deleted string is appended at the end of the global Int_ListDeleted array. Strings which are defined to be fixed (by the Int_ListDefineFixed function) can not be deleted by this function.

Parameters

int Index

Index number (zero-based).

Return Values

int

This function returns TRUE (1) if the string was deleted, else FALSE (0).

Note

The indexes out of the valid range(0 to number of listbox items - 1) are ignored. You can see which indexes are defined to be fixed in the global Int_ListFixed array.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListOutput, Int_ListGetData

Int_ListGetData

Description 

INT Int_ListGetData(
   int  Index,
   char *buf1,
   int  Size
);

This function gets the data from the listbox in the listbox window.

Index parameter is the index of the string in the listbox (inside the valid range) you get the data from. Special constants can be used (-1 = Whole content, -2 = Currently selected item).

Parameters

int Index

Index number (zero-based).

char *buf1

Buffer for the data.

int Size

The maximum number of characters which will be filled to the buffer.

Return Values

INT

This function returns TRUE (1) if the data were got, else FALSE (0).

//Int_ListGetData example - this example shows how to use the list box for items selecting.
char            buf[256],mess[256];
dword           key,keys[2]; 
key = 0;
keys[0] = VK_RETURN;
keys[1] = VK_END;
SetCommandText("Working...");
strcpy(mess,"    application API Example - Int_ListGetData\tTo choose:double-click on some item or select and press enter.");
Int_CreateTextWindow(mess,0,RGB(0,0,128),RGB_WHITE,100);
Int_ListGetData("Selection listbox",6,0,0,240,160);
Int_ListGetData("Exit","Int_CloseTextWindow();Int_ListClose();Int_PostMessage(VK_END,0);");
Int_ListSetHeader("Index\tClick to choose.");
Int_ListShow();
Int_ListAddString("1:\tFirst item");
Int_ListAddString("2:\tSecond item");
Int_ListAddString("3:\tThird item");
again:
//Waiting for selection 
key = 0;
while(key == 0)
   key = Int_GetEvents(keys,2);
if(key == keys[0])
   {
   //Acquiring the selection 
   Int_ListGetData(-2,buf,256);
   if(buf[0] == '1')
   Int_Query("Selection","You selected the first item.","Continue");
   if(buf[0] == '2')
   Int_Query("Selection","You selected the second item.","Continue");
   if(buf[0] == '3')
   Int_Query("Selection","You selected the third item.","Continue");
   goto again;
   }

Note

Left button double clicking on some item inside the list box causes sending the VK_RETURN (13) to macro, see the example for details.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListOutput

Int_ListInsertString

Description 

int Int_ListInsertString(
   int  Index,
   char *buf1,
   int  overwrite
);

This function inserts a string into the listbox.

Index parameter is the index of the line in the listbox, you insert the string.

Parameters

int Index

Index number (zero-based).

char *buf1

Buf1, which contains the string. If buffer is NULL (0), then the function selects an item in the listbox. Parameter 'index' is the zero based index of the item. 'Overwrite' parameter is then ignored.

int overwrite

Specifies whether it will overwrite the current content

0

The function will not overwrite the current content of the listbox. Fixed indexes with greater value then inserted index are shifted.

1

The function will overwrite the current content of the listbox. No change in fixed indexes.

Return Values

int

This function returns TRUE (1) if the string was inserted, else FALSE (0).

Note

This function can replace fixed lines in the listbox (defined by the Int_ListDefineFixed function). If you specify greater index then the current number of items minus one, string will be added at the end of the listbox.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListOutput, Int_ListGetData, Int_ListDefineFixed

Int_ListOutput

Description 

int Int_ListOutput(
   int  mode,
   char *Int_Filename
);

This function exports the listbox data from the listbox window to a file or to clipboard (if the optional Int_Filename parameter is not defined).

Parameters

int mode

Mode of the output from the listbox.

0

The data will be exported to the clipboard.

1

The data will be exported to the file. If you don’t specify the filename, save-file dialog box appears.

char *Int_Filename

Address of the filename.

Return Values

int

This function returns TRUE (1) if the output was successful, else FALSE (0).

//Int_ListOutput example - output data acquired from histogram.
int               pModeData[256];
dword             pMean[4],
  pMin[4],
  pMax[4],
  pMaxFreq[4];
dword             pRed[256],  
  pGreen[256],  
  pBlue[256],  
  pIntensity[256];
char              mess[256],str[256];
int               i,sel;
strcpy(mess,"API Example - Int_ListOutput");
Int_CreateTextWindow(mess,0,RGB(0,0,128),RGB_WHITE,100);
Int_ListCreateWindow("Histogram Data",6,0,0,240,450);
Int_ListAddButton("Exit","Int_CloseTextWindow();Int_ListClose();");
Int_ListSetHeader("Index\tRed\tGreen\tBlue");
Int_ListShow();
Get_Histogram(0,pModeData,pMean,pMin,pMax,pMaxFreq,pRed,pGreen,pBlue,pIntensity);
SetCommandText("Working...");
for(i=0;i<256;i=i+1)
   {
   sprintf(str,"%i\t%i\t%i\t%i","i,pRed[i],pGreen[i],pBlue[i]");
   Int_ListAddString(str);
   }
sel = Int_Question("Select action","Output to:","File...","Clipboard","","",2,0);
if(sel == 1)
   {
   SelectFile(file,"Text files|*.txt",0);
   Int_ListOutput(1,file);
   EditFile(file);
   DeleteFileQuery(file);
   }
if(sel == 2)
   Int_ListOutput(0,"");
Int_CloseTextWindow();

Note

This function uses the default data delimiters. You can specify them by calling Delimiter function.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListGetData

Int_ListReset

Description 

int Int_ListReset();

This function resets the content of the listbox inside the listbox window. The index of the deleted string is appended at the end of the global Int_ListDeleted array.

Return Values

int

This function returns TRUE (1) if the listbox was reset, else FALSE (0).

Note

Fixed indexes (defined in global Int_ListFixed array) are not deleted.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListSetHeader, Int_ListOutput, Int_ListGetData

Int_ListSetHeader

Description 

 Int_ListSetHeader(
   char *Int_str1
);

This function sets the new header to the list box window. The header defines the number of columns in the list box. The tabs inside the string define the columns. There can be up to four columns.

Parameters

char *Int_str1

A sequence of characters.

Return Values

This function returns TRUE if the header was set, else FALSE.

//Int_ListSetHeader example - changing the header by mouse.
char      mess[256];
char      h1[256],h2[256],h3[256];
dword     key,keys[20]; 
int       cmp;
key = 0;
keys[0] = VK_RETURN;
keys[1] = VK_RBUTTON;
strcpy(h1,"Data 1\tData 2\tData 3\tData 4");
strcpy(h2,"This\tis\tsecond\theader.");
strcpy(h3,"Value:\t2.897\tIndex:\t99");
strcpy(mess,"   NIS-Elements API Example - Int_ListSetHeader\tLeft mouse dblclk on item to change the header, right to stop.   ");
Int_CreateTextWindow(mess,0,RGB(0,0,128),RGB_WHITE,100);
Int_ListCreateWindow(NULL,7,0,0,240,120);
Int_ListAddButton("Info","___Info();");
Int_ListAddButton("Exit","Int_CloseTextWindow();Int_ListClose();Int_PostMessage(VK_RBUTTON,0);");
Int_ListSetHeader(h1);
Int_ListShow();
Int_ListAddString(h1);
Int_ListAddString(h2);
Int_ListAddString(h3);
while(key != keys[1])
   {
   key = Int_GetEvents(keys,2);
   if(key == keys[0])
   {
  Int_ListGetData(-2,mess,256);
   if(mess[0] == 'D')
   Int_ListSetHeader(h1);
   if(mess[0] == 'T')
   Int_ListSetHeader(h2);
   if(mess[0] == 'V')
   Int_ListSetHeader(h3);
   }
   }         
Int_CloseTextWindow();
Int_ListClose();

Note

The string can be defined by sprintf function or simply like a constant, to mark the tabs use /t symbol.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListShow, Int_ListOutput, Int_ListGetData

Int_ListShow

Description 

int Int_ListShow();

This function shows an already created listbox window.

Return Values

int

This function returns TRUE (1) if the window was showed, else FALSE (0).

//Int_ListShow example - a typical listbox.
int               pModeData[256];
dword             pMean[4],
  pMin[4],
  pMax[4],
  pMaxFreq[4];
dword             pRed[256],  
  pGreen[256],  
  pBlue[256],  
  pIntensity[256];
char              mess[256],str[256];
int               i;
strcpy(mess,"API Example - Int_ListShow");
SetCommandText("Working...");
Int_CreateTextWindow(mess,0,RGB(0,0,128),RGB_WHITE,100);
Int_ListCreateWindow("Histogram Data",6,0,0,240,350);
Int_ListAddButton("Exit","Int_CloseTextWindow();Int_ListClose();");
Int_ListSetHeader("Index\tRed\tGreen\tBlue");
Int_ListShow();
Get_Histogram(0,pModeData,pMean,pMin,pMax,pMaxFreq,pRed,pGreen,pBlue,pIntensity);
for(i=0;i<256;i=i+1)
   {
   sprintf(str,"%i\t%i\t%i\t%i","i,pRed[i],pGreen[i],pBlue[i]");
   Int_ListAddString(str);
   }

Note

The listbox window is created by calling the function Int_ListCreateWindow. You can not add more buttons after calling this function. The window can be closed manually.

See Also 
Int_ListCreateWindow, Int_ListAddButton, Int_ListSetHeader, Int_ListOutput, Int_ListGetData, Get_Histogram, Int_ListCreateWindow