LbCreate Function

Microchip Graphics Library

Microchip Graphics Library
LbCreate Function
C
LISTBOX * LbCreate(
    WORD ID, 
    SHORT left, 
    SHORT top, 
    SHORT right, 
    SHORT bottom, 
    WORD state, 
    XCHAR * pText, 
    GOL_SCHEME * pScheme
);
Overview

This function creates a LISTBOX object with the parameters given. It automatically attaches the new object into a global linked list of objects and returns the address of the object.

Input Parameters
Input Parameters 
Description 
WORD ID 
Unique user defined ID for the object instance. 
SHORT left 
Left most position of the Object. 
SHORT top 
Top most position of the Object. 
SHORT right 
Right most position of the Object. 
SHORT bottom 
Bottom most position of the Object. 
WORD state 
Sets the initial state of the object. 
XCHAR * pText 
Pointer to the initialization text for the items. 
GOL_SCHEME * pScheme 
Pointer to the style scheme. 
Returns

Returns the pointer to the object created.

Preconditions

none

Side Effects

none

Example
#define LISTBOX_ID   10

const XCHAR ItemList[] = "Line1n" "Line2n";

GOL_SCHEME *pScheme;
LISTBOX *pLb;
XCHAR *pTemp;  
WORD state, counter;

    pScheme = GOLCreateScheme();
    state = LB_DRAW;
    
    // create an empty listbox with default style scheme
    pLb = LbCreate( LISTBOX_ID,         // ID number
                    10,10,150,200,      // dimension
                    state,              // initial state
                    NULL,               // set items to be empty
                    NULL);              // use default style scheme
    // check if Listbox was created
    if (pLb == NULL)        
       return 0;
    
    // create the list of items to be placed in the listbox
    // Add items (each line will become one item, 
    // lines must be separated by 'n' character)
    pTemp = ItemList;
    counter = 0;
    while(*pTemp){
        // since each item is appended NULL is assigned to 
        // LISTITEM pointer.
        if(NULL == LbAddItem(pLb, NULL, pTemp, NULL, 0, counter))
            break;
        while((unsigned XCHAR)*pTemp++ > (unsigned XCHAR)31);
        if(*(pTemp-1) == 0)
            break;
        counter++;
    }
Microchip Graphics Library Version 3.06.02 - October 15, 2012
Copyright © 2012 Microchip Technology, Inc.  All rights reserved