Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- LRESULT CALLBACK MainWindowCallBack(
- HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
- )
- {
- LRESULT Result =0;
- switch(uMsg)
- {
- case WM_SIZE:
- {
- OutputDebugStringA("WM_SIZE\n");
- }break;
- case WM_DESTROY:
- {
- OutputDebugStringA("WM_DESTROY\n");
- }break;
- case WM_CLOSE:
- {
- OutputDebugStringA("WM_CLOSE");
- }break;
- case WM_ACTIVATEAPP:
- {
- OutputDebugStringA("WM_ACTIVATEAPP");
- }break;
- case WM_PAINT:
- { PAINTSTRUCT Paint;
- HDC DeviceContext=BeginPaint( hwnd, &Paint );
- int X=Paint.rcPaint.left;
- int Y=Paint.rcPaint.top;
- int Height= Paint.rcPaint.bottom - Paint.rcPaint.top;
- int width =Paint.rcPaint.right - Paint.rcPaint.left;
- PatBlt( DeviceContext,X,Y,Height,width,WHITENESS );
- EndPaint( hwnd, &Paint);
- }
- default:
- {
- Result= DefWindowProc(hwnd,uMsg,wParam,lParam);
- // OutputDebugStringA("Default\n");
- } break;
- }
- return(Result);
- }
- int CALLBACK WinMain(
- HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nShowCmd
- )
- {
- WNDCLASSA WindowClass ={};
- WindowClass.style=CS_OWNDC|CS_HREDRAW|CS_VREDRAW ;
- WindowClass.lpfnWndProc =MainWindowCallBack ;
- WindowClass.hInstance = hInstance;
- WindowClass.lpszClassName ="HandmadeHeroWindowClass" ;
- //WindowClass.hIcon
- if (RegisterClassA(&WindowClass))
- {
- HWND WindowHandle = CreateWindowExA(
- 0,
- WindowClass.lpszClassName,
- "HandMade Hero",
- WS_OVERLAPPEDWINDOW|WS_VISIBLE,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 0,
- 0,
- hInstance,
- 0
- );
- if (WindowHandle)
- {
- for (;;)
- {
- MSG Message;
- BOOL MessageResult= GetMessage(&Message ,0 ,0,0);
- if(MessageResult>0)
- {
- TranslateMessage(&Message);
- DispatchMessage(&Message);
- }
- else
- {
- break;
- }
- }
- }
- else
- {
- // todo(bill):logging
- }
- }
- else
- {
- // todo(bill):Logging
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement