【问题标题】:Using form and controls variables in not managed class在非托管类中使用表单和控件变量
【发布时间】:2023-03-20 15:09:01
【问题描述】:

我有一个问题,我如何在标准类中使用这个变量? 样本

ref class test
{
  Button ^x; 
};

效果很好,但我不需要托管类..

这行不通

   class test
   {
     Button ^x;
   };

也许有人有解决办法?

【问题讨论】:

标签: visual-studio-2010 visual-studio class c++-cli managed-c++


【解决方案1】:

您可以像这样在 gcroot 的帮助下完成此操作:

class test
{
    gcroot<Button^> *x;
};

然后您可以在构造函数中创建此字段的对象,例如:

x = gcnew Button();

通常像按钮一样使用 x...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2014-12-10
    • 1970-01-01
    • 2017-04-02
    • 1970-01-01
    相关资源
    最近更新 更多