home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_02 / 3n02047a < prev    next >
Text File  |  1991-12-16  |  3KB  |  104 lines

  1.  
  2. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-Begin Listing 7-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  3. /*****************************************************/
  4. /* mlecptn.c                                         */
  5. /* -- Module to implement an MLE with a caption.     */
  6. /*****************************************************/
  7.  
  8. #include <windows.h>
  9. #include "mlecptn.h"
  10.  
  11. /* Class name for MLE's parent. */
  12. #define szCaptionedMleClass "CaptionedMle"
  13.  
  14. BOOL
  15. FInitCaptionedMle(HANDLE hins)
  16. /*****************************************************/
  17. /* -- Create a class for the MLE's parent window.    */
  18. /* -- Call this routine when initializing the first  */
  19. /*    instance of the application.                   */
  20. /* -- Return false if the class could not be         */
  21. /*    registered.                                    */
  22. /* -- hins  : Application's instance handle.         */
  23. /*****************************************************/
  24.     {
  25.     WNDCLASS    wcs;
  26.  
  27.     /* The parent window doesn't have to do anything */
  28.     /* except call DefWindowProc(), so we take the */
  29.     /* easy way out and just use DefWindowProc() as */
  30.     /* the window proc itself. */
  31.     wcs.style = CS_HREDRAW | CS_VREDRAW;
  32.     wcs.lpfnWndProc = DefWindowProc;
  33.     wcs.cbClsExtra = 0;
  34.     wcs.cbWndExtra = 0;
  35.     wcs.hInstance = hins;
  36.     wcs.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  37.     wcs.hCursor = LoadCursor(NULL, IDC_ARROW);
  38.     wcs.hbrBackground = GetStockObject(WHITE_BRUSH); 
  39.     wcs.lpszMenuName = NULL;
  40.     wcs.lpszClassName = szCaptionedMleClass;
  41.     return RegisterClass(&wcs);
  42.     }
  43.  
  44. HWND
  45. HwndCaptionedMle(HWND hwndOwner, RECT * prect,
  46.     char * szCaption, BOOL fPopup)
  47. /*****************************************************/
  48. /* -- Create an MLE with a captioned parent.         */
  49. /* -- Return the window handle of the parent.        */
  50. /* -- hwndOwner : Window to own parent.              */
  51. /* -- prect     : Location of parent window.         */
  52. /* -- szCaption : Title to put in caption.           */
  53. /* -- fPopup    : Create parent as a popup window if */
  54. /*                set, otherwise as a child.         */
  55. /*****************************************************/
  56.     {
  57.     RECT    rect;
  58.     HWND    hwnd;
  59.     HANDLE  hins;
  60.  
  61.     hins = GetWindowWord(hwndOwner, GWW_HINSTANCE);
  62.  
  63.     /* Create the MLE's parent. */
  64.     if ((hwnd = CreateWindow(
  65.       szCaptionedMleClass,
  66.       szCaption,
  67.       WS_VISIBLE | WS_CAPTION |
  68.         (fPopup ? WS_POPUPWINDOW :
  69.           (WS_CHILD | WS_BORDER | WS_SYSMENU)),
  70.       prect->left,
  71.       prect->top,
  72.       prect->right - prect->left,
  73.       prect->bottom - prect->top,
  74.       hwndOwner,
  75.       NULL,
  76.       hins,
  77.       NULL)) == NULL)
  78.         return NULL;
  79.  
  80.     /* Create the MLE to just fill the client area. */
  81.     GetClientRect(hwnd, &rect);
  82.     if (CreateWindow(
  83.       "edit",
  84.       NULL,
  85.       WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT |
  86.         ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  87.       rect.left,
  88.       rect.top,
  89.       rect.right - rect.left,
  90.       rect.bottom - rect.top,
  91.       hwnd,
  92.       0,
  93.       hins,
  94.       NULL) == NULL)
  95.         {
  96.         DestroyWindow(hwnd);
  97.         return NULL;
  98.         }
  99.  
  100.     return hwnd;
  101.     }
  102. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-End   Listing 7-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  103.  
  104.