How to automatically center a window?

Source: Internet
Author: User

Q: I want to make the applicationProgramThe main window is automatically displayed in the center of the screen regardless of the screen resolution and operating system version. What should I do?

A: It's too easy ......

Principle: use the environment object in Pb and the move function of the window.

Window (w_main)CodeAs follows:

// Variable Declaration
Environment env_system
Integer int_scrwidth, int_scrheight

// close the window and refresh.
setredraw (false)
// obtain the screen width and height
getenvironment (env_system)
int_scrwidth = pixelstounits (env_system.screenwidth, xpixelstounits !)
int_scrheight = pixelstounits (env_system.screenheight, ypixelstounits !)
// move the window to the center of the screen
move (int_scrwidth-this. width)/2, (int_scrheight-this. height)/2)
// open a window and refresh
setredraw (true)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.