#include <windows.h>
#define W 320
#define H 240
char g_szWindowName[] = "test";
char g_szWindowClass[] = "test32";
HWND g_hWnd;
int p_i = 0;
char * p[] = { "privet!", "poka!" };
static LRESULT CALLBACK wnd_proc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch ( uMsg ) {
case WM_COMMAND: {
switch ( LOWORD( wParam ) ) {
case 10000: {
SetTimer( g_hWnd, 1000, 1000, NULL );
} break;
}
} break;
case WM_TIMER: {
p_i ^= 1;
InvalidateRect( hWnd, NULL, TRUE );
} break;
case WM_PAINT: {
PAINTSTRUCT ps;
BeginPaint( hWnd, &ps );
TextOut( ps.hdc, 120, 120, p[p_i], strlen( p[p_i] ) );
EndPaint( hWnd, &ps );
} return 0;
case WM_KEYDOWN: if ( (int)wParam != VK_ESCAPE ) break;
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
}
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
int APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
MSG msg;
WNDCLASS wc;
memset( &wc, 0, sizeof( WNDCLASS ) );
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = wnd_proc;
wc.hInstance = hInst;
wc.lpszClassName = g_szWindowClass;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
RegisterClass( &wc );
g_hWnd = CreateWindowEx( WS_EX_TOPMOST,
g_szWindowClass, g_szWindowName, WS_POPUP | WS_VISIBLE,
(GetSystemMetrics( SM_CXSCREEN ) >> 1) - (W >> 1),
(GetSystemMetrics( SM_CYSCREEN ) >> 1) - (H >> 1),
W, H, NULL, NULL, hInst, NULL );
// Симулирую нажатие клавиши...
SendMessage( g_hWnd, WM_COMMAND, 10000, 0 );
while ( GetMessage( &msg, NULL, 0, 0 ) ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
DestroyWindow( g_hWnd );
UnregisterClass( g_szWindowClass, hInst );
return 0;
}