#include <windows.h>
LRESULT CALLBACK WndProc(HWND , UINT , WPARAM ,LPARAM);
int APIENTRY WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASS wndClass;
HWND hWnd;
MSG msg;
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_PEN);
wndClass.lpszClassName = TEXT("基本窗口");
wndClass.lpszMenuName = NULL;
if(!RegisterClass(&wndClass))
return false;
hWnd = CreateWindow(TEXT("基本窗口"),TEXT("基本窗口"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
//弹出控制台
AllocConsole();//
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
unsigned long lgsize;
char *strbuf = "显示这些信息";
WriteFile(hOutput, strbuf, strlen(strbuf), &lgsize, 0);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd,&ps);
EndPaint(hWnd,&ps);
break;
case WM_DESTROY:
FreeConsole();
PostQuitMessage(0);
break;
return 0;
default :
return DefWindowProc(hWnd,message,wParam,lParam);
}
return 0;
}