Reputation: 31
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 which ruins the effect. If there a way to make it open wherever the first form may be?
I am using visual studio, in C++
Upvotes: 2
Views: 1255
Reputation: 942438
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();
Upvotes: 3
Reputation: 490728
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.
Upvotes: 0
Reputation: 88475
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.
Upvotes: 0