How to prevent position change of window when it is created?

Answers to frequently asked questions about Phoenix.
TechSupport
Site Admin
Posts: 809
Joined: Tue Sep 14, 2004 7:55 pm
Location: Mississauga ON, Canada

How to prevent position change of window when it is created?

Postby TechSupport » Fri Dec 07, 2007 1:12 pm

Question
How can I prevent the short position change of a centered window when it is created?

Phoenix creates this window at a default position and moves it to the new position (i.e. middle of screen)

afterwards. This position change is visible and a little bit annoying.

Answer
I am assuming the Center window option is checked in the WindowPlacement property.

If this is the main application window, uncheck its WS_VISIBLE style.
Because it is the main window, it will be shown by the OS when ShowWindow is called for the first time.
The window will already be centered when it is shown because ShowWindow is called after phnxCenterWindow in the code.

If it is a secondary modeless window, uncheck its WS_VISIBLE style and use code similar to the following when the window is shown.

Code: Select all

  LOCAL hWndPopup AS DWORD
 
  hWndPopup = Form2_Create(hWndOwner, 0)
  ShowWindow hWndPopup, %SW_SHOW


If it is a secondary modal window, uncheck it WS_VISIBLE style.
Because it is modal, the code generated by Phoenix always shows the window when ShowWindow is called for the first time.
The window will already be centered when it is shown because ShowWindow is called after phnxCenterWindow in the code.

Return to “Frequently Asked Questions”

Who is online

Users browsing this forum: No registered users and 1 guest