Add a win32 hello world program

Mike Hearn mike at navi.cx
Sun Apr 18 18:55:07 CDT 2004


Mike Hearn <mike at navi.cx>
Add a win32 hello world program which sets up a simple window and runs 
the message loop. This can be used as a starting point for test programs.

Generated from:
* mike at navi.cx--2004/wine--mainline--0.9--patch-18
* mike at navi.cx--2004/wine--mainline--0.9--patch-19
* mike at navi.cx--2004/wine--mainline--0.9--patch-20

--- mod/programs/helloworld/.cvsignore	2004-04-18 18:55:07.000000000 +0100
+++ mod/programs/helloworld/.cvsignore
@@ -0,0 +1,3 @@
+helloworld
+Makefile
+helloworld.exe.dbg.c
--- /dev/null	2003-09-15 14:40:47.000000000 +0100
+++ mod/programs/helloworld/Makefile.in	2004-04-18 18:55:07.000000000 +0100
@@ -0,0 +1,15 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = helloworld.exe
+APPMODE   = -mwindows
+IMPORTS   = user32
+EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
+EXTRADEFS = -DNO_LIBWINE_PORT
+
+C_SRCS = main.c
+
+ at MAKE_PROG_RULES@
+
+### Dependencies:
--- mod/programs/helloworld/main.c	2004-04-18 18:55:07.000000000 +0100
+++ mod/programs/helloworld/main.c
@@ -0,0 +1,68 @@
+/*
+ * Win32 Hello World
+ *
+ * You can use this to begin learning Win32, or as a starting point
+ * for test programs.
+ *
+ * (C) 2004 Mike Hearn <mh at codeweavers.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <windows.h>
+
+LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    switch (msg) {
+    case WM_DESTROY:
+        PostQuitMessage(0);
+        return 0;
+    default:
+        return DefWindowProc(hwnd, msg, wparam, lparam);
+    }
+}
+
+int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmdLine, int cmdShow)
+{
+    WNDCLASSEX class;
+    MSG msg;
+    HWND window;
+
+    /* this stuff is just boilerplate */
+    memset(&class, 0, sizeof(WNDCLASSEX));
+    class.cbSize = sizeof(WNDCLASSEX);
+    class.hInstance = instance;
+    class.lpszClassName = "MainWnd";
+    class.lpfnWndProc = WndProc;
+    class.hbrBackground = (HBRUSH) COLOR_WINDOW + 1;
+
+    if (!RegisterClassEx(&class)) {
+        MessageBox(NULL, "Could not register window class", "", MB_OK | MB_ICONERROR);
+        return 1;
+    }
+
+    window = CreateWindowEx(0, "MainWnd", "Main Window", WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
+                            CW_USEDEFAULT, CW_USEDEFAULT, 200, 150, NULL, NULL, instance, NULL);
+    ShowWindow(window, cmdShow);
+
+    /* Every thread that creates a window must pump the message loop */
+    while (GetMessage(&msg, NULL, 0, 0)) {
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+    }
+    
+    return 0;
+}




More information about the wine-patches mailing list