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

  1. Listing 3
  2.  
  3. /*****************************************************/
  4. /* tstcombo.c                                        */
  5. /* -- Exercise the LpfnSubclassComboEdit() routine.  */
  6. /*****************************************************/
  7.  
  8. #include <windows.h>
  9. #include "comboed.h"
  10.  
  11. FARPROC lpfnEdit;   /* Original EditItem wind. proc. */
  12. FARPROC lpfnFilter; /* Subclass for above. */
  13.  
  14. /* Subclasser for ComboBox's EditItem.  Don't forget */
  15. /* to export in .def file! */
  16. LONG    FAR PASCAL  EditSubclasser(HWND, WORD, WORD,
  17.                       DWORD);
  18.  
  19. VOID
  20. TestComboEdit(HWND hwndCombo)
  21. /*****************************************************/
  22. /* -- Install a subclasser for the given ComboBox to */
  23. /*    demonstrate the LpfnSubclassComboEdit()        */
  24. /*    routine.                                       */
  25. /* -- hwndCombo : ComboBox window handle.            */
  26. /*****************************************************/
  27.     {
  28.     /* Create a procedure instance of the subclasser. */
  29.     lpfnFilter = MakeProcInstance(
  30.       (FARPROC)EditSubclasser,
  31.       (HANDLE)GetWindowWord(hwndCombo, GWW_HINSTANCE));
  32.     if (lpfnFilter == NULL)
  33.         return; /* Failure. */
  34.  
  35.     /* Attempt to install the subclasser. */
  36.     lpfnEdit =
  37.       LpfnSubclassComboEdit(lpfnFilter, hwndCombo);
  38.     if (lpfnEdit == NULL)
  39.         FreeProcInstance(lpfnFilter); /* Failure. */
  40.     }
  41.  
  42. LONG FAR PASCAL
  43. EditSubclasser(HWND hwnd, WORD wMessage, WORD wParam,
  44.   DWORD lwParam)
  45. /*****************************************************/
  46. /* -- Window proc to subclass the EditItem of a      */
  47. /*    ComboBox.                                      */
  48. /* -- Display a string with double-clicked.          */
  49. /* -- Free our proecudure instance handle when done. */
  50. /*****************************************************/
  51.     {
  52.     BOOL    fHandled;   /* Handled the message? */
  53.  
  54.     switch (wMessage)
  55.         {
  56.     default:
  57.         fHandled = FALSE;
  58.         break;
  59.  
  60.     case WM_LBUTTONDBLCLK:
  61.         SetWindowText(hwnd, "Left double click");
  62.         fHandled = TRUE;
  63.         break;
  64.  
  65.     case WM_RBUTTONDBLCLK:
  66.         SetWindowText(hwnd, "Right double click");
  67.         fHandled = TRUE;
  68.         break;
  69.  
  70.     case WM_DESTROY:
  71.         /* Free the procedure instance and restore */
  72.         /* the origial window proc. */
  73.         FreeProcInstance(lpfnFilter);
  74.         SetWindowLong(hwnd, GWL_WNDPROC,
  75.           (LONG)lpfnEdit);
  76.         fHandled = FALSE;
  77.         break;
  78.         }
  79.  
  80.     if (fHandled)
  81.         return 0L;
  82.  
  83.     /* Pass this off to the EditItem's original */
  84.     /* Window Procedure. */
  85.     return CallWindowProc(lpfnEdit, hwnd, wMessage,
  86.       wParam, lwParam);
  87.     }
  88.  
  89.