Mercurial > repos > rhope
view window_test.c @ 121:1af91ceaaf49
Fixed memory leak when an output is only attached to a single null input
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 Oct 2010 21:04:12 -0400 |
parents | 76568becd6d6 |
children |
line wrap: on
line source
#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; }