I'm coming across a screwy problem that's really bugging me. (No pun intended.) I'm working in Delphi 5.
I need to host a couple of forms on a panel. I don't want the forms to display outside of this panel, so naturally I assigned the panel as each form's parent. This resulted in incorrect focus behavior and, subsequently, incorrect GUI behavior (ie: unable to click in an Edit box on one of the forms, etc).
A coworker realized that Delphi's Parent property doesn't function exactly as you'd expect and recommended using Windows.SetParent to assign the parent of the forms. This worked perfectly. Focus is fine and the forms behave like they're expected to.
Except... the Left and Top properties. For some reason, using Windows.SetParent instead of Delphi's TForm.Parent property messes up the coordinates of the Form. It doesn't have knowledge of its parent's coordinates. I try to assign the Form's Left property in client coordinates, but it automatically adjusts it to screen coordinates. When I read from Left, it remains in screen coordinates. So everytime I try to assign the Left property, it gets shifted over. (The panel resides at 225, 0. I assign a Form's Left property a value of 0. It reads back 225. I assign it 225, it reads back 450. Etc.)
What's wrong here? I need to use Windows.SetParent because I have to have correct focus behavior. But this funky Left property behavior is driving me crazy! I tried setting both Delphi's Parent property and using Windows.SetParent. I did some google searching and tried messing around with WS_POPUP and WS_CHILD properties of the form, but my child forms are children of a parent, not a form.
I'm a fairly new delphi/windows programmer so I may just be missing something commonly known. Any insight would be great, thanks!!