PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Form Show  (Read 172 times)

SeaVipe

  • Senior Member
  • ***
  • Posts: 369
  • Windows 10
Form Show
« on: September 04, 2020, 05:39:59 PM »

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)
Code: [Select]
frmJedit.ShowThis 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.
Code: [Select]
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.
« Last Edit: September 05, 2020, 12:39:03 PM by SeaVipe »
Logged
Clive Richey
*“You Either Have To Be Part Of The Solution, Or You’re Going To Be Part The Problem.” Eldridge Cleaver.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: Form Show
« Reply #1 on: September 05, 2020, 07:33:06 AM »

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?


Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Senior Member
  • ***
  • Posts: 369
  • Windows 10
Re: Form Show
« Reply #2 on: September 05, 2020, 12:52:22 PM »

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.
Logged
Clive Richey
*“You Either Have To Be Part Of The Solution, Or You’re Going To Be Part The Problem.” Eldridge Cleaver.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: Form Show
« Reply #3 on: September 06, 2020, 07:56:22 AM »

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:

Code: [Select]
''
''
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?
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Senior Member
  • ***
  • Posts: 369
  • Windows 10
Re: Form Show
« Reply #4 on: September 06, 2020, 04:12:44 PM »

Hi Paul, nothing that I try makes a difference.




Code: [Select]

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
Logged
Clive Richey
*“You Either Have To Be Part Of The Solution, Or You’re Going To Be Part The Problem.” Eldridge Cleaver.
#StaySafe, Always  Keep A Safe #SocialDistance, #WashYourHands Often and please, #StayHome!