User:Obvious/temp
/* Trim fat from windows*/
- define WIN32_LEAN_AND_MEAN
- pragma comment(linker, "/subsystem:windows")
/* Pre-processor directives*/ //#include <stdafx.h>
- include <windows.h>
/* Windows Procedure Event Handler*/ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT paintStruct; /* Device Context*/ HDC hDC; /* Text for display*/ char string[] = "Hello, World!"; /* Switch message, condition that is met will execute*/ switch(message) { /* Window is being created*/ case WM_CREATE: return 0; break; /* Window is closing*/ case WM_DESTROY: PostQuitMessage(0); return 0; break; /* Window needs update*/ case WM_PAINT: hDC = BeginPaint(hwnd,&paintStruct); /* Set txt color to blue*/ SetTextColor(hDC, COLORREF(0x00FF0000)); /* Display text in middle of window*/ TextOut(hDC,150,150,string,sizeof(string)-1); EndPaint(hwnd, &paintStruct); return 0; break; default: break; } return (DefWindowProc(hwnd,message,wParam,lParam)); } /* Main function*/ int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{ WNDCLASSEX windowClass; //window class HWND hwnd; //window handle MSG msg; //message bool done; //flag saying when app is complete /* Fill out the window class structure*/ windowClass.cbSize = sizeof(WNDCLASSEX); windowClass.style = CS_HREDRAW | CS_VREDRAW; windowClass.lpfnWndProc = WndProc; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; windowClass.hInstance = hInstance; windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); windowClass.lpszMenuName = NULL; windowClass.lpszClassName = "MyClass"; windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); /* Register window class*/ if (!RegisterClassEx(&windowClass)) { return 0; } /* Class registerd, so now create window*/ hwnd = CreateWindowEx(NULL, //extended style "MyClass", //class name "A Real Win App", //app name WS_OVERLAPPEDWINDOW | //window style WS_VISIBLE | WS_SYSMENU, 100,100, //x/y coords 400,400, //width,height NULL, //handle to parent NULL, //handle to menu hInstance, //application instance NULL); //no extra parameter's /* Check if window creation failed*/ if (!hwnd) return 0; done = false; //initialize loop condition variable /* main message loop*/ while(!done) { PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE); if (msg.message == WM_QUIT) //check for a quit message { done = true; //if found, quit app } else { /* Translate and dispatch to event queue*/ TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; }
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.