home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / LC / SEE4C10.ZIP / QUICK.C < prev    next >
C/C++ Source or Header  |  1998-05-31  |  4KB  |  179 lines

  1. /*
  2. **  QUICK.C
  3. **
  4. **  Simple program that sends a quick email!
  5. */
  6.  
  7. #include <windows.h>
  8. #include "see.h"
  9. #include "message.h"
  10. #include "paint.h"
  11. #include "about.h"
  12. #include "param.h"
  13. #include "str.h"
  14. #include "ascii.h"
  15.  
  16. #ifdef WIN32
  17. #define USE_INS HINSTANCE
  18. #define USE_PTR PSTR
  19. #else
  20. #define USE_INS HANDLE
  21. #define USE_PTR LPSTR
  22. #endif
  23.  
  24. #define DEBUG_INTEGER -4
  25. #define DEBUG_CHAR    -5
  26.  
  27. LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
  28.  
  29. /* globals */
  30.  
  31. #define MAX_BUF 1024
  32. #define MAX_STR   64
  33.  
  34. #define SET_TO    1
  35. #define SET_SUBJ  2
  36. #define SET_MSG   3
  37.  
  38. HWND hMainWnd;            /* main window handle */
  39.  
  40. static HMENU hMenu;
  41. static USE_INS hInstance;
  42. static int WinWidth = 8 * NCOLS;
  43. static int WinHeight = 12 * NROWS + 48;
  44. static HCURSOR ArrowCursor;
  45. static HCURSOR WaitCursor;
  46.  
  47. /* WinMain */
  48.  
  49. #ifdef WIN32
  50. int WINAPI
  51. #else
  52. int PASCAL
  53. #endif
  54. WinMain(USE_INS hInst, USE_INS hPrevInstance,
  55.         USE_PTR szCmdLine,  int nCmdShow)
  56. {WNDCLASS  wc;
  57.  MSG msg;
  58.  BOOL Result;
  59.  if(!hPrevInstance)
  60.    {/* register main window class */
  61.     wc.style = CS_HREDRAW | CS_VREDRAW;
  62.     wc.lpfnWndProc = MainWndProc;
  63.     wc.cbClsExtra = 0;
  64.     wc.cbWndExtra = 0;
  65.     wc.hInstance = hInst;
  66.     wc.hIcon = LoadIcon(hInst, "HostIcon");
  67.     wc.hCursor = NULL;
  68.     wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  69.     wc.lpszMenuName =  "HostMenu";
  70.     wc.lpszClassName = "HostWClass";
  71.     Result = RegisterClass(&wc);
  72.     if(!Result) return FALSE;
  73.    }
  74.  
  75.  /* create main window */
  76.  hInstance = hInst;
  77.  hMainWnd = CreateWindow(
  78.         "HostWClass",   "QUICK",    WS_OVERLAPPEDWINDOW,
  79.         CW_USEDEFAULT,  CW_USEDEFAULT,
  80.         WinWidth,       WinHeight,
  81.         NULL,           NULL,
  82.         hInstance,      NULL);
  83.  ShowWindow(hMainWnd, nCmdShow);
  84.  UpdateWindow(hMainWnd);
  85.  hMenu = GetMenu(hMainWnd);
  86.  
  87.  /* window control loop */
  88.  
  89.  while(GetMessage(&msg,NULL,0,0))
  90.    {
  91.     TranslateMessage(&msg);
  92.     DispatchMessage(&msg);
  93.    }
  94.  return (msg.wParam);
  95. } /* end WinMain */
  96.  
  97. #ifdef WIN32
  98. LRESULT CALLBACK
  99. #else
  100. long FAR PASCAL
  101. #endif
  102. MainWndProc(HWND hWindow,UINT iMsg,WPARAM wParam,LPARAM lParam)
  103. {HDC hDC;
  104.  PAINTSTRUCT ps;
  105. #ifdef WIN32
  106. #else
  107.  static FARPROC lpfnAboutDlgProc;
  108.  static FARPROC lpfnParamDlgProc;
  109. #endif
  110.  hMainWnd = hWindow;
  111.  switch (iMsg)
  112.     {case WM_CREATE:
  113.       /* create cursors */
  114.       ArrowCursor = LoadCursor(NULL, IDC_ARROW);
  115.       WaitCursor = LoadCursor(NULL, IDC_WAIT);
  116.       SetCursor(ArrowCursor);
  117. #ifdef WIN32
  118. #else
  119.       /* create thunk for Win16 */
  120.       lpfnAboutDlgProc = MakeProcInstance(AboutDlgProc,hInstance);
  121.       lpfnParamDlgProc = MakeProcInstance(ParamDlgProc,hInstance);
  122. #endif
  123.       /* initialize paint module */
  124.       PaintInit();
  125.       DisplayLine("Choose 'SendMail' above to set email fields & send email"); 
  126.       DisplayLine("Remember to enclose all email addresses in '<>' brackets");
  127.       break;
  128.  
  129.      case WM_COMMAND:
  130.          switch(wParam)
  131.            {case MSG_ABOUT :
  132. #ifdef WIN32
  133.                DialogBox(hInstance, "AboutBox", hMainWnd, AboutDlgProc);
  134. #else
  135.                DialogBox(hInstance, "AboutBox", hMainWnd, lpfnAboutDlgProc);
  136. #endif
  137.                return 0;
  138.                
  139.             case MSG_PARAM:
  140. #ifdef WIN32
  141.                DialogBox(hInstance, "ParamBox", hMainWnd, ParamDlgProc);
  142. #else
  143.                DialogBox(hInstance, "ParamBox", hMainWnd, lpfnParamDlgProc);
  144. #endif
  145.                return 0; 
  146.                
  147.             case MSG_EXIT:
  148.               DestroyWindow(hMainWnd);
  149.               break;
  150.  
  151.             case MSG_DEBUG:
  152.               break;
  153.            }
  154.          break;
  155.  
  156.     case WM_PAINT:
  157.       HideCaret(hMainWnd);
  158.       hDC = BeginPaint(hMainWnd, &ps);
  159.       SetMapMode(hDC,MM_ANISOTROPIC);
  160.       SelectObject(hDC, GetStockObject(OEM_FIXED_FONT) );
  161.       PaintMain(hDC,&ps);
  162.       EndPaint(hMainWnd,&ps);
  163.       SetCaretPos(PaintGetColPos(),PaintGetRowPos());
  164.       ShowCaret(hMainWnd);
  165.       break;
  166.  
  167.     case WM_DESTROY:
  168.       PostQuitMessage(0);
  169.       break;
  170.  
  171.     default:
  172.       return (DefWindowProc(hMainWnd, iMsg, wParam, lParam));
  173.    }
  174.  return 0;
  175. }
  176.  
  177.  
  178.  
  179.