看一看,瞧一瞧。控制台cmd的窗口大小,怎么调?

狂风乱吼 2019-04-30 09:08:17

我就知道这一行代码,而且还是错的。完整的代码怎么打。就是调试之后,cmd的窗口大小
...全文
648 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
狂风乱吼 2019-05-01
  • 打赏
  • 举报
回复
引用 2 楼 赵4老师 的回复:
C:\>mode /?
配置系统设备。

串行口:    MODE COMm[:] [BAUD=b] [PARITY=p] [DATA=d] [STOP=s]
[to=on|off] [xon=on|off] [odsr=on|off]
[octs=on|off] [dtr=on|off|hs]
[rts=on|off|hs|tg] [idsr=on|off]

设备状态: MODE [device] [/STATUS]

打印重定向:   MODE LPTn[:]=COMm[:]

选定代码页:   MODE CON[:] CP SELECT=yyy

代码页状态:   MODE CON[:] CP [/STATUS]

显示模式:   MODE CON[:] [COLS=c] [LINES=n]

击键率:  MODE CON[:] [RATE=r DELAY=d]

C:\>
还是大神nb
赵4老师 2019-05-01
  • 打赏
  • 举报
回复
C:\>mode /?
配置系统设备。

串行口:    MODE COMm[:] [BAUD=b] [PARITY=p] [DATA=d] [STOP=s]
[to=on|off] [xon=on|off] [odsr=on|off]
[octs=on|off] [dtr=on|off|hs]
[rts=on|off|hs|tg] [idsr=on|off]

设备状态: MODE [device] [/STATUS]

打印重定向:   MODE LPTn[:]=COMm[:]

选定代码页:   MODE CON[:] CP SELECT=yyy

代码页状态:   MODE CON[:] CP [/STATUS]

显示模式:   MODE CON[:] [COLS=c] [LINES=n]

击键率:  MODE CON[:] [RATE=r DELAY=d]

C:\>
赵4老师 2019-05-01
  • 打赏
  • 举报
回复
仅供参考:
//控制台的字体大小是可以改变的。系统为我们提供了许多的API,能更改字体大小的API正隐身其中。网上没有控制台字体大小的相关资料,
//关于控制台字体大小的教程是本博客独家放出。本文将教会你如何使用这些API,达到修改控制台字体大小的目的。
//一般控制台中每个输出缓冲区都有一个固定的字体。系统中的字体,每一种都有对应的序号,每种字体大小不同。想要修改为一种新的字体,
//就将这种字体的序号赋值给控制台缓冲区即可。一般来说,系统所有的字体总数不超过40个,因此循环获取信息时可以以这个为上限。
//首先放出需要用到的API列表:
//(如下大部分API都没有公布,至最近才公布了其中几个的详细信息)

//bool SetConsoleFont(HANDLE,DWORD)
//注意了,这个函数一旦调用,所有文字字体大小全部变化,窗口大小也变了。这个是用于设置字体大小
//第一个参数为输出句柄,第二个参数为新字体大小序号

//bool GetConsoleFontInfo(HANDLE,BOOL,DWORD,CONSOLE_FONT*)
//这个是用于获取字体信息
//第一个参数为输出句柄,第二个参数应设为0,第三个参数为欲获取信息的字体序号,第四个参数为CONSOLE_FONT结构体的指针,API将返回的信息放置在这个结构体里

//COORD GetConsoleFontSize(HANDLE,DWORD)
//这个是用于获取字体大小
//第一个参数为输出句柄,第二个参数为欲获取大小的字体序号,返回的COORD的两个成员就是字体的大小

//DWORD GetNumberOfConsoleFonts()
//这个是用于获取可用字体数
//返回可用字体总数

//bool GetCurrentConsoleFont(HANDLE,BOOL,CONSOLE_FONT*)
//这个是用于获取当前字体的信息
//第一个参数为输出句柄,第二个参数应设为0,第三个参数为CONSOLE_FONT结构体的指针,API将返回的信息放置在这个结构体里

