Thanks to my colleagues for the tips. I follow RASHAD. I thought that with high resolution, the top of the window should be further away from the top of the window, so I changed the code (taking into account the suggestions of RASHAD). Here is the new code for most screen resolutions:
Code: Select all
Enumeration
#WINDOW_Main
EndEnumeration
ExamineDesktops()
x_coord = DesktopWidth(0)/2 -600
y_DesktopHeight = DesktopHeight(0)
If OpenWindow(#WINDOW_Main, 0,0, 1200, 700, "PureBasic Window", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
If y_DesktopHeight > 770 ; for desktop height 800 - 20 pixels from the top
Result_win = WindowX(#WINDOW_Main ,#PB_Window_FrameCoordinate)
ResizeWindow(#WINDOW_Main, x_coord, 20, #PB_Ignore, #PB_Ignore)
EndIf
If y_DesktopHeight > 810 ; for desktop height 900 and 864 - 50 pixels from the top
Result_win = WindowX(#WINDOW_Main ,#PB_Window_FrameCoordinate)
ResizeWindow(#WINDOW_Main, x_coord, 50, #PB_Ignore, #PB_Ignore )
EndIf
; For 768, 720, 600 window will be centered - as in If OpenWindow(#WINDOW_Main, 0,0, 1200, 700, "PureBasic Window", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
EndIf
Until Quit = 1
EndIf
End