Back to index

lightning-sunbird  0.9+nobinonly
poppad.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*---------------------------------------
00039    POPPAD.C -- Popup Editor
00040    (c) Charles Petzold, 1992
00041   ---------------------------------------*/
00042 
00043 #include "nspr.h"
00044 #include "plevent.h"
00045 #include <windows.h>
00046 #include <commdlg.h>
00047 #include <stdlib.h>
00048 #include "poppad.h"
00049 #include <time.h>
00050 
00051 #define EDITID   1
00052 #define UNTITLED "(untitled)"
00053 
00054 long FAR PASCAL _export WndProc      (HWND, UINT, UINT, LONG) ;
00055 BOOL FAR PASCAL _export AboutDlgProc (HWND, UINT, UINT, LONG) ;
00056 
00057 /* Declarations for NSPR customization
00058 ** 
00059 */
00060 typedef struct PadEvent
00061 {
00062     PLEvent plEvent;
00063     int     unused;    
00064 } PadEvent;
00065 
00066 static void PR_CALLBACK TimerThread( void *arg);
00067 static void PR_CALLBACK HandlePadEvent( PadEvent *padEvent );
00068 static void PR_CALLBACK DestroyPadEvent( PadEvent *padevent );
00069 static PRThread *tThread;
00070 static PLEventQueue *padQueue; 
00071 static int  quitSwitch = 0;
00072 static long ThreadSleepTime = 1000;
00073 static long timerCount = 0;
00074 static char *startMessage = "Poppad: NSPR GUI and event test program.\n"
00075                             "You should see lines of 50 characters\n"
00076                             "with a new character appearing at 1 second intervals.\n"
00077                             "Every 10 seconds gets a '+'; every 5 seconds gets a '_';\n"
00078                             "every 1 second gets a '.'.\n\n"
00079                             "You should be able to type in the window.\n\n\n";
00080 
00081 
00082           // Functions in POPFILE.C
00083 
00084 void PopFileInitialize (HWND) ;
00085 BOOL PopFileOpenDlg    (HWND, LPSTR, LPSTR) ;
00086 BOOL PopFileSaveDlg    (HWND, LPSTR, LPSTR) ;
00087 BOOL PopFileRead       (HWND, LPSTR) ;
00088 BOOL PopFileWrite      (HWND, LPSTR) ;
00089 
00090           // Functions in POPFIND.C
00091 
00092 HWND PopFindFindDlg     (HWND) ;
00093 HWND PopFindReplaceDlg  (HWND) ;
00094 BOOL PopFindFindText    (HWND, int *, LPFINDREPLACE) ;
00095 BOOL PopFindReplaceText (HWND, int *, LPFINDREPLACE) ;
00096 BOOL PopFindNextText    (HWND, int *) ;
00097 BOOL PopFindValidFind   (void) ;
00098 
00099           // Functions in POPFONT.C
00100 
00101 void PopFontInitialize   (HWND) ;
00102 BOOL PopFontChooseFont   (HWND) ;
00103 void PopFontSetFont      (HWND) ;
00104 void PopFontDeinitialize (void) ;
00105 
00106           // Functions in POPPRNT.C
00107 
00108 BOOL PopPrntPrintFile (HANDLE, HWND, HWND, LPSTR) ;
00109 
00110           // Global variables
00111 
00112 static char szAppName [] = "PopPad" ;
00113 static HWND hDlgModeless ;
00114 static HWND hwndEdit ;
00115 
00116 int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
00117                     LPSTR lpszCmdLine, int nCmdShow)
00118     {
00119     MSG      msg;
00120     HWND     hwnd ;
00121     HANDLE   hAccel ;
00122     WNDCLASS wndclass ;
00123 
00124     PR_STDIO_INIT();
00125     PR_Init(0, 0, 0);
00126           
00127     if (!hPrevInstance) 
00128           {
00129           wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
00130           wndclass.lpfnWndProc   = WndProc ;
00131           wndclass.cbClsExtra    = 0 ;
00132           wndclass.cbWndExtra    = 0 ;
00133           wndclass.hInstance     = hInstance ;
00134           wndclass.hIcon         = LoadIcon (hInstance, szAppName) ;
00135           wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
00136           wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
00137           wndclass.lpszMenuName  = szAppName ;
00138           wndclass.lpszClassName = szAppName ;
00139 
00140           RegisterClass (&wndclass) ;
00141           }
00142 
00143      hwnd = CreateWindow (szAppName, NULL,
00144                           WS_OVERLAPPEDWINDOW,
00145                           CW_USEDEFAULT, CW_USEDEFAULT,
00146                           CW_USEDEFAULT, CW_USEDEFAULT,
00147                           NULL, NULL, hInstance, lpszCmdLine) ;
00148 
00149      ShowWindow (hwnd, nCmdShow) ;
00150      UpdateWindow (hwnd); 
00151 
00152      hAccel = LoadAccelerators (hInstance, szAppName) ;
00153      
00154      for(;;)
00155      {
00156         if ( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE  ))
00157         {
00158             if (GetMessage(&msg, NULL, 0, 0))
00159             {
00160                 if (hDlgModeless == NULL || !IsDialogMessage (hDlgModeless, &msg))
00161                 {
00162                     if (!TranslateAccelerator (hwnd, hAccel, &msg))
00163                     {
00164                         TranslateMessage (&msg) ;
00165                         DispatchMessage (&msg) ;
00166                     } /* end if !TranslateAccelerator */
00167                 } 
00168             }
00169             else
00170             {
00171                 break;    
00172             } /* end if GetMessage() */
00173         } 
00174         else /* !PeekMessage */
00175         {
00176             PR_Sleep(50);
00177         }/* end if PeekMessage() */
00178      } /* end for() */
00179 
00180      PR_JoinThread( tThread );
00181      PL_DestroyEventQueue( padQueue );
00182      PR_Cleanup();
00183      return msg.wParam ;
00184      }
00185 
00186 void DoCaption (HWND hwnd, char *szTitleName)
00187      {
00188      char szCaption [64 + _MAX_FNAME + _MAX_EXT] ;
00189 
00190      wsprintf (szCaption, "%s - %s", (LPSTR) szAppName,
00191                (LPSTR) (szTitleName [0] ? szTitleName : UNTITLED)) ;
00192 
00193      SetWindowText (hwnd, szCaption) ;
00194      }
00195 
00196 void OkMessage (HWND hwnd, char *szMessage, char *szTitleName)
00197      {
00198      char szBuffer [64 + _MAX_FNAME + _MAX_EXT] ;
00199 
00200      wsprintf (szBuffer, szMessage,
00201                (LPSTR) (szTitleName [0] ? szTitleName : UNTITLED)) ;
00202 
00203      MessageBox (hwnd, szBuffer, szAppName, MB_OK | MB_ICONEXCLAMATION) ;
00204      }
00205 
00206 short AskAboutSave (HWND hwnd, char *szTitleName)
00207      {
00208      char  szBuffer [64 + _MAX_FNAME + _MAX_EXT] ;
00209      short nReturn ;
00210 
00211      wsprintf (szBuffer, "Save current changes in %s?",
00212                (LPSTR) (szTitleName [0] ? szTitleName : UNTITLED)) ;
00213 
00214      nReturn = MessageBox (hwnd, szBuffer, szAppName,
00215                            MB_YESNOCANCEL | MB_ICONQUESTION) ;
00216 
00217      if (nReturn == IDYES)
00218           if (!SendMessage (hwnd, WM_COMMAND, IDM_SAVE, 0L))
00219                nReturn = IDCANCEL ;
00220 
00221      return nReturn ;
00222      }
00223 
00224 long FAR PASCAL _export WndProc (HWND hwnd, UINT message, UINT wParam,
00225                                                           LONG lParam)
00226      {
00227      static BOOL    bNeedSave = FALSE ;
00228      static char    szFileName  [_MAX_PATH] ;
00229      static char    szTitleName [_MAX_FNAME + _MAX_EXT] ;
00230      static FARPROC lpfnAboutDlgProc ;
00231      static HANDLE  hInst ;
00232      static int     iOffset ;
00233      static UINT    messageFindReplace ;
00234      LONG           lSelect ;
00235      LPFINDREPLACE  lpfr ;
00236      WORD           wEnable ;
00237 
00238      switch (message)
00239           {
00240           case WM_CREATE:
00241                          // Get About dialog instance address
00242 
00243                hInst = ((LPCREATESTRUCT) lParam)->hInstance ;
00244                lpfnAboutDlgProc = MakeProcInstance ((FARPROC) AboutDlgProc,
00245                                                     hInst) ;
00246 
00247                          // Create the edit control child window
00248 
00249                hwndEdit = CreateWindow ("edit", NULL,
00250                          WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
00251                               WS_BORDER | ES_LEFT | ES_MULTILINE |
00252                               ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
00253                          0, 0, 0, 0,
00254                          hwnd, EDITID, hInst, NULL) ;
00255 
00256                SendMessage (hwndEdit, EM_LIMITTEXT, 32000, 0L) ;
00257 
00258                          // Initialize common dialog box stuff
00259 
00260                PopFileInitialize (hwnd) ;
00261                PopFontInitialize (hwndEdit) ;
00262 
00263                messageFindReplace = RegisterWindowMessage (FINDMSGSTRING) ;
00264 
00265                          // Process command line
00266 
00267                lstrcpy (szFileName, (LPSTR)
00268                         (((LPCREATESTRUCT) lParam)->lpCreateParams)) ;
00269 
00270                if (lstrlen (szFileName) > 0)
00271                     {
00272                     GetFileTitle (szFileName, szTitleName,
00273                                   sizeof (szTitleName)) ;
00274 
00275                     if (!PopFileRead (hwndEdit, szFileName))
00276                          OkMessage (hwnd, "File %s cannot be read!",
00277                                           szTitleName) ;
00278                     }
00279 
00280                DoCaption (hwnd, szTitleName) ;
00281 
00282                /* Initialize Event Processing for NSPR
00283                ** Retrieve the event queue just created
00284                ** Create the TimerThread
00285                */               
00286                PL_InitializeEventsLib("someName");
00287                padQueue = PL_GetMainEventQueue();
00288                tThread = PR_CreateThread(PR_USER_THREAD,
00289                         TimerThread,
00290                         NULL,
00291                         PR_PRIORITY_NORMAL,
00292                         PR_LOCAL_THREAD,
00293                         PR_JOINABLE_THREAD,
00294                         0 );
00295                return 0 ;
00296 
00297           case WM_SETFOCUS:
00298                SetFocus (hwndEdit) ;
00299                return 0 ;
00300 
00301           case WM_SIZE: 
00302                MoveWindow (hwndEdit, 0, 0, LOWORD (lParam),
00303                                            HIWORD (lParam), TRUE) ;
00304                return 0 ;
00305 
00306           case WM_INITMENUPOPUP:
00307                switch (lParam)
00308                     {
00309                     case 1:        // Edit menu
00310 
00311                               // Enable Undo if edit control can do it
00312 
00313                          EnableMenuItem (wParam, IDM_UNDO,
00314                               SendMessage (hwndEdit, EM_CANUNDO, 0, 0L) ?
00315                                    MF_ENABLED : MF_GRAYED) ;
00316 
00317                               // Enable Paste if text is in the clipboard
00318 
00319                          EnableMenuItem (wParam, IDM_PASTE,
00320                               IsClipboardFormatAvailable (CF_TEXT) ?
00321                                    MF_ENABLED : MF_GRAYED) ;
00322 
00323                               // Enable Cut, Copy, and Del if text is selected
00324 
00325                          lSelect = SendMessage (hwndEdit, EM_GETSEL, 0, 0L) ;
00326                          wEnable = HIWORD (lSelect) != LOWORD (lSelect) ?
00327                                         MF_ENABLED : MF_GRAYED ;
00328 
00329                          EnableMenuItem (wParam, IDM_CUT,  wEnable) ;
00330                          EnableMenuItem (wParam, IDM_COPY, wEnable) ;
00331                          EnableMenuItem (wParam, IDM_DEL,  wEnable) ;
00332                          break ;
00333 
00334                     case 2:        // Search menu
00335 
00336                               // Enable Find, Next, and Replace if modeless
00337                               //   dialogs are not already active
00338 
00339                          wEnable = hDlgModeless == NULL ?
00340                                         MF_ENABLED : MF_GRAYED ;
00341 
00342                          EnableMenuItem (wParam, IDM_FIND,    wEnable) ;
00343                          EnableMenuItem (wParam, IDM_NEXT,    wEnable) ;
00344                          EnableMenuItem (wParam, IDM_REPLACE, wEnable) ;
00345                          break ;
00346                     }
00347                return 0 ;
00348 
00349           case WM_COMMAND :
00350                               // Messages from edit control
00351 
00352                if (LOWORD (lParam) && wParam == EDITID)
00353                     {
00354                     switch (HIWORD (lParam))
00355                          {
00356                          case EN_UPDATE:
00357                               bNeedSave = TRUE ;
00358                               return 0 ;
00359 
00360                          case EN_ERRSPACE:
00361                          case EN_MAXTEXT:
00362                               MessageBox (hwnd, "Edit control out of space.",
00363                                         szAppName, MB_OK | MB_ICONSTOP) ;
00364                               return 0 ;
00365                          }
00366                     break ;
00367                     }
00368 
00369                switch (wParam)
00370                     {
00371                               // Messages from File menu
00372 
00373                     case IDM_NEW:
00374                          if (bNeedSave && IDCANCEL ==
00375                                    AskAboutSave (hwnd, szTitleName))
00376                               return 0 ;
00377 
00378                          SetWindowText (hwndEdit, "\0") ;
00379                          szFileName [0]  = '\0' ;
00380                          szTitleName [0] = '\0' ;
00381                          DoCaption (hwnd, szTitleName) ;
00382                          bNeedSave = FALSE ;
00383                          return 0 ;
00384 
00385                     case IDM_OPEN:
00386                          if (bNeedSave && IDCANCEL ==
00387                                    AskAboutSave (hwnd, szTitleName))
00388                               return 0 ;
00389 
00390                          if (PopFileOpenDlg (hwnd, szFileName, szTitleName))
00391                               {
00392                               if (!PopFileRead (hwndEdit, szFileName))
00393                                    {
00394                                    OkMessage (hwnd, "Could not read file %s!",
00395                                                     szTitleName) ;
00396                                    szFileName  [0] = '\0' ;
00397                                    szTitleName [0] = '\0' ;
00398                                    }
00399                               }
00400 
00401                          DoCaption (hwnd, szTitleName) ;
00402                          bNeedSave = FALSE ;
00403                          return 0 ;
00404 
00405                     case IDM_SAVE:
00406                          if (szFileName [0])
00407                               {
00408                               if (PopFileWrite (hwndEdit, szFileName))
00409                                    {
00410                                    bNeedSave = FALSE ;
00411                                    return 1 ;
00412                                    }
00413                               else
00414                                    OkMessage (hwnd, "Could not write file %s",
00415                                                     szTitleName) ;
00416                               return 0 ;
00417                               }
00418                                                   // fall through
00419                     case IDM_SAVEAS:
00420                          if (PopFileSaveDlg (hwnd, szFileName, szTitleName))
00421                               {
00422                               DoCaption (hwnd, szTitleName) ;
00423 
00424                               if (PopFileWrite (hwndEdit, szFileName))
00425                                    {
00426                                    bNeedSave = FALSE ;
00427                                    return 1 ;
00428                                    }
00429                               else
00430                                    OkMessage (hwnd, "Could not write file %s",
00431                                                     szTitleName) ;
00432                               }
00433                          return 0 ;
00434 
00435                     case IDM_PRINT:
00436                          if (!PopPrntPrintFile (hInst, hwnd, hwndEdit,
00437                                                 szTitleName))
00438                               OkMessage (hwnd, "Could not print file %s",
00439                                          szTitleName) ;
00440                          return 0 ;
00441 
00442                     case IDM_EXIT:
00443                          SendMessage (hwnd, WM_CLOSE, 0, 0L) ;
00444                          return 0 ;
00445 
00446                               // Messages from Edit menu
00447 
00448                     case IDM_UNDO:
00449                          SendMessage (hwndEdit, WM_UNDO, 0, 0L) ;
00450                          return 0 ;
00451 
00452                     case IDM_CUT:
00453                          SendMessage (hwndEdit, WM_CUT, 0, 0L) ;
00454                          return 0 ;
00455 
00456                     case IDM_COPY:
00457                          SendMessage (hwndEdit, WM_COPY, 0, 0L) ;
00458                          return 0 ;
00459 
00460                     case IDM_PASTE:
00461                          SendMessage (hwndEdit, WM_PASTE, 0, 0L) ;
00462                          return 0 ;
00463 
00464                     case IDM_DEL:
00465                          SendMessage (hwndEdit, WM_CLEAR, 0, 0L) ;
00466                          return 0 ;
00467 
00468                     case IDM_SELALL:
00469                          SendMessage (hwndEdit, EM_SETSEL, 0,
00470                                         MAKELONG (0, 32767)) ;
00471                          return 0 ;
00472 
00473                               // Messages from Search menu
00474 
00475                     case IDM_FIND:
00476                          iOffset = HIWORD (
00477                               SendMessage (hwndEdit, EM_GETSEL, 0, 0L)) ;
00478                          hDlgModeless = PopFindFindDlg (hwnd) ;
00479                          return 0 ;
00480 
00481                     case IDM_NEXT:
00482                          iOffset = HIWORD (
00483                               SendMessage (hwndEdit, EM_GETSEL, 0, 0L)) ;
00484 
00485                          if (PopFindValidFind ())
00486                               PopFindNextText (hwndEdit, &iOffset) ;
00487                          else
00488                               hDlgModeless = PopFindFindDlg (hwnd) ;
00489 
00490                          return 0 ;
00491 
00492                     case IDM_REPLACE:
00493                          iOffset = HIWORD (
00494                               SendMessage (hwndEdit, EM_GETSEL, 0, 0L)) ;
00495 
00496                          hDlgModeless = PopFindReplaceDlg (hwnd) ;
00497                          return 0 ;
00498 
00499                     case IDM_FONT:
00500                          if (PopFontChooseFont (hwnd))
00501                               PopFontSetFont (hwndEdit) ;
00502 
00503                          return 0 ;
00504 
00505                               // Messages from Help menu
00506 
00507                     case IDM_HELP:
00508                          OkMessage (hwnd, "Help not yet implemented!", NULL) ;
00509                          return 0 ;
00510 
00511                     case IDM_ABOUT:
00512                          DialogBox (hInst, "AboutBox", hwnd, lpfnAboutDlgProc);
00513                          return 0 ;
00514                     }
00515                break ;
00516 
00517           case WM_CLOSE:
00518                if (!bNeedSave || IDCANCEL != AskAboutSave (hwnd, szTitleName))
00519                     DestroyWindow (hwnd) ;
00520 
00521                return 0 ;
00522 
00523           case WM_QUERYENDSESSION:
00524                if (!bNeedSave || IDCANCEL != AskAboutSave (hwnd, szTitleName))
00525                     return 1L ;
00526 
00527                return 0 ;
00528 
00529           case WM_DESTROY:
00530                PopFontDeinitialize () ;
00531                PostQuitMessage (0) ;
00532                quitSwitch = 1;
00533                return 0 ;
00534 
00535           default:
00536                          // Process "Find-Replace" messages
00537 
00538                if (message == messageFindReplace)
00539                     {
00540                     lpfr = (LPFINDREPLACE) lParam ;
00541 
00542                     if (lpfr->Flags & FR_DIALOGTERM)
00543                          hDlgModeless = NULL ;
00544 
00545                     if (lpfr->Flags & FR_FINDNEXT)
00546                          if (!PopFindFindText (hwndEdit, &iOffset, lpfr))
00547                               OkMessage (hwnd, "Text not found!", NULL) ;
00548 
00549                     if (lpfr->Flags & FR_REPLACE ||
00550                         lpfr->Flags & FR_REPLACEALL)
00551                          if (!PopFindReplaceText (hwndEdit, &iOffset, lpfr))
00552                               OkMessage (hwnd, "Text not found!", NULL) ;
00553 
00554                     if (lpfr->Flags & FR_REPLACEALL)
00555                          while (PopFindReplaceText (hwndEdit, &iOffset, lpfr));
00556 
00557                     return 0 ;
00558                     }
00559                break ;
00560           }
00561      return DefWindowProc (hwnd, message, wParam, lParam) ;
00562      }
00563 
00564 BOOL FAR PASCAL _export AboutDlgProc (HWND hDlg, UINT message, UINT wParam,
00565                                                                LONG lParam)
00566      {
00567      switch (message)
00568           {
00569           case WM_INITDIALOG:
00570                return TRUE ;
00571 
00572           case WM_COMMAND:
00573                switch (wParam)
00574                     {
00575                     case IDOK:
00576                          EndDialog (hDlg, 0) ;
00577                          return TRUE ;
00578                     }
00579                break ;
00580           }
00581      return FALSE ;
00582      }
00583 /*
00584 ** TimerThread() -- The Main function of the timer pop thread
00585 **
00586 */
00587 static void PR_CALLBACK TimerThread( void *arg)
00588 {
00589     do {
00590         PadEvent   *ev;
00591         
00592         /*
00593         ** Should we quit now?
00594         */
00595         if ( quitSwitch )
00596             break;
00597         /*
00598         ** Create and Post the event the event
00599         */
00600         PL_ENTER_EVENT_QUEUE_MONITOR( padQueue );
00601         ev = (PadEvent *) PR_NEW( PadEvent );
00602         PL_InitEvent( &ev->plEvent, NULL, 
00603                 (PLHandleEventProc)HandlePadEvent, 
00604                 (PLDestroyEventProc)DestroyPadEvent );
00605         PL_PostEvent( padQueue, &ev->plEvent );
00606         PL_EXIT_EVENT_QUEUE_MONITOR( padQueue );
00607             
00608         PR_Sleep( ThreadSleepTime );
00609     } while(1);
00610     return;
00611 }    
00612 
00613 /*
00614 ** HandlePadEvent() -- gets called because of PostEvent
00615 */
00616 static void PR_CALLBACK HandlePadEvent( PadEvent *padEvent )
00617 {
00618     if ( timerCount++ == 0 )
00619     {
00620         char *cp;
00621         
00622         for ( cp = startMessage; *cp != 0 ; cp++ )
00623         {
00624             SendMessage( hwndEdit, WM_CHAR, *cp, MAKELONG( *cp, 1 ));
00625         }
00626     }
00627     /* 
00628     ** Send a WM_CHAR event the edit Window
00629     */
00630     if ((timerCount % 10) == 0)
00631     {
00632         SendMessage( hwndEdit, WM_CHAR, '+', MAKELONG( '+', 1 ));
00633     }
00634     else if ((timerCount % 5) == 0)
00635     {
00636         SendMessage( hwndEdit, WM_CHAR, '_', MAKELONG( '_', 1 ));
00637     }
00638     else
00639     {
00640         SendMessage( hwndEdit, WM_CHAR, '.', MAKELONG( '.', 1 ));
00641     }
00642     
00643     if ( (timerCount % 50) == 0)
00644     {
00645         SendMessage( hwndEdit, WM_CHAR, '\n', MAKELONG( '\n', 1 ));
00646     }
00647 
00648     /*
00649     ** PL_RevokeEvents() is broken. Test to fix it.
00650     */
00651     {
00652         static long revokeCounter = 0;
00653 
00654         if (revokeCounter++ > 10 )
00655         {
00656             PR_Sleep( ThreadSleepTime * 10 );
00657             SendMessage( hwndEdit, WM_CHAR, '*', MAKELONG( '\n', 1 ));
00658             PL_RevokeEvents( padQueue, NULL );
00659             revokeCounter = 0;
00660         }
00661     }
00662     return;
00663 }
00664 
00665 /*
00666 ** DestroyPadEvent() -- Called after HandlePadEvent()
00667 */
00668 static void PR_CALLBACK DestroyPadEvent( PadEvent *padevent )
00669 {
00670    PR_Free( padevent );
00671    return;
00672 }