home *** CD-ROM | disk | FTP | other *** search
/ ftp.sberbank.sumy.ua / 2014.11.ftp.sberbank.sumy.ua.tar / ftp.sberbank.sumy.ua / incoming / 1 / KEY2SEG.cpp < prev    next >
C/C++ Source or Header  |  2014-02-08  |  7KB  |  306 lines

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <io.h>
  4.  
  5.  
  6. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  7.  
  8.  
  9.  
  10. char szClassName[ ] = "WindowsApp";
  11.  
  12. int MIN = 27163000;
  13. int MAX = 27163001;
  14. int Stop;
  15. HDC hDC;
  16. int Base = 0;
  17. int Format;
  18.  
  19. void Display320x240d24BitDibBmp()
  20. {
  21.  int x, y, number;
  22.  int RGB;
  23.  FILE *pFile; 
  24.  int hFile;
  25.  struct _finddata_t c_file;
  26.  char buffer[128];
  27.  
  28.  
  29.    Stop = 0xffffffff;  
  30.  
  31.  for( number = MIN; (number < MAX) && (Stop != 0); number++)
  32.   {
  33.    sprintf( buffer, "%08d%s", number, ".bmp"); 
  34.  
  35.    hFile = _findfirst( buffer, &c_file);
  36.    if(hFile == -1L) continue;    
  37.    _findclose(hFile);
  38.  
  39.  
  40.    pFile = fopen( buffer,"rb");
  41.   
  42.    if( pFile == 0) continue; 
  43.  
  44.    fseek( pFile , 54, SEEK_SET);
  45.  
  46.    for( y = 240-1; y >=0 ; y--) 
  47.     for( x = 0; x < 320; x++)
  48.      {
  49.       fread ( &RGB, 1, 3, pFile);
  50.   //    Beep( RGB, 1); 
  51.       SetPixel( hDC, x, y, RGB);
  52.        }
  53.    
  54.    fclose (pFile); 
  55.  } 
  56.    return;
  57.  }
  58.  
  59. void Display320x240d24BitBmp()
  60. {
  61.  int x, y, number;
  62.  int RGB;
  63.  FILE *pFile; 
  64.  int hFile;
  65.  struct _finddata_t c_file;
  66.  char buffer[128];
  67.  
  68.  
  69.    Stop = 0xffffffff;
  70.  
  71.  for( number = MIN; (number < MAX) && (Stop != 0); number++)
  72.   {
  73.    sprintf( buffer, "%08d%s", number, ".bmp"); 
  74.  
  75.    hFile = _findfirst( buffer, &c_file);
  76.    if(hFile == -1L) continue;    
  77.    _findclose(hFile);
  78.  
  79.  
  80.    pFile = fopen( buffer,"rb");
  81.   
  82.    if( pFile == 0) continue; 
  83.      
  84.    fseek( pFile , 54, SEEK_SET);
  85.  
  86.    for( y = 0; y < 240; y++) 
  87.     for( x = 0; x < 320; x++)
  88.      {
  89.       fread ( &RGB, 1, 3, pFile);
  90.   //    Beep( RGB, 1);  
  91.       SetPixel( hDC, x, y, RGB);
  92.        }
  93.    
  94.    fclose (pFile); 
  95.  }
  96.    
  97.    return;
  98.  }
  99.  
  100. void Display640x480d24BitDibBmp()
  101. {
  102.  int x, y, number;
  103.  int RGB;
  104.  FILE *pFile; 
  105.  int hFile;
  106.  struct _finddata_t c_file;
  107.  char buffer[128];
  108.  
  109.  
  110.    Stop = 0xffffffff;
  111.  
  112.  for( number = MIN; (number < MAX) && (Stop != 0); number++)
  113.   {
  114.    sprintf( buffer, "%08d%s", number, ".bmp"); 
  115.  
  116.    hFile = _findfirst( buffer, &c_file);
  117.    if(hFile == -1L) continue;    
  118.    _findclose(hFile);
  119.  
  120.  
  121.    pFile = fopen( buffer,"rb");
  122.   
  123.    if( pFile == 0) continue; 
  124.      
  125.    fseek( pFile , 54, SEEK_SET);
  126.  
  127.    for( y = 480-1; y >= 0; y--) 
  128.     for( x = 0; x < 640; x++)
  129.      {
  130.       fread( &RGB, 1, 3, pFile);
  131.   //    Beep( RGB, 1);
  132.       SetPixel( hDC, x, y, RGB);
  133.        }
  134.    
  135.    fclose (pFile); 
  136.   }
  137.    
  138.    return;
  139.  }
  140.  
  141. void Display640x480d24BitBmp()
  142. {
  143.  int x, y, number;
  144.  int RGB;
  145.  FILE *pFile; 
  146.  int hFile;
  147.  struct _finddata_t c_file;
  148.  char buffer[128];
  149.  
  150.  
  151.    Stop = 0xffffffff;
  152.  
  153.  for( number = MIN; (number < MAX) && (Stop != 0); number++)
  154.   {
  155.    sprintf( buffer, "%08d%s", number, ".bmp"); 
  156.  
  157.    hFile = _findfirst( buffer, &c_file);
  158.    if(hFile == -1L) continue;    
  159.    _findclose(hFile);
  160.  
  161.  
  162.    pFile = fopen( buffer,"rb");
  163.   
  164.    if( pFile == 0) continue; 
  165.  
  166.    fseek( pFile , 54, SEEK_SET);
  167.  
  168.    for( y = 0; y < 480; y++) 
  169.     for( x = 0; x < 640; x++)
  170.      {
  171.       fread ( &RGB, 1, 3, pFile);
  172.     //  Beep( RGB, 1); 
  173.       SetPixel( hDC, x, y, RGB);
  174.        }
  175.    
  176.    fclose (pFile); 
  177.  }   
  178.    return;
  179.  }
  180.  
  181.  
  182. int WINAPI WinMain (HINSTANCE hThisInstance,
  183.                     HINSTANCE hPrevInstance,
  184.                     LPSTR lpszArgument,
  185.                     int nFunsterStil)
  186.  
  187. {
  188.     HWND hwnd;              
  189.     MSG messages;            
  190.     WNDCLASSEX wincl;        
  191.  
  192.     Base = 0;
  193.     wincl.hInstance = hThisInstance;
  194.     wincl.lpszClassName = szClassName;
  195.     wincl.lpfnWndProc = WindowProcedure;     
  196.     wincl.style = CS_DBLCLKS;                 
  197.     wincl.cbSize = sizeof (WNDCLASSEX);
  198.  
  199.  
  200.     wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  201.     wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  202.     wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  203.     wincl.lpszMenuName = NULL;                 /* No menu */
  204.     wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
  205.     wincl.cbWndExtra = 0;                      /* structure or the window instance */
  206.  
  207.     wincl.hbrBackground = (HBRUSH) COLOR_WINDOW;
  208.  
  209.  
  210.     if (!RegisterClassEx (&wincl))
  211.         return 0;
  212.  
  213.  
  214.     hwnd = CreateWindowEx (
  215.            0,                   /* Extended possibilites for variation */
  216.            szClassName,         /* Classname */
  217.            "Windows App",       /* Title Text */
  218.            WS_OVERLAPPEDWINDOW, /* default window */
  219.            CW_USEDEFAULT,       /* Windows decides the position */
  220.            CW_USEDEFAULT,       /* where the window ends up on the screen */
  221.            660,                 /* The programs width */
  222.            550,                 /* and height in pixels */
  223.            HWND_DESKTOP,        /* The window is a child-window to desktop */
  224.            NULL,                /* No menu */
  225.            hThisInstance,       /* Program Instance handler */
  226.            NULL                 /* No Window Creation data */
  227.            );
  228.  
  229.     ShowWindow (hwnd, nFunsterStil);
  230.  
  231.      while (GetMessage (&messages, NULL, 0, 0))
  232.     {
  233.         TranslateMessage(&messages);
  234.         DispatchMessage(&messages);
  235.     }
  236.  
  237.  
  238.     return messages.wParam;
  239. }
  240.  
  241.  
  242. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  243. {
  244.  PAINTSTRUCT ps;
  245.  FILE *pFile; 
  246.  char buffer[20];
  247.  int number, ss, i;
  248.  
  249.     switch (message)                  
  250.     {
  251.         case WM_CREATE:
  252.             number = 0; 
  253.             ss = 0;
  254.  
  255.           for( number = 0; number < 0xffffffff; number++)
  256.            { 
  257.             sprintf( buffer, "%08d%s", number, ".txt");
  258.             pFile = fopen( buffer,"rb"); 
  259.  
  260.            if((pFile == 0) && ( ss != 0)) break;
  261.            if( pFile == 0) continue;  
  262.            if( pFile != 0) ss = 78;  
  263.  
  264.            for( i = 0; i < 20; i++) buffer[i] = 0;  
  265.  
  266.             fread ( buffer, 1, 1, pFile); 
  267.             Format = atoi( buffer);
  268.  
  269.             fread ( buffer, 1, 8, pFile);           
  270.             MIN = atoi( buffer); 
  271.          //   MessageBox( hwnd, buffer, buffer, MB_OK); 
  272.             fread ( buffer, 1, 8, pFile);           
  273.             MAX = atoi( buffer); 
  274.           
  275.             fclose( pFile);
  276.             }
  277.             return 0;  
  278.  
  279.         case WM_PAINT:
  280.             hDC = BeginPaint( hwnd, &ps);
  281.  
  282.            if( Format == 1)
  283.             {
  284.              Display320x240d24BitDibBmp();
  285.              Display320x240d24BitBmp();
  286.              }
  287.              
  288.            if( Format == 2)
  289.             {   
  290.              Display640x480d24BitDibBmp(); 
  291.              Display640x480d24BitBmp();
  292.              }
  293.               
  294.             EndPaint( hwnd, &ps);  
  295.             return 0;   
  296.  
  297.         case WM_DESTROY:
  298.             PostQuitMessage (0);  
  299.             break;
  300.         default:                
  301.             return DefWindowProc (hwnd, message, wParam, lParam);
  302.     }
  303.  
  304.     return 0;
  305. }
  306.