Advertisement
Guest User

Untitled

a guest
May 25th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.16 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3.  
  4. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  5.  
  6.  
  7.  
  8.  
  9. //   HINSTANCE
  10. // INSTANCE OF THE APPLICATION
  11. // ID for application which is passed by the operating system
  12. // se necesita usar para crear ventanas
  13.  
  14.  
  15. // LPSTR ARGS
  16. // LPSTR type definition for characters
  17. // args commandline arguments these are the argumments passed into program in the commandline
  18.  
  19.  
  20.  
  21. // ncmdshow takes care of some commandline stuff tells us how windows should be displayed
  22.  
  23. int WINAPI WinMain(HINSTANCE hInst , HINSTANCE hPrevInst, LPSTR args, int ncmdshow)
  24. {
  25.  
  26.     WNDCLASSW wc = {0};
  27.     wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
  28.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  29.     wc.hInstance = hInst;
  30.     wc.lpszClassName = L"claseVentana";
  31.     wc.lpfnWndProc = WindowProcedure;
  32.  
  33.  
  34.     if(!RegisterClassW(&wc))
  35.         return -1;
  36.  
  37.  
  38.     CreateWindowW(L"claseVentana", L"Titulo ventana", WS_OVERLAPPEDWINDOW | WS_VISIBLE,100,100,500,500, NULL, NULL, NULL, NULL);
  39.  
  40.  
  41.               MSG msg = {0};
  42.     while(GetMessage(&msg,NULL,NULL,NULL))
  43.     {
  44.             TranslateMessage(&msg);
  45.             DispatchMessage(&msg);
  46.     }
  47.  
  48.  
  49.     /* event driven programming system, takes care of all the tasks
  50.      that window has to perform, whenever you interact with the window
  51.      like you press a button message is sent to the message loop and the message
  52.      loop processes the msg & sends the msg to the window procedure and the
  53.      window procedure takes care of the message and takes the required action
  54.      on the window */
  55.  
  56.     return 0;
  57. }
  58. // hWnd identifies the window, window handler
  59. /* HWND is the handler by which the message has been sent, by which window
  60. handler the msg has been sent so it basically identifies the window, window handler*/
  61.  
  62. /* UINT == unsigned integer is the msg which has been sent ; todo learn about the parameters
  63. which are also required in the processing of the messages, */
  64. LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
  65.     switch(msg){
  66.     case WM_DESTROY:
  67.         PostQuitMessage(0);
  68.         break;
  69.     default:
  70.         return DefWindowProcW(hWnd,msg,wp,lp);
  71.     }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement