Visual C ++打开第二个窗体 [英] Visual C++ Opening a second form

查看:191
本文介绍了Visual C ++打开第二个窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,其中包含两个窗体,即Form1.h和Form2.h。

I have a project that contains two forms, Form1.h and Form2.h.

每个.cpp文件均为test.cpp和Form2.cpp。

The .cpp files of each is test.cpp and Form2.cpp.

我想从第一个窗体通过单击按钮打开第二个窗体,我已经将其代码放置在button1_Click方法中:

I want to open the second form from the first through a button click, of which I already have the code for, placed inside the button1_Click method:

Form2 ^ form = gcnew Form2;
form->Show();

我还将include文件放置在Form1.h中(#include Form2.h),但是我一直收到以下错误:

I have furthermore placed the include file in Form1.h (#include "Form2.h"), however I keep getting the following errors:

error C2065: 'Form2' : undeclared identifier

error C2065: 'form' : undeclared identifier

error C2061: syntax error : identifier 'Form2'

error C2065: 'form' : undeclared identifier

error C2227: left of '->Show' must point to class/struct/union/generic type

1>          type is ''unknown-type''

1>  Generating Code...

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我已经寻找了几天的解决方案,但是都没有。
任何帮助将不胜感激。

I have been searching a solution for a couple of days... none of which worked. Any help would be appreciated.

推荐答案

您是否在test.cpp中包含了Form1.h?

Have you included Form1.h in test.cpp?

这篇关于Visual C ++打开第二个窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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