x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

Question about the spawning position of the form (eVB)

I dunk for bananas Page Icon Posted 2023-05-24 6:09 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
702
Location:
Europe
Status:
In eVB, is there a way to make my main form spawn in the very center of my screen? It often pops up at the top or top left, which is a bit annoying
 Top of the page
stingraze Page Icon Posted 2023-05-25 2:22 AM
#
Avatar image of stingraze
Subscribers
H/PC Vanguard

Posts:
3,681
Location:
Japan
Status:
If there is a way to get the screen resolution, maybe you can divide it by 2 and get the offset with it?

-stingraze
 Top of the page
stingraze Page Icon Posted 2023-05-25 4:25 AM
#
Avatar image of stingraze
Subscribers
H/PC Vanguard

Posts:
3,681
Location:
Japan
Status:
 Top of the page
I dunk for bananas Page Icon Posted 2023-05-26 8:47 AM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
702
Location:
Europe
Status:
This is only available in desktop VB, not eVB sadly.. The documentation mentions Form.StartUpPosition with 2 being "centered", but nothing happens when I try to implement it

Sub Form1_Load() Form1.StartUpPosition = 2 End Sub
 Top of the page
stingraze Page Icon Posted 2023-05-26 10:42 AM
#
Avatar image of stingraze
Subscribers
H/PC Vanguard

Posts:
3,681
Location:
Japan
Status:
Yeah. I thought so. If you set the Window size targeted for 640x240 for example, I think you can divide it by 2 and offset it with
Form1.Left

and
Form1.Top

It depends on the Form size etc.
If you can get the window size of the device that would be best, but maybe you can make it so that users can select the resolution, then set it centered based on it.

-stingraze
 Top of the page
WinCEDev Page Icon Posted 2023-05-26 1:23 PM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
You can use the following one-liner in Form_Load to center your form on the screen on startup:

Move (Screen.Width - Width) * 0.5, (Screen.Height - Height) * 0.5


Unfortunately this is not perfect, as it does not take the height and position of the taskbar into account.
It should be possible to get the height of the taskbar with the SystemParametersInfo, I'll try to post a more complete example later.
 Top of the page
I dunk for bananas Page Icon Posted 2023-05-27 2:57 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
702
Location:
Europe
Status:
WinCEDev - 2023-05-26 1:23 PM


You can use the following one-liner in Form_Load to center your form on the screen on startup:

Move (Screen.Width - Width) * 0.5, (Screen.Height - Height) * 0.5


Unfortunately this is not perfect, as it does not take the height and position of the taskbar into account.
It should be possible to get the height of the taskbar with the SystemParametersInfo, I'll try to post a more complete example later.


Thank you, this works great!
 Top of the page
Jump to forum:
Seconds to generate: 0.140 - Cached queries : 64 - Executed queries : 9