Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
- // HINSTANCE
- // INSTANCE OF THE APPLICATION
- // ID for application which is passed by the operating system
- // se necesita usar para crear ventanas
- // LPSTR ARGS
- // LPSTR type definition for characters
- // args commandline arguments these are the argumments passed into program in the commandline
- // ncmdshow takes care of some commandline stuff tells us how windows should be displayed
- int WINAPI WinMain(HINSTANCE hInst , HINSTANCE hPrevInst, LPSTR args, int ncmdshow)
- {
- WNDCLASSW wc = {0};
- wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hInstance = hInst;
- wc.lpszClassName = L"claseVentana";
- wc.lpfnWndProc = WindowProcedure;
- if(!RegisterClassW(&wc))
- return -1;
- CreateWindowW(L"claseVentana", L"Titulo ventana", WS_OVERLAPPEDWINDOW | WS_VISIBLE,100,100,500,500, NULL, NULL, NULL, NULL);
- MSG msg = {0};
- while(GetMessage(&msg,NULL,NULL,NULL))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- /* event driven programming system, takes care of all the tasks
- that window has to perform, whenever you interact with the window
- like you press a button message is sent to the message loop and the message
- loop processes the msg & sends the msg to the window procedure and the
- window procedure takes care of the message and takes the required action
- on the window */
- return 0;
- }
- // hWnd identifies the window, window handler
- /* HWND is the handler by which the message has been sent, by which window
- handler the msg has been sent so it basically identifies the window, window handler*/
- /* UINT == unsigned integer is the msg which has been sent ; todo learn about the parameters
- which are also required in the processing of the messages, */
- LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp){
- switch(msg){
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProcW(hWnd,msg,wp,lp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement