MFC hidden window

Source: Internet
Author: User

1. Define the window size after a CRect is saved and started.

M_rect

2. Write the following code in the OninitDialog event:

GetWindowRect (& m_rect );

WINDOWPLACEMENT wp;

Wp. length = sizeof (WINDOWPLACEMENT );

Wp. flags = WPF_RESTORETOMAXIMIZED;

Wp. showCmd = SW_HIDE; SetWindowPlacement (& wp );

// Set a timer to hide the timer and then return to the original state, or reply in the real window,

SetTimer (6, 1, NULL );

 

3. Timer event

// Restore the original size

// SWP_HIDEWINDOW is a hidden option, and SWP_SHOWWINDOW is a realistic option.

SetWindowPos (& wndNoTopMost, m_rect.left, m_rect.top, m_rect.right, m_rect.bottom, SWP_HIDEWINDOW );

KillTimer (6 );

-----------------------------------------------------------------

Note: Move the code from the window to the lower right corner

Void MoveToRightCorner (void)
{
RECT rcWorkArea;
// Obtain the customer's available Workspace
If (SystemParametersInfo (SPI_GETWORKAREA, 0, & rcWorkArea, 0 ))
{
CRect rcWindow;
GetWindowRect (rcWindow );
// Obtain the area to be moved to the bottom right corner.
CRect rcMoveRect;
RcMoveRect. left = rcWorkArea. right-rcWindow. Width ();
RcMoveRect. right = rcWorkArea. right;
RcMoveRect. top = rcWorkArea. bottom-rcWindow. Height ();
RcMoveRect. bottom = rcWorkArea. bottom;
MoveWindow (rcMoveRect );
}
}

 

 

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.