//结构体CONSOLE_FONT:
//struct CONSOLE_FONT{ DWORD index; COORD dim;};
//第一个成员是字体的序号,第二个成员是字体的大小
//这是些未公布的API,所以需要动态载入,首先在全局声明:
#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#pragma comment(lib,"shell32")
#include <windows.h>
#include <Shlwapi.h>
#include <shlobj.h>
#include <stdio.h>
struct CONSOLE_FONT{ DWORD index; COORD dim;};
typedef BOOL (WINAPI *PROCSETCONSOLEFONT )(HANDLE, DWORD);
typedef BOOL (WINAPI *PROCGETCONSOLEFONTINFO )(HANDLE,BOOL,DWORD,CONSOLE_FONT*);
typedef COORD (WINAPI *PROCGETCONSOLEFONTSIZE )(HANDLE,DWORD);
typedef DWORD (WINAPI *PROCGETNUMBEROFCONSOLEFONTS)();
typedef BOOL (WINAPI *PROCGETCURRENTCONSOLEFONT )(HANDLE,BOOL,CONSOLE_FONT*);
PROCSETCONSOLEFONT SetConsoleFont;
PROCGETCONSOLEFONTINFO GetConsoleFontInfo;
PROCGETCONSOLEFONTSIZE GetConsoleFontSize;
PROCGETNUMBEROFCONSOLEFONTS GetNumberOfConsoleFonts;
PROCGETCURRENTCONSOLEFONT GetCurrentConsoleFont;
extern "C" HWND WINAPI GetConsoleWindow();
int main(int argc, char *argv[]) {
//然后在程序启动的时候进行载入:
HMODULE hKernel32 = GetModuleHandle("kernel32");
SetConsoleFont = (PROCSETCONSOLEFONT )GetProcAddress(hKernel32,"SetConsoleFont" );
GetConsoleFontInfo = (PROCGETCONSOLEFONTINFO )GetProcAddress(hKernel32,"GetConsoleFontInfo" );
GetConsoleFontSize = (PROCGETCONSOLEFONTSIZE )GetProcAddress(hKernel32,"GetConsoleFontSize" );
GetNumberOfConsoleFonts = (PROCGETNUMBEROFCONSOLEFONTS)GetProcAddress(hKernel32,"GetNumberOfConsoleFonts");
GetCurrentConsoleFont = (PROCGETCURRENTCONSOLEFONT )GetProcAddress(hKernel32,"GetCurrentConsoleFont" );
//载入完毕之后,就可以进行编程对字体大小控制了。

int NumOfFont,i,X=0,Y=0,IconIndex=0;
char *IconFile=NULL;
NumOfFont = GetNumberOfConsoleFonts();
CONSOLE_FONT *fonts = new CONSOLE_FONT[NumOfFont];
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleFontInfo(hConsole, 0, NumOfFont, fonts);
if (argc==1) {
printf("Set Console FontSize and Icon. Designed by zhao4zhong1@163.com 2015-07-10\n");
printf("Usage: %s [XxY] [IconFile] [IconIndex]\n",argv[0]);
printf("May availible Font Size:\n X x Y\n-- x --\n");
}
if (argc==2) {
if (2!=sscanf(argv[1],"%dx%d",&X,&Y))
IconFile=argv[1];
} else if (argc==3) {
if (2!=sscanf(argv[1],"%dx%d",&X,&Y)) {
IconFile=argv[1];
sscanf(argv[2],"%d",&IconIndex);
} else {
IconFile=argv[2];
}
} else if (argc==4) {
sscanf(argv[1],"%dx%d",&X,&Y);
IconFile=argv[2];
sscanf(argv[3],"%d",&IconIndex);
}
if (IconFile) {
HWND hwnd=GetConsoleWindow();
if (hwnd) {
HICON hIconS=NULL;
if (1<=ExtractIconEx(IconFile,IconIndex,NULL,&hIconS,1)) {
if (hIconS) {
SendMessage(hwnd,WM_SETICON,ICON_SMALL,(LPARAM)hIconS);
// DestroyIcon(hIconS);
}
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSH, NULL, NULL);//更新任务栏上的图标
}
}
}
for (i=0;i<NumOfFont;i++) {
fonts[i].dim = GetConsoleFontSize(hConsole, fonts[i].index);
// if (argc==1) printf("%2d x %2d %d %d\n",fonts[i].dim.X,fonts[i].dim.Y,i,fonts[i].index);
if (argc==1) printf("%2d x %2d\n",fonts[i].dim.X,fonts[i].dim.Y);
if (fonts[i].dim.X == X && fonts[i].dim.Y == Y) {
SetConsoleFont(hConsole, fonts[i].index);
break;
}
}
delete[] fonts;
return 0;
}
//BOOL SetConsoleTextAttribute(HANDLE hConsoleOutput, WORD wAttributes);//设置前景背景颜色

//SetCurrentConsoleFontEx function
//
//Sets extended information about the current console font.
//
//BOOL WINAPI SetCurrentConsoleFontEx(
// _In_ HANDLE hConsoleOutput,
// _In_ BOOL bMaximumWindow,
// _In_ PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx
//);
//
//Parameters
//hConsoleOutput [in]
// A handle to the console screen buffer. The handle must have the GENERIC_WRITE access right. For more information, see Console Buffer Security and Access Rights.
//bMaximumWindow [in]
// If this parameter is TRUE, font information is set for the maximum window size. If this parameter is FALSE, font information is set for the current window size.
//lpConsoleCurrentFontEx [in]
// A pointer to a CONSOLE_FONT_INFOEX structure that contains the font information.
//Return value
// If the function succeeds, the return value is nonzero.
// If the function fails, the return value is zero. To get extended error information, call GetLastError.
//Remarks
// To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers.
//Requirements
// Minimum supported client
// Windows Vista [desktop apps only]
// Minimum supported server
// Windows Server 2008 [desktop apps only]
//Header
// Wincon.h (include Windows.h)
//Library
// Kernel32.lib
//DLL
// Kernel32.dll
//See also
// Console Functions
// CONSOLE_FONT_INFOEX

