如何从cpp文件访问表单组件

时间:2012-07-18 10:01:05

标签: winforms visual-c++

我正在使用Windows窗体应用程序。我有一个表格,即Form1.h。在这种形式中,我有一个名为pictureBox1的pictureBox。我有一个main.cpp文件,我想在其中访问Form1.h的pictureBox1并从main.cpp文件中显示一些图像。

为此,我使用此代码

的main.cpp

#include "Form1.h"
    using namespace PUMA_LED_TESTER;

Form1^ form1=gcnew Form1; 

form1->pictureBox1->Image =bmp;

但是这段代码给出了错误

error C3145: 'form1' : global or static variable may not have managed type 'PUMA_LED_TESTER::Form1 ^'
          may not declare a global or static variable, or a member of a native type that refers to objects in the gc heap

我不知道为什么会出现这个错误。任何人都可以告诉我这个错误的解决方案。

先谢谢

0 个答案:

没有答案
相关问题