如何在c ++的屏幕边框绘制? [英] How to draw at border of screen in c++?

查看:225
本文介绍了如何在c ++的屏幕边框绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用图形(使用alt代码)在c ++中在屏幕边框处打印一些边框设计(见下文)但不知道如何操作。请帮忙。



示例:



使用的替代码:http://www.alt-codes.net/ [ ^ ]



对不起,预览中的图案会出现扭曲(不知道为什么),但你可以猜到我想要的东西。

1)

I was thinking of printing some border design at the screen borders(see below) in c++ using graphics (using alt codes) but don''t know how to. Please help.

examples :

Alt code used: http://www.alt-codes.net/[^]

Sorry patterns appear distorted in preview(dont know why), but you can guess what I want.
1)

╔══════════════════╗   
║                  ║
║                  ║
║                  ║
║                  ║
║                  ║
╚══════════════════╝





2)


$ b $b░░░░░░░░░ ░░░░░░░░░░░

░░░░

░░░░

░░░░

░░░░

░░░░

░░░░░░░░░░░░░░░░░░░░





等等.....



添加了代码块 - OriginalGriff [/ edit]



2)

░░░░░░░░░░░░░░░░░░░░
░░ ░░
░░ ░░
░░ ░░
░░ ░░
░░ ░░
░░░░░░░░░░░░░░░░░░░░


and so on.....

[edit]Code block added - OriginalGriff[/edit]

推荐答案

我假设您正在使用Windows上的控制台应用程序?如果不是那么这将是完全错误的。

控制台是一个相对较小的固定大小的网格80x25或者可能是120x43,具体取决于你的配置。

如果你我将在整个控制台屏幕上绘制,然后在内存中设置一个或多个80 x N阵列,并编写一个''blitter''函数,一次性将一个数组写入屏幕。

Win32函数,如 FillConsoleOutputCharacter 和Fill ConsoleOutputAttribute 将帮助你。

诀窍获取有用的符号字符,你可以构造框和边框出现在设置正确的代码页。代码页是在控制台上进行国际化的一种传统方式,实质上它是为包含重音字符或西里尔字母或其他内容的扩展ASCII字符集(字符> 127)进行交换。为了获得你想要的符号,我认为你需要的是代码页852,这是PC早期的IBM字符集定义。你得检查一下。 SetConsoleCP 功能可以让你改变它。

如果你要做很多这样的事情并且不要我不想从头开始编写所有你可能会考虑搜索 pdcurses 库,Windows端口 ncurses 这实际上是控制台的窗口库。它将有盒子,菜单,弹出窗口,按钮等。 ncurses 是Linux标准库的一部分。
I''m assuming you''re working on a Console Application on Windows? If not then this will be completely wrong.
The console is a relatively small fixed sized grid 80x25 or perhaps 120x43 depending on how you''ve configured it.
If you''re going to paint whole console screens then I would set up one or more 80 x N arrays in memory and write a ''blitter'' function to write an array to the screen all in one go.
Win32 functions like FillConsoleOutputCharacter and Fill ConsoleOutputAttribute will help you there.
The trick to getting useful symbol characters out of which you can construct boxes and borders to appear is in setting the right Code Page. A Code Page is an old fashioned way of doing internationalisation on the console, essentially it swaps the extended ASCII character set (chars>127) for one containing accented characters or cyrillic or whatever. To get the symbols you want I think it''s code page 852 you need which is an IBM character set definition from the early days of the PC. You''ll have to check. The SetConsoleCP function will enable you to change it.
If you''re going to be doing a lot of this sort of thing and don''t want to write it all yourself from scratch you might consider searching for the pdcurses library, a Windows port of ncurses which is essentially a ''windowing'' library for the console. It will have boxes, menus, popups, buttons etc. ncurses is part of the Linux Standard Base.


这篇关于如何在c ++的屏幕边框绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