home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / fonts / cw_src / altexe / wp.c < prev   
Encoding:
C/C++ Source or Header  |  1995-05-19  |  2.5 KB  |  115 lines

  1. #define        no_Trace_
  2.  
  3. #define        NOVIRTUALKEYCODES
  4. #include    "c:\windev\include\windows.h"
  5. #include    "hello.h"
  6. #define        WM_ALARM    (WM_USER+1)
  7. #define        WM_ALTKEYBKILL    (WM_USER + 1141)
  8.  
  9. long FAR PASCAL HelloWndProc();
  10. void FAR PASCAL CyrStart();
  11. void FAR PASCAL CyrStop();
  12. void FAR PASCAL CyrSwitch();
  13. void        demomsg();
  14.  
  15. BOOL bLAT= TRUE;
  16. char kreg[2][3]= { "Alt", "Def" };
  17.  
  18. extern char szAppName[];
  19. extern int legal_use;
  20. extern HANDLE hInst;
  21. extern HWND hkDlg;
  22. extern BOOL bDlgActive;
  23. extern HWND hMainDlg;
  24. extern HWND hkDlg;
  25. extern BOOL bChanged;
  26. extern char s_path [];
  27. extern char l_name [];
  28. extern char w_path [];
  29.  
  30. long FAR PASCAL HelloWndProc( hWnd, message, wParam, lParam )
  31. HWND hWnd;
  32. unsigned message;
  33. WORD wParam;
  34. LONG lParam;
  35. {
  36.     PAINTSTRUCT    ps;
  37.     RECT        rect;
  38.     HMENU        hSysMenu;
  39.     short        flabel;
  40.     WORD        wpsave;
  41.  
  42.     switch (message) {
  43.     case WM_CREATE:
  44.         hSysMenu= GetSystemMenu (hWnd, FALSE);
  45.         DeleteMenu(hSysMenu, SC_RESTORE,  MF_BYCOMMAND);
  46.         DeleteMenu(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
  47.         DeleteMenu(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
  48.         DeleteMenu(hSysMenu, SC_SIZE,     MF_BYCOMMAND);
  49.         AppendMenu(hSysMenu, MF_SEPARATOR, -1, NULL);
  50.         AppendMenu(hSysMenu, MF_STRING, SC_RESTORE,
  51.             (LPSTR) "&Settings...");
  52.         AppendMenu(hSysMenu, MF_STRING, IDM_SETTINGS,
  53.             (LPSTR) "&About AltKeyb...");
  54. #ifdef        _Trace_
  55.         CreateDebugWindow (NULL);
  56. #endif
  57.         break;
  58.     
  59.     case WM_SYSCOMMAND:
  60.  
  61.         wpsave= wParam;    wParam&= 0xFFF0;
  62.  
  63.         switch (wParam) {
  64.         case SC_RESTORE:
  65.             KeybSet ();
  66.             break;
  67.         case IDM_SETTINGS:
  68.             DoAbout ();
  69.             break;
  70.         default:
  71.             wParam= wpsave;
  72.             goto retDef;
  73.         }
  74.         break;
  75.     
  76.     case WM_ALARM:
  77.     case WM_DESTROY:
  78.     case WM_ALTKEYBKILL:
  79. #ifdef        _Trace_
  80.         DestroyDebugWindow ();
  81. #endif
  82.         CyrStop();
  83.         if (bChanged)
  84.             {
  85.             if (ask_save (l_name))
  86.                 {
  87.                 strcpy (s_path, w_path);
  88.                 strcat (s_path, l_name);
  89.                 flabel= filopen(s_path, OF_WRITE);
  90.                 if (flabel < 0)
  91.                     break;
  92.                 if (filwrite(flabel))
  93.                 _lclose(flabel);
  94.                 }
  95.             }
  96.         if (! legal_use) demomsg();
  97.         PostQuitMessage(0);
  98.         break;
  99.     case WM_TIMER:
  100.             bLAT= wParam; InvalidateRect(hWnd, NULL, TRUE);
  101.         if (hkDlg)
  102.             SendMessage(hkDlg, WM_COMMAND, IDS_SWITCH, 0L);
  103.             break;
  104.     case WM_PAINT:
  105.         BeginPaint(hWnd, (LPPAINTSTRUCT)&ps);
  106.         GetClientRect(hWnd, (LPRECT)&rect);
  107.         DrawText(ps.hdc, (LPSTR) kreg[bLAT], 3, (LPRECT)&rect, DT_WORDBREAK);
  108.         EndPaint(hWnd, (LPPAINTSTRUCT)&ps);
  109.         break;
  110.     default:
  111. retDef:        return DefWindowProc (hWnd, message, wParam, lParam);
  112.     }
  113.     return 0L;
  114. }
  115.