在C语言中,创建自定义大小的窗口通常需要依赖于操作系统提供的图形库。在Windows系统中,可以使用Win32 API来实现;在Unix-like系统中,可以使用X Window System。以下是在Windows中使用Win32 API创建自定义窗口大小的示例代码:
```c
include
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wcex;
HWND hWnd;
MSG Msg;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW CS_VREDRAW;
wcex.lpfnWndProc = WindowProcedure;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "My Window Class";
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wcex)) {
MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION MB_OK);
return 0;