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

  1. #include <windows.h>
  2. #include <stdio.h>
  3.  
  4. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  5.  
  6.  
  7. char szClassName[ ] = "WindowsApp";
  8.  
  9. int hDC;
  10.  
  11. Display320x240d24BitDibBmp()
  12. {
  13.  int x, y;
  14.  int RGB[2];
  15.  FILE *pFile; 
  16.  
  17.  
  18.    pFile = fopen("RGB-320x240-24-bit.bmp","rb");
  19.    fseek( pFile , 54, SEEK_SET);
  20.  
  21.    for( y = 240-1; y >=0 ; y--) 
  22.     for( x = 0; x < 320; x++)
  23.      {
  24.       fread ( &RGB[0], 1, 3, pFile);
  25.       SetPixel( hDC, x, y, RGB[0]);
  26.        }
  27.    
  28.    fclose (pFile); 
  29.    
  30.    return 0;
  31.  }
  32.  
  33. Display320x240d24BitBmp()
  34. {
  35.  int x, y;
  36.  int RGB[2];
  37.  FILE *pFile; 
  38.  
  39.  
  40.    pFile = fopen("RGB-320x240-24-bit.bmp","rb");
  41.    fseek( pFile , 54, SEEK_SET);
  42.  
  43.    for( y = 0; y < 240; y++) 
  44.     for( x = 0; x < 320; x++)
  45.      {
  46.       fread ( &RGB[0], 1, 3, pFile);
  47.       SetPixel( hDC, x, y, RGB[0]);
  48.        }
  49.    
  50.    fclose (pFile); 
  51.    
  52.    return 0;
  53.  }
  54.  
  55. Display640x480d24BitDibBmp()
  56. {
  57.  int x, y;
  58.  int RGB[2];
  59.  FILE *pFile; 
  60.  
  61.  
  62.    pFile = fopen("RGB-150x150-640x480-24-bit.bmp","rb");
  63.    fseek( pFile , 54, SEEK_SET);
  64.  
  65.    for( y = 480-1; y >= 0; y--) 
  66.     for( x = 0; x < 640; x++)
  67.      {
  68.       fread ( &RGB[0], 1, 3, pFile);
  69.       SetPixel( hDC, x, y, RGB[0]);
  70.        }
  71.    
  72.    fclose (pFile); 
  73.    
  74.    return 0;
  75.  }
  76.  
  77. Display640x480d24BitBmp()
  78. {
  79.  int x, y;
  80.  int RGB[2];
  81.  FILE *pFile; 
  82.  
  83.  
  84.    pFile = fopen("RGB-150x150-640x480-24-bit.bmp","rb");
  85.    fseek( pFile , 54, SEEK_SET);
  86.  
  87.    for( y = 0; y < 480; y++) 
  88.     for( x = 0; x < 640; x++)
  89.      {
  90.       fread ( &RGB[0], 1, 3, pFile);
  91.       SetPixel( hDC, x, y, RGB[0]);
  92.        }
  93.    
  94.    fclose (pFile); 
  95.    
  96.    return 0;
  97.  }
  98.  
  99.  
  100.  
  101. int WINAPI WinMain (HINSTANCE hThisInstance,
  102.                     HINSTANCE hPrevInstance,
  103.                     LPSTR lpszArgument,
  104.                     int nFunsterStil)
  105.  
  106. {
  107.     HWND hwnd;              
  108.     MSG messages;            
  109.     WNDCLASSEX wincl;        
  110.  
  111.   
  112.     wincl.hInstance = hThisInstance;
  113.     wincl.lpszClassName = szClassName;
  114.     wincl.lpfnWndProc = WindowProcedure;     
  115.     wincl.style = CS_DBLCLKS;                 
  116.     wincl.cbSize = sizeof (WNDCLASSEX);
  117.  
  118.  
  119.     wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  120.     wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  121.     wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  122.     wincl.lpszMenuName = NULL;                 /* No menu */
  123.     wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
  124.     wincl.cbWndExtra = 0;                      /* structure or the window instance */
  125.  
  126.     wincl.hbrBackground = (HBRUSH) COLOR_WINDOW;
  127.  
  128.  
  129.     if (!RegisterClassEx (&wincl))
  130.         return 0;
  131.  
  132.  
  133.     hwnd = CreateWindowEx (
  134.            0,                   /* Extended possibilites for variation */
  135.            szClassName,         /* Classname */
  136.            "Windows App",       /* Title Text */
  137.            WS_OVERLAPPEDWINDOW, /* default window */
  138.            CW_USEDEFAULT,       /* Windows decides the position */
  139.            CW_USEDEFAULT,       /* where the window ends up on the screen */
  140.            660,                 /* The programs width */
  141.            550,                 /* and height in pixels */
  142.            HWND_DESKTOP,        /* The window is a child-window to desktop */
  143.            NULL,                /* No menu */
  144.            hThisInstance,       /* Program Instance handler */
  145.            NULL                 /* No Window Creation data */
  146.            );
  147.  
  148.     ShowWindow (hwnd, nFunsterStil);
  149.  
  150.      while (GetMessage (&messages, NULL, 0, 0))
  151.     {
  152.         TranslateMessage(&messages);
  153.         DispatchMessage(&messages);
  154.     }
  155.  
  156.  
  157.     return messages.wParam;
  158. }
  159.  
  160.  
  161. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  162. {
  163.  PAINTSTRUCT ps;
  164.  
  165.  
  166.     switch (message)                  
  167.     {
  168.         case WM_PAINT:
  169.             hDC = BeginPaint( hwnd, &ps);
  170.             
  171.             Display320x240d24BitDibBmp();
  172.             Display320x240d24BitBmp();
  173.             Display640x480d24BitDibBmp(); 
  174.             Display640x480d24BitBmp();
  175.              
  176.             EndPaint( hwnd, &ps);  
  177.             return 0;   
  178.  
  179.         case WM_DESTROY:
  180.             PostQuitMessage (0);  
  181.             break;
  182.         default:                
  183.             return DefWindowProc (hwnd, message, wParam, lParam);
  184.     }
  185.  
  186.     return 0;
  187. }
  188.