如何更改C++ Windows控制台应用程序中的字体?
它似乎没有使用默认情况下cmd.exe使用的字体(Lucida Console).当我通过现有的cmd.exe(输入name.exe)运行我的应用程序时,它看起来像这样:http://dathui.mine.nu/konsol3.png这是非常正确的.但是,当我单独运行我的应用程序(双击.exe)时,它看起来像这样:http://dathui.mine.nu/konsol2.png.相同的代码,两个不同的外观.
所以现在我想知道如何更改字体,使其无论运行方式如何都始终正确.
编辑:
好的,还有一些信息.当我只使用这个小片段时:
SetConsoleOutputCP(CP_UTF8);
wchar_t s[] = L"èéøÞ????æ?a";
int bufferSize = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL);
char* m = new char[bufferSize];
WideCharToMultiByte(CP_UTF8, 0, s, -1, m, bufferSize, NULL, NULL);
wprintf(L"%S", m);
Run Code Online (Sandbox Code Playgroud)
它使用正确的字体.但在我的实际应用程序中,我WriteConsoleOutput()用来打印字符串:
CHAR_INFO* info = new CHAR_INFO[mWidth * mHeight];
for(unsigned int a = 0; a < mWidth*mHeight; ++a) {
info[a].Char.UnicodeChar = mWorld.getSymbol(mWorldX + (a % mWidth), mWorldY + (a / mWidth));
info[a].Attributes = mWorld.getColour(mWorldX + …Run Code Online (Sandbox Code Playgroud) 有没有简单的方法来检查路径是否有效?该文件现在不必存在,我想知道它是否存在.
我目前的版本是这样的:
try:
f = open(path)
except:
<path invalid>
Run Code Online (Sandbox Code Playgroud)
我正在考虑简单地检查路径是否包含任何这些字符.
我想在我的应用程序中静态地构建和使用Botan,这意味着首先
python configure.py --disable shared
Run Code Online (Sandbox Code Playgroud)
其次是
make
Run Code Online (Sandbox Code Playgroud)
然后我想为libbotan.a创建一个依赖目标作为"libbotan",我可以在其余的CMake文件中使用它.由于Botan没有使用CMake,我不确定如何在项目中包含依赖项.
我目前的尝试看起来像这样:
in deps/Botan.1.11.7/CmakeLists.txt
add_custom_command(OUTPUT botan-configure COMMAND ./configure.py --disable-shared)
add_custom_command(OUTPUT botan-build COMMAND make DEPENDS botan-configure)
add_custom_target(botan DEPENDS botan-configure botan-build)
Run Code Online (Sandbox Code Playgroud)
但是当我将botan添加为core/CMakeLists.txt中的依赖项时,就像这样
add_executable(console console.cpp)
target_link_libraries(console messages core botan ${Boost_LIBRARIES})
Run Code Online (Sandbox Code Playgroud)
我明白了
CMake Error at simpleclient/CMakeLists.txt:5 (target_link_libraries):
Target "botan" of type UTILITY may not be linked into another target. One
may link only to STATIC or SHARED libraries, or to executables with the
ENABLE_EXPORTS property set.
Run Code Online (Sandbox Code Playgroud)
我试过像这样使用ExternalProject_Add
ExternalProject_Add(botan
GIT_REPOSITORY https://github.com/randombit/botan.git
CONFIGURE_COMMAND python configure.py --disable-shared
BUILD_COMMAND make
INSTALL_COMMAND …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用pywin32附带的win32gui模块,但我无法使其工作.
我已下载它,构建它,一切似乎都位于site-packages下,我在site-packages/win32/win32gui.pyd找到了win32gui.pyd但是当我尝试导入它时,我得到:
import pyHook, win32gui
ImportError: DLL load failed: The specified module could not be found.
Run Code Online (Sandbox Code Playgroud)
我需要在某个地方移动一个dll吗?如果是的话,哪一个?
Windows 8/10 已经开始包含一个滑块,用于显示 GUI 元素应该缩放多少,右键单击桌面 -> 显示。对于使用笔记本电脑 4k 屏幕的同事来说,它是 250%,而另一位同事在 4k 28" 屏幕上使用相同的分辨率,它是 150%。
如何以编程方式读取该值?我需要调整一些图形,使其在所有屏幕上看起来都一样。
我在 Eclipse RCP 应用程序上使用 Java 工作,但通过 JNI 使用 C 或 C++ 的方法也适用。我一直在环顾四周,但找不到任何东西。
我正在安装一个用Java/Ecipse RCP编写的工具的安装程序,除了我认为可能相关的两件事之外,一切正常:
1)打开现有文件.出于某种原因,OSX不会像Windows和Linux那样提供所选文件作为参数.我如何让osx作为参数传递路径?还是有另一种方式?
2)文件类型未正确注册.双击带有扩展名的现有文件会按预期打开应用程序,但是当我"打开" - "其他"时,该工具显示为灰色,如何让osx了解该工具可以打开这些文件?
这是当前的Info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string>images/icons/macos.icns</string>
<key>NSHumanReadableCopyright</key>
<string>2016 Company</string>
<key>CFBundleGetInfoString</key>
<string>Tool description</string>
<key>CFBundleShortVersionString</key>
<string>1.2.0</string>
<key>CFBundleVersion</key>
<string>1.2.0</string>
<key>CFBundleDisplayName</key>
<string>Tool</string>
<key>CFBundleName</key>
<string>com.company.tool</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleExecutable</key>
<string>tool</string>
<key>CFBundleIdentifier</key>
<string>com.company.tool</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.company.tool.extension</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>ext</string>
</dict>
<key>UTTypeIconFile</key>
<string>images/icons/macos.icns</string>
<key>UTTypeDescription</key>
<string>tool file</string>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<string>images/icons/macos.icns</string>
<key>CFBundleTypeName</key>
<string>tool file</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.company.tool.extension</string>
</array>
</dict>
</array>
</dict> …Run Code Online (Sandbox Code Playgroud) 我想知道为什么这个简单的代码不起作用.
在main.py我有
def foo():
HTTPHelper.setHost("foo")
host = HTTPHelper.host()
Run Code Online (Sandbox Code Playgroud)
并在HTTPHelper.py中:
_host = None
def setHost(host):
_host = host
def host():
return _host
Run Code Online (Sandbox Code Playgroud)
但是当我逐步执行foo()时,主机变为NoneType,即使我之前将它设置在行上.非常困惑...
我一直在使用protobuf生成后端内部消息,但是当我搬到新笔记本电脑上并再次设置protoc时,似乎不再生成有效的Java代码。
我在最新的Ubuntu 16.04,并下载了最新protoc
$ protoc --version
libprotoc 3.5.1
Run Code Online (Sandbox Code Playgroud)
毫无错误或警告地构建
protoc --java_out=<javapath> --python_out=<pythonpath> messages.proto
Run Code Online (Sandbox Code Playgroud)
Eclipse / maven显示的消息是:
The method parseUnknownFieldProto3(CodedInputStream, UnknownFieldSet.Builder, ExtensionRegistryLite, int) is undefined for the type MessageA.Request Messages.java ...path, line etc...
snip, more of the same for other messages
Messages.Shutdown Messages.java ...path...
The method setUnknownFieldsProto3(UnknownFieldSet) is undefined for the type GeneratedMessageV3.Builder<Messages.Request.Builder> Messages.java ...path, line etc...
snip, more of the same
Run Code Online (Sandbox Code Playgroud)
如果我手动重命名parseUnknownFieldProtoc3,以parseUnknownField与同为SetUnknownFields错误消失,但像错误的解决感觉。
我想念什么?
我正在尝试将Joomla 1.5.9页面中的表源从页面中的硬编码html更改为从SQL数据库获取信息.这样做的正确方法是什么?创建一个新的模型或组件,并以某种方式在页面中使用它?
我发现了这些:http://docs.joomla.org/Tutorial : How_to_use_the_database_classes_in_your_script http://docs.joomla.org/How_to_use_the_database_classes_in_your_script
但我不知道在哪里编写php代码以及如何在页面中访问它.如果有人能指出我自定义php的基本教程或其他任何名称,我是webb开发的新手,我会很高兴.
我想将访问者模式与智能指针结合使用,但似乎编译器无法检测子类并匹配相应的函数.
我写了一个显示问题的SSCE:
test.hpp:
class Visitor;
class Area {
public:
virtual void visit(const Visitor& visitor) = 0;
};
class Area1 : public Area {
public:
virtual void visit(const Visitor& visitor);
};
class Area2 : public Area {
public:
virtual void visit(const Visitor& visitor);
};
class Visitor {
public:
virtual void visit(const Area1 &area) const = 0;
virtual void visit(const Area2 &area) const = 0;
};
Run Code Online (Sandbox Code Playgroud)
TEST.CPP:
#include "test.hpp"
void Area1::visit(const Visitor& visitor) {
visitor.visit(*this);
}
void Area2::visit(const Visitor& visitor) {
visitor.visit(*this); …Run Code Online (Sandbox Code Playgroud)