#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <winlib/winlib.h>
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam)
{
static char i = 1;
switch (msg) {
case WM_CREATE:
AllocConsole();
return 0;
case WM_DESTROY:
FreeConsole();
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,msg,wParam,lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, INT nCmdShow)
{
WNDCLASS wc;
HWND hwnd;
MSG msg;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MainWndClass";
if (! RegisterClass(&wc))
return 0;
hwnd = CreateWindow(
"MainWndClass",
"wintest",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
while (GetMessage (&msg, NULL, 0, 0)) {
ConPrintf("%d\n", msg.message);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}