Open two forms at startup in c++ builder

空扰寡人 提交于 2021-02-10 18:28:14

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/22673267/open-two-forms-at-startup-in-c-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!