//CONSOLE_FONT_INFOEX structure
//
//Contains extended information for a console font.
//
//typedef struct _CONSOLE_FONT_INFOEX {
// ULONG cbSize;
// DWORD nFont;
// COORD dwFontSize;
// UINT FontFamily;
// UINT FontWeight;
// WCHAR FaceName[LF_FACESIZE];
//} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
//
//Members
//cbSize
// The size of this structure, in bytes.
//nFont
// The index of the font in the system's console font table.
//dwFontSize
// A COORD structure that contains the width and height of each character in the font, in logical units. The X member contains the width, while the Y member contains the height.
//FontFamily
// The font pitch and family. For information about the possible values for this member, see the description of the tmPitchAndFamily member of the TEXTMETRIC structure.
//FontWeight
// The font weight. The weight can range from 100 to 1000, in multiples of 100. For example, the normal weight is 400, while 700 is bold.
//FaceName
// The name of the typeface (such as Courier or Arial).
//Remarks
// To obtain the size of the font, pass the font index to the GetConsoleFontSize function.
//Requirements
// Minimum supported client
// Windows Vista [desktop apps only]
// Minimum supported server
// Windows Server 2008 [desktop apps only]
//Header
// Wincon.h (include Windows.h)

//GetCurrentConsoleFontEx function
//
//Retrieves extended information about the current console font.
//
//BOOL WINAPI GetCurrentConsoleFontEx(
// _In_ HANDLE hConsoleOutput,
// _In_ BOOL bMaximumWindow,
// _Out_ PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx
//);
ConEmu 不是外壳程序,因此它不提供“外壳程序功能”,例如远程访问,制表符完成,命令历史记录等。ConEmu 是一个高级控制台窗口,您可以在其中运行您选择的任何 shell。但是,其中一些功能已放置在 RoadMap 中。您也可以在 cmd.exe 中尝试 Clink 进行 bash 风格的完成,而在 powershell.exe 中尝试 PSReadLine 或 PowerTab。 甚至可以从 cygwin,git-for-windows,msys2,mingw 等中选择 bash 或任何其他类似 unix 的 shell。 Windows 终端神器 ConEmu 中文版Windows 终端神器 ConEmu 中文版 ConEmu 在隐藏的控制台窗口中启动控制台程序,并提供具有各种功能的备用可定制 GUI 窗口: 平滑友好的窗口大小整; 编辑器,查看器,面板和控制台的选项卡; 在选项卡中运行简单的 GUI 应用程序(如 PuTTY); Windows 7 跳转列表和任务栏按钮上的进度; 在 Windows 7 或 64 位操作系统上轻松运行旧的 DOS 应用程序(游戏); Far Manager 中的缩略图和图块; 正常,最大化和全屏图形窗口模式; 窗口字体抗锯齿:标准,ClearType,禁用; 窗口字体:家庭字体,高度,宽度,粗体,斜体等; 支持中文版本的 Windows; 同时在控制台的不同部分使用普通/粗体/斜体字体; 在 Far Manager 3.x 中使用 24 位颜色; ANSI X3.64 和 Xterm 256 色; 光标:标准控制台(水平)或 GUI(垂直); 每个应用程序的可选设置(例如色板); 使用键盘进行垂直控制台缓冲区滚动(BufferHeight 模式); 在 Far Manager 的编辑器/查看器中显示最后命令的完整输出(超过 1K 行); 可自定义的 Far Manager 右键单击行为(长按可打开上下文菜单); 在 Far Manager 中拖放文件和文件夹(浏览器样式); 对 BDF 字体的支持有限; 用户友好的文本和块选择; 透明和桌面模式; 可定制的开始标签; 可配置和可点击的状态栏; 更多,以及更多…查看“文档”,“设置”页面和“新增功能”。 从注册表或 ConEmu.xml 文件(支持多个命名配置)中读取所有设置,然后应用命令行参数。参数/Config 和/BufferHeight 只能在命令行上指定。大多数设置是使用“设置”对话框配置的,而不是从命令行配置的。 作为 Windows 控制台窗口的增强(本地终端仿真器),ConEmu 将多个控制台和简单的 GUI 应用程序(例如 PuTTY)呈现为一个具有各种功能的可自定义的选项卡式 GUI 窗口。 而且,由于深度集成,ConEmu 是 Far Manager(Wikipedia 中的 FAR)(我最喜欢的 Shell 替换)的最佳伴侣。ConEmu 是一个活跃的项目,欢迎提出建议。

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