Skillfully using Visual C + + programming to achieve full screen display function

Source: Internet
Author: User

Objective:

In Visual C + + programming, sometimes need to use as large as possible areas as a display area, then the full screen display of the program is a good choice, the so-called full screen display, is the program interface without a menu, toolbar, and other additional items, the entire display screen as a display window to display data or images , many Windows applications offer Full-screen display features such as Word, Excel, and IE. This example shows how to implement a full screen display of a program by responding to a mouse click to draw a digital curve across the screen.

One, the realization method

The implementation of the full screen of the program is actually very easy, it is the realization of the idea is: first to customize a window class, overload the Window class OnPaint () or OnDraw () function, to achieve a specific window display function, and then invoke the API function getdevicecaps (int nindex) function to get the size of the current display screen, such as nindex logpixelsx value to get the width of the screen (in pixels), take logpixelsy value to get the height of the screen. With the size of the screen is not enough, you must also call an API function MoveWindow () to locate the current window to the entire screen. The reader should be aware that in order to realize the interaction between the window and the user, to load a cursor in the window, and to restore the full screen to the normal state, it is necessary to process the WM_KEYDOWN message in the window class, in which the user presses the ESC (exit) key in the message handler function. The program reverts to its normal display state. The following code implements all of the above functions and is able to respond to mouse actions, digital curves on the screen. The programming steps are as follows:

1, the definition of a window class Cgribblewnd, it contains two plastic variable m_pixelsx, m_pixelsy, respectively, to store the size of the window;

2, the use of ClassWizard overloaded window class Onpain () function, to achieve specific display functions;

3, the use of ClassWizard for the window class to add Wm_create, WM_ERASEBKGND, WM_KEYDOWN, wm_lbuttondown and other message processing functions to achieve a full screen window and respond to user operations;

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.