MDI Perfect Without Borders

Source: Internet
Author: User

One, macro definition

Window properties Modify Macros afx_static BOOL AFXAPI _afxmodifystyle (HWND hwnd, int nstyleoffset, DWORD Dwremove, DWORD Dwadd, UINT nflags);


#define DELETE_BORDER_CWND (Pcwndclass) \
{\
Pcwndclass->modifystyleex (ws_ex_clientedge| ws_ex_windowedge| Ws_ex_staticedge,0,swp_drawframe); \
Pcwndclass->modifystyle (ws_thickframe| ws_caption| ws_border| Ws_sysmenu, 0, Swp_drawframe);
Pcwndclass->modifystyleex (Ws_ex_appwindow,ws_ex_toolwindow);
}
#define DELETE_BORDER_CS (CS) \
{\
Cs.dwexstyle &= ~ (ws_ex_clientedge| ws_ex_windowedge| Ws_ex_staticedge); \
Cs.style &= ~ (ws_thickframe| ws_caption| ws_border| Ws_sysmenu); \
}


#define DELETE_BORDER_HWND (HWND) \
{\
_afxmodifystyle (HWnd, Gwl_exstyle, ws_ex_clientedge| ws_ex_windowedge| Ws_ex_staticedge,0,swp_drawframe); \
_afxmodifystyle (HWnd, Gwl_style, ws_thickframe| ws_caption| ws_border| Ws_sysmenu, 0, Swp_drawframe);

}

Put in the header file stdafx.h or other header files can be.

Second, cxxapp::initinstance () function content modification, in Pmainframe->showwindow (m_nCmdShow), front and back modification

1.m_pmainwnd = pMainFrame; add later

pdoctemplate->m_hmenushared=null; Block out shared menus
Pmainframe->modifystyleex (ws_ex_clientedge| ws_ex_windowedge| Ws_ex_staticedge,0,swp_drawframe); Mask the borders, headings, and menus of the main window
Pmainframe->modifystyle (ws_thickframe| ws_caption| ws_border| Ws_sysmenu, 0, Swp_drawframe); Mask the borders, headings, and menus of the main window
Pmainframe->modifystyleex (Ws_ex_appwindow,ws_ex_toolwindow); Screen task bar display

2.pmainframe->updatewindow (); add later
Masks the borders, titles, and menus of mdiclient windows

Afx_static BOOL AFXAPI _afxmodifystyle (HWND hwnd, int nstyleoffset, DWORD Dwremove, DWORD Dwadd, UINT nflags);
_afxmodifystyle (Pmainframe->m_hwndmdiclient, Gwl_exstyle, ws_ex_clientedge| ws_ex_windowedge| Ws_ex_staticedge,0,swp_drawframe); \
_afxmodifystyle (Pmainframe->m_hwndmdiclient, Gwl_style, ws_thickframe| ws_caption| ws_border| Ws_sysmenu, 0, Swp_drawframe);

Three, MainFrame.cpp in the cmainframe::oncreate inside the shield off the toolbar, task stop, menu

Screen toolbar, status bar
#if 0
if (!m_wndtoolbar.createex (this, Tbstyle_flat, Ws_child | ws_visible | Cbrs_top
| Cbrs_gripper | Cbrs_tooltips | cbrs_flyby | Cbrs_size_dynamic) | |
!m_wndtoolbar.loadtoolbar (IDR_MAINFRAME))
{
TRACE0 ("Failed to create toolbar \ n");
return-1; Failed to create
}


if (!m_wndstatusbar.create) | |
!m_wndstatusbar.setindicators (indicators,
sizeof (indicators)/sizeof (UINT))
{
TRACE0 ("Failed to create status bar \ n");
return-1; Failed to create
}


TODO: Delete These three lines if you don't need the toolbar to dock
M_wndtoolbar.enabledocking (Cbrs_align_any);
EnableDocking (Cbrs_align_any);
DockControlBar (&m_wndtoolbar);
#endif
SetMenu (NULL);//Mask Menu

Four, BOOL cchildframe::P Recreatewindow (createstruct& cs) CMDIChildWnd after: Add after:P Recreatewindow (CS)

Shield 3D Border
Cs.style = Ws_child | ws_visible;
Cs.dwexstyle &=~WS_EX_CLIENTEDGE;

Five, the activation box when the execution

Add virtual void activateframe in 1.childfrm.h (int ncmdshow =-1);

2. Add a function to the ChildFrm.cpp

Executing when a frame is activated
void cchildframe::activateframe (int ncmdshow)
{
nCmdShow = sw_maximize;
Cmdichildwnd::activateframe (nCmdShow);
}

Vi. Add in bool Cxxxview::P Recreatewindow (createstruct& CS)

Delete_border_cs (CS);

Cs.style = Ws_child | ws_visible;

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.