home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / 1991 / 06 / dflat3 / button.c < prev    next >
Text File  |  1991-05-14  |  1KB  |  47 lines

  1. /* -------------- button.c -------------- */
  2.  
  3. #include <conio.h>
  4. #include "dflat.h"
  5.  
  6. int ButtonProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  7. {
  8.     DBOX *db = GetParent(wnd)->extension;
  9.     CTLWINDOW *ct = ControlBox(db, wnd);
  10.     int rtn, i;
  11.     switch (msg)    {
  12.         case SETFOCUS:
  13.             BaseWndProc(BUTTON, wnd, msg, p1, p2);
  14.             if (p1)
  15.                 return TRUE;
  16.         case PAINT:
  17.             if (isVisible(wnd))    {
  18.                 /* -------- draw the button's shadow ------- */
  19.                 background = WndBackground(GetParent(wnd));
  20.                 foreground = BLACK;
  21.                 PutWindowChar(wnd, WindowWidth(wnd), 0, 220);
  22.                 for (i = 0; i < WindowWidth(wnd); i++)
  23.                     PutWindowChar(wnd, i+1, 1, 223);
  24.                 /* --------- write the button's text ------- */
  25.                 WriteTextLine(wnd, NULL, 0, wnd == inFocus);
  26.             }
  27.             return TRUE;
  28.         case KEYBOARD:
  29.             if (p1 == '\r')    {
  30.                 PostMessage(GetParent(wnd), COMMAND, ct->command, 0);
  31.                 return TRUE;
  32.             }
  33.             break;
  34.         case LEFT_BUTTON:
  35.             rtn = BaseWndProc(BUTTON, wnd, msg, p1, p2);
  36.             PostMessage(GetParent(wnd), COMMAND, ct->command, 0);
  37.             return rtn;
  38.         case HORIZSCROLL:
  39.             return TRUE;
  40.         default:
  41.             break;
  42.     }
  43.     return BaseWndProc(BUTTON, wnd, msg, p1, p2);
  44. }
  45.  
  46.  
  47.