Owner-Draw List Boxes and Combo Boxes

This functionality is supported only if you are using the Classic Agent.

An owner-draw list/combo box is a list/combo box that has the owner-draw style bit set. This is distinct from a custom object that looks like a standard list/combo box, but is not.

The following procedure describes how developers can modify an application so that Silk Test Classic can access the text of a standard list/combo box that is owner-draw and that does not have the HasStrings style bit turned on. (If the HasStrings style bit of the owner-draw list/combo box is turned on, then you do not need to make the modifications described here.) The procedure entails modifying each owner-draw list/combo box’s parent window procedure so that Silk Test Classic can query the parent about what is in the list/combo box.

To turn on the HasStrings style bit of the owner-draw list/combo box:

  1. Include owndraw.h, which is supplied with Silk Test Classic, in your source files.
  2. For each owner-draw list/combo box, add a message handler for each of the messages in owndraw.h (ODA_HASTEXT, ODA_GETITEMTEXT, ODA_GETITEMTEXTSIZE). Base the message handlers on the 'switch' statement cases below. If writing in C, add code, such as that shown below, to its parent s WndProc.

    LONG FAR PASCAL ListParentWndProc (HWND hWnd, UINT uiMsg,WPARAM wParam, LPARAM lParam) 
    {
       //Use a static for the registered message number 
       static UINT uiMsgGetItem Text = 0; 
    
       LPGETITEMTEXTSTRUCT LpGetItemText; 
       USHORT usItem;
       PSZ pszItemText; 
    
       //Register the QAP_GETITEMTEXT message if it is not registered 
       if (uiMsgGetItem Text == 0) 
          uiMsgGetItemText = RegisterWindowMessage("QAP_GETITEMTEXT"); 
    
       switch (uiMsg) 
       {  
       ... 
       default; 
          //Process the QAP_GETITEMTEXT message 
          if (uiMsg == uiMsgGetItemText) 
          { 
             //lParam points to a LPGETITEMTEXTSTRUCT structure 
             lpGetItemText = (LPGETITEMTEXTSTRUCT) lParam; 
    
             //Perform the requested action 
             switch (lpGetItemText->Action) 
             { 
             case ODA_HASTEXT: 
                //Tell the QAP driver if your list box contains text 
                if (your list box has text) 
                   lpGetItemText->bSuccess = TRUE; 
                else 
                   lpGetItemText->bSuccess = FALSE; 
                break; 
    
             case ODA_GETITEMTEXT: 
                //Return the text for the requested list item 
                //(lpGetItemText->itemID is the index of the item in the 
                //list/combo box -- the same number passed to LB_GETITEMDATA
                (for a list box) or CB_ GETITEMDATA (for a combo box))
                usItem = UINT (lpGetItemText->itemID); 
                pszItemText = <pointer to text of item[usItem]>; 
                strncpy (lpGetItemText->lpstrItemText, pszItemText, 
                   lpGetItemText->nMaxItemText); 
               lpGetItemText->lpstrItemText[lpGetItemText->nMaxItemText-1] 
                   = ‘\0’; 
                lpGetItemText->bSuccess = TRUE; 
                break; 
    
             case ODA_GETITEMTEXTSIZE: 
                //Return the length of the requested list item 
                usItem = UINT (lpGetItemText->itemID); 
                lpGetItemText->nMaxItemText = <length of item[usItem]> + 1; 
                lpGetItemText->bSuccess = TRUE; 
                break;
             ... 
             } 
          } 
        } 
    }