Win32 GUI Hello World

svn path=/trunk/; revision=2183
This commit is contained in:
Jason Filby 2001-08-20 19:50:21 +00:00
parent a004822e63
commit ec838a6880
2 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,35 @@
#
#
#
PATH_TO_TOP = ../..
PROGS = winhello
OBJECTS =
LIBS= ../../lib/kernel32/kernel32.a ../../lib/gdi32/gdi32.a
CFLAGS = -I../../include
all: $(PROGS:%=%.exe)
.phony: all
clean:
- $(RM) *.o *.exe *.sym
.phony: clean
install: $(PROGS:%=$(FLOPPY_DIR)/apps/%.exe)
$(PROGS:%=$(FLOPPY_DIR)/apps/%.exe): $(FLOPPY_DIR)/apps/%.exe: %.exe
$(CP) $*.exe $(FLOPPY_DIR)/apps/$*.exe
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%.exe)
$(PROGS:%=../../$(DIST_DIR)/apps/%.exe): ../../$(DIST_DIR)/apps/%.exe: %.exe
$(CP) $*.exe ../../$(DIST_DIR)/apps/$*.exe
winhello.exe: winhello.c
$(CC) $(CFLAGS) winhello.c $(LIBS) -o winhello.exe
$(NM) --numeric-sort winhello.exe > winhello.sym
include ../../rules.mak

View file

@ -0,0 +1,73 @@
#include <windows.h>
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hWnd;
wc.lpszClassName = "HelloClass";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
RegisterClass(&wc);
hWnd = CreateWindow
( "HelloClass",
"Hello World",
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
switch(msg)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
TextOut(hDC, 10, 10, "Hello World from ReactOS!", strlen("Hello World from ReactOS!"));
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}