I want to open two different forms when running my program. Forms are named Form2 and Form3. Form2 runs normally, but Form3 doesn't. I have put Application->CreateForm(__classid(TForm3), &Form3); on my project cpp file and Form3->Show(); in my Unit2.cpp file, but I get error: "Access violation at address 0047B2CE in module 'Project2.exe'. Read of address 00000384." What am I doing wrong?

有帮助吗?

解决方案

Without seeing your actual code, it is hard to say, but chances are that Form3 has simply not been created yet when you are calling Form3->Show(). You are getting an error at a memory address close to 0, which is a good indication that you are likely accessing a NULL pointer.

You don't need to call Show() unless you want more control over WHEN the Forms are shown. You could simply set their Visible property to true at design-time and let the VCL show them for you when Application->Run() is called to start the message loop.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top