home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / trace2.zip / TRACE2P.C < prev    next >
C/C++ Source or Header  |  1994-04-16  |  3KB  |  83 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 "trace2.h"
  12. #include "traceid.h"
  13.  
  14.  
  15. //----------------------------------------------
  16. //-Module declarations--------------------------
  17. //----------------------------------------------
  18. VOID ClearLB( HWND hLB );
  19. static int iFirstTimeOnly;
  20.  
  21. //----------------------------------------------
  22. //-External references--------------------------
  23. //----------------------------------------------
  24. extern   HWND       hLB;
  25. extern   HWND       hParentWnd;
  26. extern   int        iNumberItems;
  27.  
  28. //----------------------------------------------
  29. //-TracerPaint()--------------------------------
  30. //----------------------------------------------
  31.  
  32. VOID TracerPaint( HWND hWnd, USHORT msg,
  33.                                MPARAM mp1, MPARAM mp2 )
  34. {
  35.  
  36. HPS         hPS;
  37. RECTL       rRect;
  38.  
  39.     // create listbox on first paint only
  40.     if ( ! iFirstTimeOnly )
  41.     {
  42.         hLB = WinCreateWindow( hParentWnd,
  43.                                WC_LISTBOX,
  44.                                "",
  45.                                WS_VISIBLE | WS_SYNCPAINT,
  46.                                4, 4, 5, 5,
  47.                                hParentWnd,
  48.                                HWND_TOP,
  49.                                ID_TRACERLB,
  50.                                NULL,
  51.                                0 );
  52.  
  53.         WinQueryWindowRect( hWnd, &rRect );
  54.         WinSetWindowPos ( hLB, HWND_TOP, 6,
  55.                           4,
  56.                           (SHORT)(rRect.xRight - rRect.xLeft - 14),
  57.                           (SHORT)(rRect.yTop - rRect.yBottom - 4),
  58.                           SWP_SIZE | SWP_MOVE | SWP_SHOW );
  59.         ClearLB( hLB );
  60.         iFirstTimeOnly = 1;
  61.     }
  62.  
  63.     // quick and dirty
  64.     hPS = WinBeginPaint( hWnd, (HPS)NULL, (PWRECT)NULL );
  65.     GpiErase( hPS );
  66.     WinEndPaint( hPS );
  67. }
  68.  
  69. //----------------------------------------------
  70. //-ClearLB()------------------------------------
  71. //----------------------------------------------
  72.  
  73. VOID ClearLB( HWND hLB )
  74. {
  75.         iNumberItems = 0;
  76.         WinSendMsg( hLB, LM_DELETEALL,
  77.                        (MPARAM)-1L, (MPARAM)0L );
  78.         WinSendMsg( hLB, LM_INSERTITEM,
  79.                        (MPARAM)-1L, (MPARAM)(PCH)"Begin..." );
  80.         WinSendMsg( hLB, LM_SELECTITEM,  (MPARAM)iNumberItems++,
  81.                        (MPARAM)TRUE );
  82. }
  83.