我正在尝试使用模板来获取std:项目列表,其中每个项目都有一个指向包含它的列表的指针,但我一直在点击编译器消息.
这是一个非常精简的代码版本.
template <class E> class Item
{
public:
E* owner; // pointer to list that owns us.
};
template <class E> class BaseList: public std::list<E>
{
protected:
typedef std::list<E> inherited;
public:
void push_back(const E &e)
{
E tmp(e);
tmp.owner = this; // This line gives the error.
inherited::push_back(tmp);
}
};
class MyList;
class MyItem : public Item<MyList>
{
};
class MyList : public BaseList<MyItem>
{
};
void foo() // test code to instantiate template
{
MyList l;
MyItem m; …Run Code Online (Sandbox Code Playgroud) 这是一个TMemo,而不是那应该有所不同.
谷歌搜索表明我可以使用,Canvas->TextWidth()但这些是德尔福的例子,BCB似乎没有提供这个属性.
我真的想要类似于memo->Font->Height宽度的东西.
我意识到并非所有字体都是固定宽度,因此可以做出很好的估计.
我需要的只是以像素为单位获取TMemo的宽度,并合理猜测它将保存当前字体的字符数.
当然,如果我真的想要懒惰,我可以谷歌的平均身高/宽度比,因为身高已知.请记住,对于我来说,近似值对我来说已经足够好了.
http://www.plainlanguagenetwork.org/type/utbo211.htm说:"对于大多数应用,建议宽高比为3:5(0.6)"
通常,使用安装程序完成JEDI库的安装.有人知道安装人员吗?
谢谢
我使用的是第三方控件,它是TComponent的后代,我希望它有滚动条,最好是autoscrollbars.
我可以从TComponent获得它们吗?
如果不这样做,我可以将TPanel放在我的主窗体及其上的组件上并获取滚动条吗?我打算让组件(和Panel,或其他)成为alClient,以便在我的组件调整大小时自动调整,但我也喜欢它们有(自动)滚动条.
我想要一个带有BorderStyle = bsNone(没有边框,没有标题)的TForm,但它仍然是可调整大小和可移动的.我已经想出了如何处理可调整大小的部分,但我仍然坚持让它可以移动.
/**
* Overrides standard CreateParams method to create a TForm with BorderStyle
* bsNone but is nevertheless movable and resizable
**/
void __fastcall CreateParams(TCreateParams &Params)
{
BorderStyle = bsNone;
TForm::CreateParams(Params);
//set flag WS_EX_STATICEDGE
//for more details on this flag, see http://msdn.microsoft.com/en-us/library/ms632680(v=vs.85).aspx
Params.ExStyle = Params.ExStyle ^ 0x00020000L;
//set flag WS_SIZEBOX
//for more details on this flag, see http://msdn.microsoft.com/en-us/library/ff700543(v=VS.85).aspx
Params.Style = Params.Style ^ 0x00040000L;
}
Run Code Online (Sandbox Code Playgroud)
这可能只是找到正确的标志.有任何想法吗?
我正在使用C++并使用TDateTime数据类型.
如何获取当前系统日期/时间并将其放入TDateTime变量?
我有以下JSON:
{"test1":"1", "test2": {"test21":"21", "test22":"22"}}"
Run Code Online (Sandbox Code Playgroud)
但我解决它有麻烦.实际上,我在某种程度上试图阅读"test21",但不知道如何达到它.我尝试了这个,但它并不好:
UnicodeString myJSON = "{\"test1\" :\"1\",\"test2\":{\"test21\":\"21\",\"test22\":\"22\"}}";
TJSONObject *JSON = (TJSONObject*)TJSONObject::ParseJSONValue(myJSON);
TJSONValue *test2 = (TJSONValue*)JSON->Get("test2");
//TJSONString* test21 = (TJSONString*)test2->Get("test21");
Run Code Online (Sandbox Code Playgroud) 我正试图用我的hpp单元解决一个小问题.我在互联网上发现了一些例子,展示了如何使用Android JNI桥在屏幕上烘烤信息,但它只是在pascal(delphi)中,所以我决定使用相同的pas文件但是使用hpp文件进行转换.直到现在我明白了:
#ifndef Android_Jni_ToastHPP
#define Android_Jni_ToastHPP
#pragma delphiheader begin
#pragma option push
#pragma option -w- // All warnings off
#pragma option -Vx // Zero-length empty class member
#pragma pack(push,8)
#include <FMX.Helpers.Android.hpp> // Pascal unit
#include <Androidapi.JNIBridge.hpp> // Pascal unit
#include <Androidapi.JNI.JavaTypes.hpp> // Pascal unit
#include <Androidapi.JNI.GraphicsContentViewText.hpp> // Pascal unit
#include <Androidapi.JNI.Util.hpp> // Pascal unit
#include <Androidapi.JNI.App.hpp> // Pascal unit
#include <FMX.Surfaces.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Android
{
namespace Jni
{
namespace Toast
{
//-- type declarations …Run Code Online (Sandbox Code Playgroud) 我正在维护一些用Delphi 6和C++ Builder 4编写的旧应用程序.使用任一编译器编译的应用程序都会出现一种看似奇怪的现象.即使将.exe复制到其他目录,它们也会记住它们的默认工作目录.什么是确定的默认工作目录,以及如何知道什么时候默认工作目录的机理是不相同的目录中的.exe位于?
例如:比方说,我的源代码和编译的32位PE MyApp.exe在C:\CppBuilder\Projects\MyApp.然后我MyApp.exe将该文件夹中的其他文件复制到USB闪存盘F:\.然后,在资源管理器中,双击我MyApp.exe在F:\和应用程序启动.用fopen打开的文件仍然是打开的C:\CppBuilder\Projects\Myapp.如果我重命名或删除文件夹C:\CppBuilder\Projects\Myapp,则输入文件将F:\按照我的预期打开.此外,文件打开对话框的默认文件夹的工作方式类似.
这个的潜在机制是什么?
对不起,如果这是一个愚蠢的问题,但我真的找不到答案,我很尴尬地说,而且它一直让我发疯.我想确定文件的打开位置,而不使用文件名中的完整路径.再说一遍,我很抱歉.如果你知道答案,请帮助我.
I'm making a simple hangman game in c++ builder community edition and my game consists of buttons that represents letters and if the letter doesn't appear inside of the word you lose a life, and so on, and so on... But I'd though that is a little repetitive my code if I make a TButton for every letter in the abcedary. So I decide to make an array of TButton my surprise was when I code everything and any of …