home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12546.ZIP / TRACERP.C < prev   
Text File  |  1990-03-19  |  3KB  |  81 lines

  1. //-----------------------------------------------
  2. //-TRACERP.C Source code for TRACER paint routine
  3. //-----------------------------------------------
  4.  
  5. #define INCL_PM
  6. #define INCL_WIN
  7. #define INCL_DOS
  8.  
  9. #include <os2.h>
  10. #include <string.h>
  11. #include "tracer.h"
  12.  
  13. //----------------------------------------------
  14. //-Module declarations--------------------------
  15. //----------------------------------------------
  16. void FAR PASCAL ClearLB( HWND hLB );
  17. static int iFirstTimeOnly;
  18.  
  19. //----------------------------------------------
  20. //-External references--------------------------
  21. //----------------------------------------------
  22. extern   HWND       hLB;
  23. extern   HWND       hParentWnd;
  24. extern   int        iNumberItems;
  25.  
  26. //----------------------------------------------
  27. //-TRACERPaint()--------------------------------
  28. //----------------------------------------------
  29.  
  30. void FAR PASCAL TRACERPaint( HWND hWnd, USHORT msg,
  31.                                MPARAM mp1, MPARAM mp2 )
  32. {
  33.  
  34. HPS         hPS;
  35. RECTL       rRect;
  36.  
  37.     // create listbox on first paint only
  38.     if ( ! iFirstTimeOnly )
  39.     {
  40.         hLB = WinCreateWindow( hParentWnd,
  41.                                WC_LISTBOX,
  42.                                "",
  43.                                WS_VISIBLE | WS_SYNCPAINT,
  44.                                4, 4, 5, 5,
  45.                                hParentWnd,
  46.                                HWND_TOP,
  47.                                ID_TRACERLB,
  48.                                NULL,
  49.                                0 );
  50.  
  51.         WinQueryWindowRect( hWnd, &rRect );
  52.         WinSetWindowPos ( hLB, HWND_TOP, 6,
  53.                           4,
  54.                           (SHORT)(rRect.xRight - rRect.xLeft - 14),
  55.                           (SHORT)(rRect.yTop - rRect.yBottom - 4),
  56.                           SWP_SIZE | SWP_MOVE | SWP_SHOW );
  57.         ClearLB( hLB );
  58.         iFirstTimeOnly = 1;
  59.     }
  60.  
  61.     // quick and dirty
  62.     hPS = WinBeginPaint( hWnd, (HPS)NULL, (PWRECT)NULL );
  63.     GpiErase( hPS );
  64.     WinEndPaint( hPS );
  65. }
  66.  
  67. //----------------------------------------------
  68. //-ClearLB()------------------------------------
  69. //----------------------------------------------
  70.  
  71. void FAR PASCAL ClearLB( HWND hLB )
  72. {
  73.         iNumberItems = 0;
  74.         WinSendMsg( hLB, LM_DELETEALL,
  75.                        (MPARAM)-1L, (MPARAM)0L );
  76.         WinSendMsg( hLB, LM_INSERTITEM,
  77.                        (MPARAM)-1L, (MPARAM)(PCH)"Begin..." );
  78.         WinSendMsg( hLB, LM_SELECTITEM,  (MPARAM)iNumberItems++,
  79.                        (MPARAM)TRUE );
  80. }
  81.