home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / magazine / wpj1_6.zip / HELLO.ZIP / HELLO.C < prev    next >
C/C++ Source or Header  |  1993-06-07  |  20KB  |  655 lines

  1. /*============================================================================
  2.   Hello - Windows Programmer's Journal Volume 1 Number 6
  3.  
  4.   File      : Hello.C
  5.  
  6.   Prototype : 
  7.  
  8.   Call      : 
  9.  
  10.   Library   : 
  11.  
  12.   Example   : 
  13.  
  14.   24 April 1993 - dlcampbell
  15.   1993 Dave Campbell WynApse
  16. ----------------------------------------------------------------------------*/
  17. #define WINVER 0x0300
  18. #include <windows.h>
  19. #include "hello.h"
  20. #include <string.h>
  21.  
  22. char       szAppName[] = "Hello";
  23. HANDLE     hInst;
  24. HWND       hWndMain;
  25. HICON      hIcon, hIconMain;
  26. int        InitSettings;
  27. static     HMENU hMainMenu, hAlternateMenu;
  28.  
  29. static     char szFileName[128];
  30. static     char szFileSpec[16];
  31. static     char szDefExt[5];
  32. static     WORD wFileAttr;
  33. OFSTRUCT   of;
  34. LPOFSTRUCT pof;
  35.  
  36. /*----------------------------------------------------------------------------
  37.   Function Prototypes
  38. ----------------------------------------------------------------------------*/
  39. BOOL FAR PASCAL AboutDlgProc(HWND, WORD, WORD, LONG);
  40.  
  41. BOOL FAR PASCAL HelloDlgProc(HWND, WORD, WORD, LONG);
  42. long FAR PASCAL WndProc(HWND, unsigned, WORD, LONG);
  43. BOOL            InitInstance(HANDLE);
  44. BOOL FAR PASCAL TimerProc(HWND, WORD, WORD, LONG);
  45.  
  46. int DoFileOpenDlg(HANDLE, HANDLE, POFSTRUCT);
  47. BOOL FAR PASCAL FileOpenDlgProc(HWND, WORD, WORD, LONG);
  48. LPSTR lstrchr (LPSTR str, char ch);
  49.  
  50. /* The main procedure. This is called by Windows when your program is run. */
  51. /* hInstance is the handle for the current instance of the program         */
  52. /* hPrevInst is the handle for the last instance of the program to run     */
  53. /* CmdLine is a pointer to a string of whatever command line params came in*/
  54. /* nCmd is the specifies the applications appearance.                      */
  55.  
  56. int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInst, LPSTR CmdLine,
  57.                                                                      int nCmd)
  58. {
  59. MSG     msg;                                /* Message */
  60. HWND    hWnd;                       /* Our Window Handle */
  61. HMENU   hMenu;
  62.  
  63. if (!hPrevInst)                         /* If no instance already exists, */
  64.    {
  65.     if (!InitInstance(hInstance))       /* try initializing instance */
  66.         return FALSE;                     /* No dice, it failed */
  67.     }
  68.  
  69. hInst = hInstance;
  70.     
  71. hWndMain = CreateWindow(szAppName,              /* Window Class */
  72.                               "Hello World Program",  /* Window caption */
  73.                               WS_OVERLAPPEDWINDOW,    /* Overlapped style */
  74.                               CW_USEDEFAULT,          /* Use defaults for the */
  75.                               CW_USEDEFAULT,          /* X & Y Positions and  */
  76.                               CW_USEDEFAULT,          /* X & Y sizes */
  77.                               CW_USEDEFAULT,          
  78.                               NULL,                   /* Parent Window */
  79.                               NULL,
  80.                               hInstance,              /* Instance */
  81.                               NULL);                  /* Creation Params */
  82.  
  83. if (hWndMain == NULL)
  84.    return 0;
  85.  
  86. SetTimer(hWndMain, ID_TIMER, 500, MakeProcInstance((FARPROC)TimerProc, hInst));
  87.  
  88. hMenu = GetSystemMenu(hWndMain, FALSE);
  89. hAlternateMenu = LoadMenu(hInstance, "Hello2");
  90.  
  91. AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
  92. AppendMenu(hMenu, MF_STRING,    IDM_HELPABOUT, "About...");
  93. AppendMenu(hMenu, MF_STRING,    IDM_SETUP, "Setup...");
  94.  
  95. ShowWindow(hWndMain, nCmd);
  96. UpdateWindow(hWndMain);
  97.     
  98. while (GetMessage(&msg, NULL, 0, 0))
  99.    {
  100.     TranslateMessage(&msg);
  101.     DispatchMessage(&msg);
  102.    }
  103.     
  104. return msg.wParam;
  105. }                                       /* int FAR PASCAL WinMain */
  106.  
  107. BOOL InitInstance (HANDLE hInstance)
  108. {
  109. WNDCLASS wc;                            /* Window class structure */
  110.  
  111. wc.lpszMenuName  = szAppName;
  112. wc.lpszClassName = szAppName;
  113. wc.hbrBackground = GetStockObject(WHITE_BRUSH);  /* White bkgrnd */
  114. wc.hInstance     = hInstance;
  115. wc.style         = CS_VREDRAW | CS_HREDRAW;
  116. wc.lpfnWndProc   = (WNDPROC)WndProc;              /* Name of proc to handle window */
  117. wc.hCursor       = LoadCursor(NULL, IDC_ARROW);  /* Arrow Cursor */
  118. wc.hIcon         = LoadIcon(hInstance, "WPJ");  /* Generic Icon */
  119. wc.cbClsExtra    = 0;                /* no extras */
  120. wc.cbWndExtra    = 0;                /* No Extras */
  121.  
  122. hIconMain = wc.hIcon;
  123.  
  124. return (RegisterClass(&wc)); /* Let's register that class */
  125. }                                       /* BOOL InitInstance */
  126.  
  127. /* This is our main windows procedure. It receives messages in message, then,
  128. depending on what the message is, we react accordingly
  129. */
  130.  
  131. long FAR PASCAL WndProc(HWND hWnd, unsigned message, WORD wParam, LONG lParam)
  132. {
  133. HDC            hdc;
  134. PAINTSTRUCT    ps;
  135. RECT           rect;
  136. HMENU          hMenu;
  137. static FARPROC lpfnHelloDlgProc, lpfnAboutDlgProc;
  138. char           OutMsg[25];
  139.  
  140. lstrcpy(OutMsg, "");
  141.  
  142. switch (message)
  143.    {
  144.    case WM_CREATE :
  145.       hMainMenu = GetMenu(hWnd);
  146.       InitSettings = GetPrivateProfileInt("Hello", "Setup", 1, "Hello.ini");
  147.       InitSettings = InitSettings ? IDM_HELLO : IDM_GOODBYE;
  148.       hdc = GetDC(hWnd);
  149.          InvalidateRect(hWnd, NULL, TRUE);
  150.       ReleaseDC(hWnd, hdc);
  151.  
  152. /*----------------------------------------------------------------------------
  153.   fall through to WM_PAINT...
  154. ----------------------------------------------------------------------------*/
  155.    case WM_PAINT :
  156.       if (IsIconic(hWnd))
  157.          {
  158.          BeginPaint(hWnd, &ps);
  159.  
  160. /*----------------------------------------------------------------------------
  161.   Erase the background of the window with what's on the desktop. This is so
  162.   the desktop bitmap will show through the transparent areas of the icon. 
  163. ----------------------------------------------------------------------------*/
  164.          DefWindowProc(hWnd, WM_ICONERASEBKGND, (WORD)ps.hdc, 0L);
  165.  
  166. /*----------------------------------------------------------------------------
  167.   Now draw the icon. 
  168. ----------------------------------------------------------------------------*/
  169.          DrawIcon(ps.hdc, 0,0, hIcon);
  170.          EndPaint(hWnd, &ps);
  171.          }
  172.       else
  173.          {
  174.          hdc = BeginPaint(hWnd,&ps);        /* returns pointer to hdc */
  175.          GetClientRect(hWnd, &rect);
  176. /*
  177.   -1 tells the DrawText function to calculate length of string based on
  178.   NULL-termination
  179. */
  180.          DrawText(hdc, (InitSettings == IDM_HELLO) ? "Hello Windows!" : "Goodbye Windows!", -1,
  181.                                    &rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
  182.          EndPaint(hWnd,&ps);
  183.          }
  184.       return 0;
  185.  
  186.    case WM_SYSCOMMAND :
  187.       switch (wParam)
  188.          {
  189.          case IDM_SETUP :
  190.             lpfnHelloDlgProc = MakeProcInstance(HelloDlgProc, hInst);
  191.             DialogBox(hInst, "Hello", hWnd, lpfnHelloDlgProc);
  192.             FreeProcInstance(lpfnHelloDlgProc);
  193.             return 0;
  194.  
  195.          case IDM_HELPABOUT :
  196.             lpfnAboutDlgProc = MakeProcInstance(AboutDlgProc, hInst);
  197.             DialogBox(hInst, "About", hWnd, lpfnAboutDlgProc);
  198.             FreeProcInstance(lpfnAboutDlgProc);
  199.             return 0;
  200.          }
  201.  
  202.       break;
  203.  
  204.  
  205.    case WM_ERASEBKGND:
  206.       if (IsIconic(hWnd))
  207.  
  208. /*----------------------------------------------------------------------------
  209.   Don't erase the background now because we will do it at paint time when
  210.   we paint our icon.
  211. ----------------------------------------------------------------------------*/
  212.          return(TRUE);
  213.       else
  214.          return(DefWindowProc(hWnd, message, wParam, lParam));
  215.  
  216.    case WM_QUERYDRAGICON:
  217.       return((LONG)(WORD)hIconMain);
  218.  
  219.    case WM_COMMAND :
  220.       hMenu = GetMenu(hWnd);
  221.       switch (wParam)
  222.          {
  223.       case IDM_FILENEW :
  224.          lstrcpy(OutMsg, "IDM_FILENEW");
  225.          break;
  226.  
  227.       case IDM_FILEOPEN :
  228.          if (DoFileOpenDlg(hInst, hWnd, &of))
  229.             lstrcpy(OutMsg, (char far *)pof->szPathName);
  230.          break;
  231.  
  232.       case IDM_FILESAVE :
  233.          lstrcpy(OutMsg, "IDM_FILESAVE");
  234.          break;
  235.  
  236.       case IDM_FILESAVEAS :
  237.          lstrcpy(OutMsg, "IDM_FILESAVEAS");
  238.          break;
  239.  
  240.       case IDM_FILEPRINT :
  241.          lstrcpy(OutMsg, "IDM_FILEPRINT");
  242.          break;
  243.  
  244.       case IDM_FILEPRINTPREV :
  245.          lstrcpy(OutMsg, "IDM_FILEPRINTPREV");
  246.          break;
  247.  
  248.       case IDM_FILEPRINTSETUP :
  249.          lstrcpy(OutMsg, "IDM_FILEPRINTSETUP");
  250.          break;
  251.  
  252.       case IDM_FILEEXIT :
  253.          lstrcpy(OutMsg, "IDM_FILEEXIT");
  254.          break;
  255.  
  256.  
  257.       case IDM_EDITUNDO :
  258.          lstrcpy(OutMsg, "IDM_EDITUNDO");
  259.          break;
  260.  
  261.       case IDM_EDITREPEAT :
  262.          lstrcpy(OutMsg, "IDM_EDITREPEAT");
  263.          break;
  264.  
  265.       case IDM_EDITCUT :
  266.          lstrcpy(OutMsg, "IDM_EDITCUT");
  267.          break;
  268.  
  269.       case IDM_EDITCOPY :
  270.          lstrcpy(OutMsg, "IDM_EDITCOPY");
  271.          break;
  272.  
  273.       case IDM_EDITPASTE :
  274.          lstrcpy(OutMsg, "IDM_EDITPASTE");
  275.          break;
  276.  
  277.       case IDM_EDITCLEAR :
  278.          lstrcpy(OutMsg, "IDM_EDITCLEAR");
  279.          break;
  280.  
  281.       case IDM_EDITPAST :
  282.          lstrcpy(OutMsg, "IDM_EDITPAST");
  283.          break;
  284.  
  285.  
  286.       case IDM_SAMPLEDLG :
  287.          lstrcpy(OutMsg, "IDM_SAMPLEDLG");
  288.          break;
  289.  
  290.  
  291.       case IDM_HELPINDX :
  292.          lstrcpy(OutMsg, "IDM_HELPINDX");
  293.          break;
  294.  
  295.       case IDM_HELPKBD :
  296.          lstrcpy(OutMsg, "IDM_HELPKBD");
  297.          break;
  298.  
  299.       case IDM_HELPCMDS :
  300.          lstrcpy(OutMsg, "IDM_HELPCMDS");
  301.          break;
  302.  
  303.       case IDM_HELPPROCS :
  304.          lstrcpy(OutMsg, "IDM_HELPPROCS");
  305.          break;
  306.  
  307.       case IDM_HELPUSING :
  308.          lstrcpy(OutMsg, "IDM_HELPUSING");
  309.          break;
  310.  
  311.       case IDM_HELPABOUT :
  312.          lpfnAboutDlgProc = MakeProcInstance(AboutDlgProc, hInst);
  313.          DialogBox(hInst, "About", hWnd, lpfnAboutDlgProc);
  314.          FreeProcInstance(lpfnAboutDlgProc);
  315.          return 0;
  316.  
  317.       case IDM_ALTERNATE :
  318.          SetMenu(hWnd, hAlternateMenu);
  319.          return 0;
  320.  
  321.       case IDM_ALTONE : 
  322.          CheckMenuItem(hMenu, IDM_ALTONE, MF_CHECKED);
  323.          CheckMenuItem(hMenu, IDM_ALTTWO, MF_UNCHECKED);
  324.          return 0;
  325.  
  326.       case IDM_ALTTWO : 
  327.          CheckMenuItem(hMenu, IDM_ALTTWO, MF_CHECKED);
  328.          CheckMenuItem(hMenu, IDM_ALTONE, MF_UNCHECKED);
  329.          return 0;
  330.  
  331.       case IDM_ALTGRAY : 
  332.          EnableMenuItem(hMenu, IDM_ALTGRAY, MF_GRAYED);
  333.          EnableMenuItem(hMenu, IDM_ALTUNGRAY, MF_ENABLED);
  334.          return 0;
  335.  
  336.       case IDM_ALTUNGRAY : 
  337.          EnableMenuItem(hMenu, IDM_ALTUNGRAY, MF_GRAYED);
  338.          EnableMenuItem(hMenu, IDM_ALTGRAY, MF_ENABLED);
  339.          return 0;
  340.  
  341.       case IDM_ALTRESTORE : 
  342.          SetMenu(hWnd, hMainMenu);
  343.          return 0;
  344.  
  345.       case WM_DESTROY :
  346.           PostQuitMessage(0);
  347.           return 0;
  348.           }
  349.  
  350.    if (lstrlen(OutMsg) != 0)
  351.       {
  352.       MessageBox(hWnd, OutMsg, szAppName, MB_ICONEXCLAMATION | MB_OK);
  353.       return 0;
  354.       }
  355.  
  356.    }
  357. return DefWindowProc(hWnd, message, wParam, lParam);
  358. }                                       /* long FAR PASCAL WndProc */
  359.  
  360. /*============================================================================
  361.   HelloDlgProc -- 
  362.  
  363.   File      : Test.C
  364.  
  365.   Prototype : BOOL FAR PASCAL HelloDlgProc(HWND, WORD, WORD, LONG);
  366.  
  367.   Call      : HelloDlgProc(hDlg, message, wParam, lParam);
  368.  
  369.   Library   : 
  370.  
  371.   24 April 1993 - dlcampbell
  372.   (c) 1993 WynApse
  373. ----------------------------------------------------------------------------*/
  374. BOOL FAR PASCAL HelloDlgProc (HWND hDlg, WORD message, WORD wParam,
  375.                                                                   LONG lParam)
  376. {
  377. switch (message)
  378.    {
  379.    case WM_INITDIALOG :
  380.       CheckRadioButton(hDlg, IDM_HELLO, IDM_GOODBYE, InitSettings);
  381.       return TRUE;
  382.  
  383.    case WM_COMMAND :
  384.       switch (wParam)
  385.          {
  386.          case IDM_HELLO : 
  387.                WritePrivateProfileString("Hello", "Setup", "1", "Hello.ini");
  388.             InitSettings = wParam;
  389.             break;
  390.  
  391.          case IDM_GOODBYE : 
  392.                WritePrivateProfileString("Hello", "Setup", "0", "Hello.ini");
  393.             InitSettings = wParam;
  394.             break;
  395.  
  396.          case IDOK :
  397.             EndDialog(hDlg, wParam);
  398.             return TRUE;
  399.  
  400.          }
  401.       break;
  402.  
  403.    }
  404. return FALSE;
  405. }                                       /* HelloDlgProc */
  406. /*============================================================================
  407.   AboutDlgProc
  408.  
  409.   File      : ExitWin.C
  410.  
  411.   Prototype : 
  412.  
  413.   Call      : 
  414.  
  415.   Library   : 
  416.  
  417.   24 April 1993 - dlcampbell
  418.   (c) 1993 WynApse
  419. ----------------------------------------------------------------------------*/
  420. BOOL FAR PASCAL AboutDlgProc (HWND hDlg, WORD message, WORD wParam,
  421.                                                                   LONG lParam)
  422. {
  423. char szBuffer[100];
  424.  
  425. switch (message)
  426.    {
  427.    case WM_INITDIALOG :
  428.       wsprintf(szBuffer, "%s at %s", (LPSTR) __DATE__, (LPSTR) __TIME__);
  429.       SetWindowText(GetDlgItem(hDlg, ID_VERSION), szBuffer);
  430.       return TRUE;
  431.  
  432.    case WM_COMMAND :
  433.       switch (wParam)
  434.          {
  435.          case IDOK :
  436.          case IDCANCEL :
  437.             if (HIWORD(lParam) == BN_CLICKED)
  438.                EndDialog(hDlg, wParam);
  439.             return TRUE;
  440.  
  441.          default :
  442.             return TRUE;
  443.          }
  444.  
  445.    default :
  446.       return FALSE;
  447.    }
  448. }                                       /* AboutDlgProc */
  449. /*============================================================================
  450.   DoFileOpenDlg --
  451.  
  452.   File      : FileDlg.C
  453.  
  454.   Prototype : int DoFileOpenDlg(HANDLE, HANDLE, char *, char *, WORD,
  455.                                 char *, POFSTRUCT)
  456.  
  457.   Call      : DoFileOpenDlg(hInst, hWnd, szFileSpecIn, szDefExtIn, WORD,
  458.                             szFileNameOut, pofIn)
  459.  
  460.   Library   : 
  461.  
  462.   24 April 1993 - dlcampbell
  463.   (c) 1993 WynApse
  464. ----------------------------------------------------------------------------*/
  465. int DoFileOpenDlg(HANDLE hInst, HANDLE hWnd, POFSTRUCT pofIn)
  466. {
  467. FARPROC    lpfnFileOpenDlgProc;
  468. int        iReturn;
  469.  
  470. pof = pofIn;
  471. lstrcpy(szFileSpec, "*.EXE");
  472. lstrcpy(szDefExt,   "EXE");
  473. wFileAttr = DDL_DRIVES | DDL_DIRECTORY; /* 0x4010 */
  474.  
  475. lpfnFileOpenDlgProc = MakeProcInstance((FARPROC)FileOpenDlgProc, hInst);
  476. iReturn = DialogBox(hInst, "FileOpen", hWnd, lpfnFileOpenDlgProc);
  477. FreeProcInstance(lpfnFileOpenDlgProc);
  478.  
  479. return iReturn;
  480. }                                       /* DoFileOpenDlg */
  481.  
  482. /*============================================================================
  483.   FileOpenDlgProc
  484.  
  485.   File      : FileDlg.C
  486.  
  487.   Prototype : BOOL FAR PASCAL FileOpenDlgProc(HWND, WORD, WORD, LONG);
  488.  
  489.   Call      : WndProc(hWnd, message, wParam, lParam);
  490.  
  491.   Library   :
  492.  
  493.   24 April 1993 - dlcampbell
  494. ----------------------------------------------------------------------------*/
  495. BOOL FAR PASCAL FileOpenDlgProc(HWND hDlg, WORD message,
  496.                                 WORD wParam, LONG lParam)
  497. {
  498. char    cLastChar;
  499. short   nEditLen;
  500.  
  501. switch (message)
  502.    {
  503.    case WM_INITDIALOG :
  504.       SendDlgItemMessage(hDlg, IDD_FNAME, EM_LIMITTEXT, 80, 0L);
  505.       DlgDirList(hDlg, szFileSpec, IDD_FLIST, IDD_FPATH, wFileAttr);
  506.       SetDlgItemText(hDlg, IDD_FNAME, szFileSpec);
  507.       return TRUE;
  508.  
  509.    case WM_COMMAND :
  510.       switch (wParam)
  511.          {
  512.          case IDD_FLIST :
  513.             switch (HIWORD(lParam))
  514.                {
  515.                case LBN_SELCHANGE :
  516.                   if (DlgDirSelect(hDlg, szFileName, IDD_FLIST))
  517.                      lstrcat(szFileName, szFileSpec);
  518.                   SetDlgItemText(hDlg, IDD_FNAME, szFileName);
  519.                   return TRUE;
  520.  
  521.                case LBN_DBLCLK :
  522.                   if (DlgDirSelect(hDlg, szFileName, IDD_FLIST))
  523.                      {
  524.                      lstrcat(szFileName, szFileSpec);
  525.                      DlgDirList(hDlg, szFileName, IDD_FLIST, IDD_FPATH, wFileAttr);
  526.                        SetDlgItemText(hDlg, IDD_FNAME, szFileSpec);
  527.                      }
  528.                   else
  529.                      {
  530.                      SetDlgItemText(hDlg, IDD_FNAME, szFileName);
  531.                      SendMessage(hDlg, WM_COMMAND, IDOK, 0L);
  532.                      }
  533.                   return TRUE;
  534.                }
  535.             break;
  536.  
  537.          case IDD_FNAME :
  538.             if (HIWORD(lParam) == EN_CHANGE)
  539.                EnableWindow(GetDlgItem(hDlg, IDOK),
  540.                  (BOOL) SendMessage(LOWORD(lParam), WM_GETTEXTLENGTH, 0, 0L));
  541.             return TRUE;
  542.  
  543.          case IDOK :
  544.             GetDlgItemText(hDlg, IDD_FNAME, szFileName, 80);
  545.             nEditLen = lstrlen(szFileName);
  546.             cLastChar = *AnsiPrev(szFileName, szFileName + nEditLen);
  547.  
  548.             if (cLastChar == '\\' || cLastChar == ':')
  549.                lstrcat(szFileName, szFileSpec);
  550.  
  551.             if (lstrchr(szFileName, '*') || lstrchr(szFileName, '?'))
  552.                {
  553.                if (DlgDirList(hDlg, szFileName, IDD_FLIST, IDD_FPATH, wFileAttr))
  554.                   {
  555.                   lstrcpy(szFileSpec, szFileName);
  556.                   SetDlgItemText(hDlg, IDD_FNAME, szFileSpec);
  557.                   }
  558.                else
  559.                   MessageBeep(0);
  560.       
  561.                return TRUE;
  562.                }
  563.             lstrcat(lstrcat(szFileName, "\\"), szFileSpec);
  564.  
  565.             if (DlgDirList(hDlg, szFileName, IDD_FLIST, IDD_FPATH, wFileAttr))
  566.                {
  567.                lstrcpy(szFileSpec, szFileName);
  568.                SetDlgItemText(hDlg, IDD_FNAME, szFileSpec);
  569.                return TRUE;
  570.                }
  571.             szFileName[nEditLen] = '\0';
  572.  
  573.             if (-1 == OpenFile(szFileName, pof, OF_READ | OF_EXIST))
  574.                {
  575.                lstrcat(szFileName, szDefExt);
  576.                if (-1 == OpenFile(szFileName, pof, OF_READ | OF_EXIST))
  577.                   {
  578.                   MessageBeep(0);
  579.                   return TRUE;
  580.                   }
  581.                }
  582.  
  583.             EndDialog(hDlg, TRUE);
  584.             return TRUE;
  585.  
  586.          case IDCANCEL :
  587.             EndDialog(hDlg, FALSE);
  588.             return TRUE;
  589.          }
  590.    }
  591. return FALSE;
  592. }                                       /* FileOpenDlgProc */
  593.  
  594. /*============================================================================
  595.   lstrchr --
  596.  
  597.   File      : Filedlg.C
  598.  
  599.   Prototype : LPSTR lstrchr(char, char);
  600.  
  601.   Call      : lstrchr(str, ch);
  602.  
  603.   Library   : 
  604.  
  605.   24 April 1993 - dlcampbell
  606. ----------------------------------------------------------------------------*/
  607. LPSTR lstrchr(LPSTR str, char ch)
  608. {
  609. while (*str)
  610.    {
  611.    if (ch == *str)
  612.       return str;
  613.    str = AnsiNext(str);
  614.    }
  615. return NULL;
  616. }                                       /* lstrchr */
  617.  
  618.  
  619. /*============================================================================
  620.   TimerProc
  621.  
  622.   File      : Hello.C
  623.  
  624.   Prototype : 
  625.  
  626.   Call      : 
  627.  
  628.   Library   : 
  629.  
  630.   Example   : 
  631.  
  632.   6 June 1993 - dlcampbell
  633.   (c) 1993 Campbell SoftWare
  634. ----------------------------------------------------------------------------*/
  635. BOOL FAR PASCAL TimerProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
  636. {
  637. static BOOL which = 0;
  638.  
  639. if (IsIconic(hWnd))
  640.    {
  641.    if (which = !which)
  642.       {
  643.       hIcon = LoadIcon(hInst, "GO");
  644.       InvalidateRect(hWnd, NULL, FALSE);
  645.       SendMessage(hWndMain, WM_PAINT, NULL, NULL);
  646.       }
  647.    else
  648.       {
  649.       hIcon = LoadIcon(hInst, "SUNS");
  650.       InvalidateRect(hWnd, NULL, FALSE);
  651.       SendMessage(hWndMain, WM_PAINT, NULL, NULL);
  652.       }
  653.    }
  654. }                                       /* TimerProc */
  655.