Advertisement
Guest User

Untitled

a guest
Jul 25th, 2010
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.91 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. /*  Declare Windows procedure  */
  4. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  5.  
  6. /*  Make the class name into a global variable  */
  7. char szClassName[ ] = "WindowsApp";
  8.  
  9. int WINAPI WinMain (HINSTANCE hThisInstance,
  10.                     HINSTANCE hPrevInstance,
  11.                     LPSTR lpszArgument,
  12.                     int nFunsterStil)
  13.  
  14. {
  15.                    
  16.                     // PatternWindow - okno wypelnione kafelkami bitmapy
  17.  
  18. // (fragmenty funkcji WinMain())
  19.  
  20.  
  21.  
  22. HBITMAP hBitmapa;
  23.  
  24. HBRUSH hPedzelOkna;
  25.  
  26.  
  27.  
  28. // tworzymy pedzel wypelnienia okna
  29.  
  30. hBitmapa = (HBITMAP) LoadImage(NULL, "tlo.bmp", IMAGE_BITMAP,
  31.  
  32.                                0, 0, LR_LOADFROMFILE);
  33.  
  34. hPedzelOkna = CreatePatternBrush(hBitmapa);
  35.  
  36.  
  37.  
  38.  
  39.     HWND hwnd;               /* This is the handle for our window */
  40.     MSG messages;            /* Here messages to the application are saved */
  41.     WNDCLASSEX wincl;        /* Data structure for the windowclass */
  42.  
  43.     /* The Window structure */
  44.     wincl.hInstance = hThisInstance;
  45.     wincl.lpszClassName = szClassName;
  46.     wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
  47.     wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
  48.     wincl.cbSize = sizeof (WNDCLASSEX);
  49.  
  50.     /* Use default icon and mouse-pointer */
  51.     wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  52.     wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  53.     wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  54.     wincl.lpszMenuName = NULL;                 /* No menu */
  55.     wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
  56.     wincl.cbWndExtra = 0;                      /* structure or the window instance */
  57.     /* Use Windows's default color as the background of the window */
  58.     wincl.hbrBackground = hPedzelOkna;
  59.  
  60.     /* Register the window class, and if it fails quit the program */
  61.     if (!RegisterClassEx (&wincl))
  62.         return 0;
  63.  
  64.     /* The class is registered, let's create the program*/
  65.     hwnd = CreateWindowEx (
  66.            0,                   /* Extended possibilites for variation */
  67.            szClassName,         /* Classname */
  68.            "",       /* Title Text */
  69.            WS_OVERLAPPEDWINDOW, /* default window */
  70.            800,       /* Windows decides the position */
  71.            100,       /* where the window ends up on the screen */
  72.            300,                 /* The programs width */
  73.            300,                 /* and height in pixels */
  74.            NULL,        /* The window is a child-window to desktop */
  75.            NULL,                /* No menu */
  76.            hThisInstance,       /* Program Instance handler */
  77.            NULL                 /* No Window Creation data */
  78.            );
  79.  
  80.     /* Make the window visible on the screen */
  81.     ShowWindow (hwnd, nFunsterStil);
  82.  
  83.     /* Run the message loop. It will run until GetMessage() returns 0 */
  84.     while (GetMessage (&messages, NULL, 0, 0))
  85.     {
  86.         /* Translate virtual-key messages into character messages */
  87.         TranslateMessage(&messages);
  88.         /* Send message to WindowProcedure */
  89.         DispatchMessage(&messages);
  90.     }
  91.    
  92.    
  93.    
  94.     DeleteObject (hPedzelOkna);
  95.  
  96. DeleteObject (hBitmapa);
  97.  
  98.    
  99.    
  100.  
  101.     /* The program return-value is 0 - The value that PostQuitMessage() gave */
  102.     return messages.wParam;
  103. }
  104.  
  105.  
  106. /*  This function is called by the Windows function DispatchMessage()  */
  107.  
  108. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  109. {
  110.     switch (message)                  /* handle the messages */
  111.     {
  112.         case WM_DESTROY:
  113.             PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
  114.             break;
  115.         default:                      /* for messages that we don't deal with */
  116.             return DefWindowProc (hwnd, message, wParam, lParam);
  117.     }
  118.  
  119.     return 0;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement