I have one form opening a second form which is meant to look like it's replaced the first form but it opens a bit to the right and down whi开发者_如何学编程ch ruins the effect. If there a way to make it open wherever the first form may be?
I am using visual studio, in C++
Set the new form's StartPosition to Manual and give it the same Size and Location:
Form2^ frm = gcnew Form2;
frm->StartPosition = FormStartPosition::Manual;
frm->Location = this->Location;
frm->Size = this->Size;
frm->Show();
Have you tried messing with the Height/Width/Location of the new Form?
I don't know for sure, but I imagine that you could grab the location and size of the original form, and when creating the new Form, set it's Location and size to the same values, just before you call "Show" (or set Visible to true) on the new Form.
The "opening a bit to the right and down" makes it sound like you've placed the new window at the top-left corner of the parent's client area. You need to take the border width into account to get them to match up.
精彩评论