Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: C++ Builder 5.0 form positioning



Permlink Replies: 2 - Last Post: Feb 21, 2017 3:59 AM Last Post By: Andy Stobirski Threads: [ Previous | Next ]
Andy Stobirski

Posts: 18
Registered: 6/12/16
C++ Builder 5.0 form positioning
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 16, 2017 2:43 AM
Hi Goys

I'm having problems with form positioning in a multi monitor setup using C++ Builder 5.0.

For example, whilst on the Primary Monitor, opening a modal form (Foo->ShowModal()) will correctly centre that form on its parent with the appropriate properties set (Default Monitor: dmActive Form / Position: poMainFormCentre). However, attempting the same operation on the secondary monitor will cause the modal to be dispayed in the centre of the window.

Generally, I've noticed that form positioning works correctly in the primary monitor but not in the secondary monitor, where it is erratic.

Does any one have any suggestions or hints?

Andy
Asger Joergensen

Posts: 370
Registered: 11/18/08
Re: C++ Builder 5.0 form positioning
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 16, 2017 4:44 AM   in response to: Andy Stobirski in response to: Andy Stobirski
Hi Andy

Andy Stobirski wrote:

Does any one have any suggestions or hints?

Just put this in the form constructor:

   TForm* form = dynamic_cast<TForm*>( Owner );
   if( form )
   {
      Left = form->Left + ( form->Width - Width ) / 2;
      Top = form->Top + ( form->Height - Height ) / 2;
   }else{
      Position = poScreenCenter;
   }


and leave the Position in the ObjectInspector = poDefaultPosOnly

Best regards
Asger
Andy Stobirski

Posts: 18
Registered: 6/12/16
Re: C++ Builder 5.0 form positioning
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2017 3:59 AM   in response to: Asger Joergensen in response to: Asger Joergensen
That's great - it works perfectly. Thanks for taking the time to reply.

Cheers

Andy
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02