- 最後登錄
- 2024-5-4
- 在線時間
- 235 小時
- 註冊時間
- 2008-5-3
- 閱讀權限
- 30
- 精華
- 4
- UID
- 4114704
- 帖子
- 1061
- 積分
- 1327 點
- 潛水值
- 4425 米
| 一種作法,寬度需小於 640:
若用 Dev C++ 編譯,要按 [Alt + P],
點 [參數],在連結器欄設:-lgdi32- #include <windows.h>
- #include <iostream>
- using namespace std;
- extern "C" WINBASEAPI HWND WINAPI GetConsoleWindow();
- void set_size (int w, int h)
- {
- int cy = GetSystemMetrics (SM_CYCAPTION),
- bx = GetSystemMetrics (SM_CXBORDER),
- by = GetSystemMetrics (SM_CYBORDER),
- fx = GetSystemMetrics (SM_CXFIXEDFRAME),
- fy = GetSystemMetrics (SM_CYFIXEDFRAME);
- if (w > 640) w = 640;
-
- HANDLE hOut = GetStdHandle (STD_OUTPUT_HANDLE);
- HWND hwnd = GetConsoleWindow ();
- SMALL_RECT rc = {0, 0, w/8 ,h/16};
- COORD size = {w/8+1 ,h/16+1};
-
- int dx = fx+bx;
- int dy = cy+fy+by;
- SetConsoleWindowInfo (hOut,1,&rc); //變更視窗大小
- SetConsoleScreenBufferSize (hOut, size);
- SetWindowRgn (hwnd, CreateRectRgn (dx, dy, w-dx, h-dy), 1);
- }
- int main()
- {
- set_size (490, 690);
-
- cout << "frameless window";
- return getchar();
- }
複製代碼 ... |
|