0

我相当新(大约 10 周进入 1 级高中课程),我正在尝试了解如何格式化命令提示符窗口。我已经学会了如何设置窗口的大小,但不是位置。我在 Windows XP 上使用 code::blocks

4

2 回答 2

0

首先, 读这个
然后,试试这些……(在一个批处理文件中)

Set mycmdHeight=40
Set mycmdWidth=80
Set mycmdxPos=0
Set mycmdyPos=120  

或者,以编程方式,看这里这里

于 2013-10-16T22:33:13.230 回答
0

您可以使用 windows 功能将控制台窗口移动到您想要的位置。首先看返回当前窗口句柄的函数。

HWND WINAPI GetConsoleWindowNT(void)
{
// declare function pointer type

typedef HWND WINAPI (*GetConsoleWindowT)(void);

// declare one such function pointer

GetConsoleWindowT GetConsoleWindow;

// get a handle on kernel32.dll

HMODULE hK32Lib = GetModuleHandle(TEXT("KERNEL32.DLL"));

// assign procedure address to function pointer

GetConsoleWindow = (GetConsoleWindowT)GetProcAddress(hK32Lib,TEXT("GetConsoleWindow"));

// check if the function pointer is valid

// since the function is undocumented

if ( GetConsoleWindow == NULL ) {
     return NULL;
}

// call the undocumented function

return GetConsoleWindow();
}

使用上述函数获取当前窗口的句柄。

HWND hwnd = GetConsoleWindowNT();

现在,您可以使用 MoveWindow 函数将窗口移动到您想要的位置,如下所示:

MoveWindow(hWnd,1230,750,200,100,TRUE);

您可以在此处获得完整的示例程序。

于 2013-10-17T03:12:55.090 回答