home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / elistb.zip / TEST.CPP < prev    next >
C/C++ Source or Header  |  1993-05-15  |  2KB  |  103 lines

  1. // This code tests the thing
  2. #define __MAIN__
  3.  
  4. // PM includes
  5. #define INCL_PM
  6. #define INCL_WIN
  7. #include <os2.h>
  8.  
  9. // Functional includes
  10. #include <string.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13.  
  14. #include "common.h"
  15.  
  16. #include "elistbox.hpp"
  17.  
  18. // include dialog headers
  19. #include "dialog.h"
  20.  
  21.  
  22.  
  23. //  Test data
  24. #include "t.tab"                      // a table with a long and char*
  25. double dbl[70];
  26.  
  27.  
  28. TextPtrColumn  Col( "Who", 2,35,&names[0].name,sizeof( _ARR) );
  29. TextPtrColumn  nCol( "Who", 10,45,&names[6].name ,sizeof (struct _ARR ));
  30. LongColumn  Lcol( "Amount", 37,46, &names[0].l, sizeof (struct _ARR) );
  31. LongColumn  nLcol( "Amount", 2,9, ( long * )&names[0].l, sizeof (struct _ARR) );
  32. MoneyColumn mon("Amount",37,50, dbl, sizeof( double ));
  33. Column *C[]={&Col,&mon,( Column * )NULL};
  34. Column *Cc[]={&nLcol,&nCol,( Column * )NULL};
  35. Row R( C, 40 );
  36. Row R2( Cc, 60 );
  37. //***
  38.  
  39. STDPROC( MAIN_WINDOWProc );
  40. int  main(void)
  41. {
  42.  HAB hAB;
  43.  HMQ hMQ;
  44.  for( int i=0; i<70; i++ ) names[i].l=i*(1-2*(i%2));
  45.  for( i=0; i<70; i++ ) dbl[i]=i*.5*(1-2*(i%2));
  46.  hAB = WinInitialize(0L);
  47.  if(hAB == 0) return(FALSE);
  48.  hMQ=WinCreateMsgQueue(hAB, 0L);
  49.  if(hMQ == 0)    return(FALSE);
  50.  HWND wnd=WinLoadDlg(
  51.         HWND_DESKTOP,
  52.         HWND_DESKTOP,
  53.         ( PFNWP )MAIN_WINDOWProc,
  54.         NULLHANDLE,
  55.         D2 ,
  56.         NULL
  57.            );
  58.  
  59.  WinProcessDlg( wnd );
  60.  WinDestroyWindow( wnd );
  61.  WinDestroyMsgQueue(hMQ);
  62.  WinTerminate(hAB);
  63.  return 1;
  64. }
  65.  
  66. long ssel;
  67. char vect[100];               // multiselect vector
  68.  
  69. MRESULT EXPENTRY MAIN_WINDOWProc( STDPARMS )
  70. {
  71.  static char d[50];
  72.  static int i;
  73.  static double ddd=0;
  74.  switch( MSG )
  75.    {
  76.     case  WM_INITDLG:
  77.       WinCreateELB( Wnd, ELB, R, ssel, vect );
  78.       break;
  79.     case ELB_CHANGESEL:
  80.       {
  81.        char t[30];
  82.        long l=( long )mp2;
  83.        if( !(l%10) ) dbl[l]=ddd;
  84.        ddd+=dbl[l]*( vect[l] ? 1 : -1 );
  85.        sprintf( t, "%8.2f", ddd );
  86.        WinSetDlgItemText( Wnd, EF, t );
  87.       }
  88.       break;
  89.     case  WM_CONTROL:              // strong visual que of reinit!!
  90. if( ( ULONG )mp1==ELB )
  91.   {
  92.    ssel=i%3*9;
  93.    WinCreateELB( Wnd, ELB, i++%2 ? R : R2, ssel, i%2 ? vect : (char*)NULL );
  94.   }
  95.     case  WM_COMMAND:
  96.     case  WM_SYSCOMMAND:
  97.     break;
  98.    }
  99.  return( WinDefDlgProc( Wnd, MSG, mp1, mp2) );
  100. }
  101.  
  102.  
  103.