一、創建基本窗口
#include <graphics.h> #include <conio.h> // 調用_getch()函數 int main(void) { initgraph(300, 150); HWND hWnd = GetHWnd(); // 獲取窗口名稱句柄 SetWindowText(hWnd, "窗口名稱"); // 窗口標題名稱 setbkcolor(BROWN); // 設置背景色 cleardevice(); // 不加背景色顯示不出來 _getch(); // 運行完等待,不閃退 closegraph(); }
運行效果如下:
二、窗口參數的調整
2.1 禁用繪圖環境關閉按鈕
initgraph(300, 150, NOCLOSE);
2.2 禁用最小化按鈕
initgraph(300, 150, NOMINIMIZE);
2.3 禁用最小化和關閉按鈕
initgraph(300, 150, NOCLOSE | NOMINIMIZE);
2.4 保留控制台窗口
initgraph(300, 150, NOCLOSE | NOMINIMIZE | SHOWCONSOLE);