MFC forms to border, top, full screen, activate

Source: Internet
Author: User

Static removal of the long lift border is simple, directly set the "Border" property is "none" can

"Maximize Box", "Minimize box" set whether to display the Maximize/minimize button;

"System Menu" setting whether the Close button is displayed;


1. How to dynamically remove form borders in your code

DWORD dwstyle = GetStyle (); Equivalent to GetWindowLong (M_hwnd, Gwl_style);D word dwnewstyle = Ws_sysmenu | Ws_minimizebox | Ws_maximizebox | Ws_clipchildren | Ws_clipsiblings;dwnewstyle &= ~dwstyle; SetWindowLong (M_hwnd, Gwl_style, Dwnewstyle);
Or

LONG Nstyle = GetWindowLong (m_hwnd, Gwl_style); LONG NewStyle = Nstyle & (~ (Ws_caption | Ws_border | Ws_thickframe));  Remove Attributes Ws_ex_clientedgesetwindowlong (m_hwnd, Gwl_style, NewStyle);:: SetWindowPos (m_hwnd, NULL, 0, 0, 0, 0, swp_nomove | Swp_nosize | swp_framechanged);  swp_framechanged ensure immediate effect

2. How to set the form as the bottommost form

SetWindowPos (&wndbottom, 0, 0, 0, 0, swp_nosize | Swp_nomove | Swp_noactivate); or:: SetWindowPos (GetSafeHwnd (), hwnd_topmost, 0, 0, 0, 0, swp_nosize | Swp_nomove | Swp_noactivate);

3. How to set the form to the top-level form

SetWindowPos (&wndtopmost, 0, 0, 0, 0, swp_nosize | Swp_nomove | Swp_noactivate); or:: SetWindowPos (GetSafeHwnd (), hwnd_topmost, 0, 0, 0, 0, swp_nosize | Swp_nomove | Swp_noactivate);

Notes (1):

Wndbottom and wndTopMost are static members of the base class CWnd, defined as follows:

Static Afx_data const CWND wndtop;       SetWindowPos ' s pwndinsertafterstatic afx_data const CWnd wndbottom;    SetWindowPos ' s pwndinsertafterstatic afx_data const CWnd wndtopmost;   SetWindowPos pwndinsertafterstatic afx_data const CWND wndnotopmost; SetWindowPos pWndInsertAfter

Notes (2):

Swp_drawframe       Draws a box around the window swp_framechanged    sends a WM_NCCALCSIZE message into the window, even if the size of the window does not change. If you do not specify this parameter, the message wm_ Nccalcsize only send Swp_hidewindow hidden window when the window size changes      swp_showwindow      display window Swp_noredraw        window does not automatically redraw <span style= " Color: #ff0000; " >swp_noactivate      do not activate window (avoid grabbing focus) </span>swp_nocopybits      block Customer area <span style= "color: #ff0000;" >swp_nomove          Keep current position (x and Y parameters will be ignored) swp_nosize          keep current size (CX and CY parameters are ignored)  </span><span style= "color:# ff0000; " >swp_nozorder        keeps the window in the current position of the list (the Hwndinsertafter parameter is ignored) Swp_noownerzorder   does not change the position and order of all Windows </span> Swp_noreposition is    the same as the Swp_noownerzorder tag swp_nosendchanging  

4. Set the form to display full screen

int cxscreen,cyscreen; Cxscreen=getsystemmetrics (Sm_cxscreen); Cyscreen=getsystemmetrics (Sm_cyscreen); SetWindowPos (&wndtopmost,0,0,cxscreen,cyscreen,swp_showwindow);







Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MFC forms to border, top, full screen, activate

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.