![](/img/trans.png)
[英]How can I make a window with a close button and no icon/menu to the top left of the window?
[英]How can I make the command prompt window open in the top left corner?
我還很新(正在上1級高中課程大約10個星期),我想看看如何格式化命令提示符窗口。 我已經學會了如何設置窗口的大小,而不是位置。 我在Windows XP上使用code :: blocks
您可以使用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);
您可以在此處獲得完整的示例程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.