C语言创建空白Windows窗口代码
自用
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
//#include <imm.h>LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {AllocConsole();freopen("CON", "w", stdout);MSG msg;HWND hwnd;WNDCLASSW wc;wc.style = CS_HREDRAW | CS_VREDRAW;wc.cbClsExtra = 0;wc.cbWndExtra = 0;wc.lpszClassName = L"Window";wc.hInstance = hInstance;wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);wc.lpszMenuName = NULL;wc.lpfnWndProc = WndProc;wc.hCursor = LoadCursor(NULL, IDC_ARROW);wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);RegisterClassW(&wc);hwnd = CreateWindowW(wc.lpszClassName, L"Window",WS_OVERLAPPEDWINDOW | WS_VISIBLE,100, 100, 350, 250, NULL, NULL, hInstance, NULL);ShowWindow(hwnd, nCmdShow);UpdateWindow(hwnd);while (GetMessage(&msg, NULL, 0, 0)) {DispatchMessage(&msg);}return (int) msg.wParam;}LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {switch(msg) {case WM_DESTROY:PostQuitMessage(0);break;}return DefWindowProcW(hwnd, msg, wParam, lParam);}