home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_06 / 3n06031a < prev    next >
Text File  |  1992-03-31  |  2KB  |  48 lines

  1. Listing 1
  2.  
  3. /*****************************************************/
  4. /* comboed.c                                         */
  5. /* -- Subclass the EditItem of a ComboBox.           */
  6. /*****************************************************/
  7.  
  8. #include <windows.h>
  9. #include "comboed.h"
  10.  
  11. FARPROC
  12. LpfnSubclassComboEdit(FARPROC lpfn, HWND hwndCombo)
  13. /*****************************************************/
  14. /* -- If the given ComboBox contains an EditItem,    */
  15. /*    subclass it with the given window proc.        */
  16. /* -- Return the EditItem's original window          */
  17. /*    procedure, or NULL for failure.                */
  18. /* -- lpfn      : Procedure instance of subclasser.  */
  19. /* -- hwndCombo : ComboBox window handle.            */
  20. /*****************************************************/
  21.     {
  22.     HWND    hwndChild;
  23.     FARPROC lpfnEdit;
  24.  
  25.     /* Loop over all the child windows of the */
  26.     /* ComboBox.  Stop if we find an EditItem.  */
  27.     for (hwndChild = GetWindow(hwndCombo, GW_CHILD);
  28.       hwndChild != NULL;
  29.       hwndChild = GetWindow(hwndChild, GW_HWNDNEXT))
  30.         {
  31.         char    szClass[10];
  32.  
  33.         GetClassName(hwndChild, szClass,
  34.           sizeof szClass);
  35.         if (lstrcmpi(szClass, "edit") == 0)
  36.             break;
  37.         }
  38.  
  39.     if (hwndChild == NULL)
  40.         return NULL;    /* Must be CBS_DROPDOWNLIST. */
  41.  
  42.     lpfnEdit =
  43.       (FARPROC)GetWindowLong(hwndChild, GWL_WNDPROC);
  44.     SetWindowLong(hwndChild, GWL_WNDPROC, (LONG)lpfn);
  45.     return lpfnEdit;
  46.     }
  47.  
  48.