Recent

Author Topic: position problem with a dynamically created SHOWMODAL form.  (Read 3363 times)

jamie

  • Hero Member
  • *****
  • Posts: 6131
position problem with a dynamically created SHOWMODAL form.
« on: April 18, 2018, 05:04:03 am »

 When I create a dynamic MODAL form I want to have it show where my mouse just got released so the user
does not need to chase around the screen for it.

   I create the form first in code then I set the LEFT,TOP Properties to that of the MOUSE.CursorPos.....
 
   After that I do a NewForm.ShowModal ..

   Problem is the form ignores what I set after creation and just shows in the center anyways..
 
   If I set the LEFT and TOp in the OnSHow event then it works but I don't remember this being that way ?

  I am going back to my Delphi days and I thought that if you set the bounds/ left/Top properties before SHOWMODAL a
flag was set to indicate to use those settings instead of CENTER screen.

 Do I have brain fog ?
The only true wisdom is knowing you know nothing

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: position problem with a dynamically created SHOWMODAL form.
« Reply #1 on: April 18, 2018, 05:24:49 am »
I don't have such issue. You can try my example code here:
http://forum.lazarus.freepascal.org/index.php/topic,37369.msg250939.html#msg250939

And this is the code I used to set the modal form's position:
Code: Pascal  [Select][+][-]
  1.   frmPopup.Top := Button1.Top + Button1.Height + Form1.Top - frmPopup.Height;
  2.   frmPopup.Left := Button1.Left + Form1.Left;
  3.   frmPopup.ShowModal;

balazsszekely

  • Guest
Re: position problem with a dynamically created SHOWMODAL form.
« Reply #2 on: April 18, 2018, 05:34:04 am »
Set the ModalForm's Position property to poDesigned? Can you attach a small test project?

jamie

  • Hero Member
  • *****
  • Posts: 6131
Re: position problem with a dynamically created SHOWMODAL form.
« Reply #3 on: April 18, 2018, 11:16:17 pm »
Ok, I do have the Position property set for poScreenCenter, but I thought this information is assigned during the
form.create part and then if you change the settings prior to SHowModal it should change the settings to what you want..

 This is for Windows Win32 widget, maybe there is an issue I don't kow about

P.S.
 
 Just did a test In my old D3, and it seems it is behaving this way  too, so I guess I'll need to set the Position to

poDesign instead...

 The danger is over! Thanks

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018