| |

VerySource

 Forgot password?
 Register
Search
View: 1326|Reply: 5

TForm1 * Form1; Why not use this sentence without new?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-19 15:30:01
| Show all posts |Read mode
TForm1 * Form1; Why can I use this sentence without new? I haven't seen the new statement in the whole project.
And what does extern PACKAGE TForm1 * Form1; in .h mean? Is it a global variable?
Reply

Use magic Report

0

Threads

45

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-4-27 12:15:01
| Show all posts
In Application-> CreateForm

External variable
Reply

Use magic Report

0

Threads

22

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-4-27 17:45:01
| Show all posts
In Project1.cpp.
Reply

Use magic Report

0

Threads

16

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-4-28 18:15:01
| Show all posts
Menu project-> ViewSource, you can see it by yourself
Reply

Use magic Report

0

Threads

12

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-4-29 17:00:01
| Show all posts
The compiler did it for you.
Reply

Use magic Report

0

Threads

27

Posts

24.00

Credits

Newbie

Rank: 1

Credits
24.00

 China

Post time: 2020-4-30 08:45:01
| Show all posts
Create a new project by default and automatically generate code in Project.cpp
In WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int)
{
        try
        {
                 Application-> Initialize ();
                 Application-> CreateForm (__ classid (TForm1),&Form1);
                 Application-> Run ();
        }
        catch (Exception&exception)
        {
                 Application-> ShowException (&exception);
        }
        catch (...)
        {
                 try
                 {
                         throw Exception ("");
                 }
                 catch (Exception&exception)
                 {
                         Application-> ShowException (&exception);
                 }
        }
        return 0;
}

This sentence Application-> CreateForm (__ classid (TForm1),&Form1);
Created Form1

If your project has more than one Form,
You can make other Forms not new, and new yourself in the code

Menu project-> Options-> Forms
Move the corresponding form from auto-create forms to available forms

Note that you cannot "drag" all forms to the right
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list