diff window_test.c @ 0:76568becd6d6

Rhope Alpha 2a source import
author Mike Pavone <pavone@retrodev.com>
date Tue, 28 Apr 2009 23:06:07 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/window_test.c	Tue Apr 28 23:06:07 2009 +0000
@@ -0,0 +1,113 @@
+#include <windows.h>
+
+LRESULT CALLBACK WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+	switch (message)
+	{
+	/*	case WM_CREATE:
+			CreateChildControls(hwnd);
+			break;
+
+		case WM_COMMAND:
+			if( HIWORD( wParam ) == BN_CLICKED )
+			{
+				ProcessButtonClick( (char)LOWORD( wParam ) );
+			}
+			break;*/
+
+		case WM_DESTROY:
+			PostQuitMessage (0); 
+			break;
+	}
+	return DefWindowProc (hwnd, message, wParam, lParam);
+}
+char g_szClassName[ ] = "WindowsApp";
+HINSTANCE glob_instance;
+int glob_cmdshow;
+BOOL wind_created=FALSE;
+
+DWORD WINAPI message_thread(void * param)
+{
+	WSADATA wsa_data;
+	/* Define the Window Class and try to register it */
+	WNDCLASSEX wc;
+	HWND hwnd;
+	MSG messages; 
+	wc.cbSize        = sizeof (WNDCLASSEX);
+	wc.style         = 0; 
+	wc.lpfnWndProc   = WindowProc;
+	wc.cbClsExtra    = 0;
+    wc.cbWndExtra    = 0;
+    wc.hInstance     = glob_instance;
+    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
+    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
+	wc.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
+    wc.lpszMenuName  = NULL;
+    wc.lpszClassName = g_szClassName;
+    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
+	if (!RegisterClassEx (&wc)) return 0;
+
+	/* Create and Show the Window */
+	hwnd = CreateWindowEx (
+		0, g_szClassName, "The OMGWTF Calculator",
+		WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 
+		220, 270, 
+		HWND_DESKTOP, NULL, glob_instance, NULL);
+	
+	CreateWindow("STATIC", "test", SS_BLACKFRAME | SS_WHITERECT | SS_LEFT,
+		10, 10, 100, 20, hwnd, NULL, GetModuleHandle(NULL), NULL);
+		
+	ShowWindow (hwnd, glob_cmdshow);
+	
+	while (GetMessage (&messages, NULL, 0, 0))
+	{
+		TranslateMessage(&messages);
+		DispatchMessage(&messages);
+	}
+	MessageBox(NULL, "No More messages!", "Blah", MB_OK);
+	wind_created = TRUE;
+	return 0;
+}
+
+int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+	WSADATA wsa_data;
+	/* Define the Window Class and try to register it */
+	WNDCLASSEX wc;
+	HWND hwnd;
+	MSG messages; 
+	/*wc.cbSize        = sizeof (WNDCLASSEX);
+	wc.style         = 0; 
+	wc.lpfnWndProc   = WindowProc;
+	wc.cbClsExtra    = 0;
+    wc.cbWndExtra    = 0;
+    wc.hInstance     = hInstance;
+    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
+    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
+	wc.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
+    wc.lpszMenuName  = NULL;
+    wc.lpszClassName = g_szClassName;
+    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
+	if (!RegisterClassEx (&wc)) return 0;
+
+
+	hwnd = CreateWindowEx (
+		0, g_szClassName, "The OMGWTF Calculator",
+		WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 
+		220, 270, 
+		HWND_DESKTOP, NULL, hInstance, NULL);
+	ShowWindow (hwnd, nCmdShow);*/
+	glob_instance = hInstance;
+	glob_cmdshow = nCmdShow;
+	CreateThread(NULL, 0, message_thread, NULL, 0, NULL);
+	/* Process the Message Loop  */
+	while(!wind_created)
+		Sleep(0);
+	/*while (GetMessage (&messages, NULL, 0, 0))
+	{
+		TranslateMessage(&messages);
+		DispatchMessage(&messages);
+	}*/
+
+	return (int)messages.wParam;
+}
\ No newline at end of file