//test001.cpp
#include <windows.h> #include "Resource.h"
LRESULT CALLBACK MainProc( HWND hWnd, // handle to window UINT msg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ) { PAINTSTRUCT ps; HDC hDC; switch( msg) { case WM_PAINT: hDC = BeginPaint( hWnd, &ps ); TextOut( GetDC(hWnd), 10, 10, "Hello, World!", 13 ); EndPaint( hWnd, &ps ); break; case WM_DESTROY: PostQuitMessage( 0 ); break; /**************************************************************\ * Let the default window proc handle all other messages * \**************************************************************/ default: return( DefWindowProc( hWnd, msg, wParam, lParam )); } return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
WNDCLASSEX wndClass; wndClass.lpszClassName = "Test01"; wndClass.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC; wndClass.hInstance = hInstance; wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wndClass.hCursor = LoadCursor(NULL, IDC_CROSS); wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.lpszMenuName = NULL; wndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TEST_001)); wndClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TEST_002)); wndClass.lpfnWndProc = MainProc; wndClass.cbSize = sizeof(WNDCLASSEX);
if (!RegisterClassEx(&wndClass)) { return FALSE; } HWND hWindow; hWindow = CreateWindow("Test01", "Test01",
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
100, 100,00,350, NULL, NULL, hInstance, NULL); ShowWindow(hWindow, nShowCmd); UpdateWindow(hWindow);
MSG msg; while (TRUE) { PeekMessage( &msg, NULL, 0, 0 ,PM_REMOVE ); if ( msg.message == WM_QUIT ) { break; } else { TranslateMessage( &msg ); DispatchMessage( &msg ); } } return 0; }
|