Form Show

Started by SeaVipe, September 04, 2020, 06:09:59 PM

Previous topic - Next topic

SeaVipe

Hi Paul, I'm not sure if perhaps I'm calling this correctly or not:
This code Shows a form modeless and the Top and Left can be specified by the User (from an ini file for example) (fixed)
frmJedit.Show
This code however, Shows the same form modal but the Top and Left cannot be specified by the User
nor can the Top and Left be accurately saved to an ini file or Print to console etc.
and the Top and Left, when extracted from an ini file, are ignored and (quite often) random negative values are set to the Top and Left.
frmJedit.ShowDialog(frmMainJ.hWindow)
I successfully use the same code from Main to position and size the main form at startup using Application.Run(frmMainJ).
Both forms have the same properties; BorderStyle Sizable, StartPosition Manual, Window.Sate Normal.
Clive Richey

Paul Squires

Hi Clive,

Just a couple of points:

(1) .ShowDialog always displays the form as Modal. Your first example is not modeless because if a parent is not specified for .ShowDialog then the desktop screen is used. To display modeless, you use the .Show method.

(2) At what point are you trying to set the Top and Left properties? In what method handler? Load, Initialize?


Paul Squires
PlanetSquires Software

SeaVipe

Sorry Paul, too much cut and paste! I fixed the typo. For Modeless it should of course be frmJedit.Show not frmJedit.ShowDialog as in my original post. Top and Left are set in a function called from the form's Load event.
Clive Richey

Paul Squires

Hi Clive, I just created a very simple project to help me visualize the problem you are having. I have a main form with one button on it. I press the button to display a popup modal form. In the popup form's Load handler I use this code:


''
''
Function frmPopup_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
   frmPopup.Top = 100
   frmPopup.Left = 500
   Function = 0
End Function


The above code does seem to reposition the popup form (relative to the screen as opposed to the parent window).

You mention in your post that you are calling another function from with Load in order to set the position of the popup form. As a test, maybe try bypassing that function call and set the form position directly like I have done above. If that works, then slowly add back the code from the function that you were originally calling until you find the area that is generating the weird behaviour. That's worth a shot. Maybe your called function is trying to set the popup forms position relative to its parent window instead of the screen itself?
Paul Squires
PlanetSquires Software

SeaVipe

Hi Paul, nothing that I try makes a difference.






Function frmJedit_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT
    Dim cIni As CiniFile = DEFAULTPATH + "\CRM.ini"


    '' Position the form. GetInt returns a Long
    Dim As Long t = cIni.GetInt( "Jeditor", "Top", 50 )
    Dim As Long l = cIni.GetInt( "Jeditor", "Left", 50 )   
   
    frmJedit.Top    = 100 't
    frmJedit.Left   = 100 'l


End Function



The above code positions the form at:
top=-76
left=-513
Clive Richey